[gnome-shell/issue-23: 3/5] switcherPopup: Handle removal of items from SwitcherPopup
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/issue-23: 3/5] switcherPopup: Handle removal of items from SwitcherPopup
- Date: Mon, 5 Feb 2018 12:00:00 +0000 (UTC)
commit b734839644656994708bb5cb273c026650511fa8
Author: Mario Sanchez Prada <mario endlessm com>
Date: Mon Dec 4 22:41:19 2017 +0000
switcherPopup: Handle removal of items from SwitcherPopup
This will be mainly useful for closing apps from the applications
switcher, but can be implemented generically enough to select the
nearest existing item after removal if there's any, or destroying
the popup's actor otherwise.
Specifically for the apps switcher, doing this also removes the need
of having to manually either update the current app in AppSwitcher
and highlight it, if there are still any items after the removal, or
simply destroy the AppSwitcher otherwise. Besides, calling _select()
in the handler for item-removed makes sure that the list of thumbnails
in the switcher is always closed, if open, when quitting the app.
https://gitlab.gnome.org/GNOME/gnome-shell/issues/23
Closes: #23
js/ui/altTab.js | 19 +++++++------------
js/ui/switcherPopup.js | 15 +++++++++++++++
2 files changed, 22 insertions(+), 12 deletions(-)
---
diff --git a/js/ui/altTab.js b/js/ui/altTab.js
index c4eee7d7a..1b8280cc7 100644
--- a/js/ui/altTab.js
+++ b/js/ui/altTab.js
@@ -795,18 +795,13 @@ var AppSwitcher = new Lang.Class({
},
_removeIcon: function(app) {
- for (let i = 0; i < this.icons.length; i++)
- if (this.icons[i].app == app) {
- this.icons.splice(i, 1);
- this.removeItem(i);
- if (this._curApp == i)
- this._curApp = SwitcherPopup.mod(i, this.icons.length);
- if (this.icons.length > 0)
- this.highlight(this._curApp);
- else
- this.actor.destroy();
- return;
- }
+ for (let i = 0; i < this.icons.length; i++) {
+ if (this.icons[i].app != app)
+ continue;
+
+ this.icons.splice(i, 1);
+ this.removeItem(i);
+ }
},
});
diff --git a/js/ui/switcherPopup.js b/js/ui/switcherPopup.js
index 9a29ce2c2..edd138b28 100644
--- a/js/ui/switcherPopup.js
+++ b/js/ui/switcherPopup.js
@@ -133,6 +133,7 @@ var SwitcherPopup = new Lang.Class({
this.actor.add_actor(this._switcherList.actor);
this._switcherList.connect('item-activated', Lang.bind(this, this._itemActivated));
this._switcherList.connect('item-entered', Lang.bind(this, this._itemEntered));
+ this._switcherList.connect('item-removed', Lang.bind(this, this._itemRemoved));
// Need to force an allocation so we can figure out whether we
// need to scroll when selecting
@@ -247,6 +248,19 @@ var SwitcherPopup = new Lang.Class({
this._itemEnteredHandler(n);
},
+ _itemRemovedHandler: function(n) {
+ if (this._items.length > 0) {
+ let newIndex = Math.min(n, this._items.length - 1);
+ this._select(newIndex);
+ } else {
+ this.actor.destroy();
+ }
+ },
+
+ _itemRemoved: function(switcher, n) {
+ this._itemRemovedHandler(n);
+ },
+
_disableHover: function() {
this.mouseActive = false;
@@ -421,6 +435,7 @@ var SwitcherList = new Lang.Class({
removeItem: function(index) {
let item = this._items.splice(index, 1);
item[0].destroy();
+ this.emit('item-removed', index);
},
_onItemClicked: function (index) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]