summaryrefslogtreecommitdiff
path: root/src/Gtk
diff options
context:
space:
mode:
authorCamil Staps2019-10-20 12:58:02 +0200
committerCamil Staps2019-10-20 12:58:02 +0200
commit786bb35f3891fec41030caf1df7a4461ea97729e (patch)
tree3463a477bc5df53db83eaa9b8afa8fcb52d0387e /src/Gtk
parentAdd GtkBox support (diff)
Add GtkFrame
Diffstat (limited to 'src/Gtk')
-rw-r--r--src/Gtk/Internal.dcl2
-rw-r--r--src/Gtk/Internal.icl14
-rw-r--r--src/Gtk/Types.dcl4
-rw-r--r--src/Gtk/Widgets.dcl10
-rw-r--r--src/Gtk/Widgets.icl11
5 files changed, 39 insertions, 2 deletions
diff --git a/src/Gtk/Internal.dcl b/src/Gtk/Internal.dcl
index 9671870..f4436b8 100644
--- a/src/Gtk/Internal.dcl
+++ b/src/Gtk/Internal.dcl
@@ -19,6 +19,8 @@ gtk_box_pack_end :: !Pointer !Pointer !Bool !Bool !Int !.a -> .a
gtk_container_add :: !Pointer !Pointer !.a -> .a
+gtk_frame_new :: !(Maybe String) !.a -> (!Pointer, !.a)
+
gtk_init :: !.a -> .a
gtk_main_iteration :: !.a -> (!Bool, !.a)
diff --git a/src/Gtk/Internal.icl b/src/Gtk/Internal.icl
index bd68e1e..56e9f4e 100644
--- a/src/Gtk/Internal.icl
+++ b/src/Gtk/Internal.icl
@@ -55,6 +55,20 @@ gtk_container_add container widget env = code {
ccall gtk_container_add "pp:V:A"
}
+gtk_frame_new :: !(Maybe String) !.a -> (!Pointer, !.a)
+gtk_frame_new Nothing env = new 0 env
+where
+ new :: !Int !.a -> (!Pointer, !.a)
+ new _ _ = code {
+ ccall gtk_frame_new "p:p:A"
+ }
+gtk_frame_new (Just label) env = new label env
+where
+ new :: !String !.a -> (!Pointer, !.a)
+ new _ _ = code {
+ ccall gtk_frame_new "s:p:A"
+ }
+
gtk_init :: !.a -> .a
gtk_init env = init 0 0 env
where
diff --git a/src/Gtk/Types.dcl b/src/Gtk/Types.dcl
index 439359e..5339bc3 100644
--- a/src/Gtk/Types.dcl
+++ b/src/Gtk/Types.dcl
@@ -8,6 +8,10 @@ definition module Gtk.Types
= Expand
| NoExpand
+:: GtkLabel
+ = Label !String
+ | NoLabel
+
:: GtkOrientation
= Horizontal
| Vertical
diff --git a/src/Gtk/Widgets.dcl b/src/Gtk/Widgets.dcl
index 914b90b..b4a9849 100644
--- a/src/Gtk/Widgets.dcl
+++ b/src/Gtk/Widgets.dcl
@@ -5,8 +5,8 @@ from StdMaybe import :: Maybe
from System._Pointer import :: Pointer
from Gtk.State import :: State, :: StateT, :: Identity, :: GtkState
-from Gtk.Types import :: GtkDirection, :: GtkExpand, :: GtkOrientation,
- :: GtkPanedHandleWidth, :: GtkResize, :: GtkShrink
+from Gtk.Types import :: GtkDirection, :: GtkExpand, :: GtkLabel,
+ :: GtkOrientation, :: GtkPanedHandleWidth, :: GtkResize, :: GtkShrink
class ptr a :: !a -> Pointer
@@ -33,6 +33,12 @@ instance gtkContainer GtkBox
newBox :: !GtkOrientation !Int -> State GtkState GtkBox
packBox :: !w !GtkBox !GtkDirection !GtkExpand -> State GtkState () | gtkWidget w
+:: GtkFrame
+instance gtkWidget GtkFrame
+instance gtkContainer GtkFrame
+
+newFrame :: !GtkLabel !w -> State GtkState GtkFrame | gtkWidget w
+
:: GtkPaned
instance gtkWidget GtkPaned
instance gtkContainer GtkPaned
diff --git a/src/Gtk/Widgets.icl b/src/Gtk/Widgets.icl
index b7deab5..b630549 100644
--- a/src/Gtk/Widgets.icl
+++ b/src/Gtk/Widgets.icl
@@ -44,6 +44,17 @@ packBox widget box direction expand =
toState (if direction=:StartToEnd 'I'.gtk_box_pack_start 'I'.gtk_box_pack_end
box (gtkWidget widget) expand=:Expand True 0)
+:: GtkFrame :== Pointer
+
+instance gtkWidget GtkFrame where gtkWidget f = f
+instance gtkContainer GtkFrame where gtkContainer f = f
+
+newFrame :: !GtkLabel !w -> State GtkState GtkFrame | gtkWidget w
+newFrame label widget =
+ toStateR ('I'.gtk_frame_new (case label of Label l -> Just l; _ -> Nothing)) >>= \frame ->
+ addToContainer widget frame >>|
+ show frame
+
:: GtkPaned :== Pointer
instance gtkWidget GtkPaned where gtkWidget p = p