[gnome-shell/gnome-40] shellDBus: Return error on invalid app IDs



commit 887652792f200102ebf074af63b808ee063dff38
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).
    
    (cherry picked from commit 1e2a10f83b878a9bbf3d51e042c67ef741c348fd)
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2181>

 js/ui/shellDBus.js | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js
index 6574cc5288..734ca4fc7c 100644
--- a/js/ui/shellDBus.js
+++ b/js/ui/shellDBus.js
@@ -1,7 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 /* exported GnomeShell, ScreenSaverDBus */
 
-const { Gio, GLib, Meta } = imports.gi;
+const { Gio, GLib, Meta, Shell } = imports.gi;
 
 const Config = imports.misc.config;
 const ExtensionDownloader = imports.ui.extensionDownloader;
@@ -99,7 +99,24 @@ var GnomeShell = class {
         Main.osdWindowManager.show(monitorIndex, icon, label, level, maxLevel);
     }
 
-    FocusApp(id) {
+    /**
+     * Focus specified app in the overview's app grid
+     *
+     * @async
+     * @param {string} id - an application ID
+     * @param {Gio.DBusMethodInvocation} invocation - the invocation
+     * @returns {void}
+     */
+    FocusAppAsync([id], invocation) {
+        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);
     }
 


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