gthumb r2490 - in trunk: . libgthumb src
- From: mjc svn gnome org
- To: svn-commits-list gnome org
- Subject: gthumb r2490 - in trunk: . libgthumb src
- Date: Mon, 5 Jan 2009 20:49:58 +0000 (UTC)
Author: mjc
Date: Mon Jan 5 20:49:58 2009
New Revision: 2490
URL: http://svn.gnome.org/viewvc/gthumb?rev=2490&view=rev
Log:
2009-01-05 Michael J. Chudobiak <mjc svn gnome org>
* libgthumb/gth-utils.c: (gthumb_display_help):
* src/catalog-web-exporter.c: (export__final_step),
(export__copy_to_destination__step2):
* src/dlg-file-utils.c: (set_error_from_vfs_result),
(real_files_delete__continue2), (real_files_delete__continue),
(file_move_ask__continue), (file_copy_ask__continue),
(dlg_file_rename_series), (file_copy_data_free),
(file_copy__continue_or_abort__response_cb),
(continue_or_abort_dialog), (files_copy__done),
(file_progress_update_cb), (xfer_file), (copy_current_file),
(copy_next_file), (dlg_files_copy), (dlg_files_move_to_trash),
(file_delete_data_free), (files_delete__done),
(file_delete_progress_update_cb), (dlg_files_delete),
(folder_copy_data_free), (folder_progress_update_cb),
(folder_copy), (dlg_folder_move_to_trash), (copy_item__continue2),
(item_copy__continue_or_abort__response_cb),
(copy_item__continue1), (copy_current_item), (dlg_copy_items):
* src/dlg-file-utils.h:
* src/dlg-write-to-cd.c: (write_to_cd__continue):
* src/gth-browser-actions-callbacks.c: (show_folder),
(folder_delete__continue2), (folder_delete__continue),
(folder_copy__continue):
* src/gth-browser.c: (move_items__continue):
Isolate gnome_vfs code in dlg-file-utils by adding a gerror wrapper.
Patch by Christophe BisiÃre. Bug #525482.
Modified:
trunk/ChangeLog
trunk/libgthumb/gth-utils.c
trunk/src/catalog-web-exporter.c
trunk/src/dlg-file-utils.c
trunk/src/dlg-file-utils.h
trunk/src/dlg-write-to-cd.c
trunk/src/gth-browser-actions-callbacks.c
trunk/src/gth-browser.c
Modified: trunk/libgthumb/gth-utils.c
==============================================================================
--- trunk/libgthumb/gth-utils.c (original)
+++ trunk/libgthumb/gth-utils.c Mon Jan 5 20:49:58 2009
@@ -45,6 +45,7 @@
_("Could not display help"));
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s",
err->message);
g_signal_connect (G_OBJECT (dialog), "response",
Modified: trunk/src/catalog-web-exporter.c
==============================================================================
--- trunk/src/catalog-web-exporter.c (original)
+++ trunk/src/catalog-web-exporter.c Mon Jan 5 20:49:58 2009
@@ -2123,7 +2123,7 @@
static void
-export__final_step (GnomeVFSResult result,
+export__final_step (GError *error,
gpointer data)
{
CatalogWebExporter *ce = data;
@@ -2134,16 +2134,17 @@
static void
-export__copy_to_destination__step2 (GnomeVFSResult result,
+export__copy_to_destination__step2 (GError *error,
gpointer data)
{
CatalogWebExporter *ce = data;
- debug (DEBUG_INFO, "result: %s", gnome_vfs_result_to_string (result));
+ debug (DEBUG_INFO, "result: %s", error->message);
- if (result != GNOME_VFS_OK)
+ if (error != NULL)
_gtk_error_dialog_run (GTK_WINDOW (ce->window),
- gnome_vfs_result_to_string (result));
+ "%s",
+ error->message);
dlg_folder_delete (ce->window,
ce->base_tmp_dir,
Modified: trunk/src/dlg-file-utils.c
==============================================================================
--- trunk/src/dlg-file-utils.c (original)
+++ trunk/src/dlg-file-utils.c Mon Jan 5 20:49:58 2009
@@ -71,6 +71,49 @@
gpointer data);
+/* GIO Port: VFS -> GIO error code mapping */
+
+void
+set_error_from_vfs_result (GnomeVFSResult result,
+ GError **err)
+{
+ g_assert (*err == NULL);
+
+ switch (result) {
+ case GNOME_VFS_OK:
+ break;
+
+ case GNOME_VFS_ERROR_INTERRUPTED:
+ g_set_error (err,
+ G_FILE_ERROR,
+ G_FILE_ERROR_INTR,
+ _("Operation interrupted"));
+ break;
+
+ case GNOME_VFS_ERROR_NOT_FOUND:
+ g_set_error (err,
+ G_FILE_ERROR,
+ G_FILE_ERROR_NOENT,
+ _("File not found"));
+ break;
+
+ case GNOME_VFS_ERROR_BAD_PARAMETERS:
+ g_set_error (err,
+ G_IO_ERROR ,
+ G_IO_ERROR_INVALID_ARGUMENT,
+ _("Invalid argument"));
+ break;
+
+ default:
+ g_set_error (err,
+ G_FILE_ERROR,
+ G_FILE_ERROR_FAILED,
+ _("Operation failed"));
+ break;
+ }
+}
+
+
gboolean
dlg_check_folder (GthWindow *window,
const char *path)
@@ -193,16 +236,16 @@
static void
-real_files_delete__continue2 (GnomeVFSResult result,
+real_files_delete__continue2 (GError *error,
gpointer data)
{
ConfirmFileDeleteData *cfddata = data;
- if ((result != GNOME_VFS_OK) && (result != GNOME_VFS_ERROR_INTERRUPTED))
+ if ((error != NULL) && (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_INTR)))
_gtk_error_dialog_run (GTK_WINDOW (cfddata->window),
"%s %s",
_("Could not delete the images:"),
- gnome_vfs_result_to_string (result));
+ error->message);
path_list_free (cfddata->file_list);
g_free (cfddata);
@@ -210,12 +253,12 @@
static void
-real_files_delete__continue (GnomeVFSResult result,
+real_files_delete__continue (GError *error,
gpointer data)
{
ConfirmFileDeleteData *cfddata = data;
- if (result == GNOME_VFS_ERROR_NOT_FOUND) {
+ if ((error != NULL) && (g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))) {
int r = GTK_RESPONSE_YES;
if (eel_gconf_get_boolean (PREF_MSG_CANNOT_MOVE_TO_TRASH, TRUE)) {
@@ -241,7 +284,7 @@
cfddata);
}
else
- real_files_delete__continue2 (result, data);
+ real_files_delete__continue2 (error, data);
}
@@ -309,7 +352,7 @@
static void
-file_move_ask__continue (GnomeVFSResult result,
+file_move_ask__continue (GError *error,
gpointer data)
{
GtkWidget *file_sel = data;
@@ -410,7 +453,7 @@
static void
-file_copy_ask__continue (GnomeVFSResult result,
+file_copy_ask__continue (GError *error,
gpointer data)
{
GtkWidget *file_sel = data;
@@ -1045,7 +1088,7 @@
dlg_show_error (window,
msg,
error_list,
- gnome_vfs_result_to_string (result));
+ gnome_vfs_result_to_string (result)); /*FIXME: result is a gboolean */
}
path_list_free (error_list);
@@ -1080,7 +1123,7 @@
guint timeout_id;
GnomeVFSAsyncHandle *handle;
- GnomeVFSResult result;
+ GError *error;
OverwriteResult overwrite_result;
gboolean cache_copied;
gboolean copying_cache;
@@ -1111,6 +1154,10 @@
path_list_free (fcdata->created_list);
g_free (fcdata->destination);
+
+ if (fcdata->error != NULL)
+ g_error_free (fcdata->error);
+
g_free (fcdata);
}
@@ -1148,8 +1195,15 @@
copy_next_file (fcdata);
} else {
- if (fcdata->done_func != NULL)
- (*fcdata->done_func) (GNOME_VFS_ERROR_INTERRUPTED, fcdata->done_data);
+ if (fcdata->done_func != NULL) {
+ GError *error = NULL;
+ g_set_error (&error,
+ G_FILE_ERROR,
+ G_FILE_ERROR_INTR,
+ _("Operation interrupted"));
+ (*fcdata->done_func) (error, fcdata->done_data);
+ g_error_free (error);
+ }
file_copy_data_free (fcdata);
}
@@ -1159,8 +1213,7 @@
static void
-continue_or_abort_dialog (FileCopyData *fcdata,
- GnomeVFSResult result)
+continue_or_abort_dialog (FileCopyData *fcdata)
{
GtkWidget *d;
const char *error;
@@ -1169,7 +1222,6 @@
char *utf8_name;
gboolean last_file;
- fcdata->result = result;
src_file = fcdata->current_file->data;
if (fcdata->remove_source)
@@ -1181,7 +1233,7 @@
" ",
utf8_name,
"\n\n",
- gnome_vfs_result_to_string (result),
+ fcdata->error->message,
NULL);
g_free (utf8_name);
@@ -1225,7 +1277,7 @@
all_windows_add_monitor ();
if (fcdata->done_func != NULL)
- (*fcdata->done_func) (fcdata->result, fcdata->done_data);
+ (*fcdata->done_func) (fcdata->error, fcdata->done_data);
file_copy_data_free (fcdata);
}
@@ -1239,11 +1291,11 @@
FileCopyData *fcdata = data;
if (info->status != GNOME_VFS_XFER_PROGRESS_STATUS_OK) {
- fcdata->result = info->vfs_status;
+ set_error_from_vfs_result (info->vfs_status, &(fcdata->error));
return FALSE;
} else if (info->phase == GNOME_VFS_XFER_PHASE_COMPLETED) {
- if (fcdata->result == GNOME_VFS_OK) {
+ if (fcdata->error == NULL) {
if (! fcdata->copying_cache) { /* do not notify cache data. */
char *src_file;
char *dest_file;
@@ -1257,8 +1309,10 @@
copy_next_file (fcdata);
} else
files_copy__done (fcdata);
- } else
- continue_or_abort_dialog (fcdata, info->vfs_status);
+ } else {
+ set_error_from_vfs_result (info->vfs_status, &(fcdata->error));
+ continue_or_abort_dialog (fcdata);
+ }
}
return TRUE;
@@ -1309,10 +1363,12 @@
gnome_vfs_uri_unref (dest_uri);
g_list_free (dest_list);
+ set_error_from_vfs_result (result, &(fcdata->error));
+
/**/
- if (result != GNOME_VFS_OK)
- continue_or_abort_dialog (fcdata, result);
+ if (fcdata->error != NULL)
+ continue_or_abort_dialog (fcdata);
}
@@ -1390,7 +1446,7 @@
/**/
- fcdata->result = GNOME_VFS_OK;
+ fcdata->error = NULL;
src_file = fcdata->current_file->data;
dest_file = build_uri (fcdata->destination,
@@ -1543,10 +1599,10 @@
g_list_foreach (dest_list, (GFunc) gnome_vfs_uri_unref, NULL);
g_list_free (dest_list);
- if (result != GNOME_VFS_OK) {
- fcdata->result = result;
+ set_error_from_vfs_result (result, &(fcdata->error));
+
+ if (fcdata->error != NULL)
files_copy__done (fcdata);
- }
}
@@ -1609,6 +1665,8 @@
fcdata->done_func = done_func;
fcdata->done_data = done_data;
+ fcdata->error = NULL;
+
if (overwrite_all)
fcdata->overwrite_result = OVERWRITE_RESULT_ALL;
else
@@ -1692,8 +1750,15 @@
g_free (trash_path);
gnome_vfs_uri_unref (trash_uri);
- } else if (done_func != NULL)
- (*done_func) (GNOME_VFS_ERROR_NOT_FOUND, done_data);
+ } else if (done_func != NULL) {
+ GError *error = NULL;
+ g_set_error (&error,
+ G_FILE_ERROR,
+ G_FILE_ERROR_NOENT,
+ _("Could not find the trash folder"));
+ (*done_func) (error, done_data);
+ g_error_free (error);
+ }
gnome_vfs_uri_unref (first_uri);
}
@@ -1713,7 +1778,7 @@
GList *file_list;
FileOpDoneFunc done_func;
gpointer done_data;
- GnomeVFSResult result;
+ GError *error;
guint timeout_id;
@@ -1735,6 +1800,10 @@
gtk_widget_destroy (fddata->progress_dialog);
g_object_unref (fddata->gui);
path_list_free (fddata->file_list);
+
+ if (fddata->error != NULL)
+ g_error_free (fddata->error);
+
g_free (fddata);
}
@@ -1758,7 +1827,7 @@
static void
files_delete__done (FileDeleteData *fddata)
{
- if (fddata->result == GNOME_VFS_OK)
+ if (fddata->error == NULL)
all_windows_notify_files_deleted (fddata->file_list);
else
all_windows_notify_files_changed (fddata->file_list);
@@ -1766,7 +1835,7 @@
/*all_windows_add_monitor (); FIXME*/
if (fddata->done_func != NULL)
- (*fddata->done_func) (fddata->result, fddata->done_data);
+ (*fddata->done_func) (fddata->error, fddata->done_data);
file_delete_data_free (fddata);
}
@@ -1782,7 +1851,7 @@
float fraction;
if (info->status != GNOME_VFS_XFER_PROGRESS_STATUS_OK) {
- fddata->result = info->vfs_status;
+ set_error_from_vfs_result (info->vfs_status, &(fddata->error));
return FALSE;
} else if (info->phase == GNOME_VFS_XFER_PHASE_COLLECTING) {
@@ -1862,7 +1931,7 @@
fddata->done_func = done_func;
fddata->done_data = done_data;
- fddata->result = GNOME_VFS_OK;
+ fddata->error = NULL;
/**/
@@ -1935,10 +2004,10 @@
g_list_foreach (src_list, (GFunc) gnome_vfs_uri_unref, NULL);
g_list_free (src_list);
- if (result != GNOME_VFS_OK) {
- fddata->result = result;
+ set_error_from_vfs_result (result, &(fddata->error));
+
+ if (fddata->error != NULL)
files_delete__done (fddata);
- }
}
@@ -1964,7 +2033,7 @@
GtkWidget *progress_cancel;
GnomeVFSAsyncHandle *handle;
- GnomeVFSResult result;
+ GError *error;
} FolderCopyData;
@@ -1995,6 +2064,10 @@
g_object_unref (fcdata->gui);
g_free (fcdata->source);
g_free (fcdata->destination);
+
+ if (fcdata->error != NULL)
+ g_error_free (fcdata->error);
+
g_free (fcdata);
}
@@ -2010,7 +2083,7 @@
float fraction;
if (info->status != GNOME_VFS_XFER_PROGRESS_STATUS_OK) {
- fcdata->result = info->vfs_status;
+ set_error_from_vfs_result (info->vfs_status, &(fcdata->error));
return FALSE;
}
else if (info->phase == GNOME_VFS_XFER_PHASE_INITIAL) {
@@ -2036,7 +2109,7 @@
}
else if (info->phase == GNOME_VFS_XFER_PHASE_COMPLETED) {
- if (fcdata->result == GNOME_VFS_OK) {
+ if (fcdata->error == NULL) {
if (fcdata->file_op == FILE_OP_COPY)
all_windows_notify_directory_new (fcdata->destination);
@@ -2050,7 +2123,7 @@
destroy_progress_dialog (fcdata);
if (fcdata->done_func != NULL)
- (*fcdata->done_func) (fcdata->result, fcdata->done_data);
+ (*fcdata->done_func) (fcdata->error, fcdata->done_data);
folder_copy_data_free (fcdata);
return result;
@@ -2171,7 +2244,7 @@
fcdata->done_func = done_func;
fcdata->done_data = done_data;
- fcdata->result = GNOME_VFS_OK;
+ fcdata->error = NULL;
/**/
@@ -2266,8 +2339,16 @@
/**/
if (result != GNOME_VFS_OK) {
- if (done_func != NULL)
- (*done_func) (result, done_data);
+ g_assert (result == GNOME_VFS_ERROR_BAD_PARAMETERS);
+ if (done_func != NULL) {
+ GError *error = NULL;
+ g_set_error (&error,
+ G_IO_ERROR,
+ G_IO_ERROR_INVALID_ARGUMENT,
+ _("Invalid argument"));
+ (*done_func) (error, done_data);
+ g_error_free (error);
+ }
folder_copy_data_free (fcdata);
}
}
@@ -2333,8 +2414,15 @@
g_free (dest_folder);
gnome_vfs_uri_unref (trash_uri);
- } else if (done_func != NULL)
- (*done_func) (GNOME_VFS_ERROR_NOT_FOUND, done_data);
+ } else if (done_func != NULL) {
+ GError *error = NULL;
+ g_set_error (&error,
+ G_FILE_ERROR,
+ G_FILE_ERROR_NOENT,
+ _("Could not find the trash folder"));
+ (*done_func) (error, done_data);
+ g_error_free (error);
+ }
g_free (parent_dir);
gnome_vfs_uri_unref (parent_uri);
@@ -2388,13 +2476,13 @@
static void
-copy_item__continue2 (GnomeVFSResult result,
+copy_item__continue2 (GError *error,
gpointer data)
{
CopyItemsData *cidata = data;
if (cidata->done_func != NULL)
- (cidata->done_func) (GNOME_VFS_OK, cidata->done_data);
+ (cidata->done_func) (NULL, cidata->done_data);
copy_items_data_free (cidata);
}
@@ -2414,7 +2502,7 @@
copy_current_item (cidata);
} else {
if (cidata->done_func != NULL)
- (cidata->done_func) (GNOME_VFS_OK, cidata->done_data);
+ (cidata->done_func) (NULL, cidata->done_data);
copy_items_data_free (cidata);
}
@@ -2423,28 +2511,28 @@
static void
-copy_item__continue1 (GnomeVFSResult result,
+copy_item__continue1 (GError *error,
gpointer data)
{
CopyItemsData *cidata = data;
- if (result != GNOME_VFS_OK) {
+ if (error) {
gboolean last_item = cidata->current_item->next == NULL;
- const char *error;
+ const char *format;
char *folder = cidata->current_item->data;
char *message;
char *utf8_name;
GtkWidget *d;
if (cidata->remove_source)
- error = _("Could not move the folder \"%s\": %s");
+ format = _("Could not move the folder \"%s\": %s");
else
- error = _("Could not move the folder \"%s\": %s");
+ format = _("Could not move the folder \"%s\": %s");
utf8_name = basename_for_display (folder);
- message = g_strdup_printf (error,
+ message = g_strdup_printf (format,
utf8_name,
- gnome_vfs_result_to_string (result),
+ error->message,
NULL);
g_free (utf8_name);
@@ -2485,7 +2573,7 @@
if (cidata->current_item == NULL) {
if (cidata->file_list == NULL) {
if (cidata->done_func != NULL)
- (cidata->done_func) (GNOME_VFS_OK, cidata->done_data);
+ (cidata->done_func) (NULL, cidata->done_data);
copy_items_data_free (cidata);
} else
dlg_files_copy (cidata->window,
@@ -2560,7 +2648,7 @@
if ((cidata->dir_list == NULL) && (cidata->file_list == NULL)) {
if (done_func != NULL)
- (done_func) (GNOME_VFS_OK, done_data);
+ (done_func) (NULL, done_data);
copy_items_data_free (cidata);
return;
}
Modified: trunk/src/dlg-file-utils.h
==============================================================================
--- trunk/src/dlg-file-utils.h (original)
+++ trunk/src/dlg-file-utils.h Mon Jan 5 20:49:58 2009
@@ -44,8 +44,8 @@
/**/
-typedef void (*FileOpDoneFunc) (GnomeVFSResult result,
- gpointer data);
+typedef void (*FileOpDoneFunc) (GError *result,
+ gpointer data);
void dlg_files_copy (GthWindow *window,
GList *file_list,
Modified: trunk/src/dlg-write-to-cd.c
==============================================================================
--- trunk/src/dlg-write-to-cd.c (original)
+++ trunk/src/dlg-write-to-cd.c Mon Jan 5 20:49:58 2009
@@ -28,7 +28,6 @@
#include <glade/glade.h>
#include <libgnome/gnome-url.h>
#include <libgnome/gnome-help.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include "gth-browser.h"
#include "gtk-utils.h"
@@ -68,16 +67,16 @@
static void
-write_to_cd__continue (GnomeVFSResult result,
+write_to_cd__continue (GError *error,
gpointer user_data)
{
DialogData *data = user_data;
- if (result != GNOME_VFS_OK) {
+ if (error != NULL) {
_gtk_error_dialog_run (GTK_WINDOW (data->browser),
"%s %s",
_("Could not move the items:"),
- gnome_vfs_result_to_string (result));
+ error->message);
} else {
exec_command ("nautilus --no-default-window --no-desktop --browser burn://", NULL);
Modified: trunk/src/gth-browser-actions-callbacks.c
==============================================================================
--- trunk/src/gth-browser-actions-callbacks.c (original)
+++ trunk/src/gth-browser-actions-callbacks.c Mon Jan 5 20:49:58 2009
@@ -936,7 +936,7 @@
uri = add_scheme_if_absent (path);
result = gnome_vfs_url_show (uri);
if (result != GNOME_VFS_OK)
- _gtk_error_dialog_run (window, gnome_vfs_result_to_string (result));
+ _gtk_error_dialog_run (window, "%s", gnome_vfs_result_to_string (result));
g_free (uri);
}
@@ -1088,12 +1088,12 @@
static void
-folder_delete__continue2 (GnomeVFSResult result,
+folder_delete__continue2 (GError *error,
gpointer data)
{
FolderDeleteData *fddata = data;
- if (result != GNOME_VFS_OK) {
+ if (error != NULL) {
const char *message;
char *utf8_name;
@@ -1103,7 +1103,7 @@
_gtk_error_dialog_run (fddata->window,
message,
utf8_name,
- gnome_vfs_result_to_string (result));
+ error->message);
g_free (utf8_name);
}
@@ -1114,12 +1114,12 @@
static void
-folder_delete__continue (GnomeVFSResult result,
- gpointer data)
+folder_delete__continue (GError *error,
+ gpointer data)
{
FolderDeleteData *fddata = data;
- if (result == GNOME_VFS_ERROR_NOT_FOUND) {
+ if ((error != NULL) && (g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))) {
int r = GTK_RESPONSE_YES;
if (eel_gconf_get_boolean (PREF_MSG_CANNOT_MOVE_TO_TRASH, TRUE)) {
@@ -1153,7 +1153,7 @@
fddata);
}
else
- folder_delete__continue2 (result, data);
+ folder_delete__continue2 (error, data);
}
@@ -1211,7 +1211,7 @@
static void
-folder_copy__continue (GnomeVFSResult result,
+folder_copy__continue (GError *error,
gpointer data)
{
GtkWidget *file_sel = data;
@@ -1221,7 +1221,7 @@
window = g_object_get_data (G_OBJECT (file_sel), "gthumb_window");
new_path = g_object_get_data (G_OBJECT (file_sel), "new_path");
- if (result != GNOME_VFS_OK) {
+ if (error != NULL) {
const char *message;
char *utf8_name;
@@ -1231,7 +1231,7 @@
_gtk_error_dialog_run (NULL,
message,
utf8_name,
- gnome_vfs_result_to_string (result));
+ error->message);
g_free (utf8_name);
}
else if (gth_folder_selection_get_goto_destination (GTH_FOLDER_SELECTION (file_sel)))
Modified: trunk/src/gth-browser.c
==============================================================================
--- trunk/src/gth-browser.c (original)
+++ trunk/src/gth-browser.c Mon Jan 5 20:49:58 2009
@@ -3727,16 +3727,16 @@
static void
-move_items__continue (GnomeVFSResult result,
+move_items__continue (GError *error,
gpointer data)
{
GthBrowser *browser = data;
- if (result != GNOME_VFS_OK)
+ if (error != NULL)
_gtk_error_dialog_run (GTK_WINDOW (browser),
"%s %s",
_("Could not move the items:"),
- gnome_vfs_result_to_string (result));
+ error->message);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]