From a778fcc8a6f193e06ac7a352aae92c1688af17c2 Mon Sep 17 00:00:00 2001 From: nguermond Date: Wed, 15 Dec 2021 00:32:41 -0600 Subject: [PATCH] Add WRAP_WIDTH, WRAP_MODE tags to cell_properties_text, supported since gtk 2.8 --- examples/tree.ml | 6 +++++- src/gTree.ml | 4 +++- src/gTree.mli | 4 +++- src/gtkTree.props | 2 ++ tools/propcc.ml | 2 +- tools/propcc.ml4 | 2 +- 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/examples/tree.ml b/examples/tree.ml index 392dc5a9..c333f7af 100644 --- a/examples/tree.ml +++ b/examples/tree.ml @@ -36,8 +36,12 @@ let main () = let window = GWindow.window () in window#connect#destroy ~callback:GMain.quit; let view = GTree.view ~model ~packing:window#add () in + (* Allow wrapping for title field *) let col = GTree.view_column ~title:"Title" () - ~renderer:(GTree.cell_renderer_text[], ["text",title]) in + ~renderer:(GTree.cell_renderer_text[`WRAP_WIDTH 150; + `WRAP_MODE `WORD_CHAR], + ["text",title]) in + col#set_resizable true; view#append_column col; let col = GTree.view_column ~title:"Author" () ~renderer:(GTree.cell_renderer_text[], ["text",author]) in diff --git a/src/gTree.ml b/src/gTree.ml index eec480e2..201e9c0a 100644 --- a/src/gTree.ml +++ b/src/gTree.ml @@ -474,7 +474,9 @@ type cell_properties_text_only = | `STYLE of Pango.Tags.style | `TEXT of string | `UNDERLINE of Pango.Tags.underline - | `VARIANT of Pango.Tags.variant ] + | `VARIANT of Pango.Tags.variant + | `WRAP_MODE of Pango.Tags.wrap_mode + | `WRAP_WIDTH of int ] type cell_properties_text = [ cell_properties | cell_properties_text_only diff --git a/src/gTree.mli b/src/gTree.mli index 661d326d..53a2b271 100644 --- a/src/gTree.mli +++ b/src/gTree.mli @@ -532,7 +532,9 @@ type cell_properties_text = | `TEXT of string | `UNDERLINE of Pango.Tags.underline | `VARIANT of Pango.Tags.variant - | `WEIGHT of Pango.Tags.weight ] + | `WEIGHT of Pango.Tags.weight + | `WRAP_MODE of Pango.Tags.wrap_mode + | `WRAP_WIDTH of int ] type cell_properties_toggle = [ cell_properties | `ACTIVATABLE of bool diff --git a/src/gtkTree.props b/src/gtkTree.props index 523ac8c0..3313a422 100644 --- a/src/gtkTree.props +++ b/src/gtkTree.props @@ -122,6 +122,8 @@ class CellRendererText vset : CellRenderer { "variant-set" gboolean : Read / Write / NoVSet "weight" gint : Read / Write "weight-set" gboolean : Read / Write / NoVSet + "wrap-mode" PangoWrapMode : Read / Write + "wrap-width" gint : Read / Write method set_fixed_height_from_font : "int -> unit" signal edited : GtkTreePathString string } diff --git a/tools/propcc.ml b/tools/propcc.ml index 44427c8f..6b1f3f30 100644 --- a/tools/propcc.ml +++ b/tools/propcc.ml @@ -78,7 +78,7 @@ let enums = ["ExtensionMode"; "WindowTypeHint"; "EventMask"; "Gravity"; (* for canvas *) "CapStyle"; "JoinStyle"; "LineStyle"]; "Pango", "PangoEnums", - ["Stretch"; "Style"; "Underline"; "Variant"; "EllipsizeMode"]; + ["Stretch"; "Style"; "Underline"; "Variant"; "EllipsizeMode"; "WrapMode"]; (* GtkSourceView *) "Gtk", "SourceView2Enums", ["SourceSmartHomeEndType"; "SourceDrawSpacesFlags"]; diff --git a/tools/propcc.ml4 b/tools/propcc.ml4 index 98cc0d78..6e55b2f4 100644 --- a/tools/propcc.ml4 +++ b/tools/propcc.ml4 @@ -76,7 +76,7 @@ let enums = [ [ "ExtensionMode"; "WindowTypeHint"; "EventMask"; "Gravity"; (* for canvas *) "CapStyle"; "JoinStyle"; "LineStyle" ]; "Pango", "PangoEnums", - [ "Stretch"; "Style"; "Underline"; "Variant"; "EllipsizeMode" ]; + [ "Stretch"; "Style"; "Underline"; "Variant"; "EllipsizeMode"; "WrapMode" ]; (* GtkSourceView *) "Gtk", "SourceView2Enums", [ "SourceSmartHomeEndType"; "SourceDrawSpacesFlags" ];