summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Danielsson <jonas@threetimestwo.org>2015-01-12 06:52:02 -0500
committerJonas Danielsson <jonas@threetimestwo.org>2015-01-30 23:20:22 +0100
commitc87ac0b7905fe3da1d849e457c9c46198e805b33 (patch)
treea3bac80b346f202c479d67fea58988f123778bea
parent37f27c08f51d00ce34e15fc0bd75b4506a747f87 (diff)
downloadgnome-maps-wip/contacts.tar.gz
application: Add contacts to place storewip/contacts
https://bugzilla.gnome.org/show_bug.cgi?id=736803
-rw-r--r--src/application.js24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/application.js b/src/application.js
index 4f3e153f..02575de1 100644
--- a/src/application.js
+++ b/src/application.js
@@ -29,13 +29,13 @@ const GtkClutter = imports.gi.GtkClutter;
const Lang = imports.lang;
const CheckIn = imports.checkIn;
+const ContactPlace = imports.contactPlace;
const Format = imports.format;
const Geoclue = imports.geoclue;
const GeocodeService = imports.geocodeService;
const MainWindow = imports.mainWindow;
const Maps = imports.gi.GnomeMaps;
const NotificationManager = imports.notificationManager;
-const Place = imports.place;
const PlaceStore = imports.placeStore;
const RouteService = imports.routeService;
const Settings = imports.settings;
@@ -127,6 +127,19 @@ const Application = new Lang.Class({
this._mainWindow.window.destroy();
},
+ _addContacts: function() {
+ contactStore.get_contacts().forEach(function(contact) {
+ contact.geocode(function() {
+ contact.get_places().forEach(function(p) {
+ Utils.debug('Adding contact address: ' + p.name);
+ let place = new ContactPlace.ContactPlace({ place: p,
+ icon: contact.icon });
+ placeStore.addPlace(place, PlaceStore.PlaceType.CONTACT);
+ });
+ });
+ });
+ },
+
_initPlaceStore: function() {
placeStore = new PlaceStore.PlaceStore();
try {
@@ -135,6 +148,15 @@ const Application = new Lang.Class({
log('Failed to parse Maps places file, ' +
'subsequent writes will overwrite the file!');
}
+
+ if (contactStore.state === Maps.ContactStoreState.LOADED) {
+ this. _addContacts();
+ } else {
+ Utils.once(contactStore, 'notify::state', (function() {
+ if (contactStore.state === Maps.ContactStoreState.LOADED)
+ this._addContacts();
+ }).bind(this));
+ }
},
_initAppMenu: function() {