summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2022-09-07 11:10:35 +0200
committerNiels De Graef <nielsdegraef@gmail.com>2022-09-08 07:16:50 +0200
commite8d6f6ff4dfc8505fbee9c841b85d2446e08ff2c (patch)
tree10b9e68db8c5bd085cb7401fac2f3b2831e2234d
parentbe028d98b29795c3e6846ba12374274ea2ff4751 (diff)
downloadgnome-contacts-e8d6f6ff4dfc8505fbee9c841b85d2446e08ff2c.tar.gz
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.
-rw-r--r--src/contacts-app.vala2
-rw-r--r--src/contacts-preferences-window.vala2
-rw-r--r--src/contacts-store.vala11
-rw-r--r--src/contacts-utils.vala6
4 files changed, 13 insertions, 8 deletions
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index 6f15733..89117c1 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 e6abbd2..9c51210 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 faa4ee5..92eae91 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 ec38207..64ab16d 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())