[gnome-maps/wip/contacts: 78/81] Add 'show-contact' action
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/contacts: 78/81] Add 'show-contact' action
- Date: Sat, 31 Jan 2015 17:01:53 +0000 (UTC)
commit 30548e4cf867b97117785d03d222db51b2216826
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Tue Dec 16 04:48:04 2014 -0500
Add 'show-contact' action
https://bugzilla.gnome.org/show_bug.cgi?id=741591
src/application.js | 38 +++++++++++++++++++++++++++++++++++++-
src/mapView.js | 20 +++++++++++++++++++-
2 files changed, 56 insertions(+), 2 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 80d3749..4f3e153 100644
--- a/src/application.js
+++ b/src/application.js
@@ -33,7 +33,9 @@ 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;
@@ -49,6 +51,7 @@ let geoclue = null;
let geocodeService = null;
let networkMonitor = null;
let checkInManager = null;
+let contactStore = null;
const Application = new Lang.Class({
Name: 'Application',
@@ -93,6 +96,33 @@ const Application = new Lang.Class({
}).bind(this));
},
+ _showContact: function(id) {
+ contactStore.lookup(id, (function(contact) {
+ this._mainWindow.markBusy();
+ contact.geocode((function() {
+ this._mainWindow.unmarkBusy();
+ this._mainWindow.mapView.showContact(contact);
+ }).bind(this));
+ }).bind(this));
+ },
+
+ _onShowContactActivate: function(action, parameter) {
+ this._createWindow();
+ this._checkNetwork();
+ this._mainWindow.window.present();
+
+ let id = parameter.deep_unpack();
+
+ if (contactStore.state === Maps.ContactStoreState.LOADED) {
+ this. _showContact(id);
+ } else {
+ Utils.once(contactStore, 'notify::state', (function() {
+ if (contactStore.state === Maps.ContactStoreState.LOADED)
+ this._showContact(id);
+ }).bind(this));
+ }
+ },
+
_onQuitActivate: function() {
this._mainWindow.window.destroy();
},
@@ -126,7 +156,11 @@ const Application = new Lang.Class({
this._initServices();
Utils.addActions(this, {
- 'quit': { onActivate: this._onQuitActivate.bind(this) }
+ 'quit': { onActivate: this._onQuitActivate.bind(this) },
+ 'show-contact': {
+ paramType: 's',
+ onActivate: this._onShowContactActivate.bind(this)
+ }
});
this._initPlaceStore();
@@ -142,6 +176,8 @@ const Application = new Lang.Class({
networkMonitor.connect('network-changed',
this._checkNetwork.bind(this));
checkInManager = new CheckIn.CheckInManager();
+ contactStore = new Maps.ContactStore();
+ contactStore.load();
},
_createWindow: function() {
diff --git a/src/mapView.js b/src/mapView.js
index 3b89631..eb289b9 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -28,6 +28,7 @@ const GtkChamplain = imports.gi.GtkChamplain;
const Lang = imports.lang;
const Application = imports.application;
+const ContactPlace = imports.contactPlace;
const Geoclue = imports.geoclue;
const MapWalker = imports.mapWalker;
const Place = imports.place;
@@ -192,7 +193,7 @@ const MapView = new Lang.Class({
_gotoBBox: function(bbox) {
let [lat, lon] = bbox.get_center();
- let place = new Place({
+ let place = new Place.Place({
location: new Geocode.Location({ latitude : lat,
longitude : lon }),
bounding_box: new Geocode.BoundingBox({ top : bbox.top,
@@ -216,6 +217,23 @@ const MapView = new Lang.Class({
this._turnPointMarker.goToAndSelect(true);
},
+ showContact: function(contact) {
+ let places = contact.get_places();
+ if (places.length === 0)
+ return;
+
+ this._placeLayer.remove_all();
+ places.forEach((function(p) {
+ let place = new ContactPlace.ContactPlace({ place: p,
+ icon: contact.icon });
+ let marker = new PlaceMarker.PlaceMarker({ place: place,
+ mapView: this });
+ this._placeLayer.add_marker(marker);
+ }).bind(this));
+
+ this._gotoBBox(contact.bounding_box);
+ },
+
showSearchResult: function(place) {
this._placeLayer.remove_all();
let placeMarker = new PlaceMarker.PlaceMarker({ place: place,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]