[gnome-settings-daemon/wip/carlosg/clipboard-screenshots-on-shell] media-keys: Let the screenshot service save to clipboard itself



commit e9391e16e7a949639fee1fc561b8bf82d0ad5de5
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Nov 6 13:19:31 2019 +0100

    media-keys: Let the screenshot service save to clipboard itself
    
    This is both broken currently on wayland (since this daemon doesn't
    request the x11 backend, and wayland clients need a proper surface/serial
    to request clipboard), and conceptually wrong (we wouldn't like to
    enable the X11 backend just to let it save to clipboard).
    
    Let gnome-shell handle saving the screenshot to clipboard instead, this
    also saves us from saving to /tmp just to copy it to the clipboard
    afterwards.
    
    Related: https://gitlab.gnome.org/GNOME/mutter/issues/789
             https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/810

 plugins/media-keys/gsd-screenshot-utils.c | 34 ++-----------------------------
 1 file changed, 2 insertions(+), 32 deletions(-)
---
diff --git a/plugins/media-keys/gsd-screenshot-utils.c b/plugins/media-keys/gsd-screenshot-utils.c
index 45f91096..9494f97c 100644
--- a/plugins/media-keys/gsd-screenshot-utils.c
+++ b/plugins/media-keys/gsd-screenshot-utils.c
@@ -94,32 +94,6 @@ screenshot_save_to_recent (ScreenshotContext *ctx)
   g_object_unref (file);
 }
 
-static void
-screenshot_save_to_clipboard (ScreenshotContext *ctx)
-{
-  GdkPixbuf *screenshot;
-  GtkClipboard *clipboard;
-  GError *error = NULL;
-
-  screenshot = gdk_pixbuf_new_from_file (ctx->used_filename, &error);
-  if (error != NULL)
-    {
-      screenshot_play_error_sound_effect ();
-      g_warning ("Failed to save a screenshot to clipboard: %s\n", error->message);
-      g_error_free (error);
-      return;
-    }
-
-  screenshot_play_sound_effect ("screen-capture", _("Screenshot taken"));
-  clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
-                                             GDK_SELECTION_CLIPBOARD);
-  gtk_clipboard_set_image (clipboard, screenshot);
-
-  /* remove the temporary file created by the shell */
-  g_unlink (ctx->used_filename);
-  g_object_unref (screenshot);
-}
-
 static void
 bus_call_ready_cb (GObject *source,
                    GAsyncResult *res,
@@ -146,11 +120,7 @@ bus_call_ready_cb (GObject *source,
 
   if (success)
     {
-      if (ctx->copy_to_clipboard)
-        {
-          screenshot_save_to_clipboard (ctx);
-        }
-      else
+      if (!ctx->copy_to_clipboard)
         {
           screenshot_play_sound_effect ("screen-capture", _("Screenshot taken"));
           screenshot_save_to_recent (ctx);
@@ -313,7 +283,7 @@ static void
 screenshot_check_name_ready (ScreenshotContext *ctx)
 {
   if (ctx->copy_to_clipboard)
-    ctx->save_filename = screenshot_build_tmp_path ();
+    ctx->save_filename = g_strdup ("");
   else
     ctx->save_filename = screenshot_build_filename ();
 


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