[polari] roomList: Explicitly select a new room when removing the current one



commit 0dbaa8cdcacb239aadbaf1549ed2d791ea877771
Author: Florian Müllner <fmuellner gnome org>
Date:   Sun Oct 6 21:45:28 2013 +0200

    roomList: Explicitly select a new room when removing the current one
    
    When the active room is removed, we currently update the selection
    and rely on the row-selected handler to update the room; however we
    disable this handler in selection mode (as selection has a very
    different purpose there), so we end up with an inconsistent state
    after removing the active room from selection mode. Fix this by
    setting the new active room explicitly instead.

 src/roomList.js |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/src/roomList.js b/src/roomList.js
index 44eaa0e..7d4e312 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -206,10 +206,25 @@ const RoomList = new Lang.Class({
     _onLeaveActivated: function(action, param) {
         let id = param.deep_unpack();
         let row = this._roomRows[id].widget;
-        let selected = this.widget.get_selected_row();
-        if (selected == row && this.widget.get_children().length > 1) {
-            let count = row.get_index() == 0 ? 1 : -1;
-            this._moveSelection(Gtk.MovementStep.DISPLAY_LINES, count);
+
+        let activeRoom = this._roomManager.getActiveRoom();
+        let current = this._roomRows[activeRoom.id].widget;
+
+        if (current == row) {
+            let selected = this.widget.get_selected_row();
+            let newActive = null;
+            let visibleChildren = this.widget.get_children().filter(function(c) {
+                return c.visible;
+            });
+            if (visibleChildren.length > 1) {
+                this.widget.select_row(row);
+                let count = row.get_index() == 0 ? 1 : -1;
+                this._moveSelection(Gtk.MovementStep.DISPLAY_LINES, count);
+                newActive = this.widget.get_focus_child().room;
+            }
+            this._roomManager.setActiveRoom(newActive);
+            if (selected != row)
+                this.widget.select_row(selected);
         }
         row.hide();
     },


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