[polari] application: Update user-list action create hook



commit d79252c04441e2214580932df1a24d625905e206
Author: Florian Müllner <florian muellner gmail com>
Date:   Mon Jul 22 22:52:41 2013 +0200

    application: Update user-list action create hook
    
    The user list doesn't make sense when a private chat has focus,
    so disable it in that case.

 src/application.js |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index af5a03b..03925fe 100644
--- a/src/application.js
+++ b/src/application.js
@@ -59,11 +59,11 @@ const Application = new Lang.Class({
             activate: Lang.bind(this, this._onMessageUser) },
           { name: 'leave-room',
             activate: Lang.bind(this, this._onLeaveRoom),
-            create_hook: Lang.bind(this, this._roomActionsCreateHook),
+            create_hook: Lang.bind(this, this._leaveRoomCreateHook),
             accel: '<Primary>w' },
           { name: 'user-list',
             activate: Lang.bind(this, this._onToggleAction),
-            create_hook: Lang.bind(this, this._roomActionsCreateHook),
+            create_hook: Lang.bind(this, this._userListCreateHook),
             state: GLib.Variant.new('b', false),
             accel: 'F9' },
           { name: 'connections',
@@ -148,18 +148,27 @@ const Application = new Lang.Class({
             }));
     },
 
-    _updateRoomAction: function(action) {
+    _leaveRoomCreateHook: function(action) {
+        this._chatroomManager.connect('active-changed', Lang.bind(this,
+            function() {
+                action.enabled = this._chatroomManager.getActiveRoom() != null;
+            }));
         action.enabled = this._chatroomManager.getActiveRoom() != null;
-        if (action.state && !action.enabled)
+    },
+
+    _updateUserListAction: function(action) {
+        let room = this._chatroomManager.getActiveRoom();
+        action.enabled = room && room.channel.handle_type == Tp.HandleType.ROOM;
+        if (!action.enabled)
             action.change_state(GLib.Variant.new('b', false));
     },
 
-    _roomActionsCreateHook: function(action) {
+    _userListCreateHook: function(action) {
         this._chatroomManager.connect('active-changed', Lang.bind(this,
             function() {
-                this._updateRoomAction(action);
+                this._updateUserListAction(action);
             }));
-        this._updateRoomAction(action);
+        this._updateUserListAction(action);
     },
 
     _onJoinRoom: function() {


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