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)
This commit is contained in:
Ole Jørgen Brønner
2017-10-28 22:11:33 +02:00
parent c18190c3a4
commit f2ef36ed87
+16
View File
@@ -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);
};