[gnome-contacts] ContactPane: moved into Window



commit 7c1459d8a72485d4d4ee627dd202ce34111e335d
Author: Erick Pérez Castellanos <erick red gmail com>
Date:   Fri Apr 25 23:48:41 2014 -0400

    ContactPane: moved into Window
    
    Added Store as a public property. I will prefer the property being
    private but GtkBuilder would not be able of setting it that way.

 src/contacts-app.vala          |    8 +++-----
 src/contacts-contact-pane.vala |   26 +++++++++++++++++---------
 src/contacts-window.ui         |    6 +++++-
 src/contacts-window.vala       |    8 +++-----
 4 files changed, 28 insertions(+), 20 deletions(-)
---
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index 540d2af..0912edf 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -30,7 +30,7 @@ public class Contacts.App : Gtk.Application {
   public Contacts.Window window;
 
   private ListPane list_pane;
-  private ContactPane contacts_pane;
+  private weak ContactPane contacts_pane;
 
   private bool app_menu_created;
 
@@ -249,13 +249,11 @@ public class Contacts.App : Gtk.Application {
 
     window.add_left_child (list_pane);
 
-    contacts_pane = new ContactPane (contacts_store);
-    contacts_pane.set_hexpand (true);
+    contacts_pane = window.contacts_pane;
+
     contacts_pane.will_delete.connect (delete_contact);
     contacts_pane.contacts_linked.connect (contacts_linked);
 
-    window.add_right_child (contacts_pane);
-
     list_pane.contacts_marked.connect ((nr_contacts) => {
        if (nr_contacts == 0) {
          window.left_title = _("Select");
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 4d22ddf..eef0572 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -44,7 +44,21 @@ namespace Contacts {
 }
 
 public class Contacts.ContactPane : Notebook {
-  private Store contacts_store;
+  private Store _store;
+
+  public Store store {
+    get {
+      return _store;
+    }
+    set {
+      _store = value;
+
+      // Refresh the view when the store is quiescent as we may have missed
+      // some potential matches while the store was still preparing.
+      _store.quiescent.connect (update_sheet);
+    }
+  }
+
   public Contact? contact;
 
   /* 3 pages, first */
@@ -167,7 +181,7 @@ public class Contacts.ContactPane : Notebook {
     });
 
     no.clicked.connect ( () => {
-       contacts_store.add_no_suggest_link (contact, c);
+       store.add_no_suggest_link (contact, c);
        /* TODO: Add undo */
        suggestion_grid.destroy ();
       });
@@ -219,11 +233,9 @@ public class Contacts.ContactPane : Notebook {
       show_no_selection_frame ();
   }
 
-  public ContactPane (Store contacts_store) {
+  construct {
     this.show_tabs = false;
 
-    this.contacts_store = contacts_store;
-
     this.edit_contact_actions = new SimpleActionGroup ();
     this.edit_contact_actions.add_action_entries (action_entries, this);
 
@@ -258,10 +270,6 @@ public class Contacts.ContactPane : Notebook {
     main_sw.show_all ();
     insert_page (main_sw, null, 1);
 
-    // Refresh the view when the store is quiescent as we may have missed
-    // some potential matches while the store was still preparing.
-    contacts_store.quiescent.connect (update_sheet);
-
     suggestion_grid = null;
 
     /* edit mode widgetry, third page */
diff --git a/src/contacts-window.ui b/src/contacts-window.ui
index 68e4a09..cd07b4a 100644
--- a/src/contacts-window.ui
+++ b/src/contacts-window.ui
@@ -137,7 +137,11 @@
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <child>
-                  <placeholder/>
+                  <object class="ContactsContactPane" id="contacts_pane">
+                    <property name="store">contacts_store</property>
+                    <property name="visible">True</property>
+                    <property name="hexpand">True</property>
+                  </object>
                 </child>
               </object>
               <packing>
diff --git a/src/contacts-window.vala b/src/contacts-window.vala
index edb8154..1e94531 100644
--- a/src/contacts-window.vala
+++ b/src/contacts-window.vala
@@ -35,6 +35,9 @@ public class Contacts.Window : Gtk.ApplicationWindow {
   [GtkChild]
   public Store contacts_store;
 
+  [GtkChild]
+  public ContactPane contacts_pane;
+
   /* FIXME: remove from public what it is not needed */
   [GtkChild]
   public Button add_button;
@@ -106,11 +109,6 @@ public class Contacts.Window : Gtk.ApplicationWindow {
     child.show ();
   }
 
-  public void add_right_child (Widget child) {
-    right_overlay.add (child);
-    child.show ();
-  }
-
   public void add_notification (Widget notification) {
     overlay.add_overlay (notification);
   }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]