[gnome-maps] Add scale ruler
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] Add scale ruler
- Date: Mon, 1 Feb 2016 20:00:13 +0000 (UTC)
commit ec85127a77525e897e3cc86f3a6692776ed4a77d
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Mon Feb 1 10:24:06 2016 +0100
Add scale ruler
Champlain has support for adding a scale ruler. It also supports
different units. Miles vs Kilometers. This commit adds a scale to Maps
and checks the LC_MEASUREMENT locale to determine the unit.
https://bugzilla.gnome.org/show_bug.cgi?id=739363
data/ui/help-overlay.ui | 19 +++++++++++++------
src/mainWindow.js | 4 ++++
src/mapView.js | 22 ++++++++++++++++++++++
3 files changed, 39 insertions(+), 6 deletions(-)
---
diff --git a/data/ui/help-overlay.ui b/data/ui/help-overlay.ui
index e1ed46a..ad53c77 100644
--- a/data/ui/help-overlay.ui
+++ b/data/ui/help-overlay.ui
@@ -58,12 +58,19 @@
</object>
</child>
<child>
- <object class="GtkShortcutsShortcut">
- <property name="visible">1</property>
- <property name="title" translatable="yes" context="shortcut window">Go to current
location</property>
- <property name="accelerator"><Primary>L</property>
- </object>
- </child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">1</property>
+ <property name="title" translatable="yes" context="shortcut-window">Toggle scale</property>
+ <property name="accelerator"><Primary>S</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">1</property>
+ <property name="title" translatable="yes" context="shortcut window">Go to current
location</property>
+ <property name="accelerator"><Primary>L</property>
+ </object>
+ </child>
</object>
</child>
</object>
diff --git a/src/mainWindow.js b/src/mainWindow.js
index a59536a..39c1de1 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -200,6 +200,10 @@ const MainWindow = new Lang.Class({
accels: ['minus', '<Primary>minus', 'KP_Subtract', '<Primary>KP_Subtract'],
onActivate: this._mapView.view.zoom_out.bind(this._mapView.view)
},
+ 'toggle-scale': {
+ accels: ['<Primary>S'],
+ onActivate: this._mapView.toggleScale.bind(this._mapView)
+ },
'find': {
accels: ['<Primary>F'],
onActivate: this._placeEntry.grab_focus.bind(this._placeEntry)
diff --git a/src/mapView.js b/src/mapView.js
index 5d3d2a5..eb13081 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -100,6 +100,22 @@ const MapView = new Lang.Class({
this._connectRouteSignals();
},
+ _initScale: function(view) {
+ this._scale = new Champlain.Scale({ visible: true });
+ this._scale.connect_view(view);
+
+ if (Utils.getMeasurementSystem() === Utils.METRIC_SYSTEM)
+ this._scale.unit = Champlain.Unit.KM;
+ else
+ this._scale.unit = Champlain.Unit.MILES;
+
+ this._scale.set_x_expand(true);
+ this._scale.set_y_expand(true);
+ this._scale.set_x_align(Clutter.ActorAlign.START);
+ this._scale.set_y_align(Clutter.ActorAlign.END);
+ view.add_child(this._scale);
+ },
+
_initView: function(opening) {
let view = this.get_view();
view.zoom_level = 3;
@@ -117,6 +133,8 @@ const MapView = new Lang.Class({
view.min_zoom_level = MapMinZoom;
}
}).bind(this));
+
+ this._initScale(view);
return view;
},
@@ -198,6 +216,10 @@ const MapView = new Lang.Class({
}).bind(this));
},
+ toggleScale: function() {
+ this._scale.visible = !this._scale.visible;
+ },
+
openShapeLayers: function(files) {
let bbox = new Champlain.BoundingBox();
let ret = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]