[gnome-shell-extensions] workspace-indicator: Change 'update' action to 'rename'
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions] workspace-indicator: Change 'update' action to 'rename'
- Date: Fri, 18 Feb 2022 12:26:37 +0000 (UTC)
commit f0e46f4b12db6f83ee6986c4d998ba4e2124499c
Author: Florian Müllner <fmuellner gnome org>
Date: Sun Feb 13 15:06:39 2022 +0100
workspace-indicator: Change 'update' action to 'rename'
Limiting the action to the row that changed instead of the list as
a whole makes it easier to only update the changed value and not
recreate the entire list.
This doesn't make a difference right now, because we carefully sync
the list to reuse existing rows, but we are about to back the list
with a GListModel instead of updating it manually.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/218>
extensions/workspace-indicator/prefs.js | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/extensions/workspace-indicator/prefs.js b/extensions/workspace-indicator/prefs.js
index 3cffbcf..b0dfca8 100644
--- a/extensions/workspace-indicator/prefs.js
+++ b/extensions/workspace-indicator/prefs.js
@@ -19,8 +19,8 @@ class WorkspaceSettingsWidget extends Adw.PreferencesGroup {
self => self._addNewName());
this.install_action('workspaces.remove', 's',
(self, name, param) => self._removeName(param.unpack()));
- this.install_action('workspaces.update', null,
- self => self._saveNames());
+ this.install_action('workspaces.rename', '(ss)',
+ (self, name, param) => self._changeName(...param.deepUnpack()));
}
constructor() {
@@ -59,8 +59,13 @@ class WorkspaceSettingsWidget extends Adw.PreferencesGroup {
.filter(name => name !== removedName));
}
- _saveNames() {
- const names = this._getWorkspaceRows().map(row => row.name);
+ _changeName(oldName, newName) {
+ const names = this._settings.get_strv(WORKSPACE_KEY);
+ const pos = names.indexOf(oldName);
+ if (pos < 0)
+ return;
+
+ names.splice(pos, 1, newName);
this._settings.set_strv(WORKSPACE_KEY, names);
}
@@ -143,6 +148,8 @@ class WorkspaceRow extends Adw.PreferencesRow {
this.child = this._stack;
this._entry.connect('activate', () => {
+ this.activate_action('workspaces.rename',
+ new GLib.Variant('(ss)', [this.name, this._entry.text]));
this.name = this._entry.text;
this._stopEdit();
});
@@ -151,9 +158,6 @@ class WorkspaceRow extends Adw.PreferencesRow {
return;
this._stopEdit();
});
-
- this.connect('notify::name',
- () => this.activate_action('workspaces.update', null);
}
edit() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]