app: Don't throw in spawnWindow, let trySpawnWindow throw

`spawnWindow` can be useful from `user.js`, so we make it always succeed, while
we while we introduce a throwing `trySpawnWindow` for internal use.
This commit is contained in:
Tor Hedin Brønner
2019-10-18 19:21:45 +02:00
parent 2c7bfae7d7
commit 86d8b6275f
+13 -2
View File
@@ -27,7 +27,7 @@ function init() {
function spawnWithFallback(fallback, ...args) {
try {
return spawnWindow(...args);
return trySpawnWindow(...args);
} catch(e) {
return fallback();
}
@@ -133,7 +133,7 @@ function duplicateWindow(metaWindow) {
return true;
}
function spawnWindow(app, workspace) {
function trySpawnWindow(app, workspace) {
if (typeof(app) === 'string') {
app = new Shell.App({ app_info: Gio.DesktopAppInfo.new(app) });
}
@@ -146,6 +146,17 @@ function spawnWindow(app, workspace) {
}
}
function spawnWindow(app, workspace) {
if (typeof(app) === 'string') {
app = new Shell.App({ app_info: Gio.DesktopAppInfo.new(app) });
}
try {
return trySpawnWindow(app, workspace);
} catch(e) {
// Let the overide take care any fallback
return app.open_new_window(-1);
}
}
function expandCommandline(commandline, space) {
let dir = space.settings.get_string('directory');