[gnome-contacts] Window: moved more content widgets internally



commit a164df5cdb2a43e102616f5064c08c3bae8c4d70
Author: Erick Pérez Castellanos <erick red gmail com>
Date:   Sat Apr 26 11:06:27 2014 -0400

    Window: moved more content widgets internally
    
    Content widgets are those belonging in the handling contacts interface
    of Contacts, are different from the setup-widgets which are those shown
    in the setup view when implemented.
    [Done] button and [Edit] buttons made private.

 src/contacts-app.vala    |   49 +---------------------------------------------
 src/contacts-window.vala |   40 +++++++++++++++++++++++++++++++------
 2 files changed, 34 insertions(+), 55 deletions(-)
---
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index c6e3efd..3f0beba 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -34,26 +34,6 @@ public class Contacts.App : Gtk.Application {
 
   private bool app_menu_created;
 
-  private void selection_changed (Contact? new_selection) {
-    /* FIXME: ask the user lo teave edit-mode and act accordingly */
-    if (contacts_pane.on_edit_mode) {
-      contacts_pane.set_edit_mode (false);
-
-      window.right_title = "";
-      window.done_button.hide ();
-    }
-
-    contacts_pane.show_contact (new_selection, false);
-
-    /* clearing right_toolbar */
-    if (new_selection != null) {
-      window.right_title = new_selection.display_name;
-      window.edit_button.show ();
-    } else {
-      window.edit_button.hide ();
-    }
-  }
-
   public void show_contact (Contact? contact) {
     window.set_shown_contact (contact);
   }
@@ -212,31 +192,6 @@ public class Contacts.App : Gtk.Application {
     contacts_pane.contacts_linked.connect (contacts_linked);
 
     window.add_button.clicked.connect (app.new_contact);
-
-    window.edit_button.clicked.connect (() => {
-       if (contacts_pane.contact == null)
-         return;
-
-        if (window.select_button.active)
-          window.select_button.set_active (false);
-
-       var name = contacts_pane.contact.display_name;
-        window.right_title = _("Editing %s").printf (name);
-
-        window.edit_button.hide ();
-        window.done_button.show ();
-        contacts_pane.set_edit_mode (true);
-      });
-
-    window.done_button.clicked.connect (() => {
-        window.done_button.hide ();
-        window.edit_button.show ();
-        contacts_pane.set_edit_mode (false);
-
-        if (contacts_pane.contact != null) {
-         window.right_title = contacts_pane.contact.display_name;
-        }
-      });
   }
 
   public override void startup () {
@@ -331,9 +286,7 @@ public class Contacts.App : Gtk.Application {
 
   private void delete_contact (Contact contact) {
     /* unsetting edit-mode */
-    window.right_title = "";
-    window.done_button.hide ();
-    contacts_pane.set_edit_mode (false);
+    window.set_shown_contact (null);
 
     var notification = new Gd.Notification ();
     notification.timeout = 5;
diff --git a/src/contacts-window.vala b/src/contacts-window.vala
index 9f76af3..3f16c48 100644
--- a/src/contacts-window.vala
+++ b/src/contacts-window.vala
@@ -30,6 +30,10 @@ public class Contacts.Window : Gtk.ApplicationWindow {
   private Overlay overlay;
   [GtkChild]
   private ListPane list_pane;
+  [GtkChild]
+  private Button edit_button;
+  [GtkChild]
+  private Button done_button;
 
   [GtkChild]
   public Store contacts_store;
@@ -43,11 +47,6 @@ public class Contacts.Window : Gtk.ApplicationWindow {
   [GtkChild]
   public ToggleButton select_button;
 
-  [GtkChild]
-  public Button edit_button;
-  [GtkChild]
-  public Button done_button;
-
   public string left_title {
     get {
       return left_toolbar.get_title ();
@@ -78,6 +77,8 @@ public class Contacts.Window : Gtk.ApplicationWindow {
       right_toolbar.decoration_layout = ":%s".printf (tokens[1]);
       left_toolbar.decoration_layout = tokens[0];
     }
+
+    connect_content_widgets ();
   }
 
   public void activate_selection_mode (bool active) {
@@ -103,13 +104,13 @@ public class Contacts.Window : Gtk.ApplicationWindow {
   }
 
   public void set_shown_contact (Contact? c) {
-    /* FIXME: ask the user lo teave edit-mode and act accordingly */
+    /* FIXME: ask the user to leave edit-mode and act accordingly */
     if (contacts_pane.on_edit_mode) {
       contacts_pane.set_edit_mode (false);
 
       right_title = "";
-      done_button.hide ();
     }
+    done_button.hide ();
 
     contacts_pane.show_contact (c, false);
 
@@ -144,6 +145,31 @@ public class Contacts.Window : Gtk.ApplicationWindow {
          activate_selection_mode (false);
        }
       });
+
+    edit_button.clicked.connect (() => {
+       if (contacts_pane.contact == null)
+         return;
+
+       if (select_button.active)
+         select_button.set_active (false);
+
+       var name = contacts_pane.contact.display_name;
+       right_title = _("Editing %s").printf (name);
+
+       edit_button.hide ();
+       done_button.show ();
+       contacts_pane.set_edit_mode (true);
+      });
+
+    done_button.clicked.connect (() => {
+       done_button.hide ();
+       edit_button.show ();
+       contacts_pane.set_edit_mode (false);
+
+       if (contacts_pane.contact != null) {
+         right_title = contacts_pane.contact.display_name;
+       }
+      });
   }
 
   [GtkCallback]


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