window-list: 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 helper function.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/70
This commit is contained in:
Florian Müllner
2019-06-05 05:08:31 +02:00
parent a5f347ba10
commit 5a30ebe403

View File

@@ -40,9 +40,9 @@ var WorkspaceIndicator = GObject.registerClass({
this._workspaceManagerSignals = [
workspaceManager.connect('notify::n-workspaces',
this._updateMenu.bind(this)),
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));
@@ -65,14 +65,27 @@ var WorkspaceIndicator = GObject.registerClass({
super._onDestroy();
}
_updateIndicator() {
this._workspacesItems[this._currentWorkspace].setOrnament(PopupMenu.Ornament.NONE);
this._currentWorkspace = global.workspace_manager.get_active_workspace_index();
this._workspacesItems[this._currentWorkspace].setOrnament(PopupMenu.Ornament.DOT);
_onWorkspaceSwitched() {
let workspaceManager = global.workspace_manager;
this._currentWorkspace = workspaceManager.get_active_workspace_index();
this._updateMenuOrnament();
this._statusLabel.set_text(this._getStatusText());
}
_nWorkspacesChanged() {
this._updateMenu();
}
_updateMenuOrnament() {
for (let i = 0; i < this._workspacesItems.length; i++) {
this._workspacesItems[i].setOrnament(i == this._currentWorkspace
? PopupMenu.Ornament.DOT
: PopupMenu.Ornament.NONE);
}
}
_getStatusText() {
let workspaceManager = global.workspace_manager;
let current = workspaceManager.get_active_workspace_index();