[gimp] plug-ins: show screenshot options dialog immediately in Freedesktop…



commit c502fb18ce225ad087b333b8538c99248dc254a7
Author: Jehan <jehan girinstud io>
Date:   Tue Dec 14 17:59:25 2021 +0100

    plug-ins: show screenshot options dialog immediately in Freedesktop…
    
    … portal.
    
    Otherwise, it first takes a screenshot and proposes to either share or
    tweak the "Options" (in the GNOME shell implementation at least). Doing
    the other way around is much more in line with how we had done it until
    now with our custom dialogs.

 plug-ins/screenshot/screenshot-freedesktop.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/plug-ins/screenshot/screenshot-freedesktop.c b/plug-ins/screenshot/screenshot-freedesktop.c
index ba0bffa00f..502091169b 100644
--- a/plug-ins/screenshot/screenshot-freedesktop.c
+++ b/plug-ins/screenshot/screenshot-freedesktop.c
@@ -129,9 +129,10 @@ screenshot_freedesktop_shoot (ScreenshotValues  *shootvals,
                               GimpImage        **image,
                               GError           **error)
 {
-  GVariant *retval;
-  gchar    *opath         = NULL;
-  gchar    *parent_window = NULL;
+  GVariant        *retval;
+  GVariantBuilder *options;
+  gchar           *opath         = NULL;
+  gchar           *parent_window = NULL;
 
 #ifdef GDK_WINDOWING_X11
   if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
@@ -158,12 +159,23 @@ screenshot_freedesktop_shoot (ScreenshotValues  *shootvals,
   if (shootvals->screenshot_delay > 0)
     screenshot_delay (shootvals->screenshot_delay);
 
+  options = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
+  /* "interactive" option will display the options first (otherwise, it
+   * makes a screenshot first, then proposes to tweak. Since version 2
+   * of the API. For older implementations, it should just be ignored.
+   */
+  g_variant_builder_add (options, "{sv}", "interactive", g_variant_new_boolean (TRUE));
+
   retval = g_dbus_proxy_call_sync (proxy, "Screenshot",
-                                   g_variant_new ("(sa{sv})", parent_window ? parent_window : "", NULL),
+                                   g_variant_new ("(sa{sv})",
+                                                  parent_window ? parent_window : "",
+                                                  options, NULL),
                                    G_DBUS_CALL_FLAGS_NONE,
                                    -1, NULL, error);
   g_free (parent_window);
   g_object_unref (proxy);
+  g_variant_builder_unref (options);
+
   proxy = NULL;
   if (retval)
     {


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