[gnome-maps/wip/mlundblad/osm-add-location: 2/4] osmEdit: WIP: Add functionallity for adding locations
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/osm-add-location: 2/4] osmEdit: WIP: Add functionallity for adding locations
- Date: Thu, 31 Dec 2015 09:31:28 +0000 (UTC)
commit e78f97a10e989ed1672cdf264311aa3e2404374b
Author: Marcus Lundblad <ml update uu se>
Date: Mon Dec 21 22:01:03 2015 +0100
osmEdit: WIP: Add functionallity for adding locations
data/ui/context-menu.ui | 7 +++++++
src/contextMenu.js | 22 +++++++++++++++++++++-
src/osmEdit.js | 12 ++++++++++++
3 files changed, 40 insertions(+), 1 deletions(-)
---
diff --git a/data/ui/context-menu.ui b/data/ui/context-menu.ui
index b968616..36a9b25 100644
--- a/data/ui/context-menu.ui
+++ b/data/ui/context-menu.ui
@@ -24,5 +24,12 @@
<property name="visible">True</property>
</object>
</child>
+ <child>
+ <object class="GtkMenuItem" id="addOSMLocationItem">
+ <property name="name">add-osm-location-item</property>
+ <property name="label" translatable="yes">Add Location</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
</template>
</interface>
diff --git a/src/contextMenu.js b/src/contextMenu.js
index 39633b1..e58ecb1 100644
--- a/src/contextMenu.js
+++ b/src/contextMenu.js
@@ -30,6 +30,7 @@ const Application = imports.application;
const ExportViewDialog = imports.exportViewDialog;
const Lang = imports.lang;
const Location = imports.location;
+const OSMEdit = imports.osmEdit;
const Utils = imports.utils;
const ContextMenu = new Lang.Class({
@@ -38,7 +39,8 @@ const ContextMenu = new Lang.Class({
Template: 'resource:///org/gnome/Maps/ui/context-menu.ui',
InternalChildren: [ 'whatsHereItem',
'geoURIItem',
- 'exportItem' ],
+ 'exportItem',
+ 'addOSMLocationItem' ],
_init: function(params) {
this._mapView = params.mapView;
@@ -55,6 +57,8 @@ const ContextMenu = new Lang.Class({
this._onGeoURIActivated.bind(this));
this._exportItem.connect('activate',
this._onExportActivated.bind(this));
+ this._addOSMLocationItem.connect('activate',
+ this._onAddOSMLocationActivated.bind(this));
},
_onButtonReleaseEvent: function(actor, event) {
@@ -92,6 +96,22 @@ const ContextMenu = new Lang.Class({
clipboard.set_text(uri, uri.length);
},
+ _onAddOSMLocationActivated: function() {
+ let osmEdit = Application.osmEdit;
+ /* if the user is not alread signed in, show the account dialog */
+ if (!osmEdit.isSignedIn) {
+ let response = osmEdit.showAccountDialog(this.get_toplevel(), true);
+ if (!response === OSMAccountDialog.Response.SIGNED_IN)
+ return;
+ }
+
+ let response =
+ osmEdit.showEditNewDialog(this.get_toplevel(),
+ this._latitude, this._longitude);
+ /* TODO: should we create a location in the location store, and maybe
+ show a place marker (on success)? */
+ },
+
_activateExport: function() {
let view = this._mapView.view;
let surface = view.to_surface(true);
diff --git a/src/osmEdit.js b/src/osmEdit.js
index 62f15d5..5d911c6 100644
--- a/src/osmEdit.js
+++ b/src/osmEdit.js
@@ -54,6 +54,18 @@ const OSMEdit = new Lang.Class({
return response;
},
+ showEditNewDialog: function(parentWindow, latitude, longitude) {
+ let dialog = new OSMEditDialog.OSMEditDialog({
+ transient_for: parentWindow,
+ addLocation: true,
+ latitude: latitude,
+ longitude: longitude
+ });
+ let response = dialog.run();
+ dialog.destroy();
+ return response;
+ },
+
showAccountDialog: function(parentWindow, closeOnSignIn) {
let dialog = new OSMAccountDialog.OSMAccountDialog({
transient_for: parentWindow,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]