[gthumb] added a cancellable to the image saving function
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] added a cancellable to the image saving function
- Date: Sat, 19 Jan 2013 18:35:32 +0000 (UTC)
commit 7d256ccc309e9eab2f0db91a92667850482919f4
Author: Paolo Bacchilega <paobac src gnome org>
Date: Tue Jan 8 19:28:29 2013 +0100
added a cancellable to the image saving function
extensions/cairo_io/gth-image-saver-jpeg.c | 1 +
extensions/cairo_io/gth-image-saver-png.c | 1 +
extensions/cairo_io/gth-image-saver-tga.c | 1 +
extensions/cairo_io/gth-image-saver-tiff.c | 1 +
extensions/cairo_io/gth-image-saver-webp.c | 1 +
.../contact_sheet/gth-contact-sheet-creator.c | 1 +
extensions/desktop_background/actions.c | 1 +
extensions/exiv2_tools/exiv2-utils.cpp | 1 +
extensions/facebook/facebook-service.c | 1 +
extensions/gstreamer_tools/actions.c | 1 +
extensions/image_rotation/rotation-utils.c | 1 +
extensions/image_viewer/gth-image-viewer-page.c | 1 +
extensions/webalbums/gth-web-exporter.c | 3 ++
gthumb/gth-image-list-task.c | 5 ++-
gthumb/gth-image-saver.c | 33 +++++++++++++------
gthumb/gth-image-saver.h | 4 ++
gthumb/gth-image-utils.c | 1 +
17 files changed, 45 insertions(+), 13 deletions(-)
---
diff --git a/extensions/cairo_io/gth-image-saver-jpeg.c b/extensions/cairo_io/gth-image-saver-jpeg.c
index ecca7e3..2462d09 100644
--- a/extensions/cairo_io/gth-image-saver-jpeg.c
+++ b/extensions/cairo_io/gth-image-saver-jpeg.c
@@ -424,6 +424,7 @@ gth_image_saver_jpeg_save_image (GthImageSaver *base,
char **buffer,
gsize *buffer_size,
const char *mime_type,
+ GCancellable *cancellable,
GError **error)
{
#ifdef HAVE_LIBJPEG
diff --git a/extensions/cairo_io/gth-image-saver-png.c b/extensions/cairo_io/gth-image-saver-png.c
index f4e567b..70a071b 100644
--- a/extensions/cairo_io/gth-image-saver-png.c
+++ b/extensions/cairo_io/gth-image-saver-png.c
@@ -298,6 +298,7 @@ gth_image_saver_png_save_image (GthImageSaver *base,
char **buffer,
gsize *buffer_size,
const char *mime_type,
+ GCancellable *cancellable,
GError **error)
{
GthImageSaverPng *self = GTH_IMAGE_SAVER_PNG (base);
diff --git a/extensions/cairo_io/gth-image-saver-tga.c b/extensions/cairo_io/gth-image-saver-tga.c
index 4ae4eef..5e4c781 100644
--- a/extensions/cairo_io/gth-image-saver-tga.c
+++ b/extensions/cairo_io/gth-image-saver-tga.c
@@ -291,6 +291,7 @@ gth_image_saver_tga_save_image (GthImageSaver *base,
char **buffer,
gsize *buffer_size,
const char *mime_type,
+ GCancellable *cancellable,
GError **error)
{
GthImageSaverTga *self = GTH_IMAGE_SAVER_TGA (base);
diff --git a/extensions/cairo_io/gth-image-saver-tiff.c b/extensions/cairo_io/gth-image-saver-tiff.c
index d2f192e..ad35967 100644
--- a/extensions/cairo_io/gth-image-saver-tiff.c
+++ b/extensions/cairo_io/gth-image-saver-tiff.c
@@ -473,6 +473,7 @@ gth_image_saver_tiff_save_image (GthImageSaver *base,
char **buffer,
gsize *buffer_size,
const char *mime_type,
+ GCancellable *cancellable,
GError **error)
{
#ifdef HAVE_LIBTIFF
diff --git a/extensions/cairo_io/gth-image-saver-webp.c b/extensions/cairo_io/gth-image-saver-webp.c
index 0de77bd..1b4e20c 100644
--- a/extensions/cairo_io/gth-image-saver-webp.c
+++ b/extensions/cairo_io/gth-image-saver-webp.c
@@ -317,6 +317,7 @@ gth_image_saver_webp_save_image (GthImageSaver *base,
char **buffer,
gsize *buffer_size,
const char *mime_type,
+ GCancellable *cancellable,
GError **error)
{
GthImageSaverWebp *self = GTH_IMAGE_SAVER_WEBP (base);
diff --git a/extensions/contact_sheet/gth-contact-sheet-creator.c b/extensions/contact_sheet/gth-contact-sheet-creator.c
index ab1cec0..9ff69b5 100644
--- a/extensions/contact_sheet/gth-contact-sheet-creator.c
+++ b/extensions/contact_sheet/gth-contact-sheet-creator.c
@@ -359,6 +359,7 @@ end_page (GthContactSheetCreator *self,
NULL,
&buffer,
&size,
+ gth_task_get_cancellable (GTH_TASK (self)),
error))
{
g_object_unref (image);
diff --git a/extensions/desktop_background/actions.c b/extensions/desktop_background/actions.c
index a729e67..aba6f87 100644
--- a/extensions/desktop_background/actions.c
+++ b/extensions/desktop_background/actions.c
@@ -274,6 +274,7 @@ gth_browser_activate_action_tool_desktop_background (GtkAction *action,
"image/jpeg",
file_data,
TRUE,
+ NULL,
wallpaper_save_ready_cb,
wdata);
saving_wallpaper = TRUE;
diff --git a/extensions/exiv2_tools/exiv2-utils.cpp b/extensions/exiv2_tools/exiv2-utils.cpp
index 8043e25..d478621 100644
--- a/extensions/exiv2_tools/exiv2-utils.cpp
+++ b/extensions/exiv2_tools/exiv2-utils.cpp
@@ -1086,6 +1086,7 @@ exiv2_write_metadata_private (Exiv2::Image::AutoPtr image,
NULL,
&buffer,
&buffer_size,
+ NULL,
NULL))
{
thumb.setJpegThumbnail ((Exiv2::byte *) buffer, buffer_size);
diff --git a/extensions/facebook/facebook-service.c b/extensions/facebook/facebook-service.c
index ca2ddb1..b68cd37 100644
--- a/extensions/facebook/facebook-service.c
+++ b/extensions/facebook/facebook-service.c
@@ -817,6 +817,7 @@ upload_photo_file_buffer_ready_cb (void **buffer,
file_data,
(char **) buffer,
&count,
+ self->priv->post_photos->cancellable,
&error))
{
cairo_surface_destroy (surface);
diff --git a/extensions/gstreamer_tools/actions.c b/extensions/gstreamer_tools/actions.c
index b25b845..521b1f4 100644
--- a/extensions/gstreamer_tools/actions.c
+++ b/extensions/gstreamer_tools/actions.c
@@ -104,6 +104,7 @@ save_as_response_cb (GtkDialog *file_sel,
mime_type,
save_data->file_data,
TRUE,
+ NULL,
screenshot_saved_cb,
save_data);
diff --git a/extensions/image_rotation/rotation-utils.c b/extensions/image_rotation/rotation-utils.c
index 6f390e5..40a0f0d 100644
--- a/extensions/image_rotation/rotation-utils.c
+++ b/extensions/image_rotation/rotation-utils.c
@@ -331,6 +331,7 @@ file_buffer_ready_cb (void **buffer,
gth_file_data_get_mime_type (tdata->file_data),
tdata->file_data,
TRUE,
+ tdata->cancellable,
pixbuf_saved_cb,
tdata);
diff --git a/extensions/image_viewer/gth-image-viewer-page.c b/extensions/image_viewer/gth-image-viewer-page.c
index 116c61a..abf9490 100644
--- a/extensions/image_viewer/gth-image-viewer-page.c
+++ b/extensions/image_viewer/gth-image-viewer-page.c
@@ -1144,6 +1144,7 @@ _gth_image_viewer_page_real_save (GthViewerPage *base,
mime_type,
data->file_to_save,
TRUE,
+ NULL,
image_saved_cb,
data);
diff --git a/extensions/webalbums/gth-web-exporter.c b/extensions/webalbums/gth-web-exporter.c
index 4a9a0e8..6ec409b 100644
--- a/extensions/webalbums/gth-web-exporter.c
+++ b/extensions/webalbums/gth-web-exporter.c
@@ -2112,6 +2112,7 @@ save_thumbnail (gpointer data)
"image/jpeg",
file_data,
TRUE,
+ gth_task_get_cancellable (GTH_TASK (self)),
save_thumbnail_ready_cb,
self);
@@ -2345,6 +2346,7 @@ save_image_preview (gpointer data)
"image/jpeg",
file_data,
TRUE,
+ gth_task_get_cancellable (GTH_TASK (self)),
save_image_preview_ready_cb,
self);
@@ -2452,6 +2454,7 @@ save_resized_image (gpointer data)
"image/jpeg",
file_data,
TRUE,
+ gth_task_get_cancellable (GTH_TASK (self)),
save_resized_image_ready_cd,
self);
diff --git a/gthumb/gth-image-list-task.c b/gthumb/gth-image-list-task.c
index 3241094..7dd29a8 100644
--- a/gthumb/gth-image-list-task.c
+++ b/gthumb/gth-image-list-task.c
@@ -260,8 +260,8 @@ image_task_progress_cb (GthTask *task,
static void
image_task_save_current_image (GthImageListTask *self,
- GFile *file,
- gboolean replace)
+ GFile *file,
+ gboolean replace)
{
GthImage *destination;
@@ -285,6 +285,7 @@ image_task_save_current_image (GthImageListTask *self,
gth_file_data_get_mime_type (self->priv->destination_file_data),
self->priv->destination_file_data,
replace,
+ gth_task_get_cancellable (GTH_TASK (self)),
image_saved_cb,
self);
}
diff --git a/gthumb/gth-image-saver.c b/gthumb/gth-image-saver.c
index 967d84d..fbe6512 100644
--- a/gthumb/gth-image-saver.c
+++ b/gthumb/gth-image-saver.c
@@ -61,6 +61,7 @@ base_save_image (GthImageSaver *self,
char **buffer,
gsize *buffer_size,
const char *mime_type,
+ GCancellable *cancellable,
GError **error)
{
return FALSE;
@@ -152,6 +153,7 @@ gth_image_saver_save_image (GthImageSaver *self,
char **buffer,
gsize *buffer_size,
const char *mime_type,
+ GCancellable *cancellable,
GError **error)
{
return GTH_IMAGE_SAVER_GET_CLASS (self)->save_image (self,
@@ -159,15 +161,17 @@ gth_image_saver_save_image (GthImageSaver *self,
buffer,
buffer_size,
mime_type,
+ cancellable,
error);
}
static GthImageSaveData *
-_gth_image_save_to_buffer_common (GthImage *image,
- const char *mime_type,
- GthFileData *file_data,
- GError **p_error)
+_gth_image_save_to_buffer_common (GthImage *image,
+ const char *mime_type,
+ GthFileData *file_data,
+ GCancellable *cancellable,
+ GError **p_error)
{
GthImageSaver *saver;
char *buffer;
@@ -187,6 +191,7 @@ _gth_image_save_to_buffer_common (GthImage *image,
&buffer,
&buffer_size,
mime_type,
+ cancellable,
&error))
{
save_data = g_new0 (GthImageSaveData, 1);
@@ -197,6 +202,7 @@ _gth_image_save_to_buffer_common (GthImage *image,
save_data->buffer_size = buffer_size;
save_data->files = NULL;
save_data->error = NULL;
+ save_data->cancellable = _g_object_ref (cancellable);
if (save_data->file_data != NULL)
gth_hook_invoke ("save-image", save_data);
@@ -229,6 +235,7 @@ gth_image_save_file_free (GthImageSaveFile *file)
static void
gth_image_save_data_free (GthImageSaveData *data)
{
+ _g_object_unref (data->cancellable);
_g_object_unref (data->file_data);
g_object_unref (data->image);
g_list_foreach (data->files, (GFunc) gth_image_save_file_free, NULL);
@@ -238,12 +245,13 @@ gth_image_save_data_free (GthImageSaveData *data)
gboolean
-gth_image_save_to_buffer (GthImage *image,
- const char *mime_type,
- GthFileData *file_data,
- char **buffer,
- gsize *buffer_size,
- GError **p_error)
+gth_image_save_to_buffer (GthImage *image,
+ const char *mime_type,
+ GthFileData *file_data,
+ char **buffer,
+ gsize *buffer_size,
+ GCancellable *cancellable,
+ GError **p_error)
{
GthImageSaveData *save_data;
@@ -252,6 +260,7 @@ gth_image_save_to_buffer (GthImage *image,
save_data = _gth_image_save_to_buffer_common (image,
mime_type,
file_data,
+ cancellable,
p_error);
if (save_data != NULL) {
@@ -329,7 +338,7 @@ save_current_file (SaveData *save_data)
file->buffer_size,
(g_file_equal (save_data->data->file_data->file, file->file) ? save_data->data->replace : TRUE),
G_PRIORITY_DEFAULT,
- NULL,
+ save_data->data->cancellable,
file_saved_cb,
save_data);
}
@@ -357,6 +366,7 @@ gth_image_save_to_file (GthImage *image,
const char *mime_type,
GthFileData *file_data,
gboolean replace,
+ GCancellable *cancellable,
GthFileDataFunc ready_func,
gpointer user_data)
{
@@ -366,6 +376,7 @@ gth_image_save_to_file (GthImage *image,
data = _gth_image_save_to_buffer_common (image,
mime_type,
file_data,
+ cancellable,
&error);
if (data == NULL) {
diff --git a/gthumb/gth-image-saver.h b/gthumb/gth-image-saver.h
index edf417b..f49538b 100644
--- a/gthumb/gth-image-saver.h
+++ b/gthumb/gth-image-saver.h
@@ -68,6 +68,7 @@ struct _GthImageSaverClass
char **buffer,
gsize *buffer_size,
const char *mime_type,
+ GCancellable *cancellable,
GError **error);
};
@@ -83,6 +84,7 @@ typedef struct {
GthFileData *file_data;
const char *mime_type;
gboolean replace;
+ GCancellable *cancellable;
void *buffer;
gsize buffer_size;
GList *files; /* GthImageSaveFile list */
@@ -105,11 +107,13 @@ gboolean gth_image_save_to_buffer (GthImage *image,
GthFileData *file_data,
char **buffer,
gsize *buffer_size,
+ GCancellable *cancellable,
GError **error);
void gth_image_save_to_file (GthImage *image,
const char *mime_type,
GthFileData *file_data,
gboolean replace,
+ GCancellable *cancellable,
GthFileDataFunc ready_func,
gpointer user_data);
diff --git a/gthumb/gth-image-utils.c b/gthumb/gth-image-utils.c
index c4f1928..ef14751 100644
--- a/gthumb/gth-image-utils.c
+++ b/gthumb/gth-image-utils.c
@@ -167,6 +167,7 @@ _g_buffer_resize_image (void *buffer,
file_data,
(char **) resized_buffer,
resized_count,
+ cancellable,
error);
cairo_surface_destroy (scaled);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]