Guest User

Untitled

a guest
Dec 8th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 1.93 KB | None | 0 0
  1. using Gtk;
  2.  
  3. void main (string [] args) {
  4.     Gtk.init(ref args);
  5.    
  6.     Window window = new Window();
  7.     window.set_default_size(150,300);
  8.     window.destroy.connect(Gtk.main_quit);
  9.    
  10.     ListStore model = new ListStore(1, typeof(string));
  11.     string text = "Lorem ipsum dolor sit amet, consectetur adipiscing ";
  12.     string text2 = "Haste nicht gesehen, die Wahrscheinlichkeitsdefinition in C ist immer wahr wenn ungleich null";
  13.     TreeIter iter;
  14.     model.append(out iter);
  15.     model.set(iter, 0, text, -1);
  16.    
  17.     model.append(out iter);
  18.     model.set(iter, 0, text2, -1);
  19.    
  20.     TreeView view = new TreeView.with_model(model);
  21.     CellRendererText renderer = new CellRendererText();
  22.     renderer.wrap_mode = Pango.WrapMode.WORD;
  23.     renderer.wrap_width = -1;
  24.    
  25.     TreeViewColumn column = new TreeViewColumn();
  26.     column.set_title("Test");
  27.     column.pack_start(renderer, false);
  28.     column.set_attributes(renderer, "text", 0);
  29.     column.set_sizing(TreeViewColumnSizing.AUTOSIZE);
  30.     column.set_resizable(true);
  31.     view.append_column(column);
  32. //  window.size_allocate.connect_after( (alloc) => {
  33. //      int newWidth = alloc.width;
  34. //      print("%d\n", newWidth);
  35. ////        renderer.width=newWidth;
  36. ////        GLib.Value tmp = GLib.Value(typeof(int));
  37. ////        view.style_get_property("horizontal-separator", out tmp);
  38. ////        newWidth -= tmp.get_int() * 4;
  39. //      if ( renderer.wrap_width == newWidth || newWidth <= 0 ) {
  40. //          return;
  41. //      }
  42. //      if (newWidth < 150)
  43. //          newWidth = 150;
  44. //      renderer.wrap_width = newWidth;
  45. //     
  46. //      column.set_fixed_width(newWidth);
  47. //      column.set_min_width(newWidth);
  48. //      column.set_max_width(newWidth);
  49. //     
  50. //      TreeIter ite;
  51. //      bool valid = model.get_iter_first(out ite);
  52. //     
  53. //      while (valid && model.iter_is_valid(iter)) {
  54. //          model.row_changed(model.get_path(ite), ite);
  55. //          valid = model.iter_next(ref ite);
  56. ////            print("%s\n", valid.to_string());
  57. ////            view.set_size_request(0, -1);
  58. //      }
  59. //  });
  60.    
  61.     window.add(view);
  62.     window.show_all();
  63.     Gtk.main();
  64. }
Add Comment
Please, Sign In to add comment