diff options
author | Marcus Lundblad <ml@update.uu.se> | 2016-01-31 15:01:27 +0100 |
---|---|---|
committer | Marcus Lundblad <ml@update.uu.se> | 2016-02-12 08:34:54 +0100 |
commit | c4c25a8ed6553e081c3b723d2bbc8cd729a6dce8 (patch) | |
tree | d65b18b5ce711a861accbc399958d58614341bd4 /src/osmTypePopover.js | |
parent | 00aad3df22d846ca862caf36a6e39446cfa5ce6f (diff) | |
download | gnome-maps-c4c25a8ed6553e081c3b723d2bbc8cd729a6dce8.tar.gz |
osmEdit: Add support for creating new locations in the edit dialog
Adds the ability to edit newly created locations in the dialog.
Also adds a module to handle OSM tag key/value mapping to translated
POI types and a list of recently used POI types.
Also enables editing the POI type of existing objects in more simple
cases (known tag values with no combined tags).
https://bugzilla.gnome.org/show_bug.cgi?id=761327
Diffstat (limited to 'src/osmTypePopover.js')
-rw-r--r-- | src/osmTypePopover.js | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/osmTypePopover.js b/src/osmTypePopover.js new file mode 100644 index 00000000..8881a028 --- /dev/null +++ b/src/osmTypePopover.js @@ -0,0 +1,67 @@ +/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */ +/* vim: set et ts=4 sw=4: */ +/* + * Copyright (c) 2015 Marcus Lundblad. + * + * 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, see <http://www.gnu.org/licenses/>. + * + * Author: Marcus Lundblad <ml@update.uu.se> + */ + +const GObject = imports.gi.GObject; +const Gtk = imports.gi.Gtk; +const Lang = imports.lang; + +const OSMTypeListRow = imports.osmTypeListRow; +const SearchPopover = imports.searchPopover; + +const OSMTypePopover = new Lang.Class({ + Name: 'OSMTypePopover', + Extends: SearchPopover.SearchPopover, + InternalChildren: ['list'], + Template: 'resource:///org/gnome/Maps/ui/osm-type-popover.ui', + Signals : { + /* signal emitted when selecting a type, indicates OSM key and value + * and display title */ + 'selected' : { param_types: [ GObject.TYPE_STRING, + GObject.TYPE_STRING, + GObject.TYPE_STRING ] } + }, + + _init: function(props) { + this.parent(props); + + this._list.connect('row-activated', (function(list, row) { + if (row) + this.emit('selected', row.key, row.value, row.title); + }).bind(this)); + }, + + showMatches: function(matches) { + this._list.forall(function(row) { + row.destroy(); + }); + + matches.forEach((function(type) { + this._addRow(type); + }).bind(this)); + this.show(); + }, + + _addRow: function(type) { + let row = new OSMTypeListRow.OSMTypeListRow({ type: type, + can_focus: true }); + this._list.add(row); + } +}); |