~mefrio-g/dexter-rolodex/dexter-vala

« back to all changes in this revision

Viewing changes to src/Widgets/TreeView.vala

  • Committer: Mario Guerriero
  • Date: 2011-11-22 18:01:38 UTC
  • Revision ID: mefrio.g@gmail.com-20111122180138-cisoclcmo277388c
added a .desktop file and fixed some EDS things

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
        public class Treeview : Gtk.VBox {
28
28
                
29
29
                private MainWindow window;
 
30
                public E.Contact selected;
 
31
                Gee.HashMap <int, E.Contact> contact_map;
 
32
                int n_contact = 0;
30
33
                //public E.Contact selected;
31
34
                
32
 
                private int recent = 0;
33
 
                
34
35
                public TreeView view;
35
36
                TreeViewColumn column_name;
36
37
                TreeViewColumn column_surname;
43
44
                public Treeview (MainWindow window) {
44
45
                        
45
46
                        this.window = window;
 
47
                        contact_map = new Gee.HashMap <int, E.Contact> ();
 
48
                        selected = new E.Contact ();
46
49
                        
47
50
                        view = new TreeView ();
48
51
                        
50
53
                        selection.set_mode (SelectionMode.MULTIPLE);
51
54
                        selection.changed.connect (on_selection_changed);
52
55
                        
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;
 
58
                        
 
59
                        column_name = new TreeViewColumn.with_attributes ("Name", new CellRendererText (), "text", 1);
54
60
                        //column_name.visible = false;
55
61
 
56
 
                        column_surname = new TreeViewColumn.with_attributes ("Surname", new CellRendererText (), "text", 1);
57
 
                        column_surname.visible = false;
58
 
 
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;                 
61
64
 
62
65
                        view.insert_column (column_name, 0);
63
66
                        view.insert_column (column_surname, 1);
64
67
                        view.insert_column (column_recents, 2);
65
68
                                                
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);
68
71
                        
69
72
                        listmodel.set_sort_column_id (0, SortType.ASCENDING);
70
73
                        
71
 
                        pack_start (view, true, true, 0);
 
74
                        var sw = new ScrolledWindow (null, null);
 
75
                        sw.add (view);
 
76
                        pack_start (sw, true, true, 0);
72
77
                        
73
78
                        status = new Statusbar ();
74
79
                        status.sensitive = false;
84
89
                        
85
90
                            listmodel.append (out iter);
86
91
                        
87
 
                        
88
 
                            listmodel.set (iter, 0, contact.full_name, 1, "", 2, recent);
 
92
                            contact_map.set (n_contact, contact);
 
93
                            
 
94
                            listmodel.set (iter, 0, n_contact, 1, contact.full_name, 2, "");
89
95
                        
90
96
                            show_all ();
91
97
                        
92
 
                            recent++;
93
 
                        
94
 
                            status.push (0, recent.to_string () +  _("Contacs"));
 
98
                            status.push (0, n_contact.to_string () +  _("Contacs"));
 
99
                            
 
100
                            n_contact++;
95
101
                        }
96
102
                }
 
103
                
 
104
                public E.Contact get_contact (int n) {
 
105
                    return contact_map.get (n);
 
106
                }
97
107
                        
98
108
                public void on_selection_changed () {
99
109
 
113
123
                                return;
114
124
 
115
125
                        listmodel.get_value (iter, 0, out val);
116
 
 
117
 
                        string sel = val.dup_string ();
118
 
 
119
 
                        if (sel != null)
120
 
                        //if (selected.full_name != null) 
121
 
                                window.toolbar.set_buttons_sensitive (true);
122
 
                        else
123
 
                                window.toolbar.set_buttons_sensitive (false);
 
126
            
 
127
            selected = contact_map.get (val.get_int ());
 
128
            
 
129
                        window.toolbar.set_buttons_sensitive (true);
124
130
                        
125
131
                }       
126
132