[polari] roomList: Move focus when removing a room



commit c05d371e18a0f006c6beccc2e996de8aa311b37a
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Jul 24 21:32:04 2013 +0200

    roomList: Move focus when removing a room
    
    While we are joined to any rooms, we never want the roomList to
    not have any focus.

 src/roomList.js |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/src/roomList.js b/src/roomList.js
index 76e8c3d..019685d 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -97,19 +97,32 @@ const RoomList = new Lang.Class({
         return null;
     },
 
+    _changeRoom: function(row) {
+        row.can_focus = false;
+        this._roomManager.setActiveRoom(row.room);
+        row.can_focus = true;
+    },
+
     _roomAdded: function(roomManager, room) {
         let row = new RoomRow(room);
         this.widget.add(row.widget);
 
-        row.widget.can_focus = false;
-        this._roomManager.setActiveRoom(room);
-        row.widget.can_focus = true;
+        this._changeRoom(row.widget);
     },
 
     _roomRemoved: function(roomManager, room) {
         let row = this._getRowByRoom(room);
-        if (row)
-            this.widget.remove(row);
+        if (!row)
+            return;
+
+        let selected = this.widget.get_selected_row();
+        if (selected == row && this.widget.get_children().length > 1) {
+            let index = row.get_index();
+            let newFocus = this.widget.get_row_at_index(index ? index - 1
+                                                              : index + 1);
+            this._changeRoom(newFocus);
+        }
+        this.widget.remove(row);
     },
 
     _activeRoomChanged: function(roomManager, room) {


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