[polari] app: Add selection-mode action



commit 7f7c3bd384c512f4efa887bb201bb926611a6b89
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Jul 30 23:42:50 2013 +0200

    app: Add selection-mode action
    
    We'll use this action to keep track of the selection-mode state and
    control it.

 src/application.js |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 8367379..1b333f9 100644
--- a/src/application.js
+++ b/src/application.js
@@ -88,6 +88,10 @@ const Application = new Lang.Class({
             create_hook: Lang.bind(this, this._userListCreateHook),
             state: GLib.Variant.new('b', false),
             accel: 'F9' },
+          { name: 'selection-mode',
+            activate: Lang.bind(this, this._onToggleAction),
+            create_hook: Lang.bind(this, this._selectionModeHook),
+            state: GLib.Variant.new('b', false) },
           { name: 'connections',
             activate: Lang.bind(this, this._onListConnections) },
           { name: 'preferences',
@@ -189,6 +193,20 @@ const Application = new Lang.Class({
         this._updateUserListAction(action);
     },
 
+    _updateSelectionModeAction: function(action) {
+        action.enabled = this._chatroomManager.roomCount > 0;
+        if (!action.enabled)
+            action.change_state(GLib.Variant.new('b', false));
+    },
+
+    _selectionModeHook: function(action) {
+        this._chatroomManager.connect('active-changed', Lang.bind(this,
+            function() {
+                this._updateSelectionModeAction(action);
+            }));
+        this._updateSelectionModeAction(action);
+    },
+
     _onShowJoinDialog: function() {
         this._window.showJoinRoomDialog();
     },


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