[gnome-boxes/use-new-gnome-settings-app-id: 24/24] util-app, flatpak: Use new GNOME Settings app-id




commit 4b280ce6b316b98cdd3441d00af13f8ec5d40c50
Author: Felipe Borges <felipeborges gnome org>
Date:   Tue Apr 26 16:00:26 2022 +0200

    util-app, flatpak: Use new GNOME Settings app-id
    
    Flatpaked Boxes allows for calling GNOME Control Center when the user doesn't
    grant permissions for the Boxes to run in the background (after closing
    the window) when a VM is marked to "Run in background". This is useful because
    the Applications panel in gnome-control-center allows for reseting the
    flatpak app permissions.
    
    Ever since commit gnome-control-center@acd59aec, the gnome-control-center
    app id got renamed to org.gnome.Settings.
    
    With this changes, Boxes will attempt to activate org.gnome.Settings over
    DBus and fallback to the old org.gnome.ControlCenter when the first fails.
    
    Fixes #787

 build-aux/flatpak/org.gnome.BoxesDevel.json |  1 +
 src/util-app.vala                           | 37 ++++++++++++++++++++++++-----
 2 files changed, 32 insertions(+), 6 deletions(-)
---
diff --git a/build-aux/flatpak/org.gnome.BoxesDevel.json b/build-aux/flatpak/org.gnome.BoxesDevel.json
index 27e90e70..b2e4b609 100644
--- a/build-aux/flatpak/org.gnome.BoxesDevel.json
+++ b/build-aux/flatpak/org.gnome.BoxesDevel.json
@@ -14,6 +14,7 @@
         "--share=network",
         "--device=all",
         "--system-talk-name=org.freedesktop.timedate1",
+        "--talk-name=org.gnome.Settings",
         "--talk-name=org.gnome.ControlCenter",
         "--talk-name=org.freedesktop.secrets",
         "--filesystem=xdg-run/dconf",
diff --git a/src/util-app.vala b/src/util-app.vala
index 5cb92dda..d6cfeab4 100644
--- a/src/util-app.vala
+++ b/src/util-app.vala
@@ -670,14 +670,39 @@ public Gdk.Pixbuf? round_image (Gdk.Pixbuf source) {
         return Gdk.pixbuf_get_from_surface (surface, 0, 0, size, size);
     }
 
+    private DBusProxy? create_gnome_settings_dbus_proxy () {
+        DBusProxy? proxy = null;
+        try {
+            proxy = new DBusProxy.for_bus_sync (BusType.SESSION,
+                                                DBusProxyFlags.NONE,
+                                                null,
+                                                "org.gnome.Settings",
+                                                "/org/gnome/Settings",
+                                                "org.gtk.Actions");
+        } catch (GLib.Error error) {
+            debug ("Failed to launch org.gnome.Settings. Fallback to org.gnome.ControlCenter");
+        }
+
+        try {
+            proxy = new DBusProxy.for_bus_sync (BusType.SESSION,
+                                                DBusProxyFlags.NONE,
+                                                null,
+                                                "org.gnome.ControlCenter",
+                                                "/org/gnome/ControlCenter",
+                                                "org.gtk.Actions");
+        } catch (GLib.Error error) {
+            debug ("Failed to launch org.gnome.ControlCenter");
+        }
+
+        return proxy;
+    }
+
     public void open_permission_settings () {
         try {
-            var proxy = new DBusProxy.for_bus_sync (BusType.SESSION,
-                                                    DBusProxyFlags.NONE,
-                                                    null,
-                                                    "org.gnome.ControlCenter",
-                                                    "/org/gnome/ControlCenter",
-                                                    "org.gtk.Actions");
+            var proxy = create_gnome_settings_dbus_proxy ();
+            if (proxy == null)
+                throw new GLib.IOError.FAILED ("Couldn't create DBusProxy for GNOME Settings");
+
             var builder = new VariantBuilder (new VariantType ("av"));
             builder.add ("v", new Variant.string (Config.APPLICATION_ID));
             var param = new Variant.tuple ({


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