diff --git a/libgthumb/gth-monitor.c b/libgthumb/gth-monitor.c index 66766e7..3e77c99 100644 --- a/libgthumb/gth-monitor.c +++ b/libgthumb/gth-monitor.c @@ -506,27 +506,16 @@ void gth_monitor_notify_update_gfiles (GthMonitorEvent event, GList *list) { - GList *path_list = NULL; - GList *scan; - g_return_if_fail (GTH_IS_MONITOR (instance)); if (list == NULL) return; - /* FIXME: use gfile list in signals */ - for (scan = list; scan; scan = scan->next) { - GFile *gfile = scan->data; - path_list = g_list_prepend (path_list, g_file_get_parse_name (gfile)); - } - g_signal_emit (G_OBJECT (instance), monitor_signals[UPDATE_FILES], 0, event, - path_list); - - path_list_free (path_list); + list); } @@ -534,17 +523,26 @@ void gth_monitor_notify_update_files (GthMonitorEvent event, GList *list) { + GList *gfile_list = NULL; + GList *scan; + g_return_if_fail (GTH_IS_MONITOR (instance)); if (list == NULL) return; - /* FIXME: start using the above gfile equivalent */ + for (scan = list; scan; scan = scan->next) { + char *path = scan->data; + gfile_list = g_list_prepend (gfile_list, gfile_new (path)); + } + g_signal_emit (G_OBJECT (instance), monitor_signals[UPDATE_FILES], 0, event, - list); + gfile_list); + + gfile_list_free (gfile_list); } diff --git a/src/gth-browser.c b/src/gth-browser.c index f241311..5ed4e16 100644 --- a/src/gth-browser.c +++ b/src/gth-browser.c @@ -5474,29 +5474,30 @@ gth_browser_notify_files_created (GthBrowser *browser, GList *list) { GthBrowserPrivateData *priv = browser->priv; - char *current_dir; + GFile *current_dir; GList *created_in_current_dir = NULL; GList *scan; if (priv->sidebar_content != GTH_SIDEBAR_DIR_LIST) return; - current_dir = add_scheme_if_absent (priv->dir_list->path); - if (current_dir == NULL) + if (priv->dir_list->path == NULL) return; + current_dir = gfile_new (priv->dir_list->path); + for (scan = list; scan; scan = scan->next) { - char *path = scan->data; - char *parent_dir; + GFile *gfile = scan->data; + GFile *parent_dir; - parent_dir = remove_level_from_path (path); + parent_dir = g_file_get_parent (gfile); if (parent_dir == NULL) continue; - if (same_uri (parent_dir, current_dir)) { + if (g_file_equal (parent_dir, current_dir)) { FileData *file; - file = file_data_new_from_path (path); + file = file_data_new_from_gfile (gfile); if (file_filter (file, browser->priv->show_hidden_files, browser->priv->show_only_images, @@ -5506,13 +5507,15 @@ gth_browser_notify_files_created (GthBrowser *browser, file_data_unref (file); } - g_free (parent_dir); + g_object_unref (parent_dir); } if (created_in_current_dir != NULL) { gth_file_list_add_list (browser->priv->file_list, created_in_current_dir); file_data_list_free (created_in_current_dir); } + + g_object_unref (current_dir); } @@ -5521,9 +5524,17 @@ gth_browser_notify_files_deleted (GthBrowser *browser, GList *list) { GthBrowserPrivateData *priv = browser->priv; + GList *path_list = NULL; + GList *scan; g_return_if_fail (browser != NULL); + /* FIXME: should use all-gfile approach */ + for (scan = list; scan; scan = scan->next) { + GFile *gfile = scan->data; + path_list = g_list_prepend (path_list, g_file_get_parse_name (gfile)); + } + if ((priv->sidebar_content == GTH_SIDEBAR_CATALOG_LIST) && (priv->catalog_path != NULL)) { /* update the catalog. */ Catalog *catalog; @@ -5531,14 +5542,15 @@ gth_browser_notify_files_deleted (GthBrowser *browser, catalog = catalog_new (); if (catalog_load_from_disk (catalog, priv->catalog_path, NULL)) { - for (scan = list; scan; scan = scan->next) + for (scan = path_list; scan; scan = scan->next) catalog_remove_item (catalog, (char*) scan->data); catalog_write_to_disk (catalog, NULL); } catalog_free (catalog); } - gth_file_list_delete_list (browser->priv->file_list, list); + gth_file_list_delete_list (browser->priv->file_list, path_list); + path_list_free (path_list); } @@ -5548,14 +5560,21 @@ gth_browser_notify_files_changed (GthBrowser *browser, { GthBrowserPrivateData *priv = browser->priv; GList *absent_files = NULL, *scan; + GList *path_list = NULL; + + /* FIXME: should use all-gfile approach */ + for (scan = list; scan; scan = scan->next) { + GFile *gfile = scan->data; + path_list = g_list_prepend (path_list, g_file_get_parse_name (gfile)); + } - gth_file_list_update_thumb_list (priv->file_list, list); + gth_file_list_update_thumb_list (priv->file_list, path_list); /* update the current image if has changed. */ if ((priv->image != NULL) && ! priv->image_modified - && (path_list_find_path (list, priv->image->utf8_path) != NULL)) { + && (gfile_list_find_gfile (list, priv->image->gfile) != NULL)) { int pos; pos = gth_file_list_pos_from_path (priv->file_list, priv->image->utf8_path); @@ -5566,21 +5585,24 @@ gth_browser_notify_files_changed (GthBrowser *browser, /* add to the file list the changed files not included in the list. */ for (scan = list; scan; scan = scan->next) { - char *filename = scan->data; + GFile *gfile = scan->data; + char *filename = g_file_get_parse_name (gfile); FileData *fd; + /* FIXME: use gfile function here? */ fd = gth_file_list_filedata_from_path (priv->file_list, filename, NULL); if (fd != NULL) { file_data_unref (fd); continue; } - absent_files = g_list_prepend (absent_files, filename); + absent_files = g_list_prepend (absent_files, gfile); + g_object_ref (gfile); } if (absent_files != NULL) { gth_browser_notify_files_created (browser, absent_files); - g_list_free (absent_files); + gfile_list_free (absent_files); } } @@ -5598,8 +5620,8 @@ monitor_update_files_cb (GthMonitor *monitor, debug (DEBUG_INFO, "%s:\n", event_name[event]); for (scan = list; scan; scan = scan->next) { - char *filename = scan->data; - debug (DEBUG_INFO, "%s\n", filename); + GFile *gfile = scan->data; + gfile_debug (DEBUG_INFO, "affected file:", gfile); } switch (event) { diff --git a/src/gth-fullscreen.c b/src/gth-fullscreen.c index 1a33ff6..164b6ed 100644 --- a/src/gth-fullscreen.c +++ b/src/gth-fullscreen.c @@ -35,6 +35,7 @@ #include "dlg-file-utils.h" #include "file-utils.h" #include "gconf-utils.h" +#include "gfile-utils.h" #include "glib-utils.h" #include "gtk-utils.h" #include "gth-exif-utils.h" @@ -1369,7 +1370,7 @@ delete_list_from_file_list (GthFullscreen *fullscreen, FileData *file; GList *deleted; - file = file_data_new_from_path (scan->data); + file = file_data_new_from_gfile ((GFile *) (scan->data)); deleted = g_list_find_custom (fullscreen->priv->file_list, file, (GCompareFunc) filedatacmp); @@ -1403,6 +1404,9 @@ monitor_update_cat_files_cb (GthMonitor *monitor, GList *list, GthFullscreen *fullscreen) { + GList *gfile_list = NULL; + GList *scan; + if (fullscreen->priv->catalog_path == NULL) return; if (! same_uri (fullscreen->priv->catalog_path, catalog_name)) /* FIXME */ @@ -1410,7 +1414,16 @@ monitor_update_cat_files_cb (GthMonitor *monitor, switch (event) { case GTH_MONITOR_EVENT_DELETED: - delete_list_from_file_list (fullscreen, list); + + /* FIXME: should use gfiles to start with */ + for (scan = list; scan; scan = scan->next) { + char *path = scan->data; + gfile_list = g_list_prepend (gfile_list, gfile_new (path)); + } + + delete_list_from_file_list (fullscreen, gfile_list); + gfile_list_free (gfile_list); + break; default: break; @@ -1433,9 +1446,7 @@ monitor_update_files_cb (GthMonitor *monitor, case GTH_MONITOR_EVENT_CREATED: case GTH_MONITOR_EVENT_CHANGED: if ((fullscreen->priv->file != NULL) - && (g_list_find_custom (list, - fullscreen->priv->file->utf8_path, - (GCompareFunc) uricmp) != NULL)) + && (gfile_list_find_gfile (list, fullscreen->priv->file->gfile) != NULL)) { file_data_unref (fullscreen->priv->file); fullscreen->priv->file = NULL; @@ -1444,9 +1455,7 @@ monitor_update_files_cb (GthMonitor *monitor, } if (fullscreen->priv->current != NULL) { FileData *current_file = fullscreen->priv->current->data; - if (g_list_find_custom (list, - current_file->utf8_path, - (GCompareFunc) uricmp) != NULL) + if (gfile_list_find_gfile (list, current_file->gfile) != NULL) { load_current_image (fullscreen); } diff --git a/src/gth-viewer.c b/src/gth-viewer.c index 59dd66b..afe61e5 100644 --- a/src/gth-viewer.c +++ b/src/gth-viewer.c @@ -36,6 +36,7 @@ #include "file-data.h" #include "file-utils.h" #include "gconf-utils.h" +#include "gfile-utils.h" #include "glib-utils.h" #include "gth-viewer.h" #include "gth-viewer-ui.h" @@ -1214,9 +1215,7 @@ monitor_update_files_cb (GthMonitor *monitor, if (viewer->priv->image == NULL) return; - if (g_list_find_custom (list, - viewer->priv->image->utf8_path, - (GCompareFunc) uricmp) == NULL) + if (gfile_list_find_gfile (list, viewer->priv->image->gfile) == NULL) return; switch (event) {