[gnome-contacts] SetupWindow: use new AccountsList widget
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] SetupWindow: use new AccountsList widget
- Date: Wed, 24 Jul 2013 15:05:59 +0000 (UTC)
commit 5ae5f2e57d6f88138bbfbbf56edf3b84592f3c19
Author: Erick Pérez Castellanos <erick red gmail com>
Date: Wed Jul 24 01:13:33 2013 -0400
SetupWindow: use new AccountsList widget
src/contacts-setup-window.vala | 197 +++++++++-------------------------------
1 files changed, 44 insertions(+), 153 deletions(-)
---
diff --git a/src/contacts-setup-window.vala b/src/contacts-setup-window.vala
index d8fca39..d91fdad 100644
--- a/src/contacts-setup-window.vala
+++ b/src/contacts-setup-window.vala
@@ -22,94 +22,8 @@ using Folks;
public class Contacts.SetupWindow : Gtk.Window {
public bool succeeded;
private ulong source_list_changed_id;
- public Label title_label;
- public Grid content_grid;
- ToolButton select_button;
- ListStore list_store;
- TreeView tree_view;
-
- public void update_content () {
- foreach (var w in content_grid.get_children ()) {
- w.destroy ();
- }
-
- var l = new Label (_("Welcome to Contacts! Please select where you want to keep your address book:"));
- l.set_line_wrap (true);
- l.set_max_width_chars (5);
- l.set_halign (Align.FILL);
- l.set_alignment (0.0f, 0.5f);
- content_grid.add (l);
-
- Button goa_button;
-
- if (has_goa_account ()) {
- select_button.show ();
-
- tree_view = new TreeView ();
- var store = new ListStore (2, typeof (string), typeof (Folks.PersonaStore));
- list_store = store;
- tree_view.set_model (store);
- tree_view.set_headers_visible (false);
- tree_view.get_selection ().set_mode (SelectionMode.BROWSE);
-
- var column = new Gtk.TreeViewColumn ();
- tree_view.append_column (column);
-
- var renderer = new Gtk.CellRendererText ();
- column.pack_start (renderer, false);
- column.add_attribute (renderer, "text", 0);
-
- var scrolled = new ScrolledWindow(null, null);
- scrolled.set_size_request (340, 220);
- scrolled.set_policy (PolicyType.NEVER, PolicyType.AUTOMATIC);
- scrolled.set_vexpand (false);
- scrolled.set_shadow_type (ShadowType.IN);
- scrolled.add (tree_view);
-
- content_grid.add (scrolled);
-
- TreeIter iter;
- foreach (var persona_store in App.get_eds_address_books ()) {
- var name = Contact.format_persona_store_name (persona_store);
- store.append (out iter);
- store.set (iter, 0, name, 1, persona_store);
- if (persona_store == App.app.contacts_store.aggregator.primary_store) {
- tree_view.get_selection ().select_iter (iter);
- }
- }
-
- goa_button = new Button.with_label (_("Online Account Settings"));
- content_grid.add (goa_button);
-
- } else {
- select_button.hide ();
- l = new Label (_("Setup an online account or use a local address book"));
- content_grid.add (l);
-
- goa_button = new Button.with_label (_("Online Accounts"));
- content_grid.add (goa_button);
-
- var b = new Button.with_label (_("Use Local Address Book"));
- content_grid.add (b);
-
- b.clicked.connect ( () => {
- var source = eds_source_registry.ref_builtin_address_book ();
- select_source (source);
- });
- }
-
- goa_button.clicked.connect ( (button) => {
- try {
- update_content ();
- Process.spawn_command_line_async ("gnome-control-center online-accounts");
- }
- catch (Error e) {
- // TODO: Show error dialog
- }
- });
-
- content_grid.show_all ();
- }
+ AccountsList accounts_list;
+ Button done_button;
private void select_source (E.Source source) {
eds_source_registry.set_default_address_book (source);
@@ -118,76 +32,64 @@ public class Contacts.SetupWindow : Gtk.Window {
destroy ();
}
-
public SetupWindow () {
- var grid = new Grid ();
- this.add (grid);
- this.set_title (_("Contacts Setup"));
this.set_default_size (640, 480);
- this.hide_titlebar_when_maximized = true;
+ var titlebar = new HeaderBar ();
+ titlebar.set_title (_("Contacts Setup"));
+ set_titlebar (titlebar);
- var toolbar = new Toolbar ();
- toolbar.set_icon_size (IconSize.MENU);
- toolbar.get_style_context ().add_class (STYLE_CLASS_MENUBAR);
- toolbar.set_vexpand (false);
- toolbar.set_hexpand (true);
- grid.attach (toolbar, 0, 0, 1, 1);
-
- var cancel_button = new ToolButton (null, _("Cancel"));
- cancel_button.is_important = true;
- toolbar.add (cancel_button);
+ var cancel_button = new Button.with_label (_("Cancel"));
+ cancel_button.get_child ().margin = 3;
+ cancel_button.get_child ().margin_left = 6;
+ cancel_button.get_child ().margin_right = 6;
+ titlebar.pack_start (cancel_button);
cancel_button.clicked.connect ( (button) => {
this.destroy ();
});
- var item = new ToolItem ();
- title_label = new Label ("");
- title_label.set_markup (Markup.printf_escaped ("<b>%s</b>",_("Contacts Setup")));
- title_label.set_no_show_all (true);
- item.add (title_label);
- item.set_expand (true);
- toolbar.add (item);
-
- select_button = new ToolButton (null, _("Select"));
- select_button.is_important = true;
- select_button.set_no_show_all (true);
- toolbar.add (select_button);
- select_button.clicked.connect ( (button) => {
- PersonaStore selected_store;
- TreeIter iter;
-
- if (tree_view.get_selection() .get_selected (null, out iter)) {
- list_store.get (iter, 1, out selected_store);
+ /* hack to avoid accounts_list getting the focus and
+ * triggering row_selected signal */
+ cancel_button.grab_focus ();
- var e_store = selected_store as Edsf.PersonaStore;
- select_source (e_store.source);
- }
- });
+ done_button = new Button.with_label (_("Done"));
+ done_button.get_child ().margin = 3;
+ done_button.get_child ().margin_left = 6;
+ done_button.get_child ().margin_right = 6;
+ done_button.set_sensitive (false);
+ titlebar.pack_end (done_button);
- var frame = new Frame (null);
- frame.get_style_context ().add_class ("contacts-content");
+ titlebar.show_all ();
- var box = new EventBox ();
- box.set_hexpand (true);
- box.set_vexpand (true);
- box.get_style_context ().add_class ("contacts-main-view");
- box.get_style_context ().add_class ("view");
+ var grid = new Grid ();
+ grid.set_orientation (Orientation.VERTICAL);
+ grid.set_border_width (24);
+ grid.set_row_spacing (24);
+ this.add (grid);
- frame.add (box);
- grid.attach (frame, 0, 1, 1, 1);
+ var l = new Label (_("Please select your primary Contacts account"));
+ l.set_halign (Align.CENTER);
+ grid.add (l);
- content_grid = new Grid ();
- content_grid.set_border_width (12);
- content_grid.set_orientation (Orientation.VERTICAL);
- content_grid.set_halign (Align.CENTER);
- content_grid.set_row_spacing (8);
- box.add (content_grid);
+ var accounts_list = new AccountsList ();
+ accounts_list.set_halign (Align.CENTER);
+ accounts_list.update_contents (false);
- update_content ();
+ grid.add (accounts_list);
source_list_changed_id = eds_source_registry.source_changed.connect ( () => {
- update_content ();
+ accounts_list.update_contents (false);
+ });
+
+ accounts_list.account_selected.connect (() => {
+ done_button.set_sensitive (true);
+ });
+
+ done_button.clicked.connect ( (button) => {
+ PersonaStore selected_store;
+ var e_store = accounts_list.selected_store as Edsf.PersonaStore;
+
+ select_source (e_store.source);
});
grid.show_all ();
@@ -200,15 +102,4 @@ public class Contacts.SetupWindow : Gtk.Window {
}
base.destroy ();
}
-
- public override bool window_state_event (Gdk.EventWindowState e) {
- base.window_state_event (e);
-
- if ((e.new_window_state & Gdk.WindowState.MAXIMIZED) != 0)
- title_label.show ();
- else
- title_label.hide ();
-
- return false;
- }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]