[gnome-maps/wip/mlundblad/replace-notifications] Add dialog to zoom in for OSM editing
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/replace-notifications] Add dialog to zoom in for OSM editing
- Date: Tue, 22 May 2018 21:14:28 +0000 (UTC)
commit c1652fbb052178c0eb0e357c2d6a54aef7e4dd97
Author: Marcus Lundblad <ml update uu se>
Date: Tue May 22 23:12:36 2018 +0200
Add dialog to zoom in for OSM editing
data/org.gnome.Maps.data.gresource.xml | 1 +
data/ui/zoom-in-dialog.ui | 53 +++++++++++++++++++++++++++++
src/org.gnome.Maps.src.gresource.xml | 1 +
src/zoomInDialog.js | 62 ++++++++++++++++++++++++++++++++++
4 files changed, 117 insertions(+)
---
diff --git a/data/org.gnome.Maps.data.gresource.xml b/data/org.gnome.Maps.data.gresource.xml
index 004a56a..a0c1853 100644
--- a/data/org.gnome.Maps.data.gresource.xml
+++ b/data/org.gnome.Maps.data.gresource.xml
@@ -39,6 +39,7 @@
<file preprocess="xml-stripblanks">ui/transit-route-label.ui</file>
<file preprocess="xml-stripblanks">ui/transit-stop-row.ui</file>
<file preprocess="xml-stripblanks">ui/user-location-bubble.ui</file>
+ <file preprocess="xml-stripblanks">ui/zoom-in-dialog.ui</file>
<file preprocess="xml-stripblanks">ui/zoom-in-notification.ui</file>
<file alias="application.css">gnome-maps.css</file>
<file alias="ui/maptype-aerial.png">media/maptype-aerial.png</file>
diff --git a/data/ui/zoom-in-dialog.ui b/data/ui/zoom-in-dialog.ui
new file mode 100644
index 0000000..359dd46
--- /dev/null
+++ b/data/ui/zoom-in-dialog.ui
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="3.12"/>
+ <template class="Gjs_ZoomInDialog" parent="GtkDialog">
+ <property name="can_focus">False</property>
+ <property name="type">popup</property>
+ <property name="type_hint">dialog</property>
+ <property name="width_request">400</property>
+ <property name="height_request">150</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="contentArea">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Zoom in to add location!</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="titlebar">
+ <object class="GtkHeaderBar" id="headerBar">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="show-close-button">False</property>
+ <child>
+ <object class="GtkButton" id="cancelButton">
+ <property name="label" translatable="yes">Cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="zoomInButton">
+ <property name="label" translatable="yes">Zoom In</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <style>
+ <class name="default"/>
+ </style>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
\ No newline at end of file
diff --git a/src/org.gnome.Maps.src.gresource.xml b/src/org.gnome.Maps.src.gresource.xml
index d52da0e..4629824 100644
--- a/src/org.gnome.Maps.src.gresource.xml
+++ b/src/org.gnome.Maps.src.gresource.xml
@@ -100,6 +100,7 @@
<file>xmldom/dom.js</file>
<file>xmldom/domparser.js</file>
<file>xmldom/sax.js</file>
+ <file>zoomInDialog.js</file>
<file>zoomInNotification.js</file>
<file alias="geojsonvt/clip.js">clip.js</file>
<file alias="geojsonvt/convert.js">convert.js</file>
diff --git a/src/zoomInDialog.js b/src/zoomInDialog.js
new file mode 100644
index 0000000..16bb9c9
--- /dev/null
+++ b/src/zoomInDialog.js
@@ -0,0 +1,62 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * Copyright (c) 2018 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, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author: Marcus Lundblad <ml update uu se>
+ */
+
+const GObject = imports.gi.GObject;
+const Gtk = imports.gi.Gtk;
+
+const OSMEdit = imports.osmEdit;
+
+var ZoomInDialog = GObject.registerClass({
+ Template: 'resource:///org/gnome/Maps/ui/zoom-in-dialog.ui',
+ InternalChildren: [ 'cancelButton',
+ 'zoomInButton'],
+}, class ZoomInDialog extends Gtk.Dialog {
+
+ _init(params) {
+ this._latitude = params.latitude;
+ delete params.latitude;
+ this._longitude = params.longitude;
+ delete params.longitude;
+ this._view = params.view;
+ delete params.view;
+
+ /* This is a construct-only property and cannot be set by GtkBuilder */
+ params.use_header_bar = true;
+
+ super._init(params);
+
+ this._zoomInButton.connect('clicked', () => this._onZoomIn());
+ this._cancelButton.connect('clicked', () => this._onCancel());
+ }
+
+ _onZoomIn() {
+ this._view.zoom_level = OSMEdit.MIN_ADD_LOCATION_ZOOM_LEVEL;
+
+ /* center on the position first selected */
+ this._view.center_on(this._latitude, this._longitude);
+ this.response(Gtk.ResponseType.OK);
+ }
+
+ _onCancel() {
+ this.response(Gtk.ResponseType.CANCEL);
+ }
+});
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]