[gnome-documents] application: use gtk_application_add_accelerator for simple actions



commit ca6f372636744e6a609e40acbc8318b216731caf
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Jul 17 12:48:53 2012 -0400

    application: use gtk_application_add_accelerator for simple actions
    
    Instead of using custom code in a key press handler

 src/application.js |    8 +++++---
 src/mainWindow.js  |   15 ---------------
 2 files changed, 5 insertions(+), 18 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 3202f7b..4739f2f 100644
--- a/src/application.js
+++ b/src/application.js
@@ -81,7 +81,7 @@ const Application = new Lang.Class({
             }));
     },
 
-    _initMenus: function() {
+    _initActions: function() {
 	let quitAction = new Gio.SimpleAction({ name: 'quit' });
 	quitAction.connect('activate', Lang.bind(this,
             function() {
@@ -143,7 +143,9 @@ const Application = new Lang.Class({
         menu.append(_("About Documents"), 'app.about');
         menu.append(_("Quit"), 'app.quit');
 
-	this.application.set_app_menu(menu);
+        this.application.set_app_menu(menu);
+        this.application.add_accelerator('<Primary>q', 'app.quit', null);
+        this.application.add_accelerator('F11', 'app.fullscreen', null);
     },
 
     _refreshMinerNow: function(miner) {
@@ -209,7 +211,7 @@ const Application = new Lang.Class({
         let zpjMiner = new ZpjMiner.ZpjMiner();
         this._refreshMinerNow(zpjMiner);
 
-        this._initMenus();
+        this._initActions();
         this._mainWindow = new MainWindow.MainWindow(this.application);
     },
 
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 45c8fd5..1a62164 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -140,15 +140,6 @@ const MainWindow = new Lang.Class({
     },
 
     _onKeyPressEvent: function(widget, event) {
-        let keyval = event.get_keyval()[1];
-        let state = event.get_state()[1];
-
-        if ((keyval == Gdk.KEY_q) &&
-            ((state & Gdk.ModifierType.CONTROL_MASK) != 0)) {
-            this.window.destroy();
-            return true;
-        }
-
         if (Global.modeController.getWindowMode() == WindowMode.WindowMode.PREVIEW)
             return this._handleKeyPreview(event);
         else
@@ -161,12 +152,6 @@ const MainWindow = new Lang.Class({
         let fullscreen = Global.modeController.getFullscreen();
         let direction = this.window.get_direction();
 
-        if ((keyval == Gdk.KEY_f || keyval == Gdk.KEY_F11) &&
-            ((state & Gdk.ModifierType.CONTROL_MASK) == 0)) {
-            Global.modeController.toggleFullscreen();
-            return true;
-        }
-
         if ((fullscreen && keyval == Gdk.KEY_Escape) ||
             ((state & Gdk.ModifierType.MOD1_MASK) != 0 &&
              (direction == Gtk.TextDirection.LTR && keyval == Gdk.KEY_Left) ||



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]