workspace-indicator: Expose active workspace name on menu

When not using previews, we currently use a numerical presentation
like "1 / 4" for the top bar button. We will change that to use
the active workspace name instead.

As the menu already has to track workspace switches and name changes,
expose the active workspace name there, so that the button doesn't
have to duplicate the tracking.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/405>
This commit is contained in:
Florian Müllner
2025-05-29 14:53:37 +02:00
parent 1186b2a7a0
commit 01d8d4871e

View File

@@ -404,8 +404,10 @@ class WorkspacesMenu extends PopupMenu.PopupMenu {
this._desktopSettings =
new Gio.Settings({schema_id: 'org.gnome.desktop.wm.preferences'});
this._desktopSettings.connectObject('changed::workspace-names',
() => this._updateWorkspaceLabels(), this);
this._desktopSettings.connectObject('changed::workspace-names', () => {
this._updateWorkspaceLabels();
this.emit('active-name-changed');
}, this);
const {workspaceManager} = global;
workspaceManager.connectObject(
@@ -415,6 +417,12 @@ class WorkspacesMenu extends PopupMenu.PopupMenu {
this._updateWorkspaceItems();
}
get activeName() {
const {workspaceManager} = global;
const active = workspaceManager.get_active_workspace_index();
return Meta.prefs_get_workspace_name(active);
}
_updateWorkspaceItems() {
const {workspaceManager} = global;
const {nWorkspaces} = workspaceManager;
@@ -452,6 +460,7 @@ class WorkspacesMenu extends PopupMenu.PopupMenu {
? PopupMenu.Ornament.CHECK
: PopupMenu.Ornament.NONE);
});
this.emit('active-name-changed');
}
}