[xdg-desktop-portal-gnome/gbsneto/screenshot-portal-v3: 3/4] screenshot: Store screenshot portal version on startup




commit 73948015fe781117231cc5e5c3f31d846246e83a
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Aug 5 20:33:19 2022 -0300

    screenshot: Store screenshot portal version on startup
    
    This will be used by the screenshot dialog to decide whether
    or not to skip the dialog.

 src/screenshot.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
---
diff --git a/src/screenshot.c b/src/screenshot.c
index 73314b6..fe1ea88 100644
--- a/src/screenshot.c
+++ b/src/screenshot.c
@@ -39,6 +39,8 @@ typedef struct {
   const char *retval;
 } ScreenshotDialogHandle;
 
+static uint32_t screenshot_portal_version = 0;
+
 static void
 screenshot_dialog_handle_free (gpointer data)
 {
@@ -294,6 +296,8 @@ gboolean
 screenshot_init (GDBusConnection *bus,
                  GError **error)
 {
+  g_autoptr(GVariant) version_variant = NULL;
+  g_autoptr(GVariant) result = NULL;
   GDBusInterfaceSkeleton *helper;
 
   helper = G_DBUS_INTERFACE_SKELETON (xdp_impl_screenshot_skeleton_new ());
@@ -316,6 +320,28 @@ screenshot_init (GDBusConnection *bus,
   if (shell == NULL)
     return FALSE;
 
+  result = g_dbus_connection_call_sync (bus,
+                                        "org.freedesktop.portal.Desktop",
+                                        "/org/freedesktop/portal/desktop",
+                                        "org.freedesktop.DBus.Properties",
+                                        "Get",
+                                        g_variant_new ("(ss)", "org.freedesktop.portal.Screenshot", 
"version"),
+                                        G_VARIANT_TYPE ("(v)"),
+                                        G_DBUS_CALL_FLAGS_NO_AUTO_START,
+                                        -1,
+                                        NULL,
+                                        error);
+
+  version_variant = g_variant_get_child_value (result, 0);
+
+  if (!version_variant)
+    return FALSE;
+
+  g_variant_get_child (version_variant, 0, "u", &screenshot_portal_version);
+
+  if (screenshot_portal_version == 0)
+    return FALSE;
+
   g_debug ("providing %s", g_dbus_interface_skeleton_get_info (helper)->name);
 
   return TRUE;


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