[gnome-maps/wip/contacts: 3/4] test new action
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/contacts: 3/4] test new action
- Date: Fri, 30 Jan 2015 22:08:31 +0000 (UTC)
commit ddf48d5580078837c1cde0944d16912ad5540d58
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Tue Dec 9 08:53:32 2014 -0500
test new action
src/application.js | 51 ++++++++++++++----------------------
src/contact.js | 55 +++++++++++++++++++++++++++++++++++++++
src/gnome-maps.js.gresource.xml | 1 +
src/mapView.js | 14 ++++++++++
4 files changed, 90 insertions(+), 31 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 3bf5afd..decc8bb 100644
--- a/src/application.js
+++ b/src/application.js
@@ -30,6 +30,7 @@ const GtkClutter = imports.gi.GtkClutter;
const Lang = imports.lang;
const _ = imports.gettext.gettext;
+const Contact = imports.contact;
const Format = imports.format;
const Geoclue = imports.geoclue;
const GeocodeService = imports.geocodeService;
@@ -51,6 +52,8 @@ let routeService = null;
let geoclue = null;
let geocodeService = null;
let networkMonitor = null;
+let contacts = null;
+let contactsLoaded = false;
const Application = new Lang.Class({
Name: 'Application',
@@ -103,21 +106,23 @@ const Application = new Lang.Class({
this._checkNetwork();
this._mainWindow.window.present();
- let contactId = parameter.deep_unpack();
- log('lookup!');
- this._contacts.lookup(contactId, function(contact) {
- log('ID: ' + contact.id);
- log('Name: ' + contact.name);
- log('Icon: ' + contact.icon);
+ let contactArray = [];
+ contacts.lookup(parameter.deep_unpack(), (function(contact) {
contact.get_addresses().forEach(function(address) {
- log('Type: ' + address.type);
- log('Street: ' + address.street);
- log('Postal code: ' + address.postal_code);
- log('Locality: ' + address.locality);
- log('Region: ' + address.region);
- log('Country: ' + address.country);
+ contactArray.push(new Contact.Contact({ name: contact.name,
+ id: contact.id,
+ icon: contact.icon,
+ type: address.type,
+ street_address: address.street,
+ county: address.region,
+ town: address.locality,
+ postal_code: address.postal_code,
+ country: address.country
+ }));
});
- });
+
+ this._mainWindow.mapView.showContact(contactArray);
+ }).bind(this));
},
_onQuitActivate: function() {
@@ -128,24 +133,6 @@ const Application = new Lang.Class({
placeStore = new PlaceStore.PlaceStore();
try {
placeStore.load();
-
- this._contacts = new MapsC.Contacts();
- this._contacts.load(function(contacts) {
- contacts.get_list().forEach(function(contact) {
- log('ID: ' + contact.id);
- log('Name: ' + contact.name);
- log('Icon: ' + contact.icon);
- contact.get_addresses().forEach(function(address) {
- log('Type: ' + address.type);
- log('Street: ' + address.street);
- log('Postal code: ' + address.postal_code);
- log('Locality: ' + address.locality);
- log('Region: ' + address.region);
- log('Country: ' + address.country);
- });
- log('');
- });
- });
} catch (e) {
log('Failed to parse Maps places file, ' +
'subsequent writes will overwrite the file!');
@@ -191,6 +178,8 @@ const Application = new Lang.Class({
networkMonitor = Gio.NetworkMonitor.get_default();
networkMonitor.connect('network-changed',
this._checkNetwork.bind(this));
+ contacts = new MapsC.Contacts();
+ contacts.load();
},
_createWindow: function() {
diff --git a/src/contact.js b/src/contact.js
new file mode 100644
index 0000000..e91b724
--- /dev/null
+++ b/src/contact.js
@@ -0,0 +1,55 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * Copyright (c) 2014 Jonas Danielsson
+ *
+ * GNOME Maps is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * GNOME Maps is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with GNOME Maps; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author: Jonas Danielsson <jonas threetimestwo org>
+ */
+
+const _ = imports.gettext.gettext;
+
+const Geocode = imports.gi.GeocodeGlib;
+const Lang = imports.lang;
+
+const Place = imports.place;
+
+const Contact = new Lang.Class({
+ Name: 'Contact',
+ Extends: Place.Place,
+
+ _init: function(params) {
+ params.osm_id = params.id || params.osm_id || null;
+ delete params.id;
+
+ this._type = params.type;
+ delete params.type;
+
+ this.icon = params.icon;
+ delete params.icon;
+
+ if (this._type)
+ params.name = params.name + ' (' + this._type + ')';
+
+ params.osm_type = Geocode.PlaceOsmType.UNKNOWN;
+
+ this.parent(params);
+ },
+
+ get_icon: function() {
+ return this.icon;
+ }
+});
diff --git a/src/gnome-maps.js.gresource.xml b/src/gnome-maps.js.gresource.xml
index b06b5da..4399859 100644
--- a/src/gnome-maps.js.gresource.xml
+++ b/src/gnome-maps.js.gresource.xml
@@ -3,6 +3,7 @@
<gresource prefix="/org/gnome/maps">
<file>application.js</file>
<file>config.js</file>
+ <file>contact.js</file>
<file>contextMenu.js</file>
<file>epaf.js</file>
<file>favoritesPopover.js</file>
diff --git a/src/mapView.js b/src/mapView.js
index dd3e0a6..0ac0cc6 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -192,6 +192,20 @@ const MapView = new Lang.Class({
this._turnPointMarker.goToAndSelect(true);
},
+ showContact: function(contacts) {
+ this._searchResultLayer.remove_all();
+ contacts.forEach(function(contact) {
+ let marker = new SearchResultMarker.SearchResultMarker({ place: contact,
+ mapView: this });
+ this._searchResultLayer.add_marker(marker);
+ });
+
+ if (contacts.length > 0) {
+ let bbox = this._searchResultLayer.get_bounding_box();
+ this.view.ensure_visible(bbox, true);
+ }
+ },
+
showSearchResult: function(place) {
this._searchResultLayer.remove_all();
let searchResultMarker = new SearchResultMarker.SearchResultMarker({ place: place,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]