[gnome-contacts] Contact: remove the personas_changed signal.
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Contact: remove the personas_changed signal.
- Date: Sat, 17 Feb 2018 14:33:08 +0000 (UTC)
commit 1904f2df30a93664c17888cccdecf644a41c9c1b
Author: Niels De Graef <nielsdegraef gmail com>
Date: Thu Feb 15 18:25:40 2018 +0100
Contact: remove the personas_changed signal.
This is basically just a wrapper around Individual::personas_changed,
so use that instead. This allows us to simplify some of the code.
src/contacts-contact-pane.vala | 4 ++--
src/contacts-contact.vala | 31 +++++++++----------------------
src/contacts-store.vala | 5 ++---
3 files changed, 13 insertions(+), 27 deletions(-)
---
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index beb6c1c..54e0b4a 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -133,7 +133,7 @@ public class Contacts.ContactPane : Stack {
}
if (contact != null) {
- contact.personas_changed.disconnect (update_sheet);
+ contact.individual.personas_changed.disconnect (update_sheet);
contact.changed.disconnect (update_sheet);
}
@@ -142,8 +142,8 @@ public class Contacts.ContactPane : Stack {
update_sheet ();
if (contact != null) {
- contact.personas_changed.connect (update_sheet);
contact.changed.connect (update_sheet);
+ contact.individual.personas_changed.connect (update_sheet);
}
if (contact == null)
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index 387ca17..f88cf39 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -30,7 +30,6 @@ public class Contacts.Contact : GLib.Object {
public Individual individual;
uint changed_id;
- bool changed_personas;
public Persona? fake_persona = null;
@@ -48,7 +47,6 @@ public class Contacts.Contact : GLib.Object {
}
public signal void changed ();
- public signal void personas_changed ();
private bool _is_hidden;
private bool _is_hidden_uptodate;
@@ -98,13 +96,13 @@ public class Contacts.Contact : GLib.Object {
public void hide () {
_is_hidden_to_delete = true;
- queue_changed (false);
+ queue_changed ();
}
public void show () {
_is_hidden_to_delete = false;
- queue_changed (false);
+ queue_changed ();
}
public static Contact from_individual (Individual i) {
@@ -135,10 +133,6 @@ public class Contacts.Contact : GLib.Object {
is_main = calc_is_main ();
- individual.personas_changed.connect ( (added, removed) => {
- queue_changed (true);
- });
-
update ();
individual.notify.connect(notify_cb);
@@ -149,7 +143,7 @@ public class Contacts.Contact : GLib.Object {
individual = new_individual;
individual.set_data ("contact", this);
individual.notify.connect(notify_cb);
- queue_changed (true);
+ queue_changed ();
}
public void remove () {
@@ -277,14 +271,10 @@ public class Contacts.Contact : GLib.Object {
#endif
private bool changed_cb () {
- changed_id = 0;
- var changed_personas = this.changed_personas;
- this.changed_personas = false;
+ this.changed_id = 0;
this.is_main = calc_is_main ();
update ();
changed ();
- if (changed_personas)
- personas_changed ();
return false;
}
@@ -295,18 +285,15 @@ public class Contacts.Contact : GLib.Object {
}
}
- public void queue_changed (bool is_persona_change) {
- _is_hidden_uptodate = false;
- changed_personas |= is_persona_change;
-
- if (changed_id != 0)
- return;
+ public void queue_changed () {
+ this._is_hidden_uptodate = false;
- changed_id = Idle.add (changed_cb);
+ if (this.changed_id == 0)
+ this.changed_id = Idle.add (changed_cb);
}
private void notify_cb (ParamSpec pspec) {
- queue_changed (false);
+ queue_changed ();
}
private void update () {
diff --git a/src/contacts-store.vala b/src/contacts-store.vala
index c18e44f..b4836b8 100644
--- a/src/contacts-store.vala
+++ b/src/contacts-store.vala
@@ -48,9 +48,8 @@ public class Contacts.Store : GLib.Object {
}
public void refresh () {
- foreach (var c in contacts) {
- c.queue_changed (true);
- }
+ foreach (var c in contacts)
+ c.queue_changed ();
}
private bool individual_can_replace_at_split (Individual new_individual) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]