Commit 7d256ccc authored by Paolo Bacchilega's avatar Paolo Bacchilega

added a cancellable to the image saving function

parent c0402599
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
......@@ -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
......
......@@ -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);
......
......@@ -359,6 +359,7 @@ end_page (GthContactSheetCreator *self,
NULL,
&buffer,
&size,
gth_task_get_cancellable (GTH_TASK (self)),
error))
{
g_object_unref (image);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
......@@ -104,6 +104,7 @@ save_as_response_cb (GtkDialog *file_sel,
mime_type,
save_data->file_data,
TRUE,
NULL,
screenshot_saved_cb,
save_data);
......
......@@ -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);
......
......@@ -1144,6 +1144,7 @@ _gth_image_viewer_page_real_save (GthViewerPage *base,
mime_type,
data->file_to_save,
TRUE,
NULL,
image_saved_cb,
data);
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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) {
......
......@@ -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);
......
......@@ -167,6 +167,7 @@ _g_buffer_resize_image (void *buffer,
file_data,
(char **) resized_buffer,
resized_count,
cancellable,
error);
cairo_surface_destroy (scaled);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment