diff options
author | Bastien Nocera <hadess@hadess.net> | 2020-03-23 14:45:57 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2020-03-30 18:31:23 +0200 |
commit | bd55c5842e77331d46ec377542861710a56e1541 (patch) | |
tree | 3b368b147f0a43e6834e2c5bf717d778c5bf5f61 | |
parent | da47ccaf3c3d4353f6fa4ac813aeb689a1d2d20a (diff) | |
download | gtk+-bd55c5842e77331d46ec377542861710a56e1541.tar.gz |
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.
-rw-r--r-- | gtk/gtkcolorpickerportal.c | 12 |
1 files 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); |