From f2ef36ed873525ada00bb076b285e2e9b4126fe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20J=C3=B8rgen=20Br=C3=B8nner?= Date: Sat, 28 Oct 2017 22:11:33 +0200 Subject: [PATCH] Sync workspace names on workspace-removed Since workspace names are associated by index the list need adjustment when a workspace in the middle of the list is removed. (dynamic workspaces) --- tiling.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tiling.js b/tiling.js index 47da33d..30259a4 100644 --- a/tiling.js +++ b/tiling.js @@ -114,6 +114,10 @@ var spaces = (function () { global.screen.connect('notify::n-workspaces', Lang.bind(spaces, utils.dynamic_function_ref('workspacesChanged', spaces))); + spaces.workspaceRemovedSignal = + global.screen.connect('workspace-removed', + utils.dynamic_function_ref('workspaceRemoved', spaces)); + spaces.windowCreatedSignal = global.display.connect('window-created', utils.dynamic_function_ref('window_created', spaces)); @@ -145,6 +149,18 @@ var spaces = (function () { } }; + spaces.workspaceRemoved = function(screen, index) { + let settings = new Gio.Settings({ schema_id: + 'org.gnome.desktop.wm.preferences'}); + let names = settings.get_strv('workspace-names'); + + // Move removed workspace name to the end. Could've simply removed it + // too, but this way it's not lost. In the future we want a UI to select + // old names when selecting a new workspace. + names = names.slice(0, index).concat(names.slice(index+1), [names[index]]); + settings.set_strv('workspace-names', names); + }; + spaces.addSpace = function(workspace) { this._spaces[workspace] = Space(workspace); };