1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
.....
private TreeView tree;
private ListStore liststore;
private TreeModelFilter search_filter;
private TreeIter iter;
private TreePath path;
private TreeSelection selection;
private Entry filter_entry;
....
filter_entry.changed.connect(on_filter_entry_text_changed);
.....
private bool on_button_press_event (Gdk.EventButton event)
{
TreeViewColumn column;
this.selection = this.tree.get_selection ();
int x = (int)event.x;
int y = (int)event.y;
int cell_x, cell_y;
if (!(this.tree.get_path_at_pos (x, y, out path, out column, out cell_x, out cell_y)))
return true;
if ((event.type == Gdk.EventType.BUTTON_PRESS) && (event.button == 3 )) {
this.selection.get_selected (null, out this.iter);
this.selection.select_path (path);
}
if (event.button == 3) {
Menu menu = this.builder.get_object ("treeview_menu") as Menu;
menu.show_all ();
menu.popup (null, null, null, event.button, event.time);
return true;
}
return false;
}
private void on_filter_entry_text_changed ()
{
this.tree.model = search_filter;
search_filter.refilter ();
}
private bool filter_tree (TreeModel model, TreeIter iter)
{
Value cat_id;
model.get_value (iter, 1, out cat_id);
if (this.category_id == 0)
return true;
else if (cat_id.get_int () == this.category_id)
return true;
else
return false;
} |
Partager