[gtk/wip/hadess/portal-fixes: 3/5] colorpickerportal: Simplify version fetching code



commit bd55c5842e77331d46ec377542861710a56e1541
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Mar 23 14:45:57 2020 +0100

    colorpickerportal: Simplify version fetching code
    
    Simplify version checking code by using a function to fetch the uint out
    of the GVariant and don't throw a warning if it can't be fetched.

 gtk/gtkcolorpickerportal.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkcolorpickerportal.c b/gtk/gtkcolorpickerportal.c
index a382f51056..2f64a8fa9f 100644
--- a/gtk/gtkcolorpickerportal.c
+++ b/gtk/gtkcolorpickerportal.c
@@ -51,7 +51,7 @@ gtk_color_picker_portal_initable_init (GInitable     *initable,
   GtkColorPickerPortal *picker = GTK_COLOR_PICKER_PORTAL (initable);
   char *owner;
   GVariant *ret;
-  guint version;
+  guint version = 0;
 
   if (!gdk_should_use_portal ())
     return FALSE;
@@ -71,7 +71,7 @@ gtk_color_picker_portal_initable_init (GInitable     *initable,
       return FALSE;
     }
 
- owner = g_dbus_proxy_get_name_owner (picker->portal_proxy);
+  owner = g_dbus_proxy_get_name_owner (picker->portal_proxy);
   if (owner == NULL)
     {
       g_debug ("%s not provided", PORTAL_SCREENSHOT_INTERFACE);
@@ -81,8 +81,12 @@ gtk_color_picker_portal_initable_init (GInitable     *initable,
   g_free (owner);
 
   ret = g_dbus_proxy_get_cached_property (picker->portal_proxy, "version");
-  g_variant_get (ret, "u", &version);
-  g_variant_unref (ret);
+  if (ret)
+    {
+      version = g_variant_get_uint32 (ret);
+      g_variant_unref (ret);
+    }
+
   if (version != 2)
     {
       g_debug ("Screenshot portal version: %u", version);


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