[xdg-desktop-portal-gnome/gbsneto/screenshot-portal-v3: 2/3] screenshot: Store screenshot portal version on startup
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [xdg-desktop-portal-gnome/gbsneto/screenshot-portal-v3: 2/3] screenshot: Store screenshot portal version on startup
- Date: Sat, 6 Aug 2022 00:02:40 +0000 (UTC)
commit 68a050b1c0e0af0debd50facac1ea1f79df26b1e
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]