[polari] Drop selection mode



commit 5b1432e393dd34f593e022323c417480108ffd14
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Feb 21 23:56:44 2015 +0100

    Drop selection mode
    
    In hindsight, the selection mode pattern was not a good choice for
    room management - it only exposes a single action and is hardly used
    for more than one item at once. In addition to this, the action uses
    quite unfortunate wording - "Leave husband" - when applied to private
    conversations (which are usually more volatile than rooms, thus more
    commonly closed).
    As the last commit made the leave action available without switching
    to selection mode, just drop the pattern entirely now.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=736481

 data/resources/main-window.ui |   65 +++-------------------------------
 src/application.js            |   21 -----------
 src/mainWindow.js             |   33 -----------------
 src/roomList.js               |   77 +----------------------------------------
 src/roomStack.js              |    8 +----
 5 files changed, 8 insertions(+), 196 deletions(-)
---
diff --git a/data/resources/main-window.ui b/data/resources/main-window.ui
index 14e2bae..8f06072 100644
--- a/data/resources/main-window.ui
+++ b/data/resources/main-window.ui
@@ -69,30 +69,6 @@
                 <property name="pack_type">end</property>
               </packing>
             </child>
-            <child>
-              <object class="GtkToggleButton" id="button2">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="focus_on_click">False</property>
-                <property name="halign">center</property>
-                <property name="valign">center</property>
-                <property name="action_name">app.selection-mode</property>
-                <style>
-                  <class name="image-button"/>
-                </style>
-                <child>
-                  <object class="GtkImage" id="image2">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="icon_name">object-select-symbolic</property>
-                    <property name="icon_size">1</property>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="pack_type">end</property>
-              </packing>
-            </child>
           </object>
         </child>
         <child>
@@ -217,43 +193,14 @@
                   <class name="polari-room-list"/>
                 </style>
                 <child>
-                  <object class="GtkGrid" id="grid1">
+                  <object class="GtkScrolledWindow" id="room_list_scrollview">
                     <property name="visible">True</property>
-                    <property name="hexpand">False</property>
-                    <property name="orientation">vertical</property>
-                    <child>
-                      <object class="GtkScrolledWindow" id="room_list_scrollview">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="hscrollbar_policy">never</property>
-                        <property name="vexpand">True</property>
-                        <property name="hexpand">True</property>
-                        <child>
-                          <placeholder/>
-                        </child>
-                      </object>
-                    </child>
+                    <property name="can_focus">True</property>
+                    <property name="hscrollbar_policy">never</property>
+                    <property name="vexpand">True</property>
+                    <property name="hexpand">True</property>
                     <child>
-                      <object class="GtkActionBar" id="selection_action_bar">
-                        <property name="no_show_all">True</property>
-                        <child>
-                          <object class="GtkButton" id="button5">
-                            <property name="label" translatable="yes">_Leave</property>
-                            <property name="width_request">70</property>
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">True</property>
-                            <property name="action_name">app.leave-selected-rooms</property>
-                            <property name="use_underline">True</property>
-                            <style>
-                              <class name="destructive-action"/>
-                            </style>
-                          </object>
-                          <packing>
-                            <property name="pack_type">end</property>
-                          </packing>
-                        </child>
-                      </object>
+                      <placeholder/>
                     </child>
                   </object>
                 </child>
diff --git a/src/application.js b/src/application.js
index 3006927..27fde78 100644
--- a/src/application.js
+++ b/src/application.js
@@ -77,16 +77,11 @@ const Application = new Lang.Class({
             activate: Lang.bind(this, this._onLeaveCurrentRoom),
             create_hook: Lang.bind(this, this._leaveRoomCreateHook),
             accels: ['<Primary>w'] },
-          { name: 'leave-selected-rooms' },
           { name: 'user-list',
             activate: Lang.bind(this, this._onToggleAction),
             create_hook: Lang.bind(this, this._userListCreateHook),
             state: GLib.Variant.new('b', false),
             accels: ['F9', '<Primary>u'] },
-          { 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',
@@ -186,22 +181,6 @@ const Application = new Lang.Class({
         this._updateUserListAction(action);
     },
 
-    _updateSelectionModeAction: function(action) {
-        action.enabled = this._chatroomManager.getActiveRoom() != null;
-    },
-
-    _selectionModeHook: function(action) {
-        this._chatroomManager.connect('active-changed', Lang.bind(this,
-            function() {
-                this._updateSelectionModeAction(action);
-            }));
-        action.connect('notify::enabled', function() {
-            if (!action.enabled)
-                action.change_state(GLib.Variant.new('b', false));
-        });
-        this._updateSelectionModeAction(action);
-    },
-
     _onShowJoinDialog: function() {
         this._window.showJoinRoomDialog();
     },
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 0fc89f2..df6399f 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -77,21 +77,10 @@ const MainWindow = new Lang.Class({
                     this._userListAction.change_state(GLib.Variant.new('b', false));
             }));
 
-        this._selectionModeAction = app.lookup_action('selection-mode');
-        this._selectionModeAction.connect('notify::state',
-                    Lang.bind(this, this._onSelectionModeChanged));
-
         this._gtkSettings.connect('notify::gtk-decoration-layout',
                                   Lang.bind(this, this._updateDecorations));
         this._updateDecorations();
 
-        this.window.connect_after('key-press-event', Lang.bind(this,
-            function(w, event) {
-                let [, keyval] = event.get_keyval();
-                if (keyval == Gdk.KEY_Escape)
-                    this._selectionModeAction.change_state(GLib.Variant.new('b', false));
-                return Gdk.EVENT_STOP;
-            }));
         this.window.connect('window-state-event',
                             Lang.bind(this, this._onWindowStateEvent));
         this.window.connect('configure-event',
@@ -174,22 +163,6 @@ const MainWindow = new Lang.Class({
         this._saveGeometry();
     },
 
-    _onSelectionModeChanged: function() {
-        let enabled = this._selectionModeAction.state.get_boolean();
-        this._selectionActionBar.visible = enabled;
-        this._joinMenuButton.visible = !enabled;
-        this._showUserListButton.visible = !enabled;
-        this._userListAction.enabled = !enabled;
-
-        if (enabled) {
-            this._titlebarLeft.get_style_context().add_class('selection-mode');
-            this._titlebarRight.get_style_context().add_class('selection-mode');
-        } else {
-            this._titlebarLeft.get_style_context().remove_class('selection-mode');
-            this._titlebarRight.get_style_context().remove_class('selection-mode');
-        }
-    },
-
     _onAccountChanged: function(am, account) {
         if (account.connection_status != Tp.ConnectionStatus.CONNECTING)
             return;
@@ -287,12 +260,6 @@ const MainWindow = new Lang.Class({
         this._titleLabel = builder.get_object('title_label');
         this._subtitleLabel = builder.get_object('subtitle_label');
 
-        this._selectionActionBar = builder.get_object('selection_action_bar');
-
-        // slightly hackish:
-        // add the content of the internal revealer to size group
-        sizeGroup.add_widget(this._selectionActionBar.get_child().get_child());
-
         this._joinMenuButton = builder.get_object('join_menu_button');
         this._showUserListButton = builder.get_object('show_user_list_button');
         this._revealer = builder.get_object('room_list_revealer');
diff --git a/src/roomList.js b/src/roomList.js
index 7d82fae..f7ee09f 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -28,10 +28,6 @@ const RoomRow = new Lang.Class({
         this._eventBox.connect('button-release-event',
                             Lang.bind(this, this._onButtonRelease));
 
-        this._selectionModeAction = app.lookup_action('selection-mode');
-        this._selectionModeAction.connect('notify::state',
-                          Lang.bind(this, this._onSelectionModeChanged));
-
         room.connect('notify::channel', Lang.bind(this,
             function() {
                 if (!room.channel)
@@ -45,15 +41,6 @@ const RoomRow = new Lang.Class({
                            GObject.BindingFlags.SYNC_CREATE);
 
         this._updatePending();
-        this._updateMode();
-    },
-
-    _updateMode: function() {
-        let selectionMode = this._selectionModeAction.state.get_boolean();
-        this._stack.set_visible_child_name(selectionMode ? 'selection'
-                                                         : 'normal');
-        if (!selectionMode)
-            this.selection_button.active = false;
     },
 
     _updatePending: function() {
@@ -85,11 +72,6 @@ const RoomRow = new Lang.Class({
             context.remove_class('inactive');
     },
 
-    _onSelectionModeChanged: function() {
-        let selectionMode = this._selectionModeAction.state.get_boolean();
-        this._updateMode();
-    },
-
     _onButtonRelease: function(w, event) {
         let [, button] = event.get_button();
         if (button != Gdk.BUTTON_SECONDARY)
@@ -124,20 +106,14 @@ const RoomRow = new Lang.Class({
                                           valign: Gtk.Align.BASELINE });
         box.add(this._roomLabel);
 
-        this._stack = new Gtk.Stack();
-        box.add(this._stack);
-
         let frame = new Gtk.AspectFrame({ obey_child: false,
                                           shadow_type: Gtk.ShadowType.NONE });
-        this._stack.add_named(frame, 'normal');
+        box.add(frame);
 
         this._counter = new Gtk.Label({ width_chars: 2 });
         this._counter.get_style_context().add_class('pending-messages-count');
         frame.add(this._counter);
 
-        this.selection_button = new Gtk.CheckButton();
-        this._stack.add_named(this.selection_button, 'selection');
-
         this.widget.show_all();
     }
 });
@@ -158,8 +134,6 @@ const RoomList = new Lang.Class({
 
         this.widget.connect('row-selected',
                             Lang.bind(this, this._onRowSelected));
-        this.widget.connect('row-activated',
-                            Lang.bind(this, this._onRowActivated));
 
         this._roomManager = ChatroomManager.getDefault();
         this._roomManager.connect('room-added',
@@ -170,14 +144,6 @@ const RoomList = new Lang.Class({
                                   Lang.bind(this, this._activeRoomChanged));
 
         let app = Gio.Application.get_default();
-        this._selectionModeAction = app.lookup_action('selection-mode');
-        this._selectionModeAction.connect('notify::state', Lang.bind(this,
-                                          this._onSelectionModeChanged));
-
-        this._leaveSelectedAction = app.lookup_action('leave-selected-rooms');
-        this._leaveSelectedAction.connect('activate',
-                                          Lang.bind(this, this._onLeaveSelectedActivated));
-
         this._leaveAction = app.lookup_action('leave-room');
         this._leaveAction.connect('activate',
                                   Lang.bind(this, this._onLeaveActivated));
@@ -218,27 +184,6 @@ const RoomList = new Lang.Class({
             }));
     },
 
-    _onSelectionModeChanged: function() {
-        this._selectionMode = this._selectionModeAction.state.get_boolean();
-        this._leaveSelectedAction.enabled = this._selectedRows > 0;
-
-        if (this._selectionMode)
-            this.widget.get_selected_row().grab_focus();
-        else
-            this._activeRoomChanged(this._roomManager,
-                                    this._roomManager.getActiveRoom());
-    },
-
-    _onLeaveSelectedActivated: function() {
-        for (let id in this._roomRows)
-            if (this._roomRows[id].selection_button.active) {
-                let room = this._roomRows[id].widget.room;
-                let param = GLib.Variant.new('(ss)', [room.id, '']);
-                this._leaveAction.activate(param);
-            }
-        this._selectionModeAction.change_state(GLib.Variant.new('b', false));
-    },
-
     _onLeaveActivated: function(action, param) {
         let [id, ] = param.deep_unpack();
         let row = this._roomRows[id].widget;
@@ -292,17 +237,6 @@ const RoomList = new Lang.Class({
             function(w) {
                 delete this._roomRows[w.room.id];
             }));
-        roomRow.selection_button.connect('toggled', Lang.bind(this,
-            function(button) {
-                if (button.active)
-                    this._selectedRows++;
-                else
-                    this._selectedRows--;
-                this._leaveSelectedAction.enabled = this._selectedRows > 0;
-
-                if (button.active)
-                    this._selectionModeAction.change_state(GLib.Variant.new('b', true));
-            }));
     },
 
     _roomRemoved: function(roomManager, room) {
@@ -329,18 +263,9 @@ const RoomList = new Lang.Class({
     },
 
     _onRowSelected: function(w, row) {
-        if (this._selectionMode)
-            return;
         this._roomManager.setActiveRoom(row ? row.room : null);
     },
 
-    _onRowActivated: function(w, row) {
-        if (!this._selectionMode || !row)
-            return;
-        let toggle = this._roomRows[row.room.id].selection_button;
-        toggle.set_active(!toggle.active);
-    },
-
     _updateHeader: function(row, before) {
         let getAccount = function(row) {
             return row ? row.room.account : null;
diff --git a/src/roomStack.js b/src/roomStack.js
index 84006cc..976ca31 100644
--- a/src/roomStack.js
+++ b/src/roomStack.js
@@ -26,11 +26,6 @@ const RoomStack = new Lang.Class({
         this._roomManager.connect('active-state-changed',
                                   Lang.bind(this, this._updateSensitivity));
 
-        let app = Gio.Application.get_default();
-        this._selectionModeAction = app.lookup_action('selection-mode');
-        this._selectionModeAction.connect('notify::state',
-                                          Lang.bind(this, this._updateSensitivity));
-
         this._rooms = {};
 
         this._addView('placeholder', new RoomView(null));
@@ -79,8 +74,7 @@ const RoomStack = new Lang.Class({
     _updateSensitivity: function() {
         let room = this._roomManager.getActiveRoom();
         let id = room ? room.id : 'placeholder';
-        let sensitive = room && room.channel &&
-                        !this._selectionModeAction.state.get_boolean();
+        let sensitive = room && room.channel;
         this._rooms[id].inputSensitive = sensitive;
     }
 });


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