packages feed

grapefruit-ui-gtk (empty) → 0.0.0.0

raw patch · 9 files changed

+323/−0 lines, 9 filesdep +basedep +grapefruit-frpdep +grapefruit-recordssetup-changed

Dependencies added: base, grapefruit-frp, grapefruit-records, grapefruit-ui, gtk

Files

+ LICENSE view
@@ -0,0 +1,25 @@+Copyright © 2007–2009 Brandenburgische Technische Universität Cottbus+All rights reserved.++Redistribution and use in source and binary forms, with or without modification, are permitted+provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright notice, this list of conditions+      and the following disclaimer.++    * Redistributions in binary form must reproduce the above copyright notice, this list of+      conditions and the following disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of the copyright holders nor the names of the contributors may be used to+      endorse or promote products derived from this software without specific prior written+      permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER+IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF+THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.lhs view
@@ -0,0 +1,4 @@+#!/usr/bin/env runghc++> import Distribution.Simple+> main = defaultMain
+ grapefruit-ui-gtk.cabal view
@@ -0,0 +1,36 @@+Name:          grapefruit-ui-gtk+Version:       0.0.0.0+Cabal-Version: >= 1.2.3+Build-Type:    Simple+License:       BSD3+License-File:  LICENSE+Copyright:     © 2007–2009 Brandenburgische Technische Universität Cottbus+Author:        Wolfgang Jeltsch+Maintainer:    jeltsch@informatik.tu-cottbus.de+Stability:     provisional+Homepage:      http://haskell.org/haskellwiki/Grapefruit+Package-URL:   http://hackage.haskell.org/packages/archive/grapefruit-ui-gtk/0.0.0.0/grapefruit-ui-gtk-0.0.0.0.tar.gz+Synopsis:      GTK+-based backend for declarative user interface programming+Description:   Grapefruit is a library for Functional Reactive Programming (FRP) with a focus on+               user interfaces. FRP makes it possible to implement reactive and interactive systems+               in a declarative style. To learn more about FRP, have a look at+               <http://haskell.org/haskellwiki/Functional_Reactive_Programming>.+               .+               This package contains the GTK+-based user interface backend.+Category:      FRP, Reactivity, GUI, User Interfaces+Tested-With:   GHC == 6.8.3+               GHC == 6.10.1++Library+    Build-Depends:   base               >= 3.0    && < 4.1,+                     grapefruit-frp     >= 0.0    && < 0.1,+                     grapefruit-records >= 0.0    && < 0.1,+                     grapefruit-ui      >= 0.0    && < 0.1,+                     gtk                >= 0.9.13 && < 0.11+    Extensions:      TypeFamilies+    Exposed-Modules: Graphics.UI.Grapefruit.GTK+                     Graphics.UI.Grapefruit.GTK.Connector+                     Graphics.UI.Grapefruit.GTK.Item+    Other-Modules:   Graphics.UI.Grapefruit.GTK.Backend+                     Graphics.UI.Grapefruit.GTK.Backend.Std+    HS-Source-Dirs:  src
+ src/Graphics/UI/Grapefruit/GTK.hs view
@@ -0,0 +1,18 @@+-- |This module provides a GTK+-based UI backend.+module Graphics.UI.Grapefruit.GTK (++    GTK (GTK)++) where++    -- Graphics.UI.Grapefruit.GTK+    import Graphics.UI.Grapefruit.GTK.Backend     as GTKUIBackend+    import Graphics.UI.Grapefruit.GTK.Backend.Std as GTKStdUIBackend++    {-|+        Denotes the GTK+-based UI backend.++        See the documentation of "Graphics.UI.Grapefruit.Backend" for an introduction to UI+        backends.+    -}+    data GTK = GTK
+ src/Graphics/UI/Grapefruit/GTK.hs-boot view
@@ -0,0 +1,7 @@+module Graphics.UI.Grapefruit.GTK (++    GTK (GTK)++) where++    data GTK = GTK
+ src/Graphics/UI/Grapefruit/GTK/Backend.hs view
@@ -0,0 +1,26 @@+module Graphics.UI.Grapefruit.GTK.Backend () where++    -- Graphics.UI.Grapefruit+    import Graphics.UI.Grapefruit.Backend as Backend++    -- Graphics.UI.Gtk+    import qualified Graphics.UI.Gtk as Gtk++    -- Graphics.UI.Grapefruit.GTK+    import {-# SOURCE #-} Graphics.UI.Grapefruit.GTK as GTK++    instance UIBackend GTK where++        type WidgetPlacement GTK = Gtk.Widget -> IO ()++        type WindowPlacement GTK = Gtk.Window -> IO ()++        initialize GTK = Gtk.initGUI >> return ()++        handleEvents GTK = Gtk.mainGUI++        requestQuitting GTK = Gtk.mainQuit++        finalize GTK = return ()++        topLevel GTK = const (return ())
+ src/Graphics/UI/Grapefruit/GTK/Backend/Std.hs view
@@ -0,0 +1,41 @@+module Graphics.UI.Grapefruit.GTK.Backend.Std () where++    -- FRP.Grapefruit+    import FRP.Grapefruit.Record         as Record+    import FRP.Grapefruit.Record.Context as ContextRecord++    -- Graphics.UI.Grapefruit+    import Graphics.UI.Grapefruit.Backend.Std as StdUIBackend++    -- Graphics.UI.Gtk+    import qualified Graphics.UI.Gtk as Gtk++    -- Graphics.UI.Grapefruit.GTK+    import {-# SOURCE #-} Graphics.UI.Grapefruit.GTK           as GTK+    import                Graphics.UI.Grapefruit.GTK.Connector as GTKConnector+    import                Graphics.UI.Grapefruit.GTK.Item      as GTKUIItem+    import                Graphics.UI.Grapefruit.GTK.Backend   as GTKUIBackend++    instance StdUIBackend GTK where++        label = widgetBrick (Gtk.labelNew Nothing)+                            (X :& Text ::~~ attrConsumer Gtk.labelLabel)+                            X++        pushButton = widgetBrick Gtk.buttonNew+                                 (X :& Text ::~~ attrConsumer Gtk.buttonLabel)+                                 (X :& Push ::~~ eventProducer Gtk.onPressed)++        box orientation = widgetBox (case orientation of+                                         Horizontal -> newGtkBox Gtk.hBoxNew+                                         Vertical   -> newGtkBox Gtk.vBoxNew)+                                    Gtk.containerAdd+                                    X+                                    X where++            newGtkBox rawNewGtkBox = fmap Gtk.toBox (rawNewGtkBox False 0)++        window = windowBox Gtk.windowNew+                           Gtk.containerAdd+                           (X :& Title   ::~~ attrConsumer Gtk.windowTitle)+                           (X :& Closure ::~~ eventProducer Gtk.onDestroy)
+ src/Graphics/UI/Grapefruit/GTK/Connector.hs view
@@ -0,0 +1,43 @@+{-|+    This module provides convenience functions for constructing connectors specific to the+    GTK+-based backend.+-}+module Graphics.UI.Grapefruit.GTK.Connector (++    attrConsumer,+    eventProducer++) where++    -- FRP.Grapefruit+    import FRP.Grapefruit.Setup            as Setup+    import FRP.Grapefruit.Signal           as Signal+    import FRP.Grapefruit.Signal.Discrete  as DSignal+    import FRP.Grapefruit.Signal.Segmented as SSignal++    -- Graphics.UI.Gtk+    import qualified Graphics.UI.Gtk as Gtk++    {-|+        Constructs a consumer for segmented signals which makes a Gtk2Hs attribute of a Gtk2Hs+        widget being updated on every update point of the consumed signal.+    -}+    attrConsumer :: (Gtk.WidgetClass gtkWidget) =>+                    Gtk.Attr gtkWidget val -> gtkWidget -> Consumer SSignal val+    attrConsumer attr gtkWidget = SSignal.consumer $ \val -> Gtk.set gtkWidget [attr Gtk.:= val]++    -- |Constructs a producer of discrete signals that represent sequences of Gtk2Hs events.+    eventProducer :: (Gtk.WidgetClass gtkWidget)+                   => (gtkWidget -> IO () -> IO (Gtk.ConnectId gtkWidget))+                      {-^+                          an @on/EventType/@ function of Gtk2Hs, representing a certain kind of+                          event+                      -}+                   -> gtkWidget+                      -- ^a Gtk2Hs widget which provides the events+                   -> Producer DSignal ()+    eventProducer onEvent gtkWidget = DSignal.producer $+                                      \handler -> setup $+                                                  do+                                                      connectID <- onEvent gtkWidget (handler ())+                                                      return (Gtk.signalDisconnect connectID)
+ src/Graphics/UI/Grapefruit/GTK/Item.hs view
@@ -0,0 +1,123 @@+-- |This module provides convenience functions for creating GTK+-based bricks and boxes.+module Graphics.UI.Grapefruit.GTK.Item (++    widgetBrick,+    windowBrick,+    widgetBox,+    windowBox++) where++    -- FRP.Grapefruit+    import FRP.Grapefruit.Signal.Segmented   as SSignal+    import FRP.Grapefruit.Record             as Record+    import FRP.Grapefruit.Record.Optionality as OptionalityRecord+    import FRP.Grapefruit.Record.Context     as ContextRecord++    -- Graphics.UI.Grapefruit+    import           Graphics.UI.Grapefruit.Comp    as UIComp+    import           Graphics.UI.Grapefruit.Item    as UIItem+    import qualified Graphics.UI.Grapefruit.Item    as UIItem+    import           Graphics.UI.Grapefruit.Backend as UIBackend++    -- Graphics.UI.Gtk+    import qualified Graphics.UI.Gtk as Gtk++    -- Graphics.UI.Grapefruit.GTK+    import {-# SOURCE #-} Graphics.UI.Grapefruit.GTK         as GTK+    import                Graphics.UI.Grapefruit.GTK.Backend as GTKUIBackend++    -- |Constructs a GTK+-based widget brick.+    widgetBrick :: (Gtk.WidgetClass gtkWidget, OptRecord iOptRecord, Record oRecord)+                => IO gtkWidget+                   -- ^an action which creates a Gtk2Hs widget+                -> ContextConsumerRecord gtkWidget (All iOptRecord)+                   -- ^consumers of those inputs which are specific to this brick+                -> ContextProducerRecord gtkWidget oRecord+                   -- ^producers of those outputs which are specific to this brick+                -> Brick Widget GTK iOptRecord oRecord+    widgetBrick = brick commonWidgetConsumerRecord commonWidgetProducerRecord Gtk.widgetShow .+                  newWidget++    -- |Constructs a GTK+-based window brick.+    windowBrick :: (Gtk.WindowClass gtkWindow, OptRecord iOptRecord, Record oRecord)+                => IO gtkWindow+                   -- ^an action which creates a Gtk2Hs window+                -> ContextConsumerRecord gtkWindow (All iOptRecord)+                   -- ^consumers of those inputs which are specific to this brick+                -> ContextProducerRecord gtkWindow oRecord+                   -- ^producers of those outputs which are specific to this brick+                -> Brick Window GTK iOptRecord oRecord+    windowBrick = brick commonWindowConsumerRecord commonWindowProducerRecord Gtk.widgetShow .+                  newWindow++    -- |Constructs a GTK+-based widget box.+    widgetBox :: (Gtk.WidgetClass gtkWidget,+                  UIComp innerUIComp,+                  OptRecord iOptRecord,+                  Record oRecord)+              => IO gtkWidget+                 -- ^an action which creates a Gtk2Hs widget+              -> (gtkWidget -> Placement innerItem GTK)+                 -- ^conversion from a Gtk2Hs widget into the placement for its inner items+              -> ContextConsumerRecord gtkWidget (All iOptRecord)+                 -- ^consumers of those inputs which are specific to this box+              -> ContextProducerRecord gtkWidget oRecord+                 -- ^producers of those outputs which are specific to this box+              -> Box innerUIComp innerItem Widget GTK iOptRecord oRecord+    widgetBox = box commonWidgetConsumerRecord commonWidgetProducerRecord Gtk.widgetShow . newWidget++    -- |Constructs a GTK+-based window box.+    windowBox :: (Gtk.WindowClass gtkWindow,+                  UIComp innerUIComp,+                  OptRecord iOptRecord,+                  Record oRecord)+              => IO gtkWindow+                 -- ^an action which creates a Gtk2Hs window+              -> (gtkWindow -> Placement innerItem GTK)+                 -- ^conversion from a Gtk2Hs window into the placement for its inner items+              -> ContextConsumerRecord gtkWindow (All iOptRecord)+                 -- ^consumers of those inputs which are specific to this box+              -> ContextProducerRecord gtkWindow oRecord+                 -- ^producers of those outputs which are specific to this box+              -> Box innerUIComp innerItem Window GTK iOptRecord oRecord+    windowBox = box commonWindowConsumerRecord commonWindowProducerRecord Gtk.widgetShow . newWindow++    newWidget :: (Gtk.WidgetClass gtkWidget)+              => IO gtkWidget+              -> Placement Widget GTK+              -> IO gtkWidget+    newWidget = newItem Gtk.toWidget++    newWindow :: (Gtk.WindowClass gtkWindow)+              => IO gtkWindow+              -> Placement Window GTK+              -> IO gtkWindow+    newWindow = newItem Gtk.toWindow++    newItem :: (specificItem -> genericItem)+            -> IO specificItem+            -> (genericItem -> IO ())+            -> IO specificItem+    newItem genericItem newSpecificItem placement = do+                                                        specificItem <- newSpecificItem+                                                        placement (genericItem specificItem)+                                                        return specificItem++    commonWidgetConsumerRecord :: (Gtk.WidgetClass gtkWidget)+                               => ContextConsumerRecord gtkWidget+                                                        (All (CommonInputOptRecord Widget))+    commonWidgetConsumerRecord = X :& IsEnabled ::~~ SSignal.consumer . Gtk.widgetSetSensitivity++    commonWidgetProducerRecord :: (Gtk.WidgetClass gtkWidget)+                               => ContextProducerRecord gtkWidget (CommonOutputRecord Window)+    commonWidgetProducerRecord = X++    commonWindowConsumerRecord :: (Gtk.WindowClass gtkWindow)+                               => ContextConsumerRecord gtkWindow+                                                        (All (CommonInputOptRecord Window))+    commonWindowConsumerRecord = X++    commonWindowProducerRecord :: (Gtk.WindowClass gtkWindow)+                               => ContextProducerRecord gtkWindow (CommonOutputRecord Window)+    commonWindowProducerRecord = X