[gnome-contacts] Contact: remove `keep_widget_uptodate()`.



commit 80a177da171a4ff4e403e967fd1a4ef25301b2ce
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Sat Nov 3 19:09:09 2018 +0100

    Contact: remove `keep_widget_uptodate()`.
    
    We can do better using the `notify` signal on the individual itself.

 src/contacts-contact-sheet.vala | 12 +++++++++---
 src/contacts-contact.vala       |  6 ------
 2 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/src/contacts-contact-sheet.vala b/src/contacts-contact-sheet.vala
index 66b612e..de15309 100644
--- a/src/contacts-contact-sheet.vala
+++ b/src/contacts-contact-sheet.vala
@@ -117,15 +117,21 @@ public class Contacts.ContactSheet : ContactForm {
     show_all ();
   }
 
+  private void update_name_label (Gtk.Label name_label) {
+    var name = Markup.printf_escaped ("<span font='16'>%s</span>",
+                                      this.contact.individual.display_name);
+    name_label.set_markup (name);
+  }
+
   private void create_name_label () {
     var name_label = new Label ("");
     name_label.ellipsize = Pango.EllipsizeMode.END;
     name_label.xalign = 0f;
     name_label.selectable = true;
     this.container_grid.attach (name_label,  1, 0, 1, 3);
-    this.contact.keep_widget_uptodate (name_label, (w) => {
-        name_label.set_markup (Markup.printf_escaped ("<span font='16'>%s</span>",
-                                                      this.contact.individual.display_name));
+    update_name_label (name_label);
+    this.contact.individual.notify["display-name"].connect ((obj, spec) => {
+        update_name_label (name_label);
       });
   }
 
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index db13c9d..d126bc5 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -577,12 +577,6 @@ public class Contacts.Contact : GLib.Object  {
     }
   }
 
-  public void keep_widget_uptodate (Widget w, owned Gtk.Callback callback) {
-    callback(w);
-    ulong id = this.changed.connect ( () => { callback(w); });
-    w.destroy.connect (() => { this.disconnect (id); });
-  }
-
 #if HAVE_TELEPATHY
   public void fetch_contact_info () {
     /* TODO: Ideally Folks should have API for this (#675131) */


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