Add ListStore to store the identity cards
[moonshot-ui.git] / src / moonshot-window.vala
1 using Gtk;
2
3 class MainWindow : Window
4 {
5
6     private Entry search_entry;
7     private TreeView identities_list;
8
9     public MainWindow()
10     {
11         this.title = "Moonshoot";
12         this.position = WindowPosition.CENTER;
13         set_default_size (400, 300);
14
15         build_ui();
16         connect_signals();
17     }
18
19     private void search_entry_icon_press_cb ()
20     {
21         print ("Search entry icon pressed\n");
22     }
23
24     private void search_entry_text_changed_cb ()
25     {
26         var has_text = this.search_entry.get_text_length () > 0;
27         this.search_entry.set_icon_sensitive (EntryIconPosition.SECONDARY, has_text);
28     }
29
30     private void setup_identities_list ()
31     {
32         var listmodel = new ListStore (1, typeof (string)); //TODO
33
34         this.identities_list.set_model (listmodel);
35     }
36
37     private void build_ui()
38     {
39         var toolbar = new Toolbar ();
40         var open_button = new ToolButton (null, "Open"); //.from_stock (Stock.OPEN);
41         open_button.is_important = true;
42         toolbar.add (open_button);
43         //open_button.clicked.connect (on_open_clicked);
44
45         this.search_entry = new Entry();
46         this.search_entry.set_icon_from_icon_name (EntryIconPosition.SECONDARY, "system-search");
47         this.search_entry.set_icon_sensitive (EntryIconPosition.SECONDARY, false);
48         this.search_entry.set_icon_tooltip_text (EntryIconPosition.SECONDARY,
49                                                  "Search identity or service");
50         this.search_entry.icon_press.connect (search_entry_icon_press_cb);
51         this.search_entry.notify["text"].connect (search_entry_text_changed_cb);
52
53         this.identities_list = new TreeView ();
54         this.identities_list.set_headers_visible (false);
55         setup_identities_list ();
56
57         var scroll = new ScrolledWindow (null, null);
58         scroll.set_policy (PolicyType.NEVER, PolicyType.AUTOMATIC);
59         scroll.set_shadow_type (ShadowType.IN);
60         scroll.add (this.identities_list);
61
62         var button_add = new Button.from_stock ("gtk-add");
63         var button_remove = new Button.from_stock ("gtk-remove");
64         var button_box = new HButtonBox ();
65         button_box.set_layout (ButtonBoxStyle.SPREAD);
66         button_box.pack_start (button_add, false, false, 0);
67         button_box.pack_start (button_remove, false, false, 0);
68
69         var vbox = new VBox (false, 0);
70         vbox.pack_start (toolbar, false, true, 0);
71         vbox.pack_start (search_entry, false, true, 0);
72         vbox.pack_start (scroll, true, true, 0);
73         vbox.pack_start (button_box, false, false, 0);
74         add (vbox);
75     }
76
77     private void connect_signals()
78     {
79         this.destroy.connect (Gtk.main_quit);
80     }
81
82     public static int main(string[] args)
83     {
84         Gtk.init(ref args);
85
86         Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
87         Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
88         Intl.textdomain (Config.GETTEXT_PACKAGE);
89
90         var window = new MainWindow();
91         window.show_all();
92
93         Gtk.main();
94
95         return 0;
96     }
97 }