[gnome-contacts/nielsdg/core-should-stay-core: 8/11] Move primary address book logic to Contacts.Store
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts/nielsdg/core-should-stay-core: 8/11] Move primary address book logic to Contacts.Store
- Date: Thu, 8 Sep 2022 05:17:02 +0000 (UTC)
commit e8d6f6ff4dfc8505fbee9c841b85d2446e08ff2c
Author: Niels De Graef <nielsdegraef gmail com>
Date: Wed Sep 7 11:10:35 2022 +0200
Move primary address book logic to Contacts.Store
It already contains most of the logic of the primary store due to it
containing the `Folks.IndividualAggregator` which holds this too, so it
makes sense to pull it out of Utils and move it there instead.
src/contacts-app.vala | 2 +-
src/contacts-preferences-window.vala | 2 +-
src/contacts-store.vala | 11 +++++++++++
src/contacts-utils.vala | 6 ------
4 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index 6f157339..89117c1f 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -282,7 +282,7 @@ public class Contacts.App : Adw.Application {
setup_window.destroy ();
unowned var edsf_store = (Edsf.PersonaStore) selected_store;
- Utils.set_primary_store (edsf_store);
+ this.contacts_store.set_primary_address_book (edsf_store);
this.settings.did_initial_setup = true;
create_window ();
diff --git a/src/contacts-preferences-window.vala b/src/contacts-preferences-window.vala
index e6abbd29..9c512100 100644
--- a/src/contacts-preferences-window.vala
+++ b/src/contacts-preferences-window.vala
@@ -33,7 +33,7 @@ public class Contacts.PreferencesWindow : Adw.PreferencesWindow {
acc_list.notify["selected-store"].connect ((obj, pspec) => {
var edsf_store = (Edsf.PersonaStore) acc_list.selected_store;
- Utils.set_primary_store (edsf_store);
+ contacts_store.set_primary_address_book (edsf_store);
});
var goa_button_content = new Adw.ButtonContent ();
diff --git a/src/contacts-store.vala b/src/contacts-store.vala
index faa4ee5a..92eae915 100644
--- a/src/contacts-store.vala
+++ b/src/contacts-store.vala
@@ -291,4 +291,15 @@ public class Contacts.Store : GLib.Object {
return Gtk.INVALID_LIST_POSITION;
}
+
+ /**
+ * Sets the primary address book. This will be used as the primary candidate
+ * to store new contacts, and will prioritize personas coming from this store
+ * when showing them.
+ */
+ public void set_primary_address_book (Edsf.PersonaStore e_store) {
+ eds_source_registry.set_default_address_book (e_store.source);
+ var settings = new GLib.Settings ("org.freedesktop.folks");
+ settings.set_string ("primary-store", "eds:%s".printf (e_store.id));
+ }
}
diff --git a/src/contacts-utils.vala b/src/contacts-utils.vala
index ec38207b..64ab16d5 100644
--- a/src/contacts-utils.vala
+++ b/src/contacts-utils.vala
@@ -19,12 +19,6 @@ using Folks;
namespace Contacts.Utils {
- public void set_primary_store (Edsf.PersonaStore e_store) {
- eds_source_registry.set_default_address_book (e_store.source);
- var settings = new GLib.Settings ("org.freedesktop.folks");
- settings.set_string ("primary-store", "eds:%s".printf (e_store.id));
- }
-
public T? get_first<T> (Gee.Collection<T> collection) {
var i = collection.iterator();
if (i.next())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]