Guest User

Untitled

a guest
Jan 5th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 1.77 KB | None | 0 0
  1.             list_model = new ListStore(5,       typeof(int),            // ID
  2.                                                 typeof(string),         // Task name
  3.                                                 typeof(string),         // Notes
  4.                                                 typeof(string),         // Date due
  5.                                                 typeof(bool)        // Done - Toggle                                               
  6.             );                                             
  7.             set_model(list_model);
  8.  
  9.             var column = new Gtk.TreeViewColumn();
  10.            
  11.             // Done toggle column
  12.             var toggle = new CellRendererToggle();
  13.             toggle.toggled.connect((toggle, path) => {
  14.                 var tree_path = new TreePath.from_string(path);
  15.                 TreeIter iter;
  16.                 list_model.get_iter (out iter, tree_path);
  17.                 list_model.set (iter, Columns.TOGGLE, !toggle.active);
  18.             });
  19.             column.pack_start (toggle, false);
  20.             column.add_attribute (toggle, "active", Columns.TOGGLE);
  21.             insert_column(column, 0);
  22.            
  23.             // Task name cloumn
  24.             insert_column_with_attributes(-1, "Task", new CellRendererText(), "text", 1, null);
  25.                        
  26.             // Expander column
  27.             column = new Gtk.TreeViewColumn();
  28.             column.set_expand(true);
  29.             insert_column(column, 2);
  30.            
  31.             // Date column
  32.             insert_column_with_attributes(-1, "Date", new CellRendererText(), "text", 3, null);
  33.            
  34.             // Remove column
  35.             column = new Gtk.TreeViewColumn();
  36.             var remove_pixbuf = new CellRendererPixbuf();
  37.             /*Add
  38.             remove_pixbuf.clicked.connect((path) => {
  39.                 //Delete row from backend -> refresh model
  40.             }
  41.             */                        
  42.             remove_pixbuf.stock_id = "gtk-close";
  43.             column.pack_start (remove_pixbuf, false);
  44.             insert_column(column, 4);
  45.         }
Add Comment
Please, Sign In to add comment