summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamil Staps2019-12-12 15:56:03 +0100
committerCamil Staps2019-12-12 15:56:03 +0100
commit2a31ffa127305eb9090dad5596d6254ac1d22be9 (patch)
tree6b1d933bedecfdc06a4ba60f115ad24145a2fb77
parentAdd GtkSortable for TreeView columns (diff)
Add GtkTreeViewColumnSizing for TreeView columns
-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.icl7
6 files changed, 29 insertions, 4 deletions
diff --git a/src/Gtk/Internal.dcl b/src/Gtk/Internal.dcl
index 8c9da9e..5119a74 100644
--- a/src/Gtk/Internal.dcl
+++ b/src/Gtk/Internal.dcl
@@ -161,6 +161,7 @@ gtk_tree_view_column_add_attribute :: !Pointer !Pointer !String !Int !.a -> .a
gtk_tree_view_column_new :: !.a -> (!Pointer, !.a)
gtk_tree_view_column_pack_start :: !Pointer !Pointer !Bool !.a -> .a
gtk_tree_view_column_set_sort_column_id :: !Pointer !Int !.a -> .a
+gtk_tree_view_column_set_sizing :: !Pointer !Int !.a -> .a
gtk_tree_view_column_set_title :: !Pointer !String !.a -> .a
gtk_tree_view_append_column :: !Pointer !Pointer !.a -> .a
diff --git a/src/Gtk/Internal.icl b/src/Gtk/Internal.icl
index b92d3d8..edaf0a3 100644
--- a/src/Gtk/Internal.icl
+++ b/src/Gtk/Internal.icl
@@ -718,6 +718,11 @@ gtk_tree_view_column_pack_start column renderer expand env = code {
ccall gtk_tree_view_column_pack_start "ppI:V:A"
}
+gtk_tree_view_column_set_sizing :: !Pointer !Int !.a -> .a
+gtk_tree_view_column_set_sizing column sizing env = code {
+ ccall gtk_tree_view_column_set_sizing "pI:V:A"
+}
+
gtk_tree_view_column_set_sort_column_id :: !Pointer !Int !.a -> .a
gtk_tree_view_column_set_sort_column_id column id env = code {
ccall gtk_tree_view_column_set_sort_column_id "pI:V:A"
diff --git a/src/Gtk/Types.dcl b/src/Gtk/Types.dcl
index dfbde91..4676e6c 100644
--- a/src/Gtk/Types.dcl
+++ b/src/Gtk/Types.dcl
@@ -228,6 +228,13 @@ instance toInt GtkStylePriority
:: GtkTitle =: Title String
+:: GtkTreeViewColumnSizing
+ = OnlyGrow
+ | AutoSize
+ | FixedSize
+
+instance toInt GtkTreeViewColumnSizing
+
:: GtkWrapMode
= WrapNone
| WrapChar
diff --git a/src/Gtk/Types.icl b/src/Gtk/Types.icl
index 435ce9e..f43a800 100644
--- a/src/Gtk/Types.icl
+++ b/src/Gtk/Types.icl
@@ -150,6 +150,13 @@ where
StylePriorityApplication -> 600
StylePriorityUser -> 800
+instance toInt GtkTreeViewColumnSizing
+where
+ toInt sizing = case sizing of
+ OnlyGrow -> 0
+ AutoSize -> 1
+ FixedSize -> 2
+
instance toInt GtkWrapMode
where
toInt mode = case mode of
diff --git a/src/Gtk/Widgets.dcl b/src/Gtk/Widgets.dcl
index 27d5677..2857045 100644
--- a/src/Gtk/Widgets.dcl
+++ b/src/Gtk/Widgets.dcl
@@ -30,7 +30,7 @@ from Gtk.Types import
:: GtkModal, :: GtkOrientation, :: GtkPanedHandleWidth, :: GtkResize,
:: GtkResponse, :: GtkScrollbarPolicy, :: GtkSensitivity, :: GtkShrink,
:: GtkSizeRequest, :: GtkSortable, :: GtkSpacing, :: GtkStylePriority,
- :: GtkText, :: GtkTitle, :: GtkWrapMode
+ :: GtkText, :: GtkTitle, :: GtkTreeViewColumnSizing, :: GtkWrapMode
/**
* A `GtkAccelGroup` is needed for a `GtkAccelerator`. 'Accelerator' is Gtk's
@@ -365,7 +365,9 @@ newTreeView :: !GtkListStore -> GtkM GtkTreeView
* the column index in the list store that is shown. When `Expand` is used,
* excess space of the tree view is (partially) given to this column.
*/
-appendColumnToTreeView :: !String !Int !GtkSortable !GtkExpand !GtkTreeView -> GtkM GtkTreeView
+appendColumnToTreeView :: !String !Int
+ !GtkSortable !GtkTreeViewColumnSizing !GtkExpand
+ !GtkTreeView -> GtkM GtkTreeView
//* Add a signal handler for the event that the user selects a different row.
addSelectionChangedHandler :: !(GtkM ()) !GtkTreeView -> GtkM GtkTreeView
diff --git a/src/Gtk/Widgets.icl b/src/Gtk/Widgets.icl
index d4f53a4..34d0065 100644
--- a/src/Gtk/Widgets.icl
+++ b/src/Gtk/Widgets.icl
@@ -540,14 +540,17 @@ newTreeView (GtkListStore s) =
toState (g_object_unref s) >>|
show (GtkTreeView view)
-appendColumnToTreeView :: !String !Int !GtkSortable !GtkExpand !GtkTreeView -> GtkM GtkTreeView
-appendColumnToTreeView title col sortable expand tree=:(GtkTreeView tv) =
+appendColumnToTreeView :: !String !Int
+ !GtkSortable !GtkTreeViewColumnSizing !GtkExpand
+ !GtkTreeView -> GtkM GtkTreeView
+appendColumnToTreeView title col sortable sizing expand tree=:(GtkTreeView tv) =
toStateR gtk_cell_renderer_text_new >>= \renderer ->
toStateR gtk_tree_view_column_new >>= \column ->
toState (gtk_tree_view_column_set_title column title) >>|
toState (gtk_tree_view_column_pack_start column renderer expand=:Expand) >>|
toState (gtk_tree_view_column_add_attribute column renderer "text" col) >>|
if (sortable=:Sortable) (toState (gtk_tree_view_column_set_sort_column_id column col)) (pure ()) >>|
+ toState (gtk_tree_view_column_set_sizing column (toInt sizing)) >>|
toState (gtk_tree_view_append_column tv column) >>|
pure tree