[gnome-contacts/frankz/gnome-contacts-master: 1/4] introduced signal display_name_changed to notify listeners and especially to update the right titleb



commit a0bdf0eb4284e73b2d537b92af74203de7aaf1d8
Author: Frank Zschage <frank reissan de>
Date:   Mon Jan 29 20:26:38 2018 +0100

    introduced 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 | 6 ++++++
 src/contacts-window.vala       | 7 ++++---
 2 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 3f6a443..247ce15 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -67,6 +67,11 @@ public class Contacts.ContactPane : Stack {
   /* Signals */
   public signal void contacts_linked (string? main_contact, string linked_contact, LinkOperation operation);
   public signal void will_delete (Contact contact);
+  /**
+   * Passes the changed display name to all listeners after edit mode has been completed.
+   */
+  public signal void display_name_changed (string new_display_name);
+
 
   public void update_sheet () {
     if (on_edit_mode) {
@@ -273,6 +278,7 @@ 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) => {
diff --git a/src/contacts-window.vala b/src/contacts-window.vala
index 1b25885..5496f76 100644
--- a/src/contacts-window.vala
+++ b/src/contacts-window.vala
@@ -81,6 +81,9 @@ public class Contacts.Window : Gtk.ApplicationWindow {
         delete_contacts (new ArrayList<Contact>.wrap ({ contact }));
      });
     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.contact_pane_container.add (this.contact_pane);
   }
 
@@ -185,9 +188,7 @@ public class Contacts.Window : Gtk.ApplicationWindow {
       this.state = UiState.SHOWING;
     }
 
-    if (this.contact_pane.contact != null) {
-      this.right_header.title = this.contact_pane.contact.individual.display_name;
-    } else {
+    if (this.contact_pane.contact == null) {
       this.right_header.title = "";
     }
   }


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