[gthumb] GIO Fixes to allow remote mount browsing - bug 525482
- From: Michael J. Chudobiak <mjc src gnome org>
- To: svn-commits-list gnome org
- Subject: [gthumb] GIO Fixes to allow remote mount browsing - bug 525482
- Date: Thu, 4 Jun 2009 09:40:27 -0400 (EDT)
commit 57cb9a61e25ad156d2bd4f0b4df2d766e10b2399
Author: Marlodavampire <brooss teambb gmail com>
Date: Thu Jun 4 09:39:57 2009 -0400
GIO Fixes to allow remote mount browsing - bug 525482
Change path_list_classify_files_cb to use g_file_enumerator_get_next_file_async
Remove local file restriction from update_drives
---
libgthumb/file-utils.c | 48 +++++++++++++++++++++++++++++++++++++-----------
libgthumb/file-utils.h | 3 ++-
src/gth-location.c | 5 -----
3 files changed, 39 insertions(+), 17 deletions(-)
diff --git a/libgthumb/file-utils.c b/libgthumb/file-utils.c
index 303d892..4d23bba 100644
--- a/libgthumb/file-utils.c
+++ b/libgthumb/file-utils.c
@@ -127,7 +127,7 @@ path_list_data_free (PathListData *pli)
/* This function should be called by g_idle_add().
* It will add ITEMS_PER_NOTIFICATION per call to pli->files
- * and return TRUE until all files are add or
+ * and return TRUE until all files are added or
* pli->cancelled is cancelled.
* On completion pli->done_func (gth_dir_list_change_to__step2)
* is called and FALSE is returned.
@@ -137,15 +137,14 @@ path_list_classify_files_cb (gpointer data)
{
GFile *child=NULL;
GFileInfo *info;
- GError *error=NULL;
char *uri_txt;
FileData *file;
int count=0;
PathListData *pli = (PathListData *) data;
- info = g_file_enumerator_next_file (pli->gfile_enum, NULL, &error);
- while ((!(info == NULL)) && !g_cancellable_is_cancelled(pli->cancelled)) {
+ while ((!(pli->current_file == NULL)) && !g_cancellable_is_cancelled(pli->cancelled)) {
count++;
+ info = pli->current_file->data;
switch (g_file_info_get_file_type (info)) {
case G_FILE_TYPE_REGULAR:
child = g_file_get_child (pli->gfile, g_file_info_get_name (info));
@@ -168,15 +167,15 @@ path_list_classify_files_cb (gpointer data)
break;
}
- if (count == ITEMS_PER_NOTIFICATION)
+ g_object_unref(info);
+ pli->current_file=pli->current_file->next;
+
+ if (count == ITEMS_PER_NOTIFICATION)
return TRUE;
- else
- info = g_file_enumerator_next_file (pli->gfile_enum, NULL, &error);
}
-
if (pli->done_func) {
-
- /* pli is deallocated in pli->done_func */
+ // pli is deallocated in pli->done_func
+ g_list_free(pli->file_list);
pli->done_func (pli, pli->done_data);
return FALSE;
}
@@ -184,6 +183,28 @@ path_list_classify_files_cb (gpointer data)
return FALSE;
}
+/* Callback for g_file_enumerate_children_finish
+ * Calls path_list_classify through an idle callback
+ * */
+static void
+path_list_next_files_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer data)
+{
+ GError *error=NULL;
+ PathListData *pli = (PathListData *) data;
+
+ pli->file_list = g_file_enumerator_next_files_finish (pli->gfile_enum, res ,&error);
+ if (pli->error != NULL) {
+ if (pli->done_func) {
+ /* pli is deallocated in pli->done_func */
+ pli->done_func (pli, pli->done_data);
+ }
+ return;
+ }
+ pli->current_file = pli->file_list;
+ g_idle_add(path_list_classify_files_cb, pli);
+}
static void
directory_load_cb (GObject *source_object,
@@ -202,7 +223,12 @@ directory_load_cb (GObject *source_object,
}
else {
g_cancellable_reset (pli->cancelled);
- g_idle_add (path_list_classify_files_cb, pli);
+ g_file_enumerator_next_files_async (pli->gfile_enum,
+ G_MAXINT,
+ G_PRIORITY_DEFAULT,
+ pli->cancelled,
+ path_list_next_files_cb,
+ pli);
}
}
diff --git a/libgthumb/file-utils.h b/libgthumb/file-utils.h
index 3b3a257..0f066ca 100644
--- a/libgthumb/file-utils.h
+++ b/libgthumb/file-utils.h
@@ -60,6 +60,8 @@ struct _PathListData {
GHashTable *hidden_files;
gboolean fast_file_type;
GError *error;
+ GList *file_list;
+ GList *current_file;
};
typedef struct {
@@ -74,7 +76,6 @@ PathListHandle * path_list_async_new (const char *uri,
PathListDoneFunc done_func,
gpointer done_data);
void path_list_async_interrupt (PathListHandle *handle);
-gboolean path_list_classify_files_cb (gpointer data);
gboolean path_list_new (const char *path,
GList **files,
GList **dirs);
diff --git a/src/gth-location.c b/src/gth-location.c
index 94b7528..1b7db69 100644
--- a/src/gth-location.c
+++ b/src/gth-location.c
@@ -618,11 +618,6 @@ update_drives (GthLocation *loc)
gfile = g_mount_get_root (mount);
- if (! gfile_is_local (gfile)) {
- g_object_unref (gfile);
- continue;
- }
-
pixbuf = get_mount_icon (loc, mount);
uri_name = g_mount_get_name (mount);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]