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




commit 9060daecc014fcf59a40e06454674c9c8e0ff1dd
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                           | 36 ++++++++++++++++++++++++-----
 2 files changed, 31 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..197ea425 100644
--- a/src/util-app.vala
+++ b/src/util-app.vala
@@ -670,14 +670,38 @@ private async void move_config_from_cache (string config_name) {
         return Gdk.pixbuf_get_from_surface (surface, 0, 0, size, size);
     }
 
+    private DBusProxy? create_gnome_settings_dbus_proxy () {
+        try {
+            return 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 {
+            return 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 null;
+    }
+
     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]