27
27
public class Treeview : Gtk.VBox {
29
29
private MainWindow window;
30
public E.Contact selected;
31
Gee.HashMap <int, E.Contact> contact_map;
30
33
//public E.Contact selected;
32
private int recent = 0;
34
35
public TreeView view;
35
36
TreeViewColumn column_name;
36
37
TreeViewColumn column_surname;
50
53
selection.set_mode (SelectionMode.MULTIPLE);
51
54
selection.changed.connect (on_selection_changed);
53
column_name = new TreeViewColumn.with_attributes ("Name", new CellRendererText (), "text", 0);
56
column_recents = new TreeViewColumn.with_attributes ("Recents", new CellRendererText (), "text", 0);
57
column_recents.visible = false;
59
column_name = new TreeViewColumn.with_attributes ("Name", new CellRendererText (), "text", 1);
54
60
//column_name.visible = false;
56
column_surname = new TreeViewColumn.with_attributes ("Surname", new CellRendererText (), "text", 1);
57
column_surname.visible = false;
59
column_recents = new TreeViewColumn.with_attributes ("Recents", new CellRendererText (), "text", 2);
60
column_recents.visible = false;
62
column_surname = new TreeViewColumn.with_attributes ("Surname", new CellRendererText (), "text", 2);
63
column_surname.visible = false;
62
65
view.insert_column (column_name, 0);
63
66
view.insert_column (column_surname, 1);
64
67
view.insert_column (column_recents, 2);
66
listmodel = new ListStore (3, typeof(string), typeof(string), typeof(int));
69
listmodel = new ListStore (3, typeof(int), typeof(string), typeof(string));
67
70
view.set_model (listmodel);
69
72
listmodel.set_sort_column_id (0, SortType.ASCENDING);
71
pack_start (view, true, true, 0);
74
var sw = new ScrolledWindow (null, null);
76
pack_start (sw, true, true, 0);
73
78
status = new Statusbar ();
74
79
status.sensitive = false;
85
90
listmodel.append (out iter);
88
listmodel.set (iter, 0, contact.full_name, 1, "", 2, recent);
92
contact_map.set (n_contact, contact);
94
listmodel.set (iter, 0, n_contact, 1, contact.full_name, 2, "");
94
status.push (0, recent.to_string () + _("Contacs"));
98
status.push (0, n_contact.to_string () + _("Contacs"));
104
public E.Contact get_contact (int n) {
105
return contact_map.get (n);
98
108
public void on_selection_changed () {
115
125
listmodel.get_value (iter, 0, out val);
117
string sel = val.dup_string ();
120
//if (selected.full_name != null)
121
window.toolbar.set_buttons_sensitive (true);
123
window.toolbar.set_buttons_sensitive (false);
127
selected = contact_map.get (val.get_int ());
129
window.toolbar.set_buttons_sensitive (true);