[gthumb] Added gfile_list_new, to slowly replace path_list_new and friends
- From: Michael J. Chudobiak <mjc src gnome org>
- To: svn-commits-list gnome org
- Subject: [gthumb] Added gfile_list_new, to slowly replace path_list_new and friends
- Date: Wed, 10 Jun 2009 16:25:11 -0400 (EDT)
commit 4b0997a05494e4565c4079937e025b0f9ead1550
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date: Wed Jun 10 16:24:47 2009 -0400
Added gfile_list_new, to slowly replace path_list_new and friends
---
libgthumb/gfile-utils.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++
libgthumb/gfile-utils.h | 4 +++
src/dlg-web-exporter.c | 18 ++++++------
3 files changed, 76 insertions(+), 9 deletions(-)
diff --git a/libgthumb/gfile-utils.c b/libgthumb/gfile-utils.c
index f69004a..74e9798 100644
--- a/libgthumb/gfile-utils.c
+++ b/libgthumb/gfile-utils.c
@@ -778,6 +778,69 @@ gfile_path_list_new (GFile *gfile,
}
+gboolean
+gfile_list_new (GFile *gfile,
+ GList **files,
+ GList **dirs)
+{
+ GFileEnumerator *file_enum;
+ GFileInfo *info;
+ GList *f_list = NULL;
+ GList *d_list = NULL;
+ GError *error = NULL;
+
+ file_enum = g_file_enumerate_children (gfile,
+ G_FILE_ATTRIBUTE_STANDARD_NAME ","
+ G_FILE_ATTRIBUTE_STANDARD_TYPE,
+ 0, NULL, &error);
+
+ if (error != NULL) {
+ gfile_warning ("Error while reading contents of directory", gfile, error);
+ g_error_free (error);
+ return FALSE;
+ }
+
+ while ((info = g_file_enumerator_next_file (file_enum, NULL, NULL)) != NULL) {
+ GFile *child;
+ child = g_file_get_child (gfile, g_file_info_get_name (info));
+
+ switch (g_file_info_get_file_type (info)) {
+ case G_FILE_TYPE_DIRECTORY:
+ if (dirs) {
+ d_list = g_list_prepend (d_list, gfile);
+ }
+ break;
+ case G_FILE_TYPE_REGULAR:
+ if (files) {
+ f_list = g_list_prepend (f_list, gfile);
+ }
+ break;
+ default:
+ g_object_unref (child);
+ break;
+ }
+
+ g_object_unref (info);
+ }
+
+ if (dirs)
+ *dirs = g_list_reverse (d_list);
+ else
+ gfile_list_free (d_list);
+
+ if (files) {
+ *files = g_list_reverse (f_list);
+ }
+ else
+ gfile_list_free (f_list);
+
+ g_object_unref (file_enum);
+
+ return TRUE;
+}
+
+
+
/* Xfer */
static void _empty_file_progress_cb (goffset current_num_bytes,
diff --git a/libgthumb/gfile-utils.h b/libgthumb/gfile-utils.h
index adee090..063f249 100644
--- a/libgthumb/gfile-utils.h
+++ b/libgthumb/gfile-utils.h
@@ -93,6 +93,10 @@ gboolean gfile_dir_remove_recursive (GFile *dir);
gboolean gfile_path_list_new (GFile *gfile,
GList **files,
GList **dirs);
+gboolean gfile_list_new (GFile *gfile,
+ GList **files,
+ GList **dirs);
+
/* Xfer */
gboolean gfile_xfer (GFile *sfile,
diff --git a/src/dlg-web-exporter.c b/src/dlg-web-exporter.c
index d55d31a..dac0285 100644
--- a/src/dlg-web-exporter.c
+++ b/src/dlg-web-exporter.c
@@ -648,31 +648,31 @@ static void
add_theme_dir (ThemeDialogData *tdata,
char *theme_dir)
{
- GList *dir_list = NULL;
- GList *scan;
+ GList *dir_list = NULL;
+ GList *scan;
+ GFile *theme_dir_gfile;
debug (DEBUG_INFO, "theme dir: %s", theme_dir);
- if (path_is_dir (theme_dir))
- path_list_new (theme_dir, NULL, &dir_list);
+ theme_dir_gfile = gfile_new (theme_dir);
+ if (gfile_is_dir (theme_dir_gfile))
+ gfile_list_new (theme_dir_gfile, NULL, &dir_list);
for (scan = dir_list; scan; scan = scan->next) {
GtkTreeIter iter;
- char *dir = scan->data;
+ GFile *gfile = scan->data;
char *display_name;
- GFile *gfile;
- gfile = gfile_new (dir);
display_name = gfile_get_display_name (gfile);
gtk_list_store_append (tdata->list_store, &iter);
gtk_list_store_set (tdata->list_store, &iter,
THEME_NAME_COLUMN, display_name,
-1);
- g_object_unref (gfile);
+
g_free (display_name);
}
- path_list_free (dir_list);
+ gfile_list_free (dir_list);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]