[gnome-contacts] Window: replaced ListPane for loading spinner



commit 2ba3ae37d480b667b774203df15edfa89f32ccb6
Author: Erick Pérez Castellanos <erick red gmail com>
Date:   Thu May 15 22:47:21 2014 -0400

    Window: replaced ListPane for loading spinner
    
    Added regular style constructor to ListPane

 src/contacts-list-pane.vala |    4 +++
 src/contacts-window.ui      |   52 +++++++++++++++++++++++++++++++++---------
 src/contacts-window.vala    |   31 +++++++++++++++++++++----
 3 files changed, 71 insertions(+), 16 deletions(-)
---
diff --git a/src/contacts-list-pane.vala b/src/contacts-list-pane.vala
index e418ea3..c2b9948 100644
--- a/src/contacts-list-pane.vala
+++ b/src/contacts-list-pane.vala
@@ -88,6 +88,10 @@ public class Contacts.ListPane : Frame {
     filter_entry_changed_id = Timeout.add (300, filter_entry_changed_timeout);
   }
 
+  public ListPane (Store contacts_store) {
+    Object (store: contacts_store);
+  }
+
   construct {
     search_tool_item.set_expand (true);
     filter_entry.changed.connect (filter_entry_changed);
diff --git a/src/contacts-window.ui b/src/contacts-window.ui
index 1f93576..7a7da4a 100644
--- a/src/contacts-window.ui
+++ b/src/contacts-window.ui
@@ -22,7 +22,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <child>
-              <object class="GtkGrid">
+              <object class="GtkGrid" id="content_grid">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <child>
@@ -47,14 +47,44 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="ContactsListPane" id="list_pane">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="store">contacts_store</property>
-                    <signal name="selection-changed" handler="list_pane_selection_changed_cb" 
object="ContactsWindow" after="no" swapped="no"/>
-                    <signal name="link-contacts" handler="list_pane_link_contacts_cb" 
object="ContactsWindow" after="no" swapped="no"/>
-                    <signal name="delete-contacts" handler="list_pane_delete_contacts_cb" 
object="ContactsWindow" after="no" swapped="no"/>
-                  </object>
+                 <object class="GtkBox" id="loading_box">
+                   <property name="visible">True</property>
+                   <property name="can_focus">False</property>
+                   <property name="valign">center</property>
+                   <property name="hexpand">True</property>
+                   <property name="vexpand">True</property>
+                   <property name="orientation">vertical</property>
+                   <property name="width_request">300</property>
+                   <child>
+                     <object class="GtkSpinner">
+                       <property name="visible">True</property>
+                       <property name="can_focus">False</property>
+                       <property name="active">True</property>
+                       <style>
+                         <class name="contacts-watermark"/>
+                       </style>
+                     </object>
+                     <packing>
+                       <property name="expand">False</property>
+                       <property name="fill">True</property>
+                       <property name="position">0</property>
+                     </packing>
+                   </child>
+                   <child>
+                     <object class="GtkLabel" id="label1">
+                       <property name="visible">True</property>
+                       <property name="can_focus">False</property>
+                       <property name="valign">start</property>
+                       <property name="vexpand">True</property>
+                       <property name="label" translatable="yes">Loading</property>
+                     </object>
+                     <packing>
+                       <property name="expand">False</property>
+                       <property name="fill">True</property>
+                       <property name="position">1</property>
+                     </packing>
+                   </child>
+                 </object>
                   <packing>
                     <property name="left_attach">0</property>
                     <property name="top_attach">0</property>
@@ -282,11 +312,11 @@
       </packing>
     </child>
   </object>
-  <object class="GtkSizeGroup">
+  <object class="GtkSizeGroup" id="left_pane_size_group">
     <property name="mode">horizontal</property>
     <widgets>
       <widget name="left_toolbar"/>
-      <widget name="list_pane"/>
+      <widget name="loading_box"/>
     </widgets>
   </object>
   <object class="GtkSizeGroup">
diff --git a/src/contacts-window.vala b/src/contacts-window.vala
index 509c611..a927eb4 100644
--- a/src/contacts-window.vala
+++ b/src/contacts-window.vala
@@ -23,14 +23,18 @@ using Folks;
 [GtkTemplate (ui = "/org/gnome/contacts/contacts-window.ui")]
 public class Contacts.Window : Gtk.ApplicationWindow {
   [GtkChild]
+  private Grid content_grid;
+  [GtkChild]
+  private Box loading_box;
+  [GtkChild]
+  private SizeGroup left_pane_size_group;
+  [GtkChild]
   private HeaderBar left_toolbar;
   [GtkChild]
   private HeaderBar right_toolbar;
   [GtkChild]
   private Overlay overlay;
   [GtkChild]
-  private ListPane list_pane;
-  [GtkChild]
   private ContactPane contact_pane;
   [GtkChild]
   private ToggleButton select_button;
@@ -57,6 +61,7 @@ public class Contacts.Window : Gtk.ApplicationWindow {
 
   [GtkChild]
   public Store contacts_store;
+  private ListPane list_pane;
 
   /* FIXME: remove from public what it is not needed */
   [GtkChild]
@@ -105,6 +110,11 @@ public class Contacts.Window : Gtk.ApplicationWindow {
          /* Here we need to wait for Store::quiescent */
          view_switcher.visible_child_name = "content-view";
          set_titlebar (content_header_bar);
+
+          Timeout.add (5000, () => {
+             this.set_list_pane ();
+             return false;
+           });
        });
       setup_cancel_button.clicked.connect (() => {
          destroy ();
@@ -114,6 +124,20 @@ public class Contacts.Window : Gtk.ApplicationWindow {
     init_content_widgets ();
   }
 
+  public void set_list_pane () {
+    list_pane = new ListPane (store);
+    list_pane.selection_changed.connect (list_pane_selection_changed_cb);
+    list_pane.link_contacts.connect (list_pane_link_contacts_cb);
+    list_pane.delete_contacts.connect (list_pane_delete_contacts_cb);
+
+    left_pane_size_group.add_widget (list_pane);
+    left_pane_size_group.remove_widget (loading_box);
+    loading_box.destroy ();
+
+    content_grid.attach (list_pane, 0, 0, 1, 1);
+    list_pane.show ();
+  }
+
   public void activate_selection_mode (bool active) {
     if (active) {
       add_button.hide ();
@@ -263,12 +287,10 @@ public class Contacts.Window : Gtk.ApplicationWindow {
     return false;
   }
 
-  [GtkCallback]
   void list_pane_selection_changed_cb (Contact? new_selection) {
     set_shown_contact (new_selection);
   }
 
-  [GtkCallback]
   void list_pane_link_contacts_cb (LinkedList<Contact> contact_list) {
     /* getting out of selection mode */
     set_shown_contact (null);
@@ -306,7 +328,6 @@ public class Contacts.Window : Gtk.ApplicationWindow {
       });
   }
 
-  [GtkCallback]
   void list_pane_delete_contacts_cb (LinkedList<Contact> contact_list) {
     /* getting out of selection mode */
     set_shown_contact (null);


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