[gnome-shell] screenshot: Write metadata to png file
- From: Adel Gadllah <agadllah src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] screenshot: Write metadata to png file
- Date: Thu, 14 Feb 2013 18:21:23 +0000 (UTC)
commit eb5a836822d03588852ac9da9ca49e627ad9f349
Author: Adel Gadllah <adel gadllah gmail com>
Date: Thu Feb 14 18:22:24 2013 +0100
screenshot: Write metadata to png file
Use GdkPixbuf rather then cairo_surface_write_to_png_stream when saving
screenshots because this allows us to embedded metadata into the file which
is used by the background control panel to filter out screenshots.
https://bugzilla.gnome.org/show_bug.cgi?id=693737
src/shell-screenshot.c | 34 ++++++++++++++++++++--------------
1 files changed, 20 insertions(+), 14 deletions(-)
---
diff --git a/src/shell-screenshot.c b/src/shell-screenshot.c
index da75ce0..924713f 100644
--- a/src/shell-screenshot.c
+++ b/src/shell-screenshot.c
@@ -164,19 +164,6 @@ prepare_write_stream (const gchar *filename,
return stream;
}
-static cairo_status_t
-do_write_to_stream (void *closure,
- const guchar *data,
- guint length)
-{
- GOutputStream *stream = closure;
- gboolean res;
-
- res = g_output_stream_write_all (stream, data, length, NULL, NULL, NULL);
-
- return res ? CAIRO_STATUS_SUCCESS : CAIRO_STATUS_WRITE_ERROR;
-}
-
static void
write_screenshot_thread (GSimpleAsyncResult *result,
GObject *object,
@@ -194,7 +181,26 @@ write_screenshot_thread (GSimpleAsyncResult *result,
if (stream == NULL)
status = CAIRO_STATUS_FILE_NOT_FOUND;
else
- status = cairo_surface_write_to_png_stream (screenshot_data->image, do_write_to_stream, stream);
+ {
+ GdkPixbuf *pixbuf;
+ pixbuf = gdk_pixbuf_new_from_data (cairo_image_surface_get_data (screenshot_data->image),
+ GDK_COLORSPACE_RGB,
+ TRUE,
+ 8,
+ cairo_image_surface_get_width (screenshot_data->image),
+ cairo_image_surface_get_height (screenshot_data->image),
+ cairo_image_surface_get_stride (screenshot_data->image),
+ NULL,
+ NULL);
+ if (gdk_pixbuf_save_to_stream (pixbuf, stream, "png", NULL, NULL,
+ "tEXt::Software", "gnome-screenshot", NULL))
+ status = CAIRO_STATUS_SUCCESS;
+ else
+ status = CAIRO_STATUS_WRITE_ERROR;
+
+ g_clear_object (&pixbuf);
+ }
+
g_simple_async_result_set_op_res_gboolean (result, status == CAIRO_STATUS_SUCCESS);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]