summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamil Staps2019-10-27 14:41:08 +0100
committerCamil Staps2019-10-27 14:41:08 +0100
commit7afd5796929601b10d52fc024b3cfd9ed64f25af (patch)
treede6c6f6e04a666e2a26a50d75dbff2f711b7ace3
parentAdd newMessageDialog; add GtkTitle type and instance tune w GtkTitle | gtkWin... (diff)
Add GtkScrollbarPolicy and instance tune GtkScrolledWindow (GtkScrollbarPolicy, GtkScrollbarPolicy)
-rw-r--r--src/Gtk/Internal.dcl1
-rw-r--r--src/Gtk/Internal.icl5
-rw-r--r--src/Gtk/Types.dcl7
-rw-r--r--src/Gtk/Types.icl7
-rw-r--r--src/Gtk/Widgets.dcl6
-rw-r--r--src/Gtk/Widgets.icl6
6 files changed, 30 insertions, 2 deletions
diff --git a/src/Gtk/Internal.dcl b/src/Gtk/Internal.dcl
index 50fda0d..e7ac6d5 100644
--- a/src/Gtk/Internal.dcl
+++ b/src/Gtk/Internal.dcl
@@ -68,6 +68,7 @@ gtk_paned_pack2 :: !Pointer !Pointer !Bool !Bool !.a -> .a
gtk_paned_set_wide_handle :: !Pointer !Bool !.a -> .a
gtk_scrolled_window_new :: !Pointer !Pointer !.a -> (!Pointer, !.a)
+gtk_scrolled_window_set_policy :: !Pointer !Int !Int !.a -> .a
gtk_separator_new :: !Bool !.a -> (!Pointer, !.a)
diff --git a/src/Gtk/Internal.icl b/src/Gtk/Internal.icl
index aed7b79..a5e2256 100644
--- a/src/Gtk/Internal.icl
+++ b/src/Gtk/Internal.icl
@@ -290,6 +290,11 @@ gtk_scrolled_window_new hadjust vadjust env = code {
ccall gtk_scrolled_window_new "pp:p:A"
}
+gtk_scrolled_window_set_policy :: !Pointer !Int !Int !.a -> .a
+gtk_scrolled_window_set_policy window hpolicy vpolicy env = code {
+ ccall gtk_scrolled_window_set_policy "pII:V:A"
+}
+
gtk_separator_new :: !Bool !.a -> (!Pointer, !.a)
gtk_separator_new vertical env = code {
ccall gtk_separator_new "I:p:A"
diff --git a/src/Gtk/Types.dcl b/src/Gtk/Types.dcl
index 74b8c52..33d0eb9 100644
--- a/src/Gtk/Types.dcl
+++ b/src/Gtk/Types.dcl
@@ -94,6 +94,13 @@ instance toInt GtkMessageType
instance fromInt GtkResponse
instance toInt GtkResponse
+:: GtkScrollbarPolicy
+ = PersistentScrollbar
+ | AutoScrollbar
+ | NoScrollbar
+
+instance toInt GtkScrollbarPolicy
+
:: GtkShrink
= Shrink
| NoShrink
diff --git a/src/Gtk/Types.icl b/src/Gtk/Types.icl
index e9f672c..22e6adc 100644
--- a/src/Gtk/Types.icl
+++ b/src/Gtk/Types.icl
@@ -77,6 +77,13 @@ where
ResponseApply -> 9
ResponseHelp -> 10
+instance toInt GtkScrollbarPolicy
+where
+ toInt policy = case policy of
+ PersistentScrollbar -> 0
+ AutoScrollbar -> 1
+ NoScrollbar -> 2
+
instance toInt GtkStylePriority
where
toInt prio = case prio of
diff --git a/src/Gtk/Widgets.dcl b/src/Gtk/Widgets.dcl
index 405c4b5..5f2baa5 100644
--- a/src/Gtk/Widgets.dcl
+++ b/src/Gtk/Widgets.dcl
@@ -10,8 +10,8 @@ from Gtk.Tune import class tune
from Gtk.Types import :: GtkButtonsType, :: GtkCSSClass, :: GtkDirection,
:: GtkExpand, :: GtkFileChooserAction, :: GtkLabel, :: GtkMargins,
:: GtkMessageType, :: GtkModal, :: GtkOrientation, :: GtkPanedHandleWidth,
- :: GtkResize, :: GtkResponse, :: GtkShrink, :: GtkStylePriority,
- :: GtkTitle, :: GtkWrapMode
+ :: GtkResize, :: GtkResponse, :: GtkScrollbarPolicy, :: GtkShrink,
+ :: GtkStylePriority, :: GtkTitle, :: GtkWrapMode
class ptr a
where
@@ -114,6 +114,8 @@ instance gtkContainer GtkScrolledWindow
newScrolledWindow :: GtkM GtkScrolledWindow
+instance tune GtkScrolledWindow (GtkScrollbarPolicy, GtkScrollbarPolicy)
+
:: GtkSeparator
instance gtkWidget GtkSeparator
instance ptr GtkSeparator
diff --git a/src/Gtk/Widgets.icl b/src/Gtk/Widgets.icl
index ba0cb16..f2c942f 100644
--- a/src/Gtk/Widgets.icl
+++ b/src/Gtk/Widgets.icl
@@ -224,6 +224,12 @@ instance gtkContainer GtkScrolledWindow where gtkContainer sw = sw
newScrolledWindow :: GtkM GtkScrolledWindow
newScrolledWindow = toStateR (gtk_scrolled_window_new 0 0) >>= show
+instance tune GtkScrolledWindow (GtkScrollbarPolicy, GtkScrollbarPolicy)
+where
+ tune (hp,vp) window =
+ toState (gtk_scrolled_window_set_policy window (toInt hp) (toInt vp)) >>|
+ pure window
+
:: GtkSeparator :== Pointer
instance gtkWidget GtkSeparator where gtkWidget s = s