Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Gtk;
- void main (string [] args) {
- Gtk.init(ref args);
- Window window = new Window();
- window.set_default_size(150,300);
- window.destroy.connect(Gtk.main_quit);
- ListStore model = new ListStore(1, typeof(string));
- string text = "Lorem ipsum dolor sit amet, consectetur adipiscing ";
- string text2 = "Haste nicht gesehen, die Wahrscheinlichkeitsdefinition in C ist immer wahr wenn ungleich null";
- TreeIter iter;
- model.append(out iter);
- model.set(iter, 0, text, -1);
- model.append(out iter);
- model.set(iter, 0, text2, -1);
- TreeView view = new TreeView.with_model(model);
- CellRendererText renderer = new CellRendererText();
- renderer.wrap_mode = Pango.WrapMode.WORD;
- renderer.wrap_width = -1;
- TreeViewColumn column = new TreeViewColumn();
- column.set_title("Test");
- column.pack_start(renderer, false);
- column.set_attributes(renderer, "text", 0);
- column.set_sizing(TreeViewColumnSizing.AUTOSIZE);
- column.set_resizable(true);
- view.append_column(column);
- // window.size_allocate.connect_after( (alloc) => {
- // int newWidth = alloc.width;
- // print("%d\n", newWidth);
- //// renderer.width=newWidth;
- //// GLib.Value tmp = GLib.Value(typeof(int));
- //// view.style_get_property("horizontal-separator", out tmp);
- //// newWidth -= tmp.get_int() * 4;
- // if ( renderer.wrap_width == newWidth || newWidth <= 0 ) {
- // return;
- // }
- // if (newWidth < 150)
- // newWidth = 150;
- // renderer.wrap_width = newWidth;
- //
- // column.set_fixed_width(newWidth);
- // column.set_min_width(newWidth);
- // column.set_max_width(newWidth);
- //
- // TreeIter ite;
- // bool valid = model.get_iter_first(out ite);
- //
- // while (valid && model.iter_is_valid(iter)) {
- // model.row_changed(model.get_path(ite), ite);
- // valid = model.iter_next(ref ite);
- //// print("%s\n", valid.to_string());
- //// view.set_size_request(0, -1);
- // }
- // });
- window.add(view);
- window.show_all();
- Gtk.main();
- }
Add Comment
Please, Sign In to add comment