[gnome-contacts] Window: added setup view widgets



commit 4a02ad040561954fd12c3ae4b812450879e96650
Author: Erick Pérez Castellanos <erick red gmail com>
Date:   Sat Apr 26 20:00:42 2014 -0400

    Window: added setup view widgets
    
    Added placeholder code to handle setup showing logic and Contacts.Store signals

 src/contacts-app.vala    |    3 +-
 src/contacts-window.ui   |  340 ++++++++++++++++++++++++++++++----------------
 src/contacts-window.vala |   58 +++++++--
 3 files changed, 272 insertions(+), 129 deletions(-)
---
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index 45fca29..1486ee9 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -180,7 +180,8 @@ public class Contacts.App : Gtk.Application {
   private void create_window () {
     window = new Contacts.Window (this);
 
-    contacts_store = window.contacts_store;
+    /* FIXME: place where it should be placed */
+    //contacts_store = window.contacts_store;
 
     window.add_button.clicked.connect (app.new_contact);
   }
diff --git a/src/contacts-window.ui b/src/contacts-window.ui
index 772a368..99ad6b9 100644
--- a/src/contacts-window.ui
+++ b/src/contacts-window.ui
@@ -11,186 +11,290 @@
     <signal name="key-press-event" handler="key_press_event_cb" object="ContactsWindow" after="yes" 
swapped="no"/>
     <signal name="delete-event" handler="delete_event_cb" object="ContactsWindow" after="no" swapped="no"/>
     <child type="titlebar">
-      <object class="GtkBox" id="box1">
+      <placeholder />
+    </child>
+    <child>
+      <object class="GtkStack" id="view_switcher">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <child>
-          <object class="GtkHeaderBar" id="left_toolbar">
+          <object class="GtkOverlay" id="overlay">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="title" translatable="yes">All Contacts</property>
-            <property name="show_close_button">True</property>
-            <style>
-              <class name="contacts-left-header-bar"/>
-              <class name="titlebar"/>
-            </style>
             <child>
-              <object class="GtkButton" id="add_button">
+              <object class="GtkGrid">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="halign">center</property>
-                <property name="valign">center</property>
-                <child internal-child="accessible">
-                  <object class="AtkObject" id="add_button_atkobject">
-                    <property name="AtkObject::accessible-name" translatable="yes">Add contact</property>
-                  </object>
-                </child>
-                <style>
-                  <class name="image-button"/>
-                </style>
+                <property name="can_focus">False</property>
                 <child>
-                  <object class="GtkImage" id="image1">
+                  <object class="GtkOverlay">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="icon_name">list-add-symbolic</property>
-                    <property name="icon_size">1</property>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="pack_type">start</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkToggleButton" id="select_button">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="focus_on_click">False</property>
-                <property name="halign">center</property>
-                <property name="valign">center</property>
-                <child internal-child="accessible">
-                  <object class="AtkObject" id="select_button_atkobject">
-                    <property name="AtkObject::accessible-name" translatable="yes">Selection mode</property>
+                    <child>
+                      <object class="ContactsContactPane" id="contact_pane">
+                        <property name="store">contacts_store</property>
+                        <property name="show_tabs">False</property>
+                        <property name="visible">True</property>
+                        <property name="hexpand">True</property>
+                        <signal name="will-delete" handler="contact_pane_delete_contact_cb" 
object="ContactsWindow" after="no" swapped="no"/>
+                        <signal name="contacts-linked" handler="contact_pane_contacts_linked_cb" 
object="ContactsWindow" after="no" swapped="no"/>
+                      </object>
+                    </child>
                   </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
                 </child>
-                <style>
-                  <class name="image-button"/>
-                </style>
                 <child>
-                  <object class="GtkImage" id="image2">
+                  <object class="ContactsListPane" id="list_pane">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="icon_name">object-select-symbolic</property>
-                    <property name="icon_size">1</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>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
                 </child>
               </object>
-              <packing>
-                <property name="pack_type">end</property>
-              </packing>
             </child>
           </object>
+          <packing>
+            <property name="name">content-view</property>
+          </packing>
         </child>
         <child>
-          <object class="GtkHeaderBar" id="right_toolbar">
+          <object class="GtkGrid">
             <property name="visible">True</property>
-            <property name="hexpand">True</property>
-            <property name="show_close_button">True</property>
-            <style>
-              <class name="contacts-right-header-bar"/>
-              <class name="titlebar"/>
-            </style>
+            <property name="border_width">12</property>
+            <property name="row_spacing">24</property>
+            <property name="orientation">vertical</property>
             <child>
-              <object class="GtkButton" id="edit_button">
-                <property name="visible">False</property>
-                <property name="can_focus">True</property>
-                <property name="focus_on_click">False</property>
-                <property name="label" translatable="yes">Edit</property>
-                <property name="width_request">70</property>
-                <property name="valign">center</property>
-                <style>
-                  <class name="text-button"/>
-                </style>
+              <object class="GtkLabel" id="setup_explanation_label">
+                <property name="visible">True</property>
+                <property name="halign">center</property>
+                <property name="wrap">True</property>
+                <property name="max_width_chars">25</property>
+                <property name="label">New contacts will be added to the selected address book. You are able 
to view and edit contacts from other address books.</property>
               </object>
               <packing>
-                <property name="pack_type">end</property>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="done_button">
-                <property name="visible">False</property>
-                <property name="can_focus">True</property>
-                <property name="focus_on_click">False</property>
-                <property name="label" translatable="yes">Done</property>
-                <property name="width_request">70</property>
-                <property name="valign">center</property>
-                <style>
-                  <class name="text-button"/>
-                  <class name="suggested-action"/>
-                </style>
+              <object class="ContactsAccountsList" id="setup_accounts_list">
+                <property name="visible">True</property>
+                <property name="hexpand">True</property>
+                <property name="halign">center</property>
               </object>
               <packing>
-                <property name="pack_type">end</property>
+                <property name="left_attach">0</property>
+                <property name="top_attach">1</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
               </packing>
             </child>
           </object>
+          <packing>
+            <property name="name">setup-view</property>
+          </packing>
         </child>
       </object>
     </child>
+  </template>
+  <object class="GtkSizeGroup">
+    <property name="mode">vertical</property>
+    <widgets>
+      <widget name="add_button"/>
+      <widget name="edit_button"/>
+      <widget name="done_button"/>
+    </widgets>
+  </object>
+  <object class="GtkBox" id="content_header_bar">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
     <child>
-      <object class="GtkOverlay" id="overlay">
+      <object class="GtkHeaderBar" id="left_toolbar">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="title" translatable="yes">All Contacts</property>
+        <property name="show_close_button">True</property>
+        <style>
+          <class name="contacts-left-header-bar"/>
+          <class name="titlebar"/>
+        </style>
         <child>
-          <object class="GtkGrid" id="grid">
+          <object class="GtkButton" id="add_button">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
+            <property name="can_focus">True</property>
+            <property name="halign">center</property>
+            <property name="valign">center</property>
+            <child internal-child="accessible">
+              <object class="AtkObject" id="add_button_atkobject">
+                <property name="AtkObject::accessible-name" translatable="yes">Add contact</property>
+              </object>
+            </child>
+            <style>
+              <class name="image-button"/>
+            </style>
             <child>
-              <object class="GtkOverlay" id="right_overlay">
+              <object class="GtkImage">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <child>
-                  <object class="ContactsContactPane" id="contact_pane">
-                    <property name="store">contacts_store</property>
-                    <property name="show_tabs">False</property>
-                    <property name="visible">True</property>
-                    <property name="hexpand">True</property>
-                    <signal name="will-delete" handler="contact_pane_delete_contact_cb" 
object="ContactsWindow" after="no" swapped="no"/>
-                    <signal name="contacts-linked" handler="contact_pane_contacts_linked_cb" 
object="ContactsWindow" after="no" swapped="no"/>
-                  </object>
-                </child>
+                <property name="icon_name">list-add-symbolic</property>
+                <property name="icon_size">1</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="pack_type">start</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkToggleButton" id="select_button">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="focus_on_click">False</property>
+            <property name="halign">center</property>
+            <property name="valign">center</property>
+            <child internal-child="accessible">
+              <object class="AtkObject" id="select_button_atkobject">
+                <property name="AtkObject::accessible-name" translatable="yes">Selection mode</property>
               </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
             </child>
+            <style>
+              <class name="image-button"/>
+            </style>
             <child>
-              <object class="ContactsListPane" id="list_pane">
+              <object class="GtkImage">
                 <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"/>
+                <property name="icon_name">object-select-symbolic</property>
+                <property name="icon_size">1</property>
               </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
             </child>
           </object>
+          <packing>
+            <property name="pack_type">end</property>
+          </packing>
         </child>
       </object>
     </child>
-  </template>
+    <child>
+      <object class="GtkHeaderBar" id="right_toolbar">
+        <property name="visible">True</property>
+        <property name="hexpand">True</property>
+        <property name="show_close_button">True</property>
+        <style>
+          <class name="contacts-right-header-bar"/>
+          <class name="titlebar"/>
+        </style>
+        <child>
+          <object class="GtkButton" id="edit_button">
+            <property name="visible">False</property>
+            <property name="can_focus">True</property>
+            <property name="focus_on_click">False</property>
+            <property name="label" translatable="yes">Edit</property>
+            <property name="width_request">70</property>
+            <property name="valign">center</property>
+            <style>
+              <class name="text-button"/>
+            </style>
+          </object>
+          <packing>
+            <property name="pack_type">end</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="done_button">
+            <property name="visible">False</property>
+            <property name="can_focus">True</property>
+            <property name="focus_on_click">False</property>
+            <property name="label" translatable="yes">Done</property>
+            <property name="width_request">70</property>
+            <property name="valign">center</property>
+            <style>
+              <class name="text-button"/>
+              <class name="suggested-action"/>
+            </style>
+          </object>
+          <packing>
+            <property name="pack_type">end</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+  <object class="GtkHeaderBar" id="setup_header_bar">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">Select Address Book</property>
+    <property name="show_close_button">False</property>
+    <style>
+      <class name="titlebar"/>
+    </style>
+    <child>
+      <object class="GtkButton" id="setup_cancel_button">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="label" translatable="yes">Cancel</property>
+        <child internal-child="accessible">
+          <object class="AtkObject" id="setup_cancel_button_atkobject">
+            <property name="AtkObject::accessible-name" translatable="yes">Cancel setup</property>
+          </object>
+        </child>
+        <style>
+          <class name="text-button"/>
+        </style>
+      </object>
+      <packing>
+        <property name="pack_type">start</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkButton" id="setup_done_button">
+        <property name="visible">True</property>
+        <property name="sensitive">False</property>
+        <property name="can_focus">True</property>
+        <property name="focus_on_click">False</property>
+        <property name="label" translatable="yes">Done</property>
+        <child internal-child="accessible">
+          <object class="AtkObject" id="setup_done_button_atkobject">
+            <property name="AtkObject::accessible-name" translatable="yes">Setup complete</property>
+          </object>
+        </child>
+        <style>
+          <class name="text-button"/>
+          <class name="suggested-action"/>
+        </style>
+      </object>
+      <packing>
+        <property name="pack_type">end</property>
+      </packing>
+    </child>
+  </object>
   <object class="GtkSizeGroup">
-    <property name="mode">vertical</property>
+    <property name="mode">horizontal</property>
     <widgets>
-      <widget name="add_button"/>
-      <widget name="edit_button"/>
-      <widget name="done_button"/>
+      <widget name="left_toolbar"/>
+      <widget name="list_pane"/>
     </widgets>
   </object>
   <object class="GtkSizeGroup">
     <property name="mode">horizontal</property>
     <widgets>
-      <widget name="left_toolbar"/>
-      <widget name="list_pane"/>
+      <widget name="setup_explanation_label"/>
+      <widget name="setup_accounts_list"/>
     </widgets>
   </object>
-</interface>
+</interface>
\ No newline at end of file
diff --git a/src/contacts-window.vala b/src/contacts-window.vala
index 790b6c7..fe7af25 100644
--- a/src/contacts-window.vala
+++ b/src/contacts-window.vala
@@ -40,6 +40,22 @@ public class Contacts.Window : Gtk.ApplicationWindow {
   private Button done_button;
 
   [GtkChild]
+  private Stack view_switcher;
+
+  [GtkChild]
+  private Box content_header_bar;
+
+  [GtkChild]
+  private HeaderBar setup_header_bar;
+  [GtkChild]
+  private Button setup_done_button;
+  [GtkChild]
+  private Button setup_cancel_button;
+  [GtkChild]
+  private AccountsList setup_accounts_list;
+
+
+  [GtkChild]
   public Store contacts_store;
 
   /* FIXME: remove from public what it is not needed */
@@ -66,18 +82,30 @@ public class Contacts.Window : Gtk.ApplicationWindow {
 
   public Window (Gtk.Application app) {
     Object (application: app);
+    App.app.contacts_store = contacts_store;
 
-    string layout_desc;
-    string[] tokens;
-
-    layout_desc = Gtk.Settings.get_default ().gtk_decoration_layout;
-    tokens = layout_desc.split (":", 2);
-    if (tokens != null) {
-      right_toolbar.decoration_layout = ":%s".printf (tokens[1]);
-      left_toolbar.decoration_layout = tokens[0];
+    /* FIXME: order me, debug code */
+    if (true) { /* setup is done ? */
+      view_switcher.visible_child_name = "content-view";
+      set_titlebar (content_header_bar);
+    } else {
+      /* here we need to wait for Store::prepare */
+      view_switcher.visible_child_name = "setup-view";
+      set_titlebar (setup_header_bar);
+
+      setup_accounts_list.update_contents (false);
+
+      setup_done_button.clicked.connect (() => {
+         /* Here we need to wait for Store::quiescent */
+         view_switcher.visible_child_name = "content-view";
+         set_titlebar (content_header_bar);
+       });
+      setup_cancel_button.clicked.connect (() => {
+         destroy ();
+       });
     }
 
-    connect_content_widgets ();
+    init_content_widgets ();
   }
 
   public void activate_selection_mode (bool active) {
@@ -164,7 +192,17 @@ public class Contacts.Window : Gtk.ApplicationWindow {
   }
 
   /* internal API */
-  void connect_content_widgets () {
+  void init_content_widgets () {
+    string layout_desc;
+    string[] tokens;
+
+    layout_desc = Gtk.Settings.get_default ().gtk_decoration_layout;
+    tokens = layout_desc.split (":", 2);
+    if (tokens != null) {
+      right_toolbar.decoration_layout = ":%s".printf (tokens[1]);
+      left_toolbar.decoration_layout = tokens[0];
+    }
+
     list_pane.contacts_marked.connect ((nr_contacts) => {
        if (nr_contacts == 0) {
          left_title = _("Select");


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