[gnome-contacts] ContactPane: hooked actions to Editor properties



commit 82f363c2c9b6d4c03141b003c18da8bcff920124
Author: Erick Pérez Castellanos <erick red gmail com>
Date:   Sat Apr 5 10:31:34 2014 -0400

    ContactPane: hooked actions to Editor properties
    
    Hooked actions for adding single value fields to the related
    ContactEditor properties.
    This prevent adding twice a birthday field for a contact.

 src/contacts-contact-pane.vala |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)
---
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 03c7d95..cc84cd8 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -326,6 +326,28 @@ public class Contacts.ContactPane : Notebook {
     main_sw.show ();
     top_grid.show_all ();
     insert_page (top_grid, null, 2);
+
+    /* enable/disable actions*/
+    var birthday_action = this.edit_contact_actions.lookup_action ("add.birthday") as SimpleAction;
+    editor.bind_property ("has-birthday-row",
+                         birthday_action, "enabled",
+                         BindingFlags.SYNC_CREATE |
+                         BindingFlags.INVERT_BOOLEAN);
+
+    var nickname_action = this.edit_contact_actions.lookup_action ("add.nickname") as SimpleAction;
+    editor.bind_property ("has-nickname-row",
+                         nickname_action, "enabled",
+                         BindingFlags.DEFAULT |
+                         BindingFlags.SYNC_CREATE |
+                         BindingFlags.INVERT_BOOLEAN);
+
+    var notes_action = this.edit_contact_actions.lookup_action ("add.notes") as SimpleAction;
+    editor.bind_property ("has-notes-row",
+                         notes_action, "enabled",
+                         BindingFlags.DEFAULT |
+                         BindingFlags.SYNC_CREATE |
+                         BindingFlags.INVERT_BOOLEAN);
+
   }
 
   void on_add_detail (GLib.SimpleAction action, GLib.Variant? parameter) {
@@ -412,16 +434,6 @@ public class Contacts.ContactPane : Notebook {
 
       on_edit_mode = true;
 
-      /* enable/disable actions*/
-      var action = this.edit_contact_actions.lookup_action ("add.birthday") as SimpleAction;
-      action.set_enabled (! contact.has_birthday ());
-
-      action = this.edit_contact_actions.lookup_action ("add.nickname") as SimpleAction;
-      action.set_enabled (! contact.has_nickname ());
-
-      action = this.edit_contact_actions.lookup_action ("add.notes") as SimpleAction;
-      action.set_enabled (! contact.has_notes ());
-
       sheet.clear ();
 
       if (suggestion_grid != null) {


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