Skip to content

Commit

Permalink
Add WRAP_WIDTH, WRAP_MODE tags to cell_properties_text, supported sin…
Browse files Browse the repository at this point in the history
…ce gtk 2.8 (#146)
  • Loading branch information
nguermond authored Dec 18, 2021
1 parent 50a134c commit 9d8553e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
6 changes: 5 additions & 1 deletion examples/tree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/gTree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/gTree.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/gtkTree.props
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion tools/propcc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down
2 changes: 1 addition & 1 deletion tools/propcc.ml4
Original file line number Diff line number Diff line change
Expand Up @@ -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" ];
Expand Down

0 comments on commit 9d8553e

Please sign in to comment.