[gnome-shell-extensions/wip/jimmac/duller-classic-mode: 15/19] workspace-indicator: Refactor workspace signal handlers
- From: Jakub Steiner <jimmac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions/wip/jimmac/duller-classic-mode: 15/19] workspace-indicator: Refactor workspace signal handlers
- Date: Wed, 3 Jul 2019 13:02:54 +0000 (UTC)
commit c58438304e0bdb3a9b35244cca938d4cee8ff7fb
Author: Florian Müllner <fmuellner gnome org>
Date: Sun Jun 9 23:09:12 2019 +0000
workspace-indicator: Refactor workspace signal handlers
We are about to support a separate representation if horizontal
workspaces are used. To prepare for that, rename the handlers to
something more generic and split out menu-specific bits into a
dedicated help function.
https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/71
extensions/workspace-indicator/extension.js | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
---
diff --git a/extensions/workspace-indicator/extension.js b/extensions/workspace-indicator/extension.js
index ab067f6..c72cba6 100644
--- a/extensions/workspace-indicator/extension.js
+++ b/extensions/workspace-indicator/extension.js
@@ -34,12 +34,10 @@ class WorkspaceIndicator extends PanelMenu.Button {
this.menu.addMenuItem(this._workspaceSection);
this._workspaceManagerSignals = [
- workspaceManager.connect_after('workspace-added',
- this._createWorkspacesSection.bind(this)),
- workspaceManager.connect_after('workspace-removed',
- this._createWorkspacesSection.bind(this)),
+ workspaceManager.connect_after('notify::n-workspaces',
+ this._nWorkspacesChanged.bind(this)),
workspaceManager.connect_after('workspace-switched',
- this._updateIndicator.bind(this))
+ this._onWorkspaceSwitched.bind(this))
];
this.connect('scroll-event', this._onScrollEvent.bind(this));
@@ -66,14 +64,26 @@ class WorkspaceIndicator extends PanelMenu.Button {
super._onDestroy();
}
- _updateIndicator() {
- this._workspacesItems[this._currentWorkspace].setOrnament(PopupMenu.Ornament.NONE);
+ _onWorkspaceSwitched() {
this._currentWorkspace = global.workspace_manager.get_active_workspace_index();
- this._workspacesItems[this._currentWorkspace].setOrnament(PopupMenu.Ornament.DOT);
+
+ this._updateMenuOrnament();
this._statusLabel.set_text(this._labelText());
}
+ _nWorkspacesChanged() {
+ this._createWorkspacesSection();
+ }
+
+ _updateMenuOrnament() {
+ for (let i = 0; i < this._workspacesItems.length; i++) {
+ this._workspacesItems[i].setOrnament(i == this._currentWorkspace
+ ? PopupMenu.Ornament.DOT
+ : PopupMenu.Ornament.NONE);
+ }
+ }
+
_labelText(workspaceIndex) {
if (workspaceIndex == undefined) {
workspaceIndex = this._currentWorkspace;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]