[gthumb] GIO Fix error passing on directory load - bug 525482
- From: Michael J. Chudobiak <mjc src gnome org>
- To: svn-commits-list gnome org
- Subject: [gthumb] GIO Fix error passing on directory load - bug 525482
- Date: Thu, 4 Jun 2009 09:34:19 -0400 (EDT)
commit 1b094bdb30c4b4ccd54affcafbc4c1e8a17006d5
Author: Marlodavampire <brooss teambb gmail com>
Date: Thu Jun 4 09:33:42 2009 -0400
GIO Fix error passing on directory load - bug 525482
Replace GnomeVFSResult with GError for dir_list_done_cb,
gth_dir_list_change_to__step2 and directory_load_cb
Remove unused GnomeVFS includes
---
libgthumb/file-utils.c | 22 +++++++++++++++-------
libgthumb/file-utils.h | 5 +++--
src/gth-browser.c | 12 ++++++------
src/gth-dir-list.c | 16 ++++++++++++----
4 files changed, 36 insertions(+), 19 deletions(-)
diff --git a/libgthumb/file-utils.c b/libgthumb/file-utils.c
index 660a802..303d892 100644
--- a/libgthumb/file-utils.c
+++ b/libgthumb/file-utils.c
@@ -87,7 +87,7 @@ path_list_data_new (void)
pli->done_func = NULL;
pli->done_data = NULL;
pli->hidden_files = NULL;
-
+ pli->error = NULL;
return pli;
}
@@ -120,6 +120,8 @@ path_list_data_free (PathListData *pli)
if (pli->hidden_files != NULL)
g_hash_table_unref (pli->hidden_files);
+ if (pli->error != NULL)
+ g_error_free (pli->error);
g_free (pli);
}
@@ -190,12 +192,18 @@ directory_load_cb (GObject *source_object,
{
PathListData *pli;
pli = (PathListData *) data;
- GError *error = NULL;
-
- pli->gfile_enum = g_file_enumerate_children_finish (pli->gfile, res, &error);
-
- g_cancellable_reset (pli->cancelled);
- g_idle_add (path_list_classify_files_cb, pli);
+ pli->gfile_enum = g_file_enumerate_children_finish (pli->gfile, res, &pli->error);
+ if (pli->error != NULL) {
+ if (pli->done_func) {
+ /* pli is deallocated in pli->done_func */
+ pli->done_func (pli, pli->done_data);
+ }
+ return;
+ }
+ else {
+ g_cancellable_reset (pli->cancelled);
+ g_idle_add (path_list_classify_files_cb, pli);
+ }
}
diff --git a/libgthumb/file-utils.h b/libgthumb/file-utils.h
index b7724f6..3b3a257 100644
--- a/libgthumb/file-utils.h
+++ b/libgthumb/file-utils.h
@@ -59,6 +59,7 @@ struct _PathListData {
GCancellable *cancelled;
GHashTable *hidden_files;
gboolean fast_file_type;
+ GError *error;
};
typedef struct {
@@ -121,8 +122,8 @@ gboolean file_move (const char *from,
const char *to,
gboolean overwrite,
GError **error);
-void file_unlink_with_gerror (const char *full_path,
- GError **gerror);
+void file_unlink_with_gerror (const char *full_path,
+ GError **gerror);
gboolean file_unlink (const char *path);
void delete_thumbnail (const char *path);
gboolean mime_type_is (const char *mime_type,
diff --git a/src/gth-browser.c b/src/gth-browser.c
index 6ecfb06..64b6b7f 100644
--- a/src/gth-browser.c
+++ b/src/gth-browser.c
@@ -28,7 +28,6 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
-#include <libgnomevfs/gnome-vfs-result.h>
#include <glade/glade.h>
#include "bookmarks.h"
@@ -6168,9 +6167,9 @@ dir_list_started_cb (GthDirList *dir_list,
static void
-dir_list_done_cb (GthDirList *dir_list,
- GnomeVFSResult result,
- gpointer data)
+dir_list_done_cb (GthDirList *dir_list,
+ GError *error,
+ gpointer data)
{
GthBrowser *browser = data;
GthBrowserPrivateData *priv = browser->priv;
@@ -6178,7 +6177,7 @@ dir_list_done_cb (GthDirList *dir_list,
gth_browser_stop_activity_mode (browser);
- if (result != GNOME_VFS_ERROR_EOF) {
+ if (error != NULL) {
char *utf8_path;
char *parent_dir = NULL;
@@ -6186,8 +6185,9 @@ dir_list_done_cb (GthDirList *dir_list,
_gtk_error_dialog_run (GTK_WINDOW (browser),
_("Cannot load folder \"%s\": %s\n"),
utf8_path,
- gnome_vfs_result_to_string (result));
+ error->message);
g_free (utf8_path);
+ g_error_free (error);
set_cursor_not_busy (browser, TRUE);
priv->refreshing = FALSE;
diff --git a/src/gth-dir-list.c b/src/gth-dir-list.c
index d5a4d18..5a93b6b 100644
--- a/src/gth-dir-list.c
+++ b/src/gth-dir-list.c
@@ -24,7 +24,6 @@
#include <string.h>
#include <strings.h>
#include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs-result.h>
#include "typedefs.h"
#include "gth-dir-list.h"
#include "gth-file-list.h"
@@ -99,9 +98,9 @@ gth_dir_list_class_init (GthDirListClass *class)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GthDirListClass, done),
NULL, NULL,
- gthumb_marshal_VOID__INT,
+ g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
- G_TYPE_INT);
+ G_TYPE_POINTER);
object_class = G_OBJECT_CLASS (class);
object_class->finalize = gth_dir_list_finalize;
@@ -452,6 +451,7 @@ gth_dir_list_change_to__step2 (PathListData *pld,
GList *new_dir_list = NULL;
GList *new_file_list = NULL;
GList *filtered;
+ GError *error=NULL;
g_return_if_fail (pld != NULL);
@@ -461,6 +461,14 @@ gth_dir_list_change_to__step2 (PathListData *pld,
g_free (dir_list->dir_load_handle);
dir_list->dir_load_handle = NULL;
}
+
+
+ if (pld->error != NULL) {
+ error = g_error_copy (pld->error);
+ path_list_data_free (pld);
+ g_signal_emit (dir_list, gth_dir_list_signals[DONE], 0, error);
+ return;
+ }
/* Update path data. */
@@ -559,7 +567,7 @@ gth_dir_list_change_to__step2 (PathListData *pld,
dir_list->old_dir = NULL;
}
- g_signal_emit (dir_list, gth_dir_list_signals[DONE], 0, GNOME_VFS_ERROR_EOF);
+ g_signal_emit (dir_list, gth_dir_list_signals[DONE], 0, error);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]