[gnome-contacts] Remove final uses of App.app.contacts_store.



commit dd79e4d3056599514ab8cd9910348748e81982f2
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Sun Aug 27 21:53:43 2017 +0200

    Remove final uses of App.app.contacts_store.

 src/contacts-app.vala          |    2 +-
 src/contacts-contact-pane.vala |    2 +-
 src/contacts-linking.vala      |   32 ++++++++++++++++++--------------
 src/contacts-window.vala       |    2 +-
 4 files changed, 21 insertions(+), 17 deletions(-)
---
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index 3923189..5cad7d3 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -23,7 +23,7 @@ public class Contacts.App : Gtk.Application {
 
   private Settings settings;
 
-  public Store contacts_store;
+  private Store contacts_store;
 
   private Window window;
 
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index eda3193..f49c3f2 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -145,7 +145,7 @@ public class Contacts.ContactPane : Stack {
 
     yes.clicked.connect ( () => {
       var linked_contact = c.display_name;
-      link_contacts.begin (contact, c, (obj, result) => {
+      link_contacts.begin (contact, c, this.store, (obj, result) => {
        var operation = link_contacts.end (result);
        this.contacts_linked (null, linked_contact, operation);
       });
diff --git a/src/contacts-linking.vala b/src/contacts-linking.vala
index 6ad7a8c..269ba26 100644
--- a/src/contacts-linking.vala
+++ b/src/contacts-linking.vala
@@ -529,7 +529,7 @@ namespace Contacts {
     }
   }
 
-  public async LinkOperation link_contacts (Contact main, Contact? other) {
+  public async LinkOperation link_contacts (Contact main, Contact? other, Store contacts_store) {
     // This should not be used as being replaced with the new individual
     // instead we should always pick this contact to keep around
     main.set_data ("contacts-master-at-join", true);
@@ -581,7 +581,7 @@ namespace Contacts {
        var v = Value (typeof (string));
        v.set_string (main.display_name);
        details.set ("full-name", v);
-       write_persona = yield Contact.create_primary_persona_for_details 
(App.app.contacts_store.aggregator.primary_store, details);
+       write_persona = yield Contact.create_primary_persona_for_details 
(contacts_store.aggregator.primary_store, details);
        operation.added_persona (write_persona);
        linkables = main_linkables;
        if (other_linkables != null)
@@ -711,11 +711,15 @@ namespace Contacts {
   }
 
   public class LinkOperation2 : Object {
+    private Store contacts_store;
+
     /* One Set<Persona> per individual linked, with the intention
      * of restore the old perosonas set on undo operation */
     LinkedList< HashSet<Persona> > old_personas_distribution;
 
-    public LinkOperation2 () {
+    public LinkOperation2 (Store contacts_store) {
+      this.contacts_store = contacts_store;
+
       old_personas_distribution = new  LinkedList< HashSet<Persona> > ();
     }
 
@@ -740,24 +744,24 @@ namespace Contacts {
       }
       if (ind != null) {
         try {
-         yield App.app.contacts_store.aggregator.unlink_individual (ind);
-       } catch (GLib.Error e1) {
-         warning ("Error unlinking individual ā€˜%sā€™: %s", ind.id, e1.message);
-       }
+          yield this.contacts_store.aggregator.unlink_individual (ind);
+        } catch (GLib.Error e1) {
+          warning ("Error unlinking individual ā€˜%sā€™: %s", ind.id, e1.message);
+        }
       }
 
       foreach (var ps in old_personas_distribution) {
         try {
-         yield App.app.contacts_store.aggregator.link_personas (ps);
-       } catch (GLib.Error e1) {
-         warning ("Error linking personas: %s", e1.message);
-       }
+          yield this.contacts_store.aggregator.link_personas (ps);
+        } catch (GLib.Error e1) {
+          warning ("Error linking personas: %s", e1.message);
+        }
       }
     }
   }
 
-  public async LinkOperation2 link_contacts_list (LinkedList<Contact> contact_list) {
-    var operation = new LinkOperation2 ();
+  public async LinkOperation2 link_contacts_list (LinkedList<Contact> contact_list, Store contacts_store) {
+    var operation = new LinkOperation2 (contacts_store);
 
     var all_personas = new HashSet<Persona> ();
     foreach (var c in contact_list) {
@@ -767,7 +771,7 @@ namespace Contacts {
     }
 
     try {
-      yield App.app.contacts_store.aggregator.link_personas (all_personas);
+      yield contacts_store.aggregator.link_personas (all_personas);
     } catch (GLib.Error e1) {
       warning ("Error linking personas: %s", e1.message);
     }
diff --git a/src/contacts-window.vala b/src/contacts-window.vala
index 7429999..c295b83 100644
--- a/src/contacts-window.vala
+++ b/src/contacts-window.vala
@@ -410,7 +410,7 @@ public class Contacts.Window : Gtk.ApplicationWindow {
     select_button.set_active (false);
 
     LinkOperation2 operation = null;
-    link_contacts_list.begin (contact_list, (obj, result) => {
+    link_contacts_list.begin (contact_list, this.store, (obj, result) => {
         operation = link_contacts_list.end (result);
       });
 


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