[gnome-maps] mainWindow, layersPopover: Add shortcut to open a shape layer
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] mainWindow, layersPopover: Add shortcut to open a shape layer
- Date: Mon, 19 Jun 2017 19:53:59 +0000 (UTC)
commit 22dc9f5337dab13ff0b577a9d8635d9e4d0b9eb7
Author: Marcus Lundblad <ml update uu se>
Date: Tue Apr 25 22:22:30 2017 +0200
mainWindow,layersPopover: Add shortcut to open a shape layer
Add a shortcut to open a shape layer, also as a consequence move
the shape layer file chooser logic to the MainWindow class.
https://bugzilla.gnome.org/show_bug.cgi?id=776826
data/ui/layers-popover.ui | 1 +
src/layersPopover.js | 41 -----------------------------------------
src/mainWindow.js | 43 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 44 insertions(+), 41 deletions(-)
---
diff --git a/data/ui/layers-popover.ui b/data/ui/layers-popover.ui
index 573c364..ee3f4d8 100644
--- a/data/ui/layers-popover.ui
+++ b/data/ui/layers-popover.ui
@@ -69,6 +69,7 @@
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="label" translatable="yes">Load Map Layer</property>
+ <property name="action-name">win.open-shape-layer</property>
</object>
<packing>
<property name="left-attach">0</property>
diff --git a/src/layersPopover.js b/src/layersPopover.js
index 37e4450..ee40334 100644
--- a/src/layersPopover.js
+++ b/src/layersPopover.js
@@ -52,29 +52,6 @@ const ShapeLayerRow = new Lang.Class({
}
});
-const ShapeLayerFileChooser = new Lang.Class({
- Name: 'ShapeLayerFileChooser',
- Extends: Gtk.FileChooserDialog,
- Template: 'resource:///org/gnome/Maps/ui/shape-layer-file-chooser.ui',
-
- _init: function(params) {
- this.parent(params);
- let allFilter = new Gtk.FileFilter();
- allFilter.set_name(_("All Layer Files"));
- this.add_filter(allFilter);
- this.set_filter(allFilter);
-
- ShapeLayer.SUPPORTED_TYPES.forEach((function(layerClass) {
- let filter = new Gtk.FileFilter();
- [filter, allFilter].forEach(function(f) {
- layerClass.mimeTypes.forEach(f.add_mime_type.bind(f));
- });
- filter.set_name(layerClass.displayName);
- this.add_filter(filter);
- }).bind(this));
- }
-});
-
const LayersPopover = new Lang.Class({
Name: 'LayersPopover',
Extends: Gtk.Popover,
@@ -108,9 +85,6 @@ const LayersPopover = new Lang.Class({
row.set_header(header);
});
- this._loadLayerButton.connect('clicked',
- this._onLoadLayerClicked.bind(this));
-
this._streetLayerButton.connect('clicked', (function () {
this._mapView.setMapType(MapView.MapType.STREET);
}).bind(this));
@@ -133,21 +107,6 @@ const LayersPopover = new Lang.Class({
this._layersListBox.hide();
},
- _onLoadLayerClicked: function(button) {
- let fileChooser = new ShapeLayerFileChooser({
- transient_for: this.get_parent(),
- });
-
- fileChooser.connect('response', (function(widget, response) {
- if (response === Gtk.ResponseType.OK) {
- this._mapView.openShapeLayers(fileChooser.get_files());
- this.hide();
- }
- fileChooser.destroy();
- }).bind(this));
- fileChooser.show();
- },
-
_listBoxCreateWidget: function(shapeLayer) {
let row = new ShapeLayerRow({ shapeLayer: shapeLayer });
row.closeButton.connect('clicked',
diff --git a/src/mainWindow.js b/src/mainWindow.js
index cfbd438..fd97733 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -39,6 +39,7 @@ const MapView = imports.mapView;
const PlaceEntry = imports.placeEntry;
const PlaceStore = imports.placeStore;
const PrintOperation = imports.printOperation;
+const ShapeLayer = imports.shapeLayer;
const Sidebar = imports.sidebar;
const Utils = imports.utils;
const ZoomControl = imports.zoomControl;
@@ -47,6 +48,29 @@ const _CONFIGURE_ID_TIMEOUT = 100; // msecs
const _WINDOW_MIN_WIDTH = 600;
const _WINDOW_MIN_HEIGHT = 500;
+const ShapeLayerFileChooser = new Lang.Class({
+ Name: 'ShapeLayerFileChooser',
+ Extends: Gtk.FileChooserDialog,
+ Template: 'resource:///org/gnome/Maps/ui/shape-layer-file-chooser.ui',
+
+ _init: function(params) {
+ this.parent(params);
+ let allFilter = new Gtk.FileFilter();
+ allFilter.set_name(_("All Layer Files"));
+ this.add_filter(allFilter);
+ this.set_filter(allFilter);
+
+ ShapeLayer.SUPPORTED_TYPES.forEach((function(layerClass) {
+ let filter = new Gtk.FileFilter();
+ [filter, allFilter].forEach(function(f) {
+ layerClass.mimeTypes.forEach(f.add_mime_type.bind(f));
+ });
+ filter.set_name(layerClass.displayName);
+ this.add_filter(filter);
+ }).bind(this));
+ }
+});
+
const MainWindow = new Lang.Class({
Name: 'MainWindow',
Extends: Gtk.ApplicationWindow,
@@ -212,6 +236,10 @@ const MainWindow = new Lang.Class({
'print-route': {
accels: ['<Primary>P'],
onActivate: this._printRouteActivate.bind(this)
+ },
+ 'open-shape-layer': {
+ accels: ['<Primary>O'],
+ onActivate: this._onOpenShapeLayer.bind(this)
}
});
},
@@ -464,6 +492,21 @@ const MainWindow = new Lang.Class({
aboutDialog.destroy.bind(aboutDialog));
},
+ _onOpenShapeLayer: function() {
+ let fileChooser = new ShapeLayerFileChooser({
+ transient_for: this,
+ });
+
+ fileChooser.connect('response', (function(widget, response) {
+ if (response === Gtk.ResponseType.OK) {
+ this._mapView.openShapeLayers(fileChooser.get_files());
+ this.layersPopover.popdown();
+ }
+ fileChooser.destroy();
+ }).bind(this));
+ fileChooser.show();
+ },
+
markBusy: function() {
if (this._busySignalId !== 0)
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]