[gthumb] Don't generate new gfile where one exists already in FileData
- From: Michael J. Chudobiak <mjc src gnome org>
- To: svn-commits-list gnome org
- Subject: [gthumb] Don't generate new gfile where one exists already in FileData
- Date: Sun, 7 Jun 2009 15:16:39 -0400 (EDT)
commit e630e038897bdc34d6bc6fcb4cadb73ffa1461e8
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date: Sun Jun 7 15:16:14 2009 -0400
Don't generate new gfile where one exists already in FileData
---
src/catalog-web-exporter.c | 30 ++++++------------------------
src/dlg-jpegtran.c | 9 ++-------
src/gth-browser-actions-callbacks.c | 5 +----
src/rotation-utils.c | 13 ++-----------
4 files changed, 11 insertions(+), 46 deletions(-)
diff --git a/src/catalog-web-exporter.c b/src/catalog-web-exporter.c
index aa5d4a3..b0c015c 100644
--- a/src/catalog-web-exporter.c
+++ b/src/catalog-web-exporter.c
@@ -1303,7 +1303,8 @@ get_image_file (CatalogWebExporter *ce,
g_free (escaped);
} else {
- result = gfile_new (idata->src_file->utf8_path);
+ g_object_ref (idata->src_file->gfile);
+ result = idata->src_file->gfile;
}
return result;
@@ -2247,9 +2248,7 @@ save_thumbnail_cb (gpointer data)
if (idata->thumb != NULL) {
GFile *file;
- GFile *src_local_gfile = gfile_new (idata->src_file->utf8_path);
char *local_file;
- char *src_local_file;
g_signal_emit (G_OBJECT (ce),
catalog_web_exporter_signals[WEB_EXPORTER_PROGRESS],
@@ -2260,20 +2259,17 @@ save_thumbnail_cb (gpointer data)
idata,
ce->target_tmp_dir);
local_file = gfile_get_path (file);
- src_local_file = gfile_get_path (src_local_gfile);
debug (DEBUG_INFO, "save thumbnail: %s", local_file);
_gdk_pixbuf_save (idata->thumb,
local_file,
- src_local_file,
+ idata->src_file->local_path,
"jpeg",
NULL, NULL);
g_object_unref (file);
- g_object_unref (src_local_gfile);
g_free (local_file);
- g_free (src_local_file);
g_object_unref (idata->thumb);
idata->thumb = NULL;
@@ -2511,28 +2507,23 @@ save_image_preview_cb (gpointer data)
if ((! idata->no_preview) && (idata->preview != NULL)) {
GFile *file;
- GFile *src_local_gfile = gfile_new (idata->src_file->utf8_path);
char *local_file;
- char *src_local_file;
file = get_preview_file (ce,
idata,
ce->target_tmp_dir);
local_file = gfile_get_path (file);
- src_local_file = gfile_get_path (src_local_gfile);
debug (DEBUG_INFO, "saving preview: %s", local_file);
_gdk_pixbuf_save (idata->preview,
local_file,
- src_local_file,
+ idata->src_file->local_path,
"jpeg",
NULL, NULL);
g_free (local_file);
- g_free (src_local_file);
g_object_unref (file);
- g_object_unref (src_local_gfile);
}
}
@@ -2557,10 +2548,8 @@ save_resized_image_cb (gpointer data)
if (ce->copy_images && (idata->image != NULL)) {
GFile *file;
- GFile *src_local_gfile = gfile_new (idata->src_file->utf8_path);
char *image_uri;
char *local_file;
- char *src_local_file;
exporter_set_info (ce, _("Saving images"));
@@ -2569,23 +2558,20 @@ save_resized_image_cb (gpointer data)
ce->target_tmp_dir);
image_uri = gfile_get_uri (file);
local_file = gfile_get_path (file);
- src_local_file = gfile_get_path (src_local_gfile);
debug (DEBUG_INFO, "saving image: %s", local_file);
if (_gdk_pixbuf_save (idata->image,
local_file,
- src_local_file,
+ idata->src_file->local_path,
"jpeg",
NULL, NULL)) {
idata->src_file->size = get_file_size (image_uri);
}
g_free (local_file);
- g_free (src_local_file);
g_free (image_uri);
g_object_unref (file);
- g_object_unref (src_local_gfile);
}
}
@@ -2601,7 +2587,6 @@ static void
export__copy_image (CatalogWebExporter *ce)
{
ImageData *idata;
- GFile *sfile;
GFile *dfile;
gboolean copy_done;
@@ -2614,13 +2599,11 @@ export__copy_image (CatalogWebExporter *ce)
idata = ce->file_to_load->data;
- sfile = gfile_new (idata->src_file->utf8_path);
-
dfile = get_image_file (ce,
idata,
ce->target_tmp_dir);
- copy_done = gfile_copy (sfile, dfile, TRUE, NULL);
+ copy_done = gfile_copy (idata->src_file->gfile, dfile, TRUE, NULL);
if (copy_done) {
if (gfile_image_is_jpeg (dfile)) {
@@ -2645,7 +2628,6 @@ export__copy_image (CatalogWebExporter *ce)
}
}
- g_object_unref (sfile);
g_object_unref (dfile);
ce->saving_timeout = g_timeout_add (SAVING_TIMEOUT,
diff --git a/src/dlg-jpegtran.c b/src/dlg-jpegtran.c
index f9e44ab..058076e 100644
--- a/src/dlg-jpegtran.c
+++ b/src/dlg-jpegtran.c
@@ -240,10 +240,9 @@ apply_transformation_done (gpointer callback_data)
{
ApplyTransformData *at_data = callback_data;
FileData *file = at_data->current_image->data;
- GFile *gfile = gfile_new (file->utf8_path);
if (at_data->info != NULL)
- g_file_set_attributes_from_info (gfile, at_data->info, G_FILE_QUERY_INFO_NONE, NULL, NULL);
+ g_file_set_attributes_from_info (file->gfile, at_data->info, G_FILE_QUERY_INFO_NONE, NULL, NULL);
notify_file_changed (at_data->data, file->utf8_path, at_data->notify_soon);
if (at_data->done_func)
@@ -252,7 +251,6 @@ apply_transformation_done (gpointer callback_data)
if (at_data->info != NULL)
g_object_unref (at_data->info);
g_free (at_data);
- g_object_unref (gfile);
}
@@ -325,7 +323,6 @@ apply_transformation (GtkWidget *parent_window,
DoneFunc done_func,
gpointer done_data)
{
- GFile *gfile;
FileData *file = current_image->data;
ApplyTransformData *at_data;
GError *error = NULL;
@@ -338,9 +335,7 @@ apply_transformation (GtkWidget *parent_window,
at_data->done_func = done_func;
at_data->done_data = done_data;
- gfile = gfile_new (file->utf8_path);
- at_data->info = g_file_query_info (gfile, "owner::*,access::*", G_FILE_QUERY_INFO_NONE, NULL, &error);
- g_object_unref (gfile);
+ at_data->info = g_file_query_info (file->gfile, "owner::*,access::*", G_FILE_QUERY_INFO_NONE, NULL, &error);
if (error) {
g_object_unref (at_data->info);
at_data->info = NULL;
diff --git a/src/gth-browser-actions-callbacks.c b/src/gth-browser-actions-callbacks.c
index c5b90de..5819c32 100644
--- a/src/gth-browser-actions-callbacks.c
+++ b/src/gth-browser-actions-callbacks.c
@@ -648,7 +648,6 @@ gth_browser_activate_action_edit_current_catalog_new (GtkAction *action,
FileData *fd;
GFileOutputStream *handle;
GError *error;
- GFile *gfile;
catalog_list = gth_browser_get_catalog_list (browser);
if (catalog_list->path == NULL)
@@ -677,14 +676,13 @@ gth_browser_activate_action_edit_current_catalog_new (GtkAction *action,
CATALOG_EXT,
NULL);
fd = file_data_new_from_path (new_catalog_path);
- gfile = gfile_new (fd->utf8_path);
g_free (new_name);
g_free (new_catalog_path);
if (path_is_file (fd->utf8_path)) {
_gtk_error_dialog_run (GTK_WINDOW (browser),
_("The name \"%s\" is already used. " "Please use a different name."), fd->utf8_name);
- } else if ((handle = g_file_create (gfile, G_FILE_CREATE_PRIVATE, NULL, &error)) != NULL) {
+ } else if ((handle = g_file_create (fd->gfile, G_FILE_CREATE_PRIVATE, NULL, &error)) != NULL) {
gth_monitor_notify_update_catalog (fd->utf8_path, GTH_MONITOR_EVENT_CREATED);
gth_monitor_notify_reload_catalogs ();
g_object_unref (handle);
@@ -696,7 +694,6 @@ gth_browser_activate_action_edit_current_catalog_new (GtkAction *action,
g_error_free (error);
}
- g_object_unref (gfile);
file_data_unref (fd);
}
diff --git a/src/rotation-utils.c b/src/rotation-utils.c
index 9f7d580..59c3c53 100644
--- a/src/rotation-utils.c
+++ b/src/rotation-utils.c
@@ -142,7 +142,6 @@ apply_transformation_jpeg (FileData *file,
char *tmp_dir = NULL;
char *tmp_output_file = NULL;
JXFORM_CODE transf;
- GFile *gfile;
GFileInfo *info;
if (file == NULL)
@@ -163,9 +162,7 @@ apply_transformation_jpeg (FileData *file,
goto apply_transformation_jpeg__free_and_close;
}
- gfile = gfile_new (file->utf8_path);
- info = g_file_query_info (gfile, "owner::*,access::*", G_FILE_QUERY_INFO_NONE, NULL, NULL);
- g_object_unref (gfile);
+ info = g_file_query_info (file->gfile, "owner::*,access::*", G_FILE_QUERY_INFO_NONE, NULL, NULL);
switch (transform) {
case GTH_TRANSFORM_NONE:
@@ -211,14 +208,8 @@ apply_transformation_jpeg (FileData *file,
}
if (info != NULL) {
- char *local_uri;
-
- local_uri = get_uri_from_local_path (file->local_path);
- gfile = gfile_new (file->utf8_path);
- g_file_set_attributes_from_info (gfile, info, G_FILE_QUERY_INFO_NONE, NULL, NULL);
+ g_file_set_attributes_from_info (file->gfile, info, G_FILE_QUERY_INFO_NONE, NULL, NULL);
g_object_unref (info);
- g_object_unref (gfile);
- g_free (local_uri);
}
apply_transformation_jpeg__free_and_close:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]