[gnome-maps] osmEdit: Add support for editing website
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] osmEdit: Add support for editing website
- Date: Tue, 9 Feb 2016 22:00:13 +0000 (UTC)
commit 7a7b9fa0e47bdd2d69df1169eee4cc5d2d84b10b
Author: Marcus Lundblad <ml update uu se>
Date: Sat Feb 6 13:59:41 2016 +0100
osmEdit: Add support for editing website
Also show a website link in the expanded place area when available.
And fix a bug where the expanded area wasn't cleared properly when
successfully updating an OSM object, when we're at it.
https://bugzilla.gnome.org/show_bug.cgi?id=761634
src/osmEditDialog.js | 1 +
src/osmUtils.js | 1 +
src/overpass.js | 2 ++
src/place.js | 12 ++++++++++++
src/placeBubble.js | 39 ++++++++++++++++++++++++++++-----------
5 files changed, 44 insertions(+), 11 deletions(-)
---
diff --git a/src/osmEditDialog.js b/src/osmEditDialog.js
index 599e98f..12977b1 100644
--- a/src/osmEditDialog.js
+++ b/src/osmEditDialog.js
@@ -69,6 +69,7 @@ let _osmWikipediaRewriteFunc = function(text) {
* (only used for TEXT fields)
*/
const OSM_FIELDS = [{name: _("Name"), tag: 'name', type: EditFieldType.TEXT},
+ {name: _("Website"), tag: 'website', type: EditFieldType.TEXT},
{name: _("Wikipedia"), tag: 'wikipedia', type: EditFieldType.TEXT,
rewriteFunc: this._osmWikipediaRewriteFunc},
{name: _("Population"), tag: 'population',
diff --git a/src/osmUtils.js b/src/osmUtils.js
index 4c2f183..5d5b471 100644
--- a/src/osmUtils.js
+++ b/src/osmUtils.js
@@ -49,6 +49,7 @@ function getWikipediaOSMArticleFormatFromUrl(url) {
function updatePlaceFromOSMObject(place, object) {
place.name = object.get_tag('name');
place.population = object.get_tag('population');
+ place.website = object.get_tag('website');
place.wiki = object.get_tag('wikipedia');
place.openingHours = object.get_tag('opening_hours');
place.wheelchair = object.get_tag('wheelchair');
diff --git a/src/overpass.js b/src/overpass.js
index e471fd4..dd627c1 100644
--- a/src/overpass.js
+++ b/src/overpass.js
@@ -94,6 +94,8 @@ const Overpass = new Lang.Class({
place.name = element.tags.name;
if (element.tags.population)
place.population = element.tags.population;
+ if (element.tags.website)
+ place.website = element.tags.website;
if (element.tags.wikipedia)
place.wiki = element.tags.wikipedia;
if (element.tags.wheelchair)
diff --git a/src/place.js b/src/place.js
index 1a7f1b7..17546c9 100644
--- a/src/place.js
+++ b/src/place.js
@@ -36,6 +36,9 @@ const Place = new Lang.Class({
this._population = params.population;
delete params.population;
+ this._website = params.website;
+ delete params.website;
+
this._wiki = params.wiki;
delete params.wiki;
@@ -100,6 +103,14 @@ const Place = new Lang.Class({
return this._population;
},
+ set website(v) {
+ this._website = v;
+ },
+
+ get website() {
+ return this._website;
+ },
+
set wiki(v) {
this._wiki = v;
},
@@ -198,6 +209,7 @@ const Place = new Lang.Class({
country_code: this.contry_code,
continent: this.continent,
population: this.population,
+ website: this.website,
wiki: this.wiki,
wheelchair: this.wheelchair,
openingHours: this.openingHours };
diff --git a/src/placeBubble.js b/src/placeBubble.js
index f1f0ec4..7b1c810 100644
--- a/src/placeBubble.js
+++ b/src/placeBubble.js
@@ -138,14 +138,18 @@ const PlaceBubble = new Lang.Class({
info: place.wheelchairTranslated });
}
+ if (place.website) {
+ expandedContent.push({ linkText: _("Website"),
+ linkUrl: place.website,
+ tooltip: place.website });
+ }
+
if (place.wiki) {
let link = this._formatWikiLink(place.wiki);
- let href = Format.vprintf('<a href="%s">%s</a>',
- [link, _("Wikipedia")]);
- expandedContent.push({ info: href });
+ expandedContent.push({ linkText: _("Wikipedia"),
+ linkUrl: link});
}
-
content.forEach((function(row) {
let label = new Gtk.Label({ label: row,
visible: true,
@@ -165,10 +169,23 @@ const PlaceBubble = new Lang.Class({
this._expandedContent.attach(label, col++, row, 1, 1);
}
- let info = new Gtk.Label({ label: expandedContent[row].info,
+ let info;
+
+ if (expandedContent[row].linkUrl) {
+ info = new Gtk.LinkButton({ label: expandedContent[row].linkText,
+ visible: true,
+ uri: expandedContent[row].linkUrl,
+ halign: Gtk.Align.START });
+ } else {
+ info = new Gtk.Label({ label: expandedContent[row].info,
visible: true,
use_markup: true,
halign: Gtk.Align.START });
+ }
+
+ if (expandedContent[row].tooltip)
+ info.tooltip_text = expandedContent[row].tooltip;
+
this._expandedContent.attach(info, col, row, col == 0 ? 2 : 1, 1);
}
@@ -178,13 +195,13 @@ const PlaceBubble = new Lang.Class({
// clear the view widgets to be able to re-populate an updated place
_clearView: function() {
- let widgets = this._boxContent.get_children();
+ this._boxContent.get_children().forEach(function(child) {
+ child.destroy();
+ });
- /* remove the dynamically added content, the title label
- has position 0 in the box */
- for (let i = 1; i < widgets.length; i++) {
- this._boxContent.remove(widgets[i]);
- }
+ this._expandedContent.get_children().forEach(function(child) {
+ child.destroy();
+ });
},
_initEditButton: function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]