[gnome-maps] mainWindow: Convert zoom bindings to accelerators
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] mainWindow: Convert zoom bindings to accelerators
- Date: Sun, 19 Oct 2014 13:10:43 +0000 (UTC)
commit 0243f90d2bf2f745960d14c69ec00b22843528e4
Author: Ankita Patil <patil ankita r gmail com>
Date: Thu Oct 2 16:03:09 2014 +0530
mainWindow: Convert zoom bindings to accelerators
Adding a accelerator instead of key-press-event,
Which allows user to perform operation without mouse.
https://bugzilla.gnome.org/show_bug.cgi?id=731540
src/mainWindow.js | 39 +++++++++++++++++++--------------------
1 files changed, 19 insertions(+), 20 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 8a6ecfe..04acd18 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -83,6 +83,7 @@ const MainWindow = new Lang.Class({
this._layersButton = ui.layersButton;
this._initActions();
+ this._initAccelerators();
this._initSignals();
this._initHeaderbar();
this._restoreWindowGeometry();
@@ -127,6 +128,13 @@ const MainWindow = new Lang.Class({
return sidebar;
},
+ _initAccelerators: function() {
+ this.window.application.set_accels_for_action('win.zoom-in',
+ ['<Primary>plus']);
+ this.window.application.set_accels_for_action('win.zoom-out',
+ ['<Primary>minus']);
+ },
+
_initActions: function() {
Utils.initActions(this.window, [
{
@@ -159,7 +167,17 @@ const MainWindow = new Lang.Class({
signalHandlers: {
'change-state': this._onToggleSidebarChangeState
}
- }
+ }, {
+ properties: { name: 'zoom-in' },
+ signalHandlers: {
+ activate: this.mapView.view.zoom_in.bind(this.mapView.view)
+ }
+ },{
+ properties: { name: 'zoom-out' },
+ signalHandlers: {
+ activate: this.mapView.view.zoom_out.bind(this.mapView.view)
+ }
+ },
], this);
let action = this.window.lookup_action('goto-user-location');
@@ -174,9 +192,6 @@ const MainWindow = new Lang.Class({
this._onConfigureEvent.bind(this));
this.window.connect('window-state-event',
this._onWindowStateEvent.bind(this));
- this.window.connect('key-press-event',
- this._onKeyPressEvent.bind(this));
-
this.mapView.view.connect('button-press-event',
this._overlay.grab_focus.bind(this._overlay));
@@ -266,22 +281,6 @@ const MainWindow = new Lang.Class({
Application.settings.set('window-maximized', maximized);
},
- _onKeyPressEvent: function(widget, event) {
- let state = event.get_state()[1];
-
- if (state & Gdk.ModifierType.CONTROL_MASK) {
- let keyval = event.get_keyval()[1];
-
- if (keyval === Gdk.KEY_plus)
- this.mapView.view.zoom_in();
-
- if (keyval === Gdk.KEY_minus)
- this.mapView.view.zoom_out();
- }
-
- return false;
- },
-
_quit: function() {
// remove configure event handler if still there
if (this._configureId !== 0) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]