[gnome-maps] Use Overpass to get extra info for search bubble
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] Use Overpass to get extra info for search bubble
- Date: Thu, 20 Nov 2014 19:43:20 +0000 (UTC)
commit d2924bda5c96474610483b10e6fc338d0e7235da
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Thu Nov 13 01:55:13 2014 -0500
Use Overpass to get extra info for search bubble
https://bugzilla.gnome.org/show_bug.cgi?id=726625
src/placeEntry.js | 1 -
src/search-result-bubble.ui | 11 +++++++
src/searchResultBubble.js | 69 ++++++++++++++++++++++++++++++++++++------
3 files changed, 70 insertions(+), 11 deletions(-)
---
diff --git a/src/placeEntry.js b/src/placeEntry.js
index ff05eb6..cb57a28 100644
--- a/src/placeEntry.js
+++ b/src/placeEntry.js
@@ -61,7 +61,6 @@ const PlaceEntry = new Lang.Class({
if (p) {
if (p.name) {
this.text = p.name;
- Application.placeStore.addRecent(p);
} else
this.text = p.location.latitude + ', ' + p.location.longitude;
} else
diff --git a/src/search-result-bubble.ui b/src/search-result-bubble.ui
index ae0cd46..c6f2b6a 100644
--- a/src/search-result-bubble.ui
+++ b/src/search-result-bubble.ui
@@ -2,6 +2,15 @@
<!-- Generated with glade 3.18.1 -->
<interface>
<requires lib="gtk+" version="3.12"/>
+ <object class="GtkStack" id="stack">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkSpinner" id="spinner">
+ <property name="visible">True</property>
+ <property name="active">True</property>
+ </object>
+ </child>
+ <child>
<object class="GtkBox" id="box-content">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -26,4 +35,6 @@
</packing>
</child>
</object>
+ </child>
+ </object>
</interface>
diff --git a/src/searchResultBubble.js b/src/searchResultBubble.js
index e851a71..ca164b8 100644
--- a/src/searchResultBubble.js
+++ b/src/searchResultBubble.js
@@ -20,12 +20,15 @@
* Author: Damián Nohales <damiannohales gmail com>
*/
-const Geocode = imports.gi.GeocodeGlib;
const Gtk = imports.gi.Gtk;
+const Format = imports.format;
const Lang = imports.lang;
const _ = imports.gettext.gettext;
+const Application = imports.application;
const MapBubble = imports.mapBubble;
+const Overpass = imports.overpass;
+const Place = imports.place;
const PlaceFormatter = imports.placeFormatter;
const Utils = imports.utils;
@@ -34,21 +37,49 @@ const SearchResultBubble = new Lang.Class({
Extends: MapBubble.MapBubble,
_init: function(params) {
- let ui = Utils.getUIObject('search-result-bubble', [ 'box-content',
+ let ui = Utils.getUIObject('search-result-bubble', [ 'stack',
+ 'box-content',
'label-title']);
params.buttons = MapBubble.Button.ROUTE;
this.parent(params);
- let place = this.place;
-
Utils.load_icon(this.place.icon, 48, (function(pixbuf) {
this.image.pixbuf = pixbuf;
}).bind(this));
- let formatter = new PlaceFormatter.PlaceFormatter(place);
+ this._stack = ui.stack;
+ this._title = ui.labelTitle;
+ this._boxContent = ui.boxContent;
+
+ if (Application.placeStore.exists(this.place.osm_id, null)) {
+ let place = Application.placeStore.get(this.place.osm_id);
+ this._populate(place);
+ } else {
+ let overpass = new Overpass.Overpass();
+ overpass.addInfo(this.place, (function(status, code, place) {
+ if (!status)
+ place = new Place.Place({ place: this.place });
+
+ this._populate(place);
+ Application.placeStore.addRecent(place);
+ }).bind(this));
+ }
+ this.content.add(this._stack);
+ },
+
+ _formatWikiLink: function(wiki) {
+ let tokens = wiki.split(':');
+
+ return Format.vprintf('http://%s.wikipedia.org/wiki/%s', [ tokens[0],
+ tokens[1] ]);
+ },
+
+ _populate: function(place) {
let infos = [];
+ let formatter = new PlaceFormatter.PlaceFormatter(place);
+
+ this._title.label = formatter.title;
- ui.labelTitle.label = formatter.title;
infos = formatter.rows.map(function(row) {
row = row.map(function(prop) {
switch (prop) {
@@ -63,13 +94,31 @@ const SearchResultBubble = new Lang.Class({
return row.join(', ');
});
- infos.forEach(function(info) {
+ if (place.population)
+ infos.push(_("Population: %s").format(place.population));
+
+ if (place.openingHours)
+ infos.push(_("Opening hours: %s").format(place.openingHours));
+
+ if (place.wiki) {
+ let link = this._formatWikiLink(place.wiki);
+ let href = Format.vprintf('<a href="%s">%s</a>',
+ [link, _("Wikipedia article")]);
+ infos.push(href);
+ }
+
+ if (place.wheelchair) {
+ infos.push(_("Wheelchair access: %s").format(place.wheelchair));
+ }
+
+ infos.forEach((function(info) {
let label = new Gtk.Label({ label: info,
visible: true,
+ use_markup: true,
halign: Gtk.Align.START });
- ui.boxContent.pack_start(label, false, true, 0);
- });
+ this._boxContent.pack_start(label, false, true, 0);
+ }).bind(this));
- this.content.add(ui.boxContent);
+ this._stack.visible_child = this._boxContent;
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]