app: Fall back to original spawn when space.directory is unset

If the user haven't set a workspace directory we play it safe and call the
spawn the app with the non-kludged method.
This commit is contained in:
Tor Hedin Brønner
2019-10-18 19:21:45 +02:00
parent 957e27a1d1
commit 2c7bfae7d7
+25 -18
View File
@@ -24,45 +24,52 @@ var customHandlers, customSpawnHandlers;
function init() {
customHandlers = { 'org.gnome.Terminal.desktop': newGnomeTerminal };
customSpawnHandlers = {};
Kludges.registerOverridePrototype(
function spawnWithFallback(fallback, ...args) {
try {
return spawnWindow(...args);
} catch(e) {
return fallback();
}
}
let overrideWithFallback = Kludges.overrideWithFallback;
overrideWithFallback(
Shell.App, "open_new_window",
function(workspaceId) {
log(`Shell.App.open_new_window`);
return spawnWindow(this, global.workspace_manager.get_workspace_by_index(workspaceId));
(fallback, app, workspaceId) => {
return spawnWithFallback(fallback, app, global.workspace_manager.get_workspace_by_index(workspaceId));
}
);
Kludges.registerOverridePrototype(
overrideWithFallback(
Shell.App, "launch_action",
function(name, ...args) {
(fallback, app, name, ...args) => {
log(`ShellApp.launch_action ${name}`);
if (name === 'new-window')
return spawnWindow(this);
return spawnWithFallback(fallback, app);
else {
let original = Kludges.getSavedProp(Gio.DesktopAppInfo.prototype, "launch_action");
return original.call(this, name, ...args);
return fallback();
}
}
);
Kludges.registerOverridePrototype(
overrideWithFallback(
Gio.DesktopAppInfo, "launch",
function() {
(fallback, appInfo) => {
log(`DesktopAppInfo.launch`);
return spawnWindow(this.get_id());
return spawnWithFallback(fallback, appInfo.get_id());
}
);
Kludges.registerOverridePrototype(
overrideWithFallback(
Gio.DesktopAppInfo, "launch_action",
function(name, ...args) {
(fallback, appInfo, name, ...args) => {
log(`DesktopAppInfo.launch_action ${name}`);
if (name === 'new-window')
return spawnWindow(this.get_id());
return spawnWithFallback(fallback, appInfo.get_id());
else {
let original = Kludges.getSavedProp(Gio.DesktopAppInfo.prototype, "launch_action");
return original.call(this, name, ...args);
return fallback();
}
}