summaryrefslogtreecommitdiff
path: root/src/contacts-setup-window.vala
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2017-12-30 15:10:38 +0100
committerNiels De Graef <nielsdegraef@gmail.com>2017-12-30 15:14:46 +0100
commit489f6d3c01f4ea0bdfa3a9cca0dae727517706ee (patch)
tree084a017d1074faf5204e9faf4303b12e02b7f024 /src/contacts-setup-window.vala
parent819edbdddaca2df37c3aa15c14f8226f1f1b5d86 (diff)
downloadgnome-contacts-489f6d3c01f4ea0bdfa3a9cca0dae727517706ee.tar.gz
Extract setup window into a separate class.
This simplifies the code in ContactsWindow by a bit and also prevents unnecessary loading of the setup UI.
Diffstat (limited to 'src/contacts-setup-window.vala')
-rw-r--r--src/contacts-setup-window.vala74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/contacts-setup-window.vala b/src/contacts-setup-window.vala
new file mode 100644
index 0000000..4b13a85
--- /dev/null
+++ b/src/contacts-setup-window.vala
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2011 Alexander Larsson <alexl@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+using Gee;
+using Gtk;
+using Folks;
+
+[GtkTemplate (ui = "/org/gnome/Contacts/ui/contacts-setup-window.ui")]
+public class Contacts.SetupWindow : Gtk.ApplicationWindow {
+ [GtkChild]
+ private Grid content;
+
+ [GtkChild]
+ private Button setup_done_button;
+
+ private AccountsList setup_accounts_list;
+
+ /**
+ * Fired after the user has succesfully performed the setup proess.
+ */
+ public signal void setup_done (Edsf.PersonaStore selected_address_book);
+
+ public SetupWindow (App app, Store store) {
+ Object (application: app);
+ this.setup_accounts_list = new AccountsList (store);
+ this.setup_accounts_list.hexpand = true;
+ this.setup_accounts_list.halign = Align.CENTER;
+ this.setup_accounts_list.show ();
+ this.content.add (this.setup_accounts_list);
+
+ // Listen for changes
+ store.eds_persona_store_changed.connect ( () => {
+ this.setup_accounts_list.update_contents (false);
+ });
+
+ ulong id2 = 0;
+ id2 = this.setup_accounts_list.account_selected.connect (() => {
+ this.setup_done_button.set_sensitive (true);
+ this.setup_accounts_list.disconnect (id2);
+ });
+
+ fill_accounts_list (store);
+
+ this.setup_done_button.clicked.connect (() => {
+ var selected_store = this.setup_accounts_list.selected_store as Edsf.PersonaStore;
+ setup_done (selected_store);
+ });
+ }
+
+ private void fill_accounts_list (Store store) {
+ if (store.is_prepared) {
+ this.setup_accounts_list.update_contents (false);
+ return;
+ }
+
+ store.prepared.connect ( () => {
+ this.setup_accounts_list.update_contents (false);
+ });
+ }
+}