[gnome-contacts/frankz/gnome-contacts-master: 2/4] ContactPane: Update right titlebar after editing contact introduced a signal display_name_changed to



commit a9204ec37443b5c9dbd7ed27d839183c479dbce5
Author: Frank Zschage <frank reissan de>
Date:   Mon Jan 29 21:45:08 2018 +0100

    ContactPane: Update right titlebar after editing contact
    introduced a signal display_name_changed to notify listeners and especially to update the right titlebar 
after the name of a contact has been changed to fix issue #78

 src/contacts-contact-pane.vala | 2 +-
 src/contacts-window.vala       | 9 +++++----
 2 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 247ce15..beb6c1c 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -278,12 +278,12 @@ public class Contacts.ContactPane : Stack {
 
        if (editor.name_changed ()) {
          var v = editor.get_full_name_value ();
-         display_name_changed (v.get_string ());
          Contact.set_individual_property.begin (contact,
                                                 "full-name", v,
                                                 (obj, result) => {
                                                   try {
                                                     Contact.set_individual_property.end (result);
+                                                    display_name_changed (v.get_string ());
                                                   } catch (Error e) {
                                                     show_message (e.message);
                                                     /* FIXME: add this back */
diff --git a/src/contacts-window.vala b/src/contacts-window.vala
index 5496f76..2ceeac6 100644
--- a/src/contacts-window.vala
+++ b/src/contacts-window.vala
@@ -82,7 +82,7 @@ public class Contacts.Window : Gtk.ApplicationWindow {
      });
     this.contact_pane.contacts_linked.connect (contact_pane_contacts_linked_cb);
     this.contact_pane.display_name_changed.connect ((display_name) => {
-      right_header.title = display_name;
+      this.right_header.title = display_name;
     });
     this.contact_pane_container.add (this.contact_pane);
   }
@@ -187,8 +187,9 @@ public class Contacts.Window : Gtk.ApplicationWindow {
       this.contact_pane.set_edit_mode (false, drop_changes);
       this.state = UiState.SHOWING;
     }
-
-    if (this.contact_pane.contact == null) {
+    if (this.contact_pane.contact != null) {
+      this.right_header.title = this.contact_pane.contact.individual.display_name;
+    } else {
       this.right_header.title = "";
     }
   }
@@ -278,7 +279,7 @@ public class Contacts.Window : Gtk.ApplicationWindow {
     // Clear the contacts so any changed information is stored
     this.contact_pane.show_contact (null);
     return false;
-  }
+         }
 
   void list_pane_selection_changed_cb (Contact? new_selection) {
     set_shown_contact (new_selection);


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