[polari] app: Add shortcut accessors for the first nine rooms



commit dbd03ca4c41abb533db27a16bcefde5925c24ca7
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Feb 28 03:07:55 2014 +0100

    app: Add shortcut accessors for the first nine rooms
    
    Add alt+n shortcuts to directly switch to the n-th room. This will be
    really useful once we start ordering rooms by relevance, but as it
    doesn't hurt to have them around using the current order, just add
    them now.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709983

 src/application.js |    8 +++++++-
 src/roomList.js    |   10 ++++++++++
 2 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 0b5811c..56c5b05 100644
--- a/src/application.js
+++ b/src/application.js
@@ -126,7 +126,9 @@ const Application = new Lang.Class({
           { name: 'first-room',
             accel: '<Primary>Home' },
           { name: 'last-room',
-            accel: '<Primary>End' }
+            accel: '<Primary>End' },
+          { name: 'nth-room',
+            parameter_type: GLib.VariantType.new('i') }
         ];
         actionEntries.forEach(Lang.bind(this,
             function(actionEntry) {
@@ -149,6 +151,10 @@ const Application = new Lang.Class({
                 this.add_action(action);
         }));
 
+        for (let i = 1; i < 10; i++)
+            this.add_accelerator('<Alt>' + i, 'app.nth-room',
+                                 GLib.Variant.new('i', i));
+
         this._window = new MainWindow.MainWindow(this);
         this._window.window.connect('destroy', Lang.bind(this,
             function() {
diff --git a/src/roomList.js b/src/roomList.js
index c77bf2a..7009528 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -196,6 +196,16 @@ const RoomList = new Lang.Class({
             function() {
                 this._moveSelection(Gtk.MovementStep.BUFFER_ENDS, 1);
             }));
+        action = app.lookup_action('nth-room');
+        action.connect('activate', Lang.bind(this,
+            function(action, param) {
+                let n = param.get_int32();
+                if (n > this._roomManager.roomCount)
+                    return;
+                this._moveSelection(Gtk.MovementStep.BUFFER_ENDS, -1);
+                if (n > 1)
+                    this._moveSelection(Gtk.MovementStep.DISPLAY_LINES, n - 1);
+            }));
     },
 
     _onSelectionModeChanged: function() {


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