[recipes] Avoid calling into gr-app from utils



commit 37533b3ce7ebf67522e694e60733db25a9b5198d
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Jan 18 14:34:54 2017 -0500

    Avoid calling into gr-app from utils
    
    This is problematic for the current test setup, so avoid it.

 src/gr-app.c   |   22 ----------------------
 src/gr-app.h   |    1 -
 src/gr-utils.c |   21 ++++++++++++++++++++-
 3 files changed, 20 insertions(+), 24 deletions(-)
---
diff --git a/src/gr-app.c b/src/gr-app.c
index 1e74bc8..cf4e536 100644
--- a/src/gr-app.c
+++ b/src/gr-app.c
@@ -929,20 +929,7 @@ gr_app_dbus_unregister (GApplication    *application,
 static void
 gr_app_init (GrApp *self)
 {
-        g_autoptr(GDBusConnection) bus = NULL;
-
         self->store = gr_recipe_store_new ();
-
-        bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
-        self->portal = g_dbus_proxy_new_sync (bus,
-                                              0,
-                                              NULL,
-                                              "org.freedesktop.portal.Desktop",
-                                              "/org/freedesktop/portal/desktop",
-                                              "org.freedesktop.portal.FileChooser",
-                                              NULL,
-                                              NULL);
-
 }
 
 static void
@@ -974,12 +961,3 @@ gr_app_get_recipe_store (GrApp *app)
 {
         return app->store;
 }
-
-gboolean
-gr_app_portals_available (GrApp *app)
-{
-        g_autofree char *owner = NULL;
-
-        owner = g_dbus_proxy_get_name_owner (app->portal);
-        return owner != NULL;
-}
diff --git a/src/gr-app.h b/src/gr-app.h
index 30e8b7a..6db6956 100644
--- a/src/gr-app.h
+++ b/src/gr-app.h
@@ -29,6 +29,5 @@ G_DECLARE_FINAL_TYPE (GrApp, gr_app, GR, APP, GtkApplication)
 
 GrApp         *gr_app_new              (void);
 GrRecipeStore *gr_app_get_recipe_store (GrApp *app);
-gboolean       gr_app_portals_available (GrApp *app);
 
 G_END_DECLS
diff --git a/src/gr-utils.c b/src/gr-utils.c
index 119b1e4..23def35 100644
--- a/src/gr-utils.c
+++ b/src/gr-utils.c
@@ -436,5 +436,24 @@ in_flatpak_sandbox (void)
 gboolean
 portals_available (void)
 {
-        return gr_app_portals_available (GR_APP (g_application_get_default ()));
+        static GDBusProxy *portal = NULL;
+        g_autofree char *owner = NULL;
+
+        if (portal == NULL) {
+                g_autoptr(GDBusConnection) bus = NULL;
+
+                bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+                portal = g_dbus_proxy_new_sync (bus,
+                                                0,
+                                                NULL,
+                                                "org.freedesktop.portal.Desktop",
+                                                "/org/freedesktop/portal/desktop",
+                                                "org.freedesktop.portal.FileChooser",
+                                                NULL,
+                                                NULL);
+        }
+
+        owner = g_dbus_proxy_get_name_owner (portal);
+
+        return owner != NULL;
 }


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