[gnome-flashback] screenshot: save to clipboard when filename is empty
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] screenshot: save to clipboard when filename is empty
- Date: Tue, 18 Feb 2020 19:48:07 +0000 (UTC)
commit 86472c44364d5fd7fbc1ec8a3364e19855537189
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Tue Feb 18 21:42:26 2020 +0200
screenshot: save to clipboard when filename is empty
GNOME Settings Daemon no longer do this.
https://gitlab.gnome.org/GNOME/gnome-settings-daemon/commit/41a84e315d865bff16fb45717d1ef0ee23c65f25
configure.ac | 1 +
gnome-flashback/libscreenshot/gf-screenshot.c | 39 +++++++++++++++++++++++++++
po/POTFILES.in | 1 +
3 files changed, 41 insertions(+)
---
diff --git a/configure.ac b/configure.ac
index f42b205..05bfc3b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -234,6 +234,7 @@ PKG_CHECK_MODULES([SCREENSAVER], [
PKG_CHECK_MODULES([SCREENSHOT], [
gio-unix-2.0 >= $GLIB_REQUIRED
gtk+-3.0 >= $GTK_REQUIRED
+ libcanberra-gtk3 >= $CANBERRA_REQUIRED
x11
xext
xfixes
diff --git a/gnome-flashback/libscreenshot/gf-screenshot.c b/gnome-flashback/libscreenshot/gf-screenshot.c
index 2b73aa6..5bbdffb 100644
--- a/gnome-flashback/libscreenshot/gf-screenshot.c
+++ b/gnome-flashback/libscreenshot/gf-screenshot.c
@@ -22,6 +22,8 @@
#include "config.h"
#include "gf-screenshot.h"
+#include <canberra-gtk.h>
+#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <X11/extensions/shape.h>
@@ -249,6 +251,37 @@ screenshot_add_cursor (GdkPixbuf *pixbuf,
}
}
+static void
+play_sound_effect (const char *event_id,
+ const char *event_desc)
+{
+ ca_context *c;
+
+ c = ca_gtk_context_get ();
+
+ ca_context_play (c, 0,
+ CA_PROP_EVENT_ID, event_id,
+ CA_PROP_EVENT_DESCRIPTION, event_desc,
+ CA_PROP_CANBERRA_CACHE_CONTROL, "permanent",
+ NULL);
+}
+
+static void
+save_to_clipboard (GfScreenshot *self,
+ GdkPixbuf *pixbuf)
+{
+ GdkDisplay *display;
+ GtkClipboard *clipboard;
+
+ display = gdk_display_get_default ();
+ clipboard = gtk_clipboard_get_for_display (display, GDK_SELECTION_CLIPBOARD);
+
+ play_sound_effect ("screen-capture", _("Screenshot taken"));
+
+ gtk_clipboard_set_image (clipboard, pixbuf);
+ g_object_unref (pixbuf);
+}
+
static gchar *
get_unique_path (const gchar *path,
const gchar *filename)
@@ -325,6 +358,12 @@ save_screenshot (GfScreenshot *screenshot,
if (pixbuf == NULL)
return FALSE;
+ if (filename_in == NULL || *filename_in == '\0')
+ {
+ save_to_clipboard (screenshot, pixbuf);
+ return TRUE;
+ }
+
filename = get_filename (filename_in);
creation_time = g_date_time_format (screenshot->datetime, "%c");
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 9186c3b..007044a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -38,6 +38,7 @@ gnome-flashback/libpolkit/flashback-polkit-dialog.c
gnome-flashback/libpolkit/flashback-polkit-dialog.ui
gnome-flashback/libscreensaver/gf-auth.c
gnome-flashback/libscreensaver/gf-unlock-dialog.c
+gnome-flashback/libscreenshot/gf-screenshot.c
gvc/gvc/gvc-mixer-control.c
system-indicators/si-bluetooth.c
system-indicators/si-desktop-menu-item.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]