[gnome-contacts] Make keep_widget_uptodate a Contects helper function
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Make keep_widget_uptodate a Contects helper function
- Date: Mon, 19 Dec 2011 13:52:45 +0000 (UTC)
commit 8c037ecc076bb13d6ef5ec72107d553673705367
Author: Alexander Larsson <alexl redhat com>
Date: Mon Dec 19 13:52:54 2011 +0100
Make keep_widget_uptodate a Contects helper function
src/contacts-contact-pane.vala | 7 ++-----
src/contacts-contact.vala | 6 ++++++
2 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 6768be4..5381aaf 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -1501,7 +1501,6 @@ public class Contacts.ContactPane : ScrolledWindow {
card_grid.set_row_spacing (16);
var l = new Label (null);
- l.set_markup ("<span font='24'>" + contact.display_name + "</span>");
l.set_hexpand (true);
l.set_halign (Align.START);
l.set_valign (Align.START);
@@ -1509,11 +1508,9 @@ public class Contacts.ContactPane : ScrolledWindow {
l.set_ellipsize (Pango.EllipsizeMode.END);
l.xalign = 0.0f;
- var old_contact = contact;
- ulong id = contact.changed.connect ( () => {
- l.set_markup ("<span font='24'>" + contact.display_name + "</span>");
+ contact.keep_widget_uptodate (l, (w) => {
+ (w as Label).set_markup ("<span font='24'>" + contact.display_name + "</span>");
});
- l.destroy.connect (() => { old_contact.disconnect (id); });
var event_box = new EventBox ();
event_box.set_visible_window (false);
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index b31a5a2..2590c8d 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -1126,6 +1126,12 @@ public class Contacts.Contact : GLib.Object {
break;
}
}
+
+ public void keep_widget_uptodate (Widget w, Gtk.Callback callback) {
+ callback(w);
+ ulong id = this.changed.connect ( () => { callback(w); });
+ w.destroy.connect (() => { this.disconnect (id); });
+ }
}
public class Contacts.FakePersonaStore : PersonaStore {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]