[gnome-shell/wip/fmuellner/focus-app-error: 4058/4058] shellDBus: Return error on invalid app IDs




commit 41cb4fd438651008fe5669589dbb201860e1867c
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Jan 8 22:03:13 2019 +0100

    shellDBus: Return error on invalid app IDs
    
    When passing an invalid or unknown app ID to FocusApp(), we currently
    open the app picker and silently fail to select the desired app.
    Instead of half-working like that, make it clear that the argument
    was invalid by returning an appropriate error. (It's easy to get the
    ID wrong, as unlike appstream/flatpak IDs, we include the ".desktop"
    suffix).

 js/ui/shellDBus.js | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js
index aeabe6d81e..51738310f5 100644
--- a/js/ui/shellDBus.js
+++ b/js/ui/shellDBus.js
@@ -153,6 +153,15 @@ var GnomeShell = class {
             return;
         }
 
+        const appSys = Shell.AppSystem.get_default();
+        if (appSys.lookup_app(id) === null) {
+            invocation.return_error_literal(
+                Gio.DBusError,
+                Gio.DBusError.FILE_NOT_FOUND,
+                `No application with ID ${id}`);
+            return;
+        }
+
         Main.overview.selectApp(id);
         invocation.return_value(null);
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]