[gthumb: 21/22] [import-task] load the exif metadata for http uris as well
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb: 21/22] [import-task] load the exif metadata for http uris as well
- Date: Sat, 30 Jan 2010 23:21:01 +0000 (UTC)
commit eee063c41969101f8fb6c0db423988799029577a
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sat Jan 30 23:41:53 2010 +0100
[import-task] load the exif metadata for http uris as well
Load the file in a buffer and read the exif metadata from the
buffer, because g_file_get_path returns NULL for http uris.
Changed BufferReadyCallback to allow to reuse a buffer.
extensions/catalogs/actions.c | 31 +++---
extensions/catalogs/dlg-add-to-catalog.c | 19 ++--
extensions/catalogs/dlg-catalog-properties.c | 15 +--
extensions/catalogs/gth-catalog.c | 24 ++--
extensions/catalogs/gth-file-source-catalogs.c | 63 +++++-----
extensions/image_rotation/rotation-utils.c | 21 ++--
extensions/importer/gth-import-task.c | 126 ++++++++-----------
.../picasaweb/picasa-account-properties-dialog.c | 10 +-
extensions/picasaweb/picasa-web-service.c | 10 +-
extensions/search/actions.c | 10 +-
extensions/search/gth-search-task.c | 17 ++--
gthumb/gio-utils.c | 11 +-
gthumb/gio-utils.h | 2 +-
gthumb/gth-pixbuf-list-task.c | 10 +-
gthumb/pixbuf-io.c | 10 +-
15 files changed, 177 insertions(+), 202 deletions(-)
---
diff --git a/extensions/catalogs/actions.c b/extensions/catalogs/actions.c
index 402d289..c4911d2 100644
--- a/extensions/catalogs/actions.c
+++ b/extensions/catalogs/actions.c
@@ -50,8 +50,6 @@ typedef struct {
GList *file_data_list;
GFile *gio_file;
GthCatalog *catalog;
- char *buffer;
- gsize length;
} RemoveFromCatalogData;
@@ -62,7 +60,6 @@ remove_from_catalog_end (GError *error,
if (error != NULL)
_gtk_error_dialog_from_gerror_show (GTK_WINDOW (data->browser), _("Could not remove the files from the catalog"), &error);
- g_free (data->buffer);
g_object_unref (data->catalog);
g_object_unref (data->gio_file);
_g_object_list_unref (data->file_data_list);
@@ -71,10 +68,10 @@ remove_from_catalog_end (GError *error,
static void
-catalog_save_done_cb (void *buffer,
- gsize count,
- GError *error,
- gpointer user_data)
+catalog_save_done_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
RemoveFromCatalogData *data = user_data;
@@ -102,27 +99,29 @@ catalog_save_done_cb (void *buffer,
static void
-catalog_buffer_ready_cb (void *buffer,
- gsize count,
- GError *error,
- gpointer user_data)
+catalog_buffer_ready_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
RemoveFromCatalogData *data = user_data;
GList *scan;
+ void *catalog_buffer;
+ gsize catalog_size;
if (error != NULL) {
remove_from_catalog_end (error, data);
return;
}
- data->catalog = gth_hook_invoke_get ("gth-catalog-load-from-data", buffer);
+ data->catalog = gth_hook_invoke_get ("gth-catalog-load-from-data", *buffer);
if (data->catalog == NULL) {
error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, _("Invalid file format"));
remove_from_catalog_end (error, data);
return;
}
- gth_catalog_load_from_data (data->catalog, buffer, count, &error);
+ gth_catalog_load_from_data (data->catalog, *buffer, count, &error);
if (error != NULL) {
remove_from_catalog_end (error, data);
return;
@@ -134,15 +133,15 @@ catalog_buffer_ready_cb (void *buffer,
gth_catalog_remove_file (data->catalog, file_data->file);
}
- data->buffer = gth_catalog_to_data (data->catalog, &data->length);
+ catalog_buffer = gth_catalog_to_data (data->catalog, &catalog_size);
if (error != NULL) {
remove_from_catalog_end (error, data);
return;
}
g_write_file_async (data->gio_file,
- data->buffer,
- data->length,
+ catalog_buffer,
+ catalog_size,
G_PRIORITY_DEFAULT,
NULL,
catalog_save_done_cb,
diff --git a/extensions/catalogs/dlg-add-to-catalog.c b/extensions/catalogs/dlg-add-to-catalog.c
index 4ed6a83..6d93425 100644
--- a/extensions/catalogs/dlg-add-to-catalog.c
+++ b/extensions/catalogs/dlg-add-to-catalog.c
@@ -37,15 +37,12 @@ typedef struct {
gboolean view_destination;
GFile *catalog_file;
GthCatalog *catalog;
- char *buffer;
- gsize length;
} AddData;
static void
add_data_free (AddData *add_data)
{
- g_free (add_data->buffer);
_g_object_unref (add_data->catalog);
_g_object_list_unref (add_data->files);
_g_object_unref (add_data->catalog_file);
@@ -94,10 +91,10 @@ get_selected_catalog (DialogData *data)
static void
-catalog_save_done_cb (void *buffer,
- gsize count,
- GError *error,
- gpointer user_data)
+catalog_save_done_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
AddData *add_data = user_data;
@@ -128,6 +125,8 @@ catalog_ready_cb (GObject *catalog,
{
AddData *add_data = user_data;
GList *scan;
+ char *buffer;
+ gsize length;
GFile *gio_file;
if (error != NULL) {
@@ -142,11 +141,11 @@ catalog_ready_cb (GObject *catalog,
gth_catalog_insert_file (add_data->catalog, file_to_add->file, -1);
}
- add_data->buffer = gth_catalog_to_data (add_data->catalog, &add_data->length);
+ buffer = gth_catalog_to_data (add_data->catalog, &length);
gio_file = gth_catalog_file_to_gio_file (add_data->catalog_file);
g_write_file_async (gio_file,
- add_data->buffer,
- add_data->length,
+ buffer,
+ length,
G_PRIORITY_DEFAULT,
NULL,
catalog_save_done_cb,
diff --git a/extensions/catalogs/dlg-catalog-properties.c b/extensions/catalogs/dlg-catalog-properties.c
index 7a11842..e6aef15 100644
--- a/extensions/catalogs/dlg-catalog-properties.c
+++ b/extensions/catalogs/dlg-catalog-properties.c
@@ -52,10 +52,10 @@ destroy_cb (GtkWidget *widget,
static void
-catalog_saved_cb (void *buffer,
- gsize count,
- GError *error,
- gpointer user_data)
+catalog_saved_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
DialogData *data = user_data;
@@ -80,7 +80,6 @@ catalog_saved_cb (void *buffer,
else
_gtk_error_dialog_from_gerror_show (GTK_WINDOW (data->browser), _("Could not save the catalog"), &error);
- g_free (buffer);
gtk_widget_destroy (data->dialog);
}
@@ -99,7 +98,7 @@ save_button_clicked_cb (GtkButton *button,
GthDateTime *date_time;
GFile *gio_file;
char *buffer;
- gsize buffer_size;
+ gsize size;
if (strcmp (gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("name_entry"))), "") != 0) {
GFile *parent;
@@ -135,10 +134,10 @@ save_button_clicked_cb (GtkButton *button,
gth_hook_invoke ("dlg-catalog-properties-save", data->builder, data->file_data, data->catalog);
gio_file = gth_catalog_file_to_gio_file (data->file_data->file);
- buffer = gth_catalog_to_data (data->catalog, &buffer_size);
+ buffer = gth_catalog_to_data (data->catalog, &size);
g_write_file_async (gio_file,
buffer,
- buffer_size,
+ size,
G_PRIORITY_DEFAULT,
NULL,
catalog_saved_cb,
diff --git a/extensions/catalogs/gth-catalog.c b/extensions/catalogs/gth-catalog.c
index c1151a1..f6cf36b 100644
--- a/extensions/catalogs/gth-catalog.c
+++ b/extensions/catalogs/gth-catalog.c
@@ -561,16 +561,16 @@ catalog_file_info_ready_cb (GObject *source_object,
static void
-list__catalog_buffer_ready_cb (void *buffer,
- gsize count,
- GError *error,
- gpointer user_data)
+list__catalog_buffer_ready_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
ListData *list_data = user_data;
GthCatalog *catalog = list_data->catalog;
- if ((error == NULL) && (buffer != NULL)) {
- gth_catalog_load_from_data (catalog, buffer, count, &error);
+ if ((error == NULL) && (*buffer != NULL)) {
+ gth_catalog_load_from_data (catalog, *buffer, count, &error);
if (error != NULL) {
gth_catalog_list_done (list_data, error);
return;
@@ -1027,18 +1027,18 @@ typedef struct {
static void
-load__catalog_buffer_ready_cb (void *buffer,
- gsize count,
- GError *error,
- gpointer user_data)
+load__catalog_buffer_ready_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
LoadData *load_data = user_data;
GthCatalog *catalog = NULL;
if (error == NULL) {
- catalog = gth_hook_invoke_get ("gth-catalog-load-from-data", buffer);
+ catalog = gth_hook_invoke_get ("gth-catalog-load-from-data", *buffer);
if (catalog != NULL)
- gth_catalog_load_from_data (catalog, buffer, count, &error);
+ gth_catalog_load_from_data (catalog, *buffer, count, &error);
}
load_data->ready_func (G_OBJECT (catalog), error, load_data->user_data);
diff --git a/extensions/catalogs/gth-file-source-catalogs.c b/extensions/catalogs/gth-file-source-catalogs.c
index cde6f85..00c02d5 100644
--- a/extensions/catalogs/gth-file-source-catalogs.c
+++ b/extensions/catalogs/gth-file-source-catalogs.c
@@ -201,30 +201,30 @@ metadata_op_free (MetadataOpData *metadata_op)
static void
-write_metadata_write_buffer_ready_cb (void *buffer,
- gsize count,
- GError *error,
- gpointer user_data)
+write_metadata_write_buffer_ready_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
MetadataOpData *metadata_op = user_data;
GthFileSourceCatalogs *catalogs = metadata_op->catalogs;
- g_free (buffer);
-
metadata_op->ready_callback (G_OBJECT (catalogs), error, metadata_op->user_data);
metadata_op_free (metadata_op);
}
static void
-write_metadata_load_buffer_ready_cb (void *buffer,
- gsize count,
- GError *error,
- gpointer user_data)
+write_metadata_load_buffer_ready_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
MetadataOpData *metadata_op = user_data;
GthFileSourceCatalogs *catalogs = metadata_op->catalogs;
GFile *gio_file;
+ void *catalog_buffer;
+ gsize catalog_size;
if (error != NULL) {
metadata_op->ready_callback (G_OBJECT (catalogs), error, metadata_op->user_data);
@@ -232,7 +232,7 @@ write_metadata_load_buffer_ready_cb (void *buffer,
return;
}
- gth_catalog_load_from_data (metadata_op->catalog, buffer, count, &error);
+ gth_catalog_load_from_data (metadata_op->catalog, *buffer, count, &error);
if (error != NULL) {
metadata_op->ready_callback (G_OBJECT (catalogs), error, metadata_op->user_data);
@@ -245,11 +245,11 @@ write_metadata_load_buffer_ready_cb (void *buffer,
g_file_info_get_attribute_string (metadata_op->file_data->info, "sort::type"),
g_file_info_get_attribute_boolean (metadata_op->file_data->info, "sort::inverse"));
- buffer = gth_catalog_to_data (metadata_op->catalog, &count);
+ catalog_buffer = gth_catalog_to_data (metadata_op->catalog, &catalog_size);
gio_file = gth_catalog_file_to_gio_file (metadata_op->file_data->file);
g_write_file_async (gio_file,
- buffer,
- count,
+ catalog_buffer,
+ catalog_size,
G_PRIORITY_DEFAULT,
gth_file_source_get_cancellable (GTH_FILE_SOURCE (metadata_op->catalogs)),
write_metadata_write_buffer_ready_cb,
@@ -670,15 +670,12 @@ typedef struct {
gpointer user_data;
GList *files;
GthCatalog *catalog;
- char *buffer;
- gsize length;
} CopyOpData;
static void
copy_op_data_free (CopyOpData *cod)
{
- g_free (cod->buffer);
_g_object_unref (cod->catalog);
_g_object_list_unref (cod->files);
_g_object_list_unref (cod->file_list);
@@ -689,10 +686,10 @@ copy_op_data_free (CopyOpData *cod)
static void
-catalog_save_done_cb (void *buffer,
- gsize count,
- GError *error,
- gpointer user_data)
+catalog_save_done_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
CopyOpData *cod = user_data;
@@ -714,6 +711,8 @@ catalog_ready_cb (GObject *catalog,
{
CopyOpData *cod = user_data;
GList *scan;
+ char *buffer;
+ gsize size;
GFile *gio_file;
if (error != NULL) {
@@ -727,11 +726,11 @@ catalog_ready_cb (GObject *catalog,
for (scan = cod->files; scan; scan = scan->next)
gth_catalog_insert_file (cod->catalog, (GFile *) scan->data, -1);
- cod->buffer = gth_catalog_to_data (cod->catalog, &cod->length);
+ buffer = gth_catalog_to_data (cod->catalog, &size);
gio_file = gth_catalog_file_to_gio_file (cod->destination->file);
g_write_file_async (gio_file,
- cod->buffer,
- cod->length,
+ buffer,
+ size,
G_PRIORITY_DEFAULT,
NULL,
catalog_save_done_cb,
@@ -842,15 +841,13 @@ reorder_data_free (ReorderData *reorder_data)
static void
-reorder_buffer_ready_cb (void *buffer,
- gsize count,
- GError *error,
- gpointer user_data)
+reorder_buffer_ready_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
ReorderData *reorder_data = user_data;
- g_free (buffer);
-
gth_monitor_order_changed (gth_main_get_default_monitor (),
reorder_data->destination->file,
reorder_data->new_order);
@@ -904,7 +901,7 @@ reorder_catalog_ready_cb (GObject *object,
ReorderData *reorder_data = user_data;
GthCatalog *catalog;
char *buffer;
- gsize buffer_size;
+ gsize size;
GFile *gio_file;
if (error != NULL) {
@@ -917,11 +914,11 @@ reorder_catalog_ready_cb (GObject *object,
reorder_data->new_order = reorder_catalog_list (catalog, reorder_data->file_list, reorder_data->dest_pos);
gth_catalog_set_order (catalog, "general::unsorted", FALSE);
- buffer = gth_catalog_to_data (catalog, &buffer_size);
+ buffer = gth_catalog_to_data (catalog, &size);
gio_file = gth_file_source_to_gio_file (reorder_data->file_source, reorder_data->destination->file);
g_write_file_async (gio_file,
buffer,
- buffer_size,
+ size,
G_PRIORITY_DEFAULT,
gth_file_source_get_cancellable (reorder_data->file_source),
reorder_buffer_ready_cb,
diff --git a/extensions/image_rotation/rotation-utils.c b/extensions/image_rotation/rotation-utils.c
index 17569b5..8a7bf0e 100644
--- a/extensions/image_rotation/rotation-utils.c
+++ b/extensions/image_rotation/rotation-utils.c
@@ -233,14 +233,13 @@ transformation_data_free (TransformatioData *tdata)
static void
-write_file_ready_cb (void *buffer,
- gsize count,
- GError *error,
- gpointer user_data)
+write_file_ready_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
TransformatioData *tdata = user_data;
- g_free (buffer);
tdata->ready_func (error, tdata->user_data);
transformation_data_free (tdata);
}
@@ -259,10 +258,10 @@ pixbuf_saved_cb (GthFileData *file_data,
static void
-file_buffer_ready_cb (void *buffer,
- gsize count,
- GError *error,
- gpointer user_data)
+file_buffer_ready_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
TransformatioData *tdata = user_data;
@@ -277,7 +276,7 @@ file_buffer_ready_cb (void *buffer,
void *out_buffer;
gsize out_buffer_size;
- if (! jpegtran (buffer,
+ if (! jpegtran (*buffer,
count,
&out_buffer,
&out_buffer_size,
@@ -305,7 +304,7 @@ file_buffer_ready_cb (void *buffer,
GdkPixbuf *original_pixbuf;
GdkPixbuf *transformed_pixbuf;
- istream = g_memory_input_stream_new_from_data (buffer, count, NULL);
+ istream = g_memory_input_stream_new_from_data (*buffer, count, NULL);
original_pixbuf = gdk_pixbuf_new_from_stream (istream, tdata->cancellable, &error);
if (original_pixbuf == NULL) {
tdata->ready_func (error, tdata->user_data);
diff --git a/extensions/importer/gth-import-task.c b/extensions/importer/gth-import-task.c
index ff7155f..5d41f8a 100644
--- a/extensions/importer/gth-import-task.c
+++ b/extensions/importer/gth-import-task.c
@@ -22,6 +22,7 @@
#include <config.h>
#include <extensions/catalogs/gth-catalog.h>
+#include <extensions/exiv2/exiv2-utils.h>
#include <extensions/image_rotation/rotation-utils.h>
#include "gth-import-task.h"
#include "utils.h"
@@ -208,22 +209,39 @@ transformation_ready_cb (GError *error,
static void
-copy_ready_cb (GError *error,
- gpointer user_data)
+write_buffer_ready_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
GthImportTask *self = user_data;
+ GthFileData *file_data;
gboolean appling_tranformation = FALSE;
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) {
- self->priv->delete_imported = FALSE;
- error = NULL;
- }
-
if (error != NULL) {
gth_task_completed (GTH_TASK (self), error);
return;
}
+ file_data = self->priv->current->data;
+ if (self->priv->delete_imported) {
+ GError *local_error = NULL;
+
+ if (! g_file_delete (file_data->file,
+ gth_task_get_cancellable (GTH_TASK (self)),
+ &local_error))
+ {
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) {
+ self->priv->delete_imported = FALSE;
+ local_error = NULL;
+ }
+ if (local_error != NULL) {
+ gth_task_completed (GTH_TASK (self), local_error);
+ return;
+ }
+ }
+ }
+
if (self->priv->adjust_orientation && gth_main_extension_is_active ("image_rotation")) {
GthMetadata *metadata;
@@ -257,49 +275,10 @@ copy_ready_cb (GError *error,
static void
-copy_progress_cb (GObject *object,
- const char *description,
- const char *details,
- gboolean pulse,
- double fraction,
- gpointer user_data)
-{
- GthImportTask *self = user_data;
- char *local_details = NULL;
-
- if (! pulse) {
- char *s1;
- char *s2;
-
- s1 = g_format_size_for_display (((double) self->priv->current_file_size * fraction) + self->priv->copied_size);
- s2 = g_format_size_for_display (self->priv->tot_size);
- /* translators: this a copy progress message, for example: 1.2MB of 12MB */
- local_details = g_strdup_printf (_("%s of %s"), s1, s2);
- details = local_details;
-
- fraction = (((double) self->priv->current_file_size * fraction) + self->priv->copied_size) / self->priv->tot_size;
- }
-
- gth_task_progress (GTH_TASK (self), description, details, pulse, fraction);
-
- g_free (local_details);
-}
-
-
-static void
-copy_dialog_cb (gboolean opened,
- gpointer user_data)
-{
- GthImportTask *self = user_data;
-
- gth_task_dialog (GTH_TASK (self), opened);
-}
-
-
-static void
-file_info_ready_cb (GList *files,
- GError *error,
- gpointer user_data)
+file_buffer_ready_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
GthImportTask *self = user_data;
GthFileData *file_data;
@@ -312,7 +291,8 @@ file_info_ready_cb (GList *files,
}
file_data = self->priv->current->data;
- self->priv->current_file_size = g_file_info_get_size (file_data->info);
+ if (gth_main_extension_is_active ("exiv2"))
+ exiv2_read_metadata_from_buffer (*buffer, count, file_data->info, NULL);
destination = gth_import_utils_get_file_destination (file_data,
self->priv->destination,
@@ -330,27 +310,23 @@ file_info_ready_cb (GList *files,
destination_file = _g_file_get_destination (file_data->file, NULL, destination);
if (self->priv->overwrite_files || ! g_file_query_exists (destination_file, NULL)) {
- GFileCopyFlags copy_flags;
-
_g_object_unref (self->priv->destination_file);
self->priv->destination_file = gth_file_data_new (destination_file, file_data->info);
- copy_flags = G_FILE_COPY_ALL_METADATA | G_FILE_COPY_TARGET_DEFAULT_PERMS;
- if (self->priv->overwrite_files)
- copy_flags |= G_FILE_COPY_OVERWRITE;
+ gth_task_progress (GTH_TASK (self),
+ _("Importing files"),
+ g_file_info_get_display_name (file_data->info),
+ FALSE,
+ (self->priv->copied_size + ((double) self->priv->current_file_size / 3.0 * 2.0)) / self->priv->tot_size);
- _g_copy_file_async (file_data,
- destination_file,
- self->priv->delete_imported,
- copy_flags,
+ g_write_file_async (self->priv->destination_file->file,
+ *buffer,
+ count,
G_PRIORITY_DEFAULT,
gth_task_get_cancellable (GTH_TASK (self)),
- copy_progress_cb,
- self,
- copy_dialog_cb,
- self,
- copy_ready_cb,
+ write_buffer_ready_cb,
self);
+ *buffer = NULL; /* g_write_file_async takes ownership of the buffer */
}
else
call_when_idle ((DataFunc) import_next_file, self);
@@ -364,7 +340,6 @@ static void
import_current_file (GthImportTask *self)
{
GthFileData *file_data;
- GList *list;
if (self->priv->current == NULL) {
save_catalogs (self);
@@ -377,14 +352,19 @@ import_current_file (GthImportTask *self)
}
file_data = self->priv->current->data;
- list = g_list_prepend (NULL, file_data);
- _g_query_metadata_async (list,
- "Embedded::Photo::DateTimeOriginal,Embedded::Image::Orientation",
- gth_task_get_cancellable (GTH_TASK (self)),
- file_info_ready_cb,
- self);
+ self->priv->current_file_size = g_file_info_get_size (file_data->info);
- g_list_free (list);
+ gth_task_progress (GTH_TASK (self),
+ _("Importing files"),
+ g_file_info_get_display_name (file_data->info),
+ FALSE,
+ (self->priv->copied_size + ((double) self->priv->current_file_size / 3.0)) / self->priv->tot_size);
+
+ g_load_file_async (file_data->file,
+ G_PRIORITY_DEFAULT,
+ gth_task_get_cancellable (GTH_TASK (self)),
+ file_buffer_ready_cb,
+ self);
}
diff --git a/extensions/picasaweb/picasa-account-properties-dialog.c b/extensions/picasaweb/picasa-account-properties-dialog.c
index 0922695..4787292 100644
--- a/extensions/picasaweb/picasa-account-properties-dialog.c
+++ b/extensions/picasaweb/picasa-account-properties-dialog.c
@@ -121,10 +121,10 @@ picasa_account_properties_dialog_get_type (void)
static void
-image_buffer_ready_cb (void *buffer,
- gsize count,
- GError *error,
- gpointer user_data)
+image_buffer_ready_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
PicasaAccountPropertiesDialog *self = user_data;
GInputStream *stream;
@@ -135,7 +135,7 @@ image_buffer_ready_cb (void *buffer,
return;
}
- stream = g_memory_input_stream_new_from_data (buffer, count, NULL);
+ stream = g_memory_input_stream_new_from_data (*buffer, count, NULL);
pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, NULL);
if (pixbuf != NULL) {
gtk_widget_show (GET_WIDGET ("challange_box"));
diff --git a/extensions/picasaweb/picasa-web-service.c b/extensions/picasaweb/picasa-web-service.c
index bf2fefa..35c1e91 100644
--- a/extensions/picasaweb/picasa-web-service.c
+++ b/extensions/picasaweb/picasa-web-service.c
@@ -409,10 +409,10 @@ post_photo_ready_cb (SoupSession *session,
static void
-post_photo_file_buffer_ready_cb (void *buffer,
- gsize count,
- GError *error,
- gpointer user_data)
+post_photo_file_buffer_ready_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
PicasaWebService *self = user_data;
GthFileData *file_data;
@@ -495,7 +495,7 @@ post_photo_file_buffer_ready_cb (void *buffer,
/* the file part */
- body = soup_buffer_new (SOUP_MEMORY_TEMPORARY, buffer, count);
+ body = soup_buffer_new (SOUP_MEMORY_TEMPORARY, *buffer, count);
soup_multipart_append_form_file (multipart,
"file",
NULL,
diff --git a/extensions/search/actions.c b/extensions/search/actions.c
index 90ffb24..64bab01 100644
--- a/extensions/search/actions.c
+++ b/extensions/search/actions.c
@@ -103,10 +103,10 @@ search_data_free (SearchData *search_data)
static void
-search_update_buffer_ready_cb (void *buffer,
- gsize count,
- GError *error,
- gpointer user_data)
+search_update_buffer_ready_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
SearchData *search_data = user_data;
GError *local_error = NULL;
@@ -118,7 +118,7 @@ search_update_buffer_ready_cb (void *buffer,
return;
}
- search = gth_search_new_from_data (buffer, count, &local_error);
+ search = gth_search_new_from_data (*buffer, count, &local_error);
if (search == NULL) {
_gtk_error_dialog_from_gerror_show (GTK_WINDOW (search_data->browser), _("Could not perform the search"), &local_error);
return;
diff --git a/extensions/search/gth-search-task.c b/extensions/search/gth-search-task.c
index c698b6b..48d216a 100644
--- a/extensions/search/gth-search-task.c
+++ b/extensions/search/gth-search-task.c
@@ -107,14 +107,13 @@ embedded_dialog_response_cb (GeditMessageArea *message_area,
static void
-save_search_result_copy_done_cb (void *buffer,
- gsize count,
- GError *error,
- gpointer user_data)
+save_search_result_copy_done_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
GthSearchTask *task = user_data;
- g_free (buffer);
gth_browser_update_extra_widget (task->priv->browser);
task->priv->io_operation = FALSE;
@@ -277,10 +276,10 @@ browser_location_ready_cb (GthBrowser *browser,
static void
-clear_search_result_copy_done_cb (void *buffer,
- gsize count,
- GError *error,
- gpointer user_data)
+clear_search_result_copy_done_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
GthSearchTask *task = user_data;
diff --git a/gthumb/gio-utils.c b/gthumb/gio-utils.c
index af6a386..df149bc 100644
--- a/gthumb/gio-utils.c
+++ b/gthumb/gio-utils.c
@@ -1950,14 +1950,14 @@ load_file__stream_read_cb (GObject *source_object,
count = g_input_stream_read_finish (load_data->stream, result, &error);
if (count < 0) {
- load_data->callback (NULL, -1, error, load_data->user_data);
+ load_data->callback (&load_data->buffer, -1, error, load_data->user_data);
load_data_free (load_data);
return;
}
else if (count == 0) {
if (load_data->buffer != NULL)
((char *)load_data->buffer)[load_data->count] = 0;
- load_data->callback (load_data->buffer, load_data->count, NULL, load_data->user_data);
+ load_data->callback (&load_data->buffer, load_data->count, NULL, load_data->user_data);
load_data_free (load_data);
return;
}
@@ -1986,7 +1986,7 @@ load_file__file_read_cb (GObject *source_object,
load_data->stream = (GInputStream *) g_file_read_finish (G_FILE (source_object), result, &error);
if (load_data->stream == NULL) {
- load_data->callback (NULL, -1, error, load_data->user_data);
+ load_data->callback (&load_data->buffer, -1, error, load_data->user_data);
load_data_free (load_data);
return;
}
@@ -2039,6 +2039,7 @@ typedef struct {
static void
write_data_free (WriteData *write_data)
{
+ g_free (write_data->buffer);
g_free (write_data);
}
@@ -2048,7 +2049,7 @@ write_file__notify (gpointer user_data)
{
WriteData *write_data = user_data;
- write_data->callback (write_data->buffer, write_data->count, write_data->error, write_data->user_data);
+ write_data->callback (&write_data->buffer, write_data->count, write_data->error, write_data->user_data);
write_data_free (write_data);
}
@@ -2113,7 +2114,7 @@ write_file__replace_ready_cb (GObject *source_object,
stream = (GOutputStream*) g_file_replace_finish ((GFile*) source_object, result, &error);
if (stream == NULL) {
- write_data->callback (write_data->buffer, write_data->count, error, write_data->user_data);
+ write_data->callback (&write_data->buffer, write_data->count, error, write_data->user_data);
write_data_free (write_data);
return;
}
diff --git a/gthumb/gio-utils.h b/gthumb/gio-utils.h
index 8b3a74d..ec8bf68 100644
--- a/gthumb/gio-utils.h
+++ b/gthumb/gio-utils.h
@@ -49,7 +49,7 @@ typedef void (*ListReadyCallback) (GList *files,
GList *dirs,
GError *error,
gpointer user_data);
-typedef void (*BufferReadyCallback) (void *buffer,
+typedef void (*BufferReadyCallback) (void **buffer,
gsize count,
GError *error,
gpointer user_data);
diff --git a/gthumb/gth-pixbuf-list-task.c b/gthumb/gth-pixbuf-list-task.c
index a27ac98..a4cd40a 100644
--- a/gthumb/gth-pixbuf-list-task.c
+++ b/gthumb/gth-pixbuf-list-task.c
@@ -155,10 +155,10 @@ pixbuf_task_completed_cb (GthTask *task,
static void
-file_buffer_ready_cb (void *buffer,
- gsize count,
- GError *error,
- gpointer user_data)
+file_buffer_ready_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
GthPixbufListTask *self = user_data;
GInputStream *istream;
@@ -168,7 +168,7 @@ file_buffer_ready_cb (void *buffer,
return;
}
- istream = g_memory_input_stream_new_from_data (buffer, count, NULL);
+ istream = g_memory_input_stream_new_from_data (*buffer, count, NULL);
self->priv->original_pixbuf = gdk_pixbuf_new_from_stream (istream, gth_task_get_cancellable (GTH_TASK (self)), &error);
g_object_unref (istream);
diff --git a/gthumb/pixbuf-io.c b/gthumb/pixbuf-io.c
index 252283a..5a7d11b 100644
--- a/gthumb/pixbuf-io.c
+++ b/gthumb/pixbuf-io.c
@@ -92,13 +92,15 @@ static void save_current_file (SaveData *save_data);
static void
-file_saved_cb (void *buffer,
- gsize count,
- GError *error,
- gpointer user_data)
+file_saved_cb (void **buffer,
+ gsize count,
+ GError *error,
+ gpointer user_data)
{
SaveData *save_data = user_data;
+ *buffer = NULL; /* do not free the buffer, it's owned by file->buffer */
+
if (error != NULL) {
save_data->data->error = &error;
save_completed (save_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]