replaced directory path with FileData* dir_fd
authorVladimir Nadvornik <nadvornik@suse.cz>
Tue, 3 Jun 2008 19:44:19 +0000 (19:44 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Tue, 3 Jun 2008 19:44:19 +0000 (19:44 +0000)
43 files changed:
src/bar_sort.c
src/cache_maint.c
src/collect-io.c
src/collect-table.c
src/dupe.c
src/filedata.c
src/filedata.h
src/image-overlay.c
src/img-view.c
src/layout.c
src/layout.h
src/layout_image.c
src/layout_util.c
src/main.c
src/pan-calendar.c
src/pan-folder.c
src/pan-grid.c
src/pan-item.c
src/pan-timeline.c
src/pan-types.h
src/pan-util.c
src/pan-view.c
src/pan-view.h
src/remote.c
src/search.c
src/search.h
src/slideshow.c
src/trash.c
src/typedefs.h
src/utilops.c
src/utilops.h
src/view_dir.c
src/view_dir.h
src/view_dir_list.c
src/view_dir_list.h
src/view_dir_tree.c
src/view_dir_tree.h
src/view_file.c
src/view_file.h
src/view_file_icon.c
src/view_file_icon.h
src/view_file_list.c
src/view_file_list.h

index e76069d..f530540 100644 (file)
@@ -89,6 +89,7 @@ static void bar_sort_add_close(SortData *sd);
 static void bar_sort_collection_list_build(GtkWidget *bookmarks)
 {
        gchar *collect_path;
+       FileData *dir_fd;
        GList *list;
        GList *work;
 
@@ -96,7 +97,9 @@ static void bar_sort_collection_list_build(GtkWidget *bookmarks)
        bookmark_list_set_key(bookmarks, SORT_KEY_COLLECTIONS);
 
        collect_path = g_build_filename(homedir(), GQ_RC_DIR_COLLECTIONS, NULL);
-       filelist_read(collect_path, &list, NULL);
+       dir_fd = file_data_new_simple(collect_path);
+       filelist_read(dir_fd, &list, NULL);
+       file_data_unref(dir_fd);
        g_free(collect_path);
 
        list = filelist_sort_path(list);
index 81bb15a..fd7a58c 100644 (file)
@@ -173,7 +173,7 @@ static gint cache_maintain_home_cb(gpointer data)
                {
                cm->done_list = g_list_prepend(cm->done_list, fd);
 
-               if (filelist_read(fd->path, &list, &dlist))
+               if (filelist_read(fd, &list, &dlist))
                        {
                        GList *work;
 
@@ -276,6 +276,7 @@ void cache_maintain_home(gint metadata, gint clear, GtkWidget *parent)
        CMData *cm;
        GList *dlist;
        gchar *base;
+       FileData *dir_fd;
        const gchar *msg;
        const gchar *cache_folder;
        GtkWidget *hbox;
@@ -290,14 +291,16 @@ void cache_maintain_home(gint metadata, gint clear, GtkWidget *parent)
                }
 
        base = g_build_filename(homedir(), cache_folder, NULL);
-       
-       if (!filelist_read(base, NULL, &dlist))
+       dir_fd = file_data_new_simple(base);
+       if (!filelist_read(dir_fd, NULL, &dlist))
                {
                g_free(base);
+               file_data_unref(dir_fd);
                return;
                }
 
-       dlist = g_list_append(dlist, file_data_new_simple(base));
+       dlist = g_list_append(dlist, dir_fd);
+       g_free(base);
 
        cm = g_new0(CMData, 1);
        cm->list = dlist;
@@ -361,6 +364,7 @@ gint cache_maintain_home_dir(const gchar *dir, gint recursive, gint clear)
        gchar *base;
        gint base_length;
        GList *dlist = NULL;
+       FileData *dir_fd;
        GList *flist = NULL;
        gint still_have_a_file = FALSE;
 
@@ -368,8 +372,10 @@ gint cache_maintain_home_dir(const gchar *dir, gint recursive, gint clear)
 
        base_length = strlen(homedir()) + strlen("/") + strlen(GQ_CACHE_RC_THUMB);
        base = g_strconcat(homedir(), "/", GQ_CACHE_RC_THUMB, dir, NULL);
+       dir_fd = file_data_new_simple(base);
+       g_free(base);
 
-       if (filelist_read(base, &flist, &dlist))
+       if (filelist_read(dir_fd, &flist, &dlist))
                {
                GList *work;
 
@@ -421,7 +427,7 @@ gint cache_maintain_home_dir(const gchar *dir, gint recursive, gint clear)
 
        filelist_free(dlist);
        filelist_free(flist);
-       g_free(base);
+       file_data_unref(dir_fd);
 
        return still_have_a_file;
 }
@@ -429,16 +435,19 @@ gint cache_maintain_home_dir(const gchar *dir, gint recursive, gint clear)
 /* This checks relative caches in dir/.thumbnails and
  * removes them if they have no source counterpart.
  */
-gint cache_maintain_dir(const gchar *dir, gint recursive, gint clear)
+gint cache_maintain_dir(FileData *dir_fd, gint recursive, gint clear)
 {
        GList *list = NULL;
        gchar *cachedir;
+       FileData *cachedir_fd;
        gint still_have_a_file = FALSE;
        GList *work;
 
        cachedir = g_build_filename(dir, GQ_CACHE_LOCAL_THUMB, NULL);
+       cachedir_fd = file_data_new_simple(cachedir);
+       g_free(cachedir);
 
-       filelist_read(cachedir, &list, NULL);
+       filelist_read(cachedir_fd, &list, NULL);
        work = list;
 
        while (work)
@@ -449,7 +458,7 @@ gint cache_maintain_dir(const gchar *dir, gint recursive, gint clear)
                fd = work->data;
                work = work->next;
 
-               source = g_build_filename(dir, fd->name, NULL);
+               source = g_build_filename(dir->path, fd->name, NULL);
 
                if (clear ||
                    extension_truncate(source, GQ_CACHE_EXT_THUMB) ||
@@ -476,13 +485,13 @@ gint cache_maintain_dir(const gchar *dir, gint recursive, gint clear)
                }
 
        filelist_free(list);
-       g_free(cachedir);
+       file_data_unref(cachedir_fd);
 
        if (recursive)
                {
                list = NULL;
 
-               filelist_read(dir, NULL, &list);
+               filelist_read(dir_fd, NULL, &list);
                work = list;
                while (work)
                        {
@@ -708,18 +717,18 @@ static void cache_manager_render_stop_cb(GenericDialog *fd, gpointer data)
        cache_manager_render_finish(cd);
 }
 
-static void cache_manager_render_folder(CleanData *cd, const gchar *path)
+static void cache_manager_render_folder(CleanData *cd, FileData *dir_fd)
 {
        GList *list_d = NULL;
        GList *list_f = NULL;
 
        if (cd->recurse)
                {
-               filelist_read(path, &list_f, &list_d);
+               filelist_read(dir_fd, &list_f, &list_d);
                }
        else
                {
-               filelist_read(path, &list_f, NULL);
+               filelist_read(dir_fd, &list_f, NULL);
                }
 
        list_f = filelist_filter(list_f, FALSE);
@@ -779,7 +788,7 @@ static gint cache_manager_render_file(CleanData *cd)
                fd = cd->list_dir->data;
                cd->list_dir = g_list_remove(cd->list_dir, fd);
 
-               cache_manager_render_folder(cd, fd->path);
+               cache_manager_render_folder(cd, fd);
 
                file_data_unref(fd);
 
@@ -809,6 +818,7 @@ static void cache_manager_render_start_cb(GenericDialog *fd, gpointer data)
                }
        else
                {
+               FileData *dir_fd;
                gtk_widget_set_sensitive(cd->group, FALSE);
                gtk_widget_set_sensitive(cd->button_start, FALSE);
                gtk_widget_set_sensitive(cd->button_stop, TRUE);
@@ -816,7 +826,9 @@ static void cache_manager_render_start_cb(GenericDialog *fd, gpointer data)
 
                spinner_set_interval(cd->spinner, SPINNER_SPEED);
 
-               cache_manager_render_folder(cd, path);
+               dir_fd = file_data_new_simple(path);
+               cache_manager_render_folder(cd, dir_fd);
+               file_data_unref(dir_fd);
                while (cache_manager_render_file(cd));
                }
 
@@ -1001,6 +1013,7 @@ static void cache_manager_standard_clean_start_cb(GenericDialog *gd, gpointer da
        CleanData *cd = data;
        GList *list;
        gchar *path;
+       FileData *dir_fd;
 
        if (cd->list || !GTK_WIDGET_SENSITIVE(cd->button_start)) return;
 
@@ -1011,18 +1024,24 @@ static void cache_manager_standard_clean_start_cb(GenericDialog *gd, gpointer da
        gtk_progress_bar_set_text(GTK_PROGRESS_BAR(cd->progress), _("running..."));
 
        path = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, THUMB_FOLDER_NORMAL, NULL);
-       filelist_read(path, &list, NULL);
+       dir_fd = file_data_new_simple(path);
+       filelist_read(dir_fd, &list, NULL);
        cd->list = list;
+       file_data_unref(dir_fd);
        g_free(path);
 
        path = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, THUMB_FOLDER_LARGE, NULL);
-       filelist_read(path, &list, NULL);
+       dir_fd = file_data_new_simple(path);
+       filelist_read(dir_fd, &list, NULL);
        cd->list = g_list_concat(cd->list, list);
+       file_data_unref(dir_fd);
        g_free(path);
 
        path = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, THUMB_FOLDER_FAIL, NULL);
-       filelist_read(path, &list, NULL);
+       dir_fd = file_data_new_simple(path);
+       filelist_read(dir_fd, &list, NULL);
        cd->list = g_list_concat(cd->list, list);
+       file_data_unref(dir_fd);
        g_free(path);
 
        cd->count_total = g_list_length(cd->list);
index 29e2560..f9d10e3 100644 (file)
@@ -668,9 +668,12 @@ static void collect_manager_refresh(void)
        GList *list;
        GList *work;
        gchar *base;
+       FileData *dir_fd;
 
        base = g_build_filename(homedir(), GQ_RC_DIR_COLLECTIONS, NULL);
-       filelist_read(base, &list, NULL);
+       dir_fd = file_data_new_simple(base);
+       filelist_read(dir_fd, &list, NULL);
+       file_data_unref(dir_fd);
        g_free(base);
 
        work = collection_manager_entry_list;
index ca0a757..8c69d0c 100644 (file)
@@ -1898,13 +1898,13 @@ void collection_table_refresh(CollectTable *ct)
  *-------------------------------------------------------------------
  */
 
-static void collection_table_add_dir_recursive(CollectTable *ct, gchar *path, gint recursive)
+static void collection_table_add_dir_recursive(CollectTable *ct, FileData *dir_fd, gint recursive)
 {
        GList *d;
        GList *f;
        GList *work;
 
-       if (!filelist_read(path, &f, recursive ? &d : NULL))
+       if (!filelist_read(dir_fd, &f, recursive ? &d : NULL))
                return;
 
        f = filelist_filter(f, FALSE);
@@ -1918,7 +1918,7 @@ static void collection_table_add_dir_recursive(CollectTable *ct, gchar *path, gi
        work = g_list_last(d);
        while (work)
                {
-               collection_table_add_dir_recursive(ct, ((FileData *)work->data)->path, TRUE);
+               collection_table_add_dir_recursive(ct, (FileData *)work->data, TRUE);
                work = work->prev;
                }
 
@@ -1933,7 +1933,7 @@ static void confirm_dir_list_do(CollectTable *ct, GList *list, gint recursive)
                {
                FileData *fd = work->data;
                work = work->next;
-               if (isdir(fd->path)) collection_table_add_dir_recursive(ct, fd->path, recursive);
+               if (isdir(fd->path)) collection_table_add_dir_recursive(ct, fd, recursive);
                }
        collection_table_insert_filelist(ct, list, ct->marker_info);
 }
index 9e73c7e..d6dd295 100644 (file)
@@ -1733,8 +1733,7 @@ static void dupe_files_add(DupeWindow *dw, CollectionData *collection, CollectIn
                else if (isdir(fd->path) && recurse)
                        {
                        GList *f, *d;
-
-                       if (filelist_read(fd->path, &f, &d))
+                       if (filelist_read(fd, &f, &d))
                                {
                                GList *work;
 
@@ -3309,7 +3308,7 @@ static void confirm_dir_list_add(GtkWidget *widget, gpointer data)
                        {
                        GList *list;
 
-                       filelist_read(fd->path, &list, NULL);
+                       filelist_read(fd, &list, NULL);
                        list = filelist_filter(list, FALSE);
                        if (list)
                                {
index 78afa87..65c4386 100644 (file)
@@ -616,7 +616,7 @@ static GList *filelist_filter_out_sidecars(GList *flist)
        return flist_filtered;
 }
 
-static gint filelist_read_real(const gchar *path, GList **files, GList **dirs, gint follow_symlinks)
+static gint filelist_read_real(FileData *dir_fd, GList **files, GList **dirs, gint follow_symlinks)
 {
        DIR *dp;
        struct dirent *dir;
@@ -630,7 +630,7 @@ static gint filelist_read_real(const gchar *path, GList **files, GList **dirs, g
        if (files) *files = NULL;
        if (dirs) *dirs = NULL;
 
-       pathl = path_from_utf8(path);
+       pathl = path_from_utf8(dir_fd->path);
        if (!pathl) return FALSE;
 
        dp = opendir(pathl);
@@ -690,14 +690,14 @@ static gint filelist_read_real(const gchar *path, GList **files, GList **dirs, g
        return TRUE;
 }
 
-gint filelist_read(const gchar *path, GList **files, GList **dirs)
+gint filelist_read(FileData *dir_fd, GList **files, GList **dirs)
 {
-       return filelist_read_real(path, files, dirs, TRUE);
+       return filelist_read_real(dir_fd, files, dirs, TRUE);
 }
 
-gint filelist_read_lstat(const gchar *path, GList **files, GList **dirs)
+gint filelist_read_lstat(FileData *dir_fd, GList **files, GList **dirs)
 {
-       return filelist_read_real(path, files, dirs, FALSE);
+       return filelist_read_real(dir_fd, files, dirs, FALSE);
 }
 
 void filelist_free(GList *list)
@@ -828,11 +828,10 @@ static void filelist_recursive_append(GList **list, GList *dirs)
        while (work)
                {
                FileData *fd = (FileData *)(work->data);
-               const gchar *path = fd->path;
                GList *f;
                GList *d;
 
-               if (filelist_read(path, &f, &d))
+               if (filelist_read(fd, &f, &d))
                        {
                        f = filelist_filter(f, FALSE);
                        f = filelist_sort_path(f);
@@ -848,12 +847,12 @@ static void filelist_recursive_append(GList **list, GList *dirs)
                }
 }
 
-GList *filelist_recursive(const gchar *path)
+GList *filelist_recursive(FileData *dir_fd)
 {
        GList *list;
        GList *d;
 
-       if (!filelist_read(path, &list, &d)) return NULL;
+       if (!filelist_read(dir_fd, &list, &d)) return NULL;
        list = filelist_filter(list, FALSE);
        list = filelist_sort_path(list);
 
index 5bf552e..5b499d3 100644 (file)
@@ -36,8 +36,8 @@ GList *filelist_insert_sort(GList *list, FileData *fd, SortType method, gint asc
 GList *filelist_sort_full(GList *list, SortType method, gint ascend, GCompareFunc cb);
 GList *filelist_insert_sort_full(GList *list, void *data, SortType method, gint ascend, GCompareFunc cb);
 
-gint filelist_read(const gchar *path, GList **files, GList **dirs);
-gint filelist_read_lstat(const gchar *path, GList **files, GList **dirs);
+gint filelist_read(FileData *dir_fd, GList **files, GList **dirs);
+gint filelist_read_lstat(FileData *dir_fd, GList **files, GList **dirs);
 void filelist_free(GList *list);
 GList *filelist_copy(GList *list);
 GList *filelist_from_path_list(GList *list);
@@ -46,7 +46,7 @@ GList *filelist_to_path_list(GList *list);
 GList *filelist_filter(GList *list, gint is_dir_list);
 
 GList *filelist_sort_path(GList *list);
-GList *filelist_recursive(const gchar *path);
+GList *filelist_recursive(FileData *dir_fd);
 
 gchar *file_data_sc_list_to_string(FileData *fd);
 gboolean file_data_add_ci(FileData *fd, FileDataChangeType type, const gchar *src, const gchar *dest);
index 2f1d96f..de8539c 100644 (file)
@@ -465,7 +465,7 @@ static GdkPixbuf *image_osd_info_render(OverlayStateData *osd)
                        else
                                {
                                t = layout_list_count(lw, NULL);
-                               n = layout_list_get_index(lw, image_get_path(lw->image)) + 1;
+                               n = layout_list_get_index(lw, image_get_fd(lw->image)) + 1;
                                }
                        }
                else if (view_window_find_image(imd, &n, &t))
index 861cbe0..e598c9c 100644 (file)
@@ -963,7 +963,7 @@ void view_window_new(FileData *fd)
                                         G_CALLBACK(view_window_collection_unref_cb), cd);
                        }
                }
-       else if (isdir(fd->path) && filelist_read(fd->path, &list, NULL))
+       else if (isdir(fd->path) && filelist_read(fd, &list, NULL))
                {       
                list = filelist_sort_path(list);
                list = filelist_filter(list, FALSE);
@@ -1223,13 +1223,13 @@ static void view_close_cb(GtkWidget *widget, gpointer data)
        view_window_close(vw);
 }
 
-static LayoutWindow *view_new_layout_with_path(const gchar *path)
+static LayoutWindow *view_new_layout_with_fd(FileData *fd)
 {
        LayoutWindow *nw;
 
        nw = layout_new(NULL, FALSE, FALSE);
        layout_sort_set(nw, options->file_sort.method, options->file_sort.ascending);
-       layout_set_path(nw, path);
+       layout_set_fd(nw, fd);
        return nw;
 }
 
@@ -1238,20 +1238,17 @@ static void view_set_layout_path_cb(GtkWidget *widget, gpointer data)
 {
        ViewWindow *vw = data;
        LayoutWindow *lw;
-       const gchar *path;
        ImageWindow *imd;
 
        imd = view_window_active_image(vw);
 
        if (!imd || !imd->image_fd) return;
-       path = imd->image_fd->path;
-       if (!path) return;
 
        lw = layout_find_by_image_fd(imd);
        if (lw)
-               layout_set_path(lw, path);
+               layout_set_fd(lw, imd->image_fd);
        else
-               view_new_layout_with_path(path);
+               view_new_layout_with_fd(imd->image_fd);
        view_window_close(vw);
 }
 
@@ -1362,11 +1359,11 @@ static void view_dir_list_do(ViewWindow *vw, GList *list, gint skip, gint recurs
 
                                if (recurse)
                                        {
-                                       list = filelist_recursive(fd->path);
+                                       list = filelist_recursive(fd);
                                        }
                                else
                                        { /*FIXME */
-                                       filelist_read(fd->path, &list, NULL);
+                                       filelist_read(fd, &list, NULL);
                                        list = filelist_sort_path(list);
                                        list = filelist_filter(list, FALSE);
                                        }
index 34d15c7..5328a02 100644 (file)
@@ -123,7 +123,7 @@ static void layout_path_entry_changed_cb(GtkWidget *widget, gpointer data)
        if (gtk_combo_box_get_active(GTK_COMBO_BOX(widget)) < 0) return;
 
        buf = g_strdup(gtk_entry_get_text(GTK_ENTRY(lw->path_entry)));
-       if (!buf || (lw->path && strcmp(buf, lw->path) == 0))
+       if (!buf || (lw->dir_fd && strcmp(buf, lw->dir_fd->path) == 0))
                {
                g_free(buf);
                return;
@@ -146,7 +146,7 @@ static void layout_path_entry_tab_cb(const gchar *path, gpointer data)
 
        if (isdir(buf))
                {
-               if ((!lw->path || strcmp(lw->path, buf) != 0) && layout_set_path(lw, buf))
+               if ((!lw->dir_fd || strcmp(lw->dir_fd->path, buf) != 0) && layout_set_path(lw, buf))
                        {
                        gint pos = -1;
                        /* put the G_DIR_SEPARATOR back, if we are in tab completion for a dir and result was path change */
@@ -155,7 +155,7 @@ static void layout_path_entry_tab_cb(const gchar *path, gpointer data)
                                                  strlen(gtk_entry_get_text(GTK_ENTRY(lw->path_entry))));
                        }
                }
-       else if (lw->path && strcmp(lw->path, base) == 0)
+       else if (lw->dir_fd && strcmp(lw->dir_fd->path, base) == 0)
                {
                layout_list_scroll_to_subpart(lw, filename_from_path(buf));
                }
@@ -209,7 +209,7 @@ static GtkWidget *layout_tool_setup(LayoutWindow *lw)
        g_signal_connect(G_OBJECT(lw->path_entry->parent), "changed",
                         G_CALLBACK(layout_path_entry_changed_cb), lw);
 
-       lw->vd = vd_new(lw->dir_view_type, lw->path);
+       lw->vd = vd_new(lw->dir_view_type, lw->dir_fd);
        vd_set_layout(lw->vd, lw);
        vd_set_select_func(lw->vd, layout_vd_select_cb, lw);
 
@@ -794,11 +794,11 @@ FileData *layout_list_get_fd(LayoutWindow *lw, gint index)
        return NULL;
 }
 
-gint layout_list_get_index(LayoutWindow *lw, const gchar *path)
+gint layout_list_get_index(LayoutWindow *lw, FileData *fd)
 {
-       if (!layout_valid(&lw)) return -1;
+       if (!layout_valid(&lw) || !fd) return -1;
 
-       if (lw->vf) return vf_index_by_path(lw->vf, path);
+       if (lw->vf) return vf_index_by_path(lw->vf, fd->path);
 
        return -1;
 }
@@ -899,75 +899,85 @@ void layout_selection_to_mark(LayoutWindow *lw, gint mark, SelectionToMarkMode m
 const gchar *layout_get_path(LayoutWindow *lw)
 {
        if (!layout_valid(&lw)) return NULL;
-       return lw->path;
+       return lw->dir_fd ? lw->dir_fd->path : NULL;
 }
 
 static void layout_sync_path(LayoutWindow *lw)
 {
-       if (!lw->path) return;
+       if (!lw->dir_fd) return;
 
-       lw->last_time = filetime(lw->path);
+       lw->last_version = lw->dir_fd->version;
 
-       if (lw->path_entry) gtk_entry_set_text(GTK_ENTRY(lw->path_entry), lw->path);
-       if (lw->vd) vd_set_path(lw->vd, lw->path);
+       if (lw->path_entry) gtk_entry_set_text(GTK_ENTRY(lw->path_entry), lw->dir_fd->path);
+       if (lw->vd) vd_set_fd(lw->vd, lw->dir_fd);
 
-       if (lw->vf) vf_set_path(lw->vf, lw->path);
+       if (lw->vf) vf_set_fd(lw->vf, lw->dir_fd);
 }
 
 gint layout_set_path(LayoutWindow *lw, const gchar *path)
+{
+       FileData *fd = file_data_new_simple(path);
+       gint ret = layout_set_fd(lw, fd);
+       file_data_unref(fd);
+       return ret;
+}
+
+
+gint layout_set_fd(LayoutWindow *lw, FileData *fd)
 {
        gint have_file = FALSE;
 
        if (!layout_valid(&lw)) return FALSE;
 
-       if (!path || !isname(path)) return FALSE;
-       if (lw->path && path && strcmp(path, lw->path) == 0)
+       if (!fd || !isname(fd->path)) return FALSE;
+       if (lw->dir_fd && fd == lw->dir_fd)
                {
                return TRUE;
                }
 
-       if (isdir(path))
+       if (isdir(fd->path))
                {
-               g_free(lw->path);
-               lw->path = g_strdup(path);
+               file_data_unref(lw->dir_fd);
+               lw->dir_fd = file_data_ref(fd);
                }
        else
                {
                gchar *base;
 
-               base = remove_level_from_path(path);
-               if (lw->path && strcmp(lw->path, base) == 0)
+               base = remove_level_from_path(fd->path);
+               if (lw->dir_fd && strcmp(lw->dir_fd->path, base) == 0)
                        {
                        g_free(base);
                        }
                else if (isdir(base))
                        {
-                       g_free(lw->path);
-                       lw->path = base;
+                       file_data_unref(lw->dir_fd);
+                       lw->dir_fd = file_data_new_simple(base);
+                       g_free(base);
                        }
                else
                        {
                        g_free(base);
                        return FALSE;
                        }
-               if (isfile(path)) have_file = TRUE;
+               if (isfile(fd->path)) have_file = TRUE;
                }
 
-       if (lw->path_entry) tab_completion_append_to_history(lw->path_entry, lw->path);
+       if (lw->path_entry) tab_completion_append_to_history(lw->path_entry, lw->dir_fd->path);
        layout_sync_path(lw);
 
        if (have_file)
                {
                gint row;
 
-               row = layout_list_get_index(lw, path);
+               row = layout_list_get_index(lw, fd);
                if (row >= 0)
                        {
                        layout_image_set_index(lw, row);
                        }
                else
                        {
-                       layout_image_set_fd(lw, file_data_new_simple(path));
+                       layout_image_set_fd(lw, fd);
                        }
                }
        else if (!options->lazy_image_sync)
@@ -980,7 +990,7 @@ gint layout_set_path(LayoutWindow *lw, const gchar *path)
 
 static void layout_refresh_lists(LayoutWindow *lw)
 {
-       if (lw->path) lw->last_time = filetime(lw->path);
+       if (lw->dir_fd) lw->last_version = lw->dir_fd->version;
 
        if (lw->vd) vd_refresh(lw->vd);
 
@@ -991,7 +1001,7 @@ static void layout_refresh_by_time(LayoutWindow *lw)
 {
        layout_refresh_lists(lw);
 
-       if (lw->image && filetime(layout_image_get_path(lw)) >= lw->last_time)
+       if (lw->image && layout_image_get_fd(lw)->version != lw->last_version) // FIXME - move to layout_image and fix
                {
                layout_image_refresh(lw);
                }
@@ -1014,13 +1024,9 @@ static gint layout_check_for_update_cb(gpointer data)
 
        if (!options->update_on_time_change) return TRUE;
 
-       if (lw->path)
+       if (lw->dir_fd)
                {
-               time_t new_time;
-
-               new_time = filetime(lw->path);
-
-               if (new_time > 0 && new_time > lw->last_time)
+               if (lw->dir_fd->version != lw->last_version)
                        {
                        DEBUG_1("layout path time changed, refreshing...");
                        layout_refresh_by_time(lw);
@@ -1576,7 +1582,7 @@ static void layout_grid_setup(LayoutWindow *lw)
 
 void layout_style_set(LayoutWindow *lw, gint style, const gchar *order)
 {
-       gchar *path;
+       FileData *dir_fd;
        gint i;
 
        if (!layout_valid(&lw)) return;
@@ -1601,8 +1607,8 @@ void layout_style_set(LayoutWindow *lw, gint style, const gchar *order)
        layout_image_slideshow_stop(lw);
        layout_image_full_screen_stop(lw);
 
-       path = lw->path;
-       lw->path = NULL;
+       dir_fd = lw->dir_fd;
+       lw->dir_fd = NULL;
        lw->image = NULL;
        lw->utility_box = NULL;
 
@@ -1658,19 +1664,19 @@ void layout_style_set(LayoutWindow *lw, gint style, const gchar *order)
 
        /* sync */
 
-       if (image_get_path(lw->image))
+       if (image_get_fd(lw->image))
                {
-               layout_set_path(lw, image_get_path(lw->image));
+               layout_set_fd(lw, image_get_fd(lw->image));
                }
        else
                {
-               layout_set_path(lw, path);
+               layout_set_fd(lw, dir_fd);
                }
        image_top_window_set_sync(lw->image, (lw->tools_float || lw->tools_hidden));
 
        /* clean up */
 
-       g_free(path);
+       file_data_unref(dir_fd);
 }
 
 void layout_styles_update(void)
@@ -1829,7 +1835,7 @@ void layout_free(LayoutWindow *lw)
 
        gtk_widget_destroy(lw->window);
 
-       g_free(lw->path);
+       file_data_unref(lw->dir_fd);
 
        g_free(lw);
 }
@@ -1842,12 +1848,12 @@ static gint layout_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer dat
        return TRUE;
 }
 
-LayoutWindow *layout_new(const gchar *path, gint popped, gint hidden)
+LayoutWindow *layout_new(FileData *dir_fd, gint popped, gint hidden)
 {
-       return layout_new_with_geometry(path, popped, hidden, NULL);
+       return layout_new_with_geometry(dir_fd, popped, hidden, NULL);
 }
 
-LayoutWindow *layout_new_with_geometry(const gchar *path, gint popped, gint hidden,
+LayoutWindow *layout_new_with_geometry(FileData *dir_fd, gint popped, gint hidden,
                                       const gchar *geometry)
 {
        LayoutWindow *lw;
@@ -1958,9 +1964,9 @@ LayoutWindow *layout_new_with_geometry(const gchar *path, gint popped, gint hidd
        layout_util_sync(lw);
        layout_status_update_all(lw);
 
-       if (path)
+       if (dir_fd)
                {
-               layout_set_path(lw, path);
+               layout_set_fd(lw, dir_fd);
                }
        else
                {
@@ -1972,7 +1978,7 @@ LayoutWindow *layout_new_with_geometry(const gchar *path, gint popped, gint hidd
                }
 
        /* set up the time stat timeout */
-       lw->last_time = 0;
+       lw->last_version = 0;
        lw->last_time_id = g_timeout_add(5000, layout_check_for_update_cb, lw);
 
        if (geometry)
@@ -2000,10 +2006,10 @@ LayoutWindow *layout_new_with_geometry(const gchar *path, gint popped, gint hidd
 static void layout_real_time_update(LayoutWindow *lw)
 {
        /* this resets the last time stamp of path so that a refresh does not occur
-        * from an internal file operation.
+        * from an internal file operation. FIXME
         */
 
-       if (lw->path) lw->last_time = filetime(lw->path);
+       if (lw->dir_fd) lw->last_version = lw->dir_fd->version;
 }
 
 static void layout_real_renamed(LayoutWindow *lw, FileData *fd)
index 892bc8b..f0003a2 100644 (file)
@@ -17,8 +17,8 @@
 extern GList *layout_window_list;
 
 
-LayoutWindow *layout_new(const gchar *path, gint popped, gint hidden);
-LayoutWindow *layout_new_with_geometry(const gchar *path, gint popped, gint hidden,
+LayoutWindow *layout_new(FileData *dir_fd, gint popped, gint hidden);
+LayoutWindow *layout_new_with_geometry(FileData *dir_fd, gint popped, gint hidden,
                                       const gchar *geometry);
 
 void layout_close(LayoutWindow *lw);
@@ -31,6 +31,7 @@ LayoutWindow *layout_find_by_image_fd(ImageWindow *imd);
 
 const gchar *layout_get_path(LayoutWindow *lw);
 gint layout_set_path(LayoutWindow *lw, const gchar *path);
+gint layout_set_fd(LayoutWindow *lw, FileData *fd);
 
 void layout_status_update_progress(LayoutWindow *lw, gdouble val, const gchar *text);
 void layout_status_update_info(LayoutWindow *lw, const gchar *text);
@@ -40,7 +41,7 @@ void layout_status_update_all(LayoutWindow *lw);
 GList *layout_list(LayoutWindow *lw);
 guint layout_list_count(LayoutWindow *lw, gint64 *bytes);
 FileData *layout_list_get_fd(LayoutWindow *lw, gint index);
-gint layout_list_get_index(LayoutWindow *lw, const gchar *path);
+gint layout_list_get_index(LayoutWindow *lw, FileData *fd);
 void layout_list_sync_fd(LayoutWindow *lw, FileData *fd);
 
 GList *layout_selection_list(LayoutWindow *lw);
index 637c612..89ae6d2 100644 (file)
@@ -442,7 +442,7 @@ void layout_image_slideshow_start(LayoutWindow *lw)
        else
                {
                lw->slideshow = slideshow_start(lw->image, lw,
-                               layout_list_get_index(lw, layout_image_get_path(lw)),
+                               layout_list_get_index(lw, layout_image_get_fd(lw)),
                                layout_image_slideshow_stop_func, lw);
                }
 
@@ -705,12 +705,12 @@ static void li_pop_menu_hide_cb(GtkWidget *widget, gpointer data)
 static void li_set_layout_path_cb(GtkWidget *widget, gpointer data)
 {
        LayoutWindow *lw = data;
-       const gchar *path;
+       FileData *fd;
 
        if (!layout_valid(&lw)) return;
 
-       path = layout_image_get_path(lw);
-       if (path) layout_set_path(lw, path);
+       fd = layout_image_get_fd(lw);
+       if (fd) layout_set_fd(lw, fd);
 }
 
 static gint li_check_if_current_path(LayoutWindow *lw, const gchar *path)
@@ -718,10 +718,10 @@ static gint li_check_if_current_path(LayoutWindow *lw, const gchar *path)
        gchar *dirname;
        gint ret;
 
-       if (!path || !layout_valid(&lw) || !lw->path) return FALSE;
+       if (!path || !layout_valid(&lw) || !lw->dir_fd) return FALSE;
 
        dirname = g_path_get_dirname(path);
-       ret = (strcmp(lw->path, dirname) == 0);
+       ret = (strcmp(lw->dir_fd->path, dirname) == 0);
        g_free(dirname);
        return ret;
 }
@@ -887,15 +887,18 @@ static void layout_image_dnd_receive(GtkWidget *widget, GdkDragContext *context,
                                {
                                gchar *base;
                                gint row;
+                               FileData *dir_fd;
 
                                base = remove_level_from_path(fd->path);
-                               if (strcmp(base, layout_get_path(lw)) != 0)
+                               dir_fd = file_data_new_simple(base);
+                               if (dir_fd != lw->dir_fd)
                                        {
-                                       layout_set_path(lw, base);
+                                       layout_set_fd(lw, dir_fd);
                                        }
+                               file_data_unref(dir_fd);
                                g_free(base);
 
-                               row = layout_list_get_index(lw, fd->path);
+                               row = layout_list_get_index(lw, fd);
                                if (source && info_list)
                                        {
                                        layout_image_set_collection(lw, source, info_list->data);
@@ -911,7 +914,7 @@ static void layout_image_dnd_receive(GtkWidget *widget, GdkDragContext *context,
                                }
                        else if (isdir(fd->path))
                                {
-                               layout_set_path(lw, fd->path);
+                               layout_set_fd(lw, fd);
                                layout_image_set_fd(lw, NULL);
                                }
                        }
@@ -982,14 +985,14 @@ static void layout_image_dnd_end(GtkWidget *widget, GdkDragContext *context, gpo
        LayoutWindow *lw = data;
        if (context->action == GDK_ACTION_MOVE)
                {
-               const gchar *path;
+               FileData *fd;
                gint row;
 
-               path = layout_image_get_path(lw);
-               row = layout_list_get_index(lw, path);
+               fd = layout_image_get_fd(lw);
+               row = layout_list_get_index(lw, fd);
                if (row < 0) return;
 
-               if (!isfile(path))
+               if (!isfile(fd->path))
                        {
                        if ((guint) row < layout_list_count(lw, NULL) - 1)
                                {
@@ -1154,7 +1157,7 @@ CollectionData *layout_image_get_collection(LayoutWindow *lw, CollectInfo **info
 
 gint layout_image_get_index(LayoutWindow *lw)
 {
-       return layout_list_get_index(lw, image_get_path(lw->image));
+       return layout_list_get_index(lw, image_get_fd(lw->image));
 }
 
 /*
@@ -1205,7 +1208,7 @@ void layout_image_set_index(LayoutWindow *lw, gint index)
 
        if (!layout_valid(&lw)) return;
 
-       old = layout_list_get_index(lw, layout_image_get_path(lw));
+       old = layout_list_get_index(lw, layout_image_get_fd(lw));
        fd = layout_list_get_fd(lw, index);
 
        if (old > index)
@@ -1366,7 +1369,7 @@ void layout_image_next(LayoutWindow *lw)
        if (layout_selection_count(lw, 0) > 1)
                {
                GList *x = layout_selection_list_by_index(lw);
-               gint old = layout_list_get_index(lw, layout_image_get_path(lw));
+               gint old = layout_list_get_index(lw, layout_image_get_fd(lw));
                GList *y;
 
                for (y = x; y && (GPOINTER_TO_INT(y->data)) != old; y = y->next)
@@ -1436,7 +1439,7 @@ void layout_image_prev(LayoutWindow *lw)
        if (layout_selection_count(lw, 0) > 1)
                {
                GList *x = layout_selection_list_by_index(lw);
-               gint old = layout_list_get_index(lw, layout_image_get_path(lw));
+               gint old = layout_list_get_index(lw, layout_image_get_fd(lw));
                GList *y;
                GList *last;
 
@@ -1824,7 +1827,7 @@ void layout_image_activate(LayoutWindow *lw, gint i)
        if (fd)
                {
 //             layout_list_sync_path(lw, path);
-               layout_set_path(lw, fd->path);
+               layout_set_fd(lw, fd);
                }
 }
 
index bbef712..1fefb5b 100644 (file)
@@ -83,9 +83,9 @@ gint layout_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
 
        if (lw->path_entry && GTK_WIDGET_HAS_FOCUS(lw->path_entry))
                {
-               if (event->keyval == GDK_Escape && lw->path)
+               if (event->keyval == GDK_Escape && lw->dir_fd)
                        {
-                       gtk_entry_set_text(GTK_ENTRY(lw->path_entry), lw->path);
+                       gtk_entry_set_text(GTK_ENTRY(lw->path_entry), lw->dir_fd->path);
                        }
 
                /* the gtkaccelgroup of the window is stealing presses before they get to the entry (and more),
@@ -196,7 +196,7 @@ static void layout_menu_new_window_cb(GtkAction *action, gpointer data)
 
        nw = layout_new(NULL, FALSE, FALSE);
        layout_sort_set(nw, options->file_sort.method, options->file_sort.ascending);
-       layout_set_path(nw, layout_get_path(lw));
+       layout_set_fd(nw, lw->dir_fd);
 }
 
 static void layout_menu_new_cb(GtkAction *action, gpointer data)
@@ -221,7 +221,7 @@ static void layout_menu_search_cb(GtkAction *action, gpointer data)
        if (lw->full_screen)
                layout_image_full_screen_stop(lw);
 
-       search_new(lw->path, layout_image_get_path(lw));
+       search_new(lw->dir_fd, layout_image_get_fd(lw));
 }
 
 static void layout_menu_dupes_cb(GtkAction *action, gpointer data)
@@ -239,7 +239,7 @@ static void layout_menu_pan_cb(GtkAction *action, gpointer data)
        if (lw->full_screen)
                layout_image_full_screen_stop(lw);
 
-       pan_window_new(layout_get_path(lw));
+       pan_window_new(lw->dir_fd);
 }
 
 static void layout_menu_print_cb(GtkAction *action, gpointer data)
@@ -253,7 +253,7 @@ static void layout_menu_dir_cb(GtkAction *action, gpointer data)
 {
        LayoutWindow *lw = data;
 
-       file_util_create_dir(lw->path, layout_window(lw));
+       file_util_create_dir(lw->dir_fd, layout_window(lw));
 }
 
 static void layout_menu_copy_cb(GtkAction *action, gpointer data)
@@ -1476,8 +1476,12 @@ static void layout_button_home_cb(GtkWidget *widget, gpointer data)
 {
        LayoutWindow *lw = data;
        const gchar *path = homedir();
-
-       if (path) layout_set_path(lw, path);
+       if (path)
+               {
+               FileData *dir_fd = file_data_new_simple(path);
+               layout_set_fd(lw, dir_fd);
+               file_data_unref(dir_fd);
+               }
 }
 
 static void layout_button_refresh_cb(GtkWidget *widget, gpointer data)
index 8f120fa..cfc561c 100644 (file)
@@ -197,11 +197,14 @@ static void parse_command_line_add_dir(const gchar *dir, gchar **path, gchar **f
 {
        GList *files;
        gchar *path_parsed;
+       FileData *dir_fd;
 
        path_parsed = g_strdup(dir);
        parse_out_relatives(path_parsed);
+       dir_fd = file_data_new_simple(path_parsed);
+       
 
-       if (filelist_read(path_parsed, &files, NULL))
+       if (filelist_read(dir_fd, &files, NULL))
                {
                GList *work;
 
@@ -223,6 +226,7 @@ static void parse_command_line_add_dir(const gchar *dir, gchar **path, gchar **f
                }
 
        g_free(path_parsed);
+       file_data_unref(dir_fd);
 }
 
 static void parse_command_line_process_dir(const gchar *dir, gchar **path, gchar **file,
index b3488e5..785714c 100644 (file)
@@ -186,7 +186,7 @@ void pan_calendar_update(PanWindow *pw, PanItem *pi_day)
        pan_layout_resize(pw);
 }
 
-void pan_calendar_compute(PanWindow *pw, const gchar *path, gint *width, gint *height)
+void pan_calendar_compute(PanWindow *pw, FileData *dir_fd, gint *width, gint *height)
 {
        GList *list;
        GList *work;
@@ -202,7 +202,7 @@ void pan_calendar_compute(PanWindow *pw, const gchar *path, gint *width, gint *h
        gint end_year = 0;
        gint end_month = 0;
 
-       list = pan_list_tree(path, SORT_NONE, TRUE, pw->ignore_symlinks);
+       list = pan_list_tree(dir_fd, SORT_NONE, TRUE, pw->ignore_symlinks);
 
        if (pw->cache_list && pw->exif_date_enable)
                {
index 25f64e5..c499453 100644 (file)
@@ -215,7 +215,7 @@ static void pan_flower_build(PanWindow *pw, FlowerGroup *group, FlowerGroup *par
        g_free(group);
 }
 
-static FlowerGroup *pan_flower_group(PanWindow *pw, const gchar *path, gint x, gint y)
+static FlowerGroup *pan_flower_group(PanWindow *pw, FileData *dir_fd, gint x, gint y)
 {
        FlowerGroup *group;
        GList *f;
@@ -227,19 +227,19 @@ static FlowerGroup *pan_flower_group(PanWindow *pw, const gchar *path, gint x, g
        gint grid_size;
        gint grid_count;
 
-       if (!filelist_read(path, &f, &d)) return NULL;
+       if (!filelist_read(dir_fd, &f, &d)) return NULL;
        if (!f && !d) return NULL;
 
        f = filelist_sort(f, SORT_NAME, TRUE);
        d = filelist_sort(d, SORT_NAME, TRUE);
 
-       pi_box = pan_item_text_new(pw, x, y, path, PAN_TEXT_ATTR_NONE,
+       pi_box = pan_item_text_new(pw, x, y, dir_fd->path, PAN_TEXT_ATTR_NONE,
                                   PAN_TEXT_BORDER_SIZE,
                                   PAN_TEXT_COLOR, 255);
 
        y += pi_box->height;
 
-       pi_box = pan_item_box_new(pw, file_data_new_simple(path),
+       pi_box = pan_item_box_new(pw, dir_fd,
                                  x, y,
                                  PAN_BOX_BORDER * 2, PAN_BOX_BORDER * 2,
                                  PAN_BOX_OUTLINE_THICKNESS,
@@ -309,7 +309,7 @@ static FlowerGroup *pan_flower_group(PanWindow *pw, const gchar *path, gint x, g
 
                if (!pan_is_ignored(fd->path, pw->ignore_symlinks))
                        {
-                       child = pan_flower_group(pw, fd->path, 0, 0);
+                       child = pan_flower_group(pw, fd, 0, 0);
                        if (child) group->children = g_list_prepend(group->children, child);
                        }
                }
@@ -338,19 +338,19 @@ static FlowerGroup *pan_flower_group(PanWindow *pw, const gchar *path, gint x, g
        return group;
 }
 
-void pan_flower_compute(PanWindow *pw, const gchar *path,
+void pan_flower_compute(PanWindow *pw, FileData *dir_fd,
                        gint *width, gint *height,
                        gint *scroll_x, gint *scroll_y)
 {
        FlowerGroup *group;
        GList *list;
 
-       group = pan_flower_group(pw, path, 0, 0);
+       group = pan_flower_group(pw, dir_fd, 0, 0);
        pan_flower_build(pw, group, NULL);
 
        pan_flower_size(pw, width, height);
 
-       list = pan_item_find_by_path(pw, PAN_ITEM_BOX, path, FALSE, FALSE);
+       list = pan_item_find_by_fd(pw, PAN_ITEM_BOX, dir_fd, FALSE, FALSE);
        if (list)
                {
                PanItem *pi = list->data;
@@ -360,7 +360,7 @@ void pan_flower_compute(PanWindow *pw, const gchar *path,
        g_list_free(list);
 }
 
-static void pan_folder_tree_path(PanWindow *pw, const gchar *path,
+static void pan_folder_tree_path(PanWindow *pw, FileData *dir_fd,
                                 gint *x, gint *y, gint *level,
                                 PanItem *parent,
                                 gint *width, gint *height)
@@ -371,7 +371,7 @@ static void pan_folder_tree_path(PanWindow *pw, const gchar *path,
        PanItem *pi_box;
        gint y_height = 0;
 
-       if (!filelist_read(path, &f, &d)) return;
+       if (!filelist_read(dir_fd, &f, &d)) return;
        if (!f && !d) return;
 
        f = filelist_sort(f, SORT_NAME, TRUE);
@@ -379,13 +379,13 @@ static void pan_folder_tree_path(PanWindow *pw, const gchar *path,
 
        *x = PAN_BOX_BORDER + ((*level) * MAX(PAN_BOX_BORDER, PAN_THUMB_GAP));
 
-       pi_box = pan_item_text_new(pw, *x, *y, path, PAN_TEXT_ATTR_NONE,
+       pi_box = pan_item_text_new(pw, *x, *y, dir_fd->path, PAN_TEXT_ATTR_NONE,
                                   PAN_TEXT_BORDER_SIZE,
                                   PAN_TEXT_COLOR, 255);
 
        *y += pi_box->height;
 
-       pi_box = pan_item_box_new(pw, file_data_new_simple(path),
+       pi_box = pan_item_box_new(pw, dir_fd,
                                  *x, *y,
                                  PAN_BOX_BORDER, PAN_BOX_BORDER,
                                  PAN_BOX_OUTLINE_THICKNESS,
@@ -435,7 +435,7 @@ static void pan_folder_tree_path(PanWindow *pw, const gchar *path,
                if (!pan_is_ignored(fd->path, pw->ignore_symlinks))
                        {
                        *level = *level + 1;
-                       pan_folder_tree_path(pw, fd->path, x, y, level, pi_box, width, height);
+                       pan_folder_tree_path(pw, fd, x, y, level, pi_box, width, height);
                        *level = *level - 1;
                        }
                }
@@ -450,7 +450,7 @@ static void pan_folder_tree_path(PanWindow *pw, const gchar *path,
        pan_item_size_coordinates(pi_box, PAN_BOX_BORDER, width, height);
 }
 
-void pan_folder_tree_compute(PanWindow *pw, const gchar *path, gint *width, gint *height)
+void pan_folder_tree_compute(PanWindow *pw, FileData *dir_fd, gint *width, gint *height)
 {
        gint x, y;
        gint level;
@@ -462,7 +462,7 @@ void pan_folder_tree_compute(PanWindow *pw, const gchar *path, gint *width, gint
        w = PAN_BOX_BORDER * 2;
        h = PAN_BOX_BORDER * 2;
 
-       pan_folder_tree_path(pw, path, &x, &y, &level, NULL, &w, &h);
+       pan_folder_tree_path(pw, dir_fd, &x, &y, &level, NULL, &w, &h);
 
        if (width) *width = w;
        if (height) *height = h;
index 3290563..f6fd311 100644 (file)
@@ -17,7 +17,7 @@
 #include <math.h>
 
 
-void pan_grid_compute(PanWindow *pw, const gchar *path, gint *width, gint *height)
+void pan_grid_compute(PanWindow *pw, FileData *dir_fd, gint *width, gint *height)
 {
        GList *list;
        GList *work;
@@ -25,7 +25,7 @@ void pan_grid_compute(PanWindow *pw, const gchar *path, gint *width, gint *heigh
        gint grid_size;
        gint next_y;
 
-       list = pan_list_tree(path, SORT_NAME, TRUE, pw->ignore_symlinks);
+       list = pan_list_tree(dir_fd, SORT_NAME, TRUE, pw->ignore_symlinks);
 
        grid_size = (gint)sqrt((double)g_list_length(list));
        if (pw->size > PAN_IMAGE_SIZE_THUMB_LARGE)
index 7d56c8a..cd3c147 100644 (file)
@@ -793,6 +793,14 @@ GList *pan_item_find_by_path(PanWindow *pw, PanItemType type, const gchar *path,
        return g_list_reverse(list);
 }
 
+GList *pan_item_find_by_fd(PanWindow *pw, PanItemType type, FileData *fd,
+                            gint ignore_case, gint partial)
+{
+       if (!fd) return NULL;
+       return pan_item_find_by_path(pw, type, fd->path, ignore_case, partial); 
+}
+
+
 static PanItem *pan_item_find_by_coord_l(GList *list, PanItemType type, gint x, gint y, const gchar *key)
 {
        GList *work;
index f60b1dd..21bbe2f 100644 (file)
@@ -15,7 +15,7 @@
 #include "pan-types.h"
 
 
-void pan_timeline_compute(PanWindow *pw, const gchar *path, gint *width, gint *height)
+void pan_timeline_compute(PanWindow *pw, FileData *dir_fd, gint *width, gint *height)
 {
        GList *list;
        GList *work;
@@ -30,7 +30,7 @@ void pan_timeline_compute(PanWindow *pw, const gchar *path, gint *width, gint *h
        gint x_width;
        gint y_height;
 
-       list = pan_list_tree(path, SORT_NONE, TRUE, pw->ignore_symlinks);
+       list = pan_list_tree(dir_fd, SORT_NONE, TRUE, pw->ignore_symlinks);
 
        if (pw->cache_list && pw->exif_date_enable)
                {
index 74b95b1..6d19e8b 100644 (file)
@@ -194,7 +194,7 @@ struct _PanWindow
 
        gint overlay_id;
 
-       gchar *path;
+       FileData *dir_fd;
        PanLayoutType layout;
        PanImageSize size;
        gint thumb_size;
@@ -268,6 +268,8 @@ void pan_item_size_coordinates(PanItem *pi, gint border, gint *w, gint *h);
 PanItem *pan_item_find_by_key(PanWindow *pw, PanItemType type, const gchar *key);
 GList *pan_item_find_by_path(PanWindow *pw, PanItemType type, const gchar *path,
                             gint ignore_case, gint partial);
+GList *pan_item_find_by_fd(PanWindow *pw, PanItemType type, FileData *fd,
+                            gint ignore_case, gint partial);
 PanItem *pan_item_find_by_coord(PanWindow *pw, PanItemType type,
                                gint x, gint y, const gchar *key);
 
@@ -340,20 +342,20 @@ time_t pan_date_to_time(gint year, gint month, gint day);
 
 gint pan_is_link_loop(const gchar *s);
 gint pan_is_ignored(const gchar *s, gint ignore_symlinks);
-GList *pan_list_tree(const gchar *path, SortType sort, gint ascend,
+GList *pan_list_tree(FileData *dir_fd, SortType sort, gint ascend,
                     gint ignore_symlinks);
 
 
 /* the different view types */
 
 void pan_calendar_update(PanWindow *pw, PanItem *pi_day);
-void pan_calendar_compute(PanWindow *pw, const gchar *path, gint *width, gint *height);
-void pan_flower_compute(PanWindow *pw, const gchar *path,
+void pan_calendar_compute(PanWindow *pw, FileData *dir_fd, gint *width, gint *height);
+void pan_flower_compute(PanWindow *pw, FileData *dir_fd,
                        gint *width, gint *height,
                        gint *scroll_x, gint *scroll_y);
-void pan_folder_tree_compute(PanWindow *pw, const gchar *path, gint *width, gint *height);
-void pan_grid_compute(PanWindow *pw, const gchar *path, gint *width, gint *height);
-void pan_timeline_compute(PanWindow *pw, const gchar *path, gint *width, gint *height);
+void pan_folder_tree_compute(PanWindow *pw, FileData *dir_fd, gint *width, gint *height);
+void pan_grid_compute(PanWindow *pw, FileData *dir_fd, gint *width, gint *height);
+void pan_timeline_compute(PanWindow *pw, FileData *dir_fd, gint *width, gint *height);
 
 
 #endif
index e38af8c..0c1c60e 100644 (file)
@@ -208,7 +208,7 @@ gint pan_is_ignored(const gchar *s, gint ignore_symlinks)
        return FALSE;
 }
 
-GList *pan_list_tree(const gchar *path, SortType sort, gint ascend,
+GList *pan_list_tree(FileData *dir_fd, SortType sort, gint ascend,
                     gint ignore_symlinks)
 {
        GList *flist;
@@ -216,7 +216,7 @@ GList *pan_list_tree(const gchar *path, SortType sort, gint ascend,
        GList *result;
        GList *folders;
 
-       filelist_read(path, &flist, &dlist);
+       filelist_read(dir_fd, &flist, &dlist);
        if (sort != SORT_NONE)
                {
                flist = filelist_sort(flist, sort, ascend);
@@ -233,7 +233,7 @@ GList *pan_list_tree(const gchar *path, SortType sort, gint ascend,
                folders = g_list_remove(folders, fd);
 
                if (!pan_is_ignored(fd->path, ignore_symlinks) &&
-                   filelist_read(fd->path, &flist, &dlist))
+                   filelist_read(fd, &flist, &dlist))
                        {
                        if (sort != SORT_NONE)
                                {
index 876ec49..49ece45 100644 (file)
@@ -565,13 +565,13 @@ static void pan_cache_free(PanWindow *pw)
        pw->cache_cl = NULL;
 }
 
-static void pan_cache_fill(PanWindow *pw, const gchar *path)
+static void pan_cache_fill(PanWindow *pw, FileData *dir_fd)
 {
        GList *list;
 
        pan_cache_free(pw);
 
-       list = pan_list_tree(path, SORT_NAME, TRUE, pw->ignore_symlinks);
+       list = pan_list_tree(dir_fd, SORT_NAME, TRUE, pw->ignore_symlinks);
        pw->cache_todo = g_list_reverse(list);
 
        pw->cache_total = g_list_length(pw->cache_todo);
@@ -884,7 +884,7 @@ static void pan_window_items_free(PanWindow *pw)
  *-----------------------------------------------------------------------------
  */
 
-static void pan_layout_compute(PanWindow *pw, const gchar *path,
+static void pan_layout_compute(PanWindow *pw, FileData *dir_fd,
                               gint *width, gint *height,
                               gint *scroll_x, gint *scroll_y)
 {
@@ -944,19 +944,19 @@ static void pan_layout_compute(PanWindow *pw, const gchar *path,
                {
                case PAN_LAYOUT_GRID:
                default:
-                       pan_grid_compute(pw, path, width, height);
+                       pan_grid_compute(pw, dir_fd, width, height);
                        break;
                case PAN_LAYOUT_FOLDERS_LINEAR:
-                       pan_folder_tree_compute(pw, path, width, height);
+                       pan_folder_tree_compute(pw, dir_fd, width, height);
                        break;
                case PAN_LAYOUT_FOLDERS_FLOWER:
-                       pan_flower_compute(pw, path, width, height, scroll_x, scroll_y);
+                       pan_flower_compute(pw, dir_fd, width, height, scroll_x, scroll_y);
                        break;
                case PAN_LAYOUT_CALENDAR:
-                       pan_calendar_compute(pw, path, width, height);
+                       pan_calendar_compute(pw, dir_fd, width, height);
                        break;
                case PAN_LAYOUT_TIMELINE:
-                       pan_timeline_compute(pw, path, width, height);
+                       pan_timeline_compute(pw, dir_fd, width, height);
                        break;
                }
 
@@ -1076,7 +1076,7 @@ static gint pan_layout_update_idle_cb(gpointer data)
                {
                if (!pw->cache_list && !pw->cache_todo)
                        {
-                       pan_cache_fill(pw, pw->path);
+                       pan_cache_fill(pw, pw->dir_fd);
                        if (pw->cache_todo)
                                {
                                pan_window_message(pw, _("Reading image data..."));
@@ -1110,7 +1110,7 @@ static gint pan_layout_update_idle_cb(gpointer data)
                        }
                }
 
-       pan_layout_compute(pw, pw->path, &width, &height, &scroll_x, &scroll_y);
+       pan_layout_compute(pw, pw->dir_fd, &width, &height, &scroll_x, &scroll_y);
 
        pan_window_zoom_limit(pw);
 
@@ -1158,18 +1158,18 @@ static void pan_layout_update(PanWindow *pw)
        pan_layout_update_idle(pw);
 }
 
-static void pan_layout_set_path(PanWindow *pw, const gchar *path)
+static void pan_layout_set_fd(PanWindow *pw, FileData *dir_fd)
 {
-       if (!path) return;
+       if (!dir_fd) return;
 
-       if (strcmp(path, G_DIR_SEPARATOR_S) == 0)
+       if (strcmp(dir_fd->path, G_DIR_SEPARATOR_S) == 0)
                {
-               pan_warning_folder(path, pw->window);
+               pan_warning_folder(dir_fd->path, pw->window);
                return;
                }
 
-       g_free(pw->path);
-       pw->path = g_strdup(path);
+       file_data_unref(pw->dir_fd);
+       pw->dir_fd = file_data_ref(dir_fd);
 
        pan_layout_update(pw);
 }
@@ -2276,9 +2276,11 @@ static void pan_window_entry_activate_cb(const gchar *new_text, gpointer data)
                }
        else
                {
+               FileData *dir_fd = file_data_new_simple(path);
                tab_completion_append_to_history(pw->path_entry, path);
 
-               pan_layout_set_path(pw, path);
+               pan_layout_set_fd(pw, dir_fd);
+               file_data_unref(dir_fd);
                }
 
        g_free(path);
@@ -2315,7 +2317,7 @@ static void pan_window_close(PanWindow *pw)
        pan_window_items_free(pw);
        pan_cache_free(pw);
 
-       g_free(pw->path);
+       file_data_unref(pw->dir_fd);
 
        g_free(pw);
 }
@@ -2328,7 +2330,7 @@ static gint pan_window_delete_cb(GtkWidget *w, GdkEventAny *event, gpointer data
        return TRUE;
 }
 
-static void pan_window_new_real(const gchar *path)
+static void pan_window_new_real(FileData *dir_fd)
 {
        PanWindow *pw;
        GtkWidget *vbox;
@@ -2341,7 +2343,7 @@ static void pan_window_new_real(const gchar *path)
 
        pw = g_new0(PanWindow, 1);
 
-       pw->path = g_strdup(path);
+       pw->dir_fd = file_data_ref(dir_fd);
        pw->layout = PAN_LAYOUT_TIMELINE;
        pw->size = PAN_IMAGE_SIZE_THUMB_NORMAL;
        pw->thumb_size = PAN_THUMB_SIZE_NORMAL;
@@ -2387,7 +2389,7 @@ static void pan_window_new_real(const gchar *path)
 
        pref_spacer(box, 0);
        pref_label_new(box, _("Location:"));
-       combo = tab_completion_new_with_history(&pw->path_entry, path, "pan_view_path", -1,
+       combo = tab_completion_new_with_history(&pw->path_entry, dir_fd->path, "pan_view_path", -1,
                                                pan_window_entry_activate_cb, pw);
        g_signal_connect(G_OBJECT(pw->path_entry->parent), "changed",
                         G_CALLBACK(pan_window_entry_change_cb), pw);
@@ -2551,12 +2553,12 @@ static void pan_window_new_real(const gchar *path)
 
 static void pan_warning_ok_cb(GenericDialog *gd, gpointer data)
 {
-       gchar *path = data;
+       FileData *dir_fd = data;
 
        generic_dialog_close(gd);
 
-       pan_window_new_real(path);
-       g_free(path);
+       pan_window_new_real(dir_fd);
+       file_data_unref(dir_fd);
 }
 
 static void pan_warning_hide_cb(GtkWidget *button, gpointer data)
@@ -2567,7 +2569,7 @@ static void pan_warning_hide_cb(GtkWidget *button, gpointer data)
        pref_list_int_set(PAN_PREF_GROUP, PAN_PREF_HIDE_WARNING, hide_dlg);
 }
 
-static gint pan_warning(const gchar *path)
+static gint pan_warning(FileData *dir_fd)
 {
        GenericDialog *gd;
        GtkWidget *box;
@@ -2576,9 +2578,9 @@ static gint pan_warning(const gchar *path)
        GtkWidget *ct_button;
        gint hide_dlg;
 
-       if (path && strcmp(path, G_DIR_SEPARATOR_S) == 0)
+       if (dir_fd && strcmp(dir_fd->path, G_DIR_SEPARATOR_S) == 0)
                {
-               pan_warning_folder(path, NULL);
+               pan_warning_folder(dir_fd->path, NULL);
                return TRUE;
                }
 
@@ -2590,7 +2592,7 @@ static gint pan_warning(const gchar *path)
 
        gd = generic_dialog_new(_("Pan View Performance"), GQ_WMCLASS, "pan_view_warning", NULL, FALSE,
                                NULL, NULL);
-       gd->data = g_strdup(path);
+       gd->data = file_data_ref(dir_fd);
        generic_dialog_add_button(gd, GTK_STOCK_OK, NULL,
                                  pan_warning_ok_cb, TRUE);
 
@@ -2627,11 +2629,11 @@ static gint pan_warning(const gchar *path)
  *-----------------------------------------------------------------------------
  */
 
-void pan_window_new(const gchar *path)
+void pan_window_new(FileData *dir_fd)
 {
-       if (pan_warning(path)) return;
+       if (pan_warning(dir_fd)) return;
 
-       pan_window_new_real(path);
+       pan_window_new_real(dir_fd);
 }
 
 
@@ -2913,7 +2915,7 @@ static void pan_window_get_dnd_data(GtkWidget *widget, GdkDragContext *context,
                        {
                        FileData *fd = list->data;
 
-                       pan_layout_set_path(pw, fd->path);
+                       pan_layout_set_fd(pw, fd);
                        }
 
                filelist_free(list);
index ea99f75..5b89cef 100644 (file)
@@ -15,7 +15,7 @@
 #define PAN_VIEW_H
 
 
-void pan_window_new(const gchar *path);
+void pan_window_new(FileData *dir_fd);
 
 
 #endif
index 717a3d0..8ae077e 100644 (file)
@@ -397,8 +397,9 @@ static void gr_fullscreen_stop(const gchar *text, gpointer data)
 static void gr_slideshow_start_rec(const gchar *text, gpointer data)
 {
        GList *list;
-
-       list = filelist_recursive(text);
+       FileData *dir_fd = file_data_new_simple(text);
+       list = filelist_recursive(dir_fd);
+       file_data_unref(dir_fd);
        if (!list) return;
 //printf("length: %d\n", g_list_length(list));
        layout_image_slideshow_stop(NULL);
index 91ff764..c507c44 100644 (file)
@@ -124,7 +124,7 @@ struct _SearchData
        GtkWidget *menu_keywords;
        GtkWidget *entry_keywords;
 
-       gchar *search_path;
+       FileData *search_dir_fd;
        gint   search_path_recurse;
        gchar *search_name;
        gint   search_name_match_case;
@@ -1942,17 +1942,22 @@ static gint search_step_cb(gpointer data)
 
                if (sd->search_type == SEARCH_MATCH_NONE)
                        {
-                       success = filelist_read(fd->path, &list, &dlist);
+                       success = filelist_read(fd, &list, &dlist);
                        }
                else if (sd->search_type == SEARCH_MATCH_ALL &&
-                        sd->search_path &&
-                        strlen(fd->path) >= strlen(sd->search_path))
+                        sd->search_dir_fd &&
+                        strlen(fd->path) >= strlen(sd->search_dir_fd->path))
                        {
                        const gchar *path;
 
-                       path = fd->path + strlen(sd->search_path);
-                       if (path != fd->path) success = filelist_read(path, &list, NULL);
-                       success |= filelist_read(fd->path, NULL, &dlist);
+                       path = fd->path + strlen(sd->search_dir_fd->path);
+                       if (path != fd->path)
+                               {
+                               FileData *dir_fd = file_data_new_simple(path);
+                               success = filelist_read(dir_fd, &list, NULL);
+                               file_data_unref(dir_fd);
+                               }
+                       success |= filelist_read(fd, NULL, &dlist);
                        if (success)
                                {
                                GList *work;
@@ -2016,10 +2021,9 @@ static void search_start(SearchData *sd)
        search_stop(sd);
        search_result_clear(sd);
 
-       if (sd->search_path)
+       if (sd->search_dir_fd)
                {
-               sd->search_folder_list = g_list_prepend(sd->search_folder_list,
-                                                       file_data_new_simple(sd->search_path));
+               sd->search_folder_list = g_list_prepend(sd->search_folder_list, sd->search_dir_fd);
                }
 
        if (!sd->search_name_match_case)
@@ -2137,11 +2141,10 @@ static void search_start_cb(GtkWidget *widget, gpointer data)
                path = remove_trailing_slash(gtk_entry_get_text(GTK_ENTRY(sd->path_entry)));
                if (isdir(path))
                        {
-                       g_free(sd->search_path);
-                       sd->search_path = path;
-                       path = NULL;
+                       file_data_unref(sd->search_dir_fd);
+                       sd->search_dir_fd = file_data_new_simple(path);
 
-                       tab_completion_append_to_history(sd->path_entry, sd->search_path);
+                       tab_completion_append_to_history(sd->path_entry, sd->search_dir_fd->path);
 
                        search_start(sd);
                        }
@@ -2157,9 +2160,11 @@ static void search_start_cb(GtkWidget *widget, gpointer data)
        else if (sd->search_type == SEARCH_MATCH_ALL)
                {
                /* search metadata */
+               path = g_build_filename(homedir(), GQ_CACHE_RC_METADATA, NULL);
 
-               g_free(sd->search_path);
-               sd->search_path = g_build_filename(homedir(), GQ_CACHE_RC_METADATA, NULL);
+               file_data_unref(sd->search_dir_fd);
+               sd->search_dir_fd = file_data_new_simple(path);
+               g_free(path);
 
                search_start(sd);
                }
@@ -2170,8 +2175,8 @@ static void search_start_cb(GtkWidget *widget, gpointer data)
 
                list = search_result_refine_list(sd);
 
-               g_free(sd->search_path);
-               sd->search_path = NULL;
+               file_data_unref(sd->search_dir_fd);
+               sd->search_dir_fd = NULL;
 
                search_start(sd);
 
@@ -2516,7 +2521,8 @@ static void search_window_destroy_cb(GtkWidget *widget, gpointer data)
        search_stop(sd);
        search_result_clear(sd);
 
-       g_free(sd->search_path);
+       file_data_unref(sd->search_dir_fd);
+
        g_free(sd->search_name);
        g_free(sd->search_similarity_path);
        string_list_free(sd->search_keyword_list);
@@ -2524,7 +2530,7 @@ static void search_window_destroy_cb(GtkWidget *widget, gpointer data)
        g_free(sd);
 }
 
-void search_new(const gchar *path, const gchar *example_file)
+void search_new(FileData *dir_fd, FileData *example_file)
 {
        SearchData *sd;
        GtkWidget *vbox;
@@ -2541,7 +2547,7 @@ void search_new(const gchar *path, const gchar *example_file)
 
        sd = g_new0(SearchData, 1);
 
-       sd->search_path = g_strdup(path);
+       sd->search_dir_fd = file_data_ref(dir_fd);
        sd->search_path_recurse = TRUE;
        sd->search_size = 0;
        sd->search_width = 640;
@@ -2567,7 +2573,7 @@ void search_new(const gchar *path, const gchar *example_file)
        sd->match_keywords_enable = FALSE;
 
        sd->search_similarity = 95;
-       sd->search_similarity_path = g_strdup(example_file);
+       sd->search_similarity_path = g_strdup(example_file->path);
        sd->search_similarity_cd = NULL;
 
        sd->search_idle_id = -1;
@@ -2611,7 +2617,7 @@ void search_new(const gchar *path, const gchar *example_file)
        gtk_widget_show(sd->menu_path);
 
        hbox2 = pref_box_new(hbox, TRUE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
-       combo = tab_completion_new_with_history(&sd->path_entry, sd->search_path,
+       combo = tab_completion_new_with_history(&sd->path_entry, sd->search_dir_fd->path,
                                                "search_path", -1,
                                                NULL, NULL);
        tab_completion_add_select_button(sd->path_entry, NULL, TRUE);
index 27abad2..82fc128 100644 (file)
@@ -15,7 +15,7 @@
 #define SEARCH_H
 
 
-void search_new(const gchar *path, const gchar *example_file);
+void search_new(FileData *dir_fd, FileData *example_file);
 
 
 void search_maint_renamed(FileData *fd);
index 9870a9e..8a23892 100644 (file)
@@ -35,7 +35,7 @@ void slideshow_free(SlideShowData *ss)
 
        if (ss->filelist) filelist_free(ss->filelist);
        if (ss->cd) collection_unref(ss->cd);
-       g_free(ss->layout_path);
+       file_data_unref(ss->dir_fd);
 
        g_list_free(ss->list);
        g_list_free(ss->list_done);
@@ -120,7 +120,7 @@ static void slideshow_list_init(SlideShowData *ss, gint start_index)
 gint slideshow_should_continue(SlideShowData *ss)
 {
        FileData *imd_fd;
-       const gchar *path;
+       FileData *dir_fd;
 
        if (!ss) return FALSE;
 
@@ -140,10 +140,9 @@ gint slideshow_should_continue(SlideShowData *ss)
                }
 
        if (!ss->layout) return FALSE;
-       path = layout_get_path(ss->layout);
+       dir_fd = ss->layout->dir_fd;
 
-       if (path && ss->layout_path &&
-           strcmp(path, ss->layout_path) == 0)
+       if (dir_fd && ss->dir_fd && dir_fd == ss->dir_fd)
                {
                if (ss->from_selection && ss->slide_count == layout_selection_count(ss->layout, NULL)) return TRUE;
                if (!ss->from_selection && ss->slide_count == layout_list_count(ss->layout, NULL)) return TRUE;
@@ -328,7 +327,7 @@ static SlideShowData *real_slideshow_start(ImageWindow *imd, LayoutWindow *lw,
        ss->filelist = filelist;
        ss->cd = cd;
        ss->layout = lw;
-       ss->layout_path = NULL;
+       ss->dir_fd = NULL;
 
        ss->list = NULL;
        ss->list_done = NULL;
@@ -358,7 +357,7 @@ static SlideShowData *real_slideshow_start(ImageWindow *imd, LayoutWindow *lw,
                /* layout method */
 
                ss->slide_count = layout_selection_count(ss->layout, NULL);
-               ss->layout_path = g_strdup(layout_get_path(ss->layout));
+               ss->dir_fd = file_data_ref(ss->layout->dir_fd);
                if (ss->slide_count < 2)
                        {
                        ss->slide_count = layout_list_count(ss->layout, NULL);
index deeb6d8..ba4ab52 100644 (file)
@@ -35,8 +35,15 @@ static gint file_util_safe_number(gint64 free_space)
        GList *work;
        gint sorted = FALSE;
        gint warned = FALSE;
+       FileData *dir_fd;
 
-       if (!filelist_read(options->file_ops.safe_delete_path, &list, NULL)) return 0;
+       dir_fd = file_data_new_simple(options->file_ops.safe_delete_path);
+       if (!filelist_read(dir_fd, &list, NULL)) 
+               {
+               file_data_unref(dir_fd);
+               return 0;
+               }
+       file_data_unref(dir_fd);
 
        work = list;
        while (work)
index a70aaa1..5a5fefd 100644 (file)
@@ -440,7 +440,7 @@ struct _FileData {
 
 struct _LayoutWindow
 {
-       gchar *path;
+       FileData *dir_fd;
 
        /* base */
 
@@ -538,7 +538,7 @@ struct _LayoutWindow
        /* directory update check */
 
        gint last_time_id;
-       time_t last_time;
+       gint last_version;
 
        /* misc */
 
@@ -564,7 +564,7 @@ struct _ViewDir
        GtkWidget *widget;
        GtkWidget *view;
 
-       gchar *path;
+       FileData *dir_fd;
 
        FileData *click_fd;
 
@@ -606,7 +606,7 @@ struct _ViewFile
        GtkWidget *widget;
        GtkWidget *listview;
 
-       gchar *path;
+       FileData *dir_fd;
        GList *list;
 
        SortType sort_method;
@@ -680,7 +680,7 @@ struct _SlideShowData
 
        GList *filelist;
        CollectionData *cd;
-       gchar *layout_path;
+       FileData *dir_fd;
        LayoutWindow *layout;
 
        GList *list;
index f3bc22b..2e93458 100644 (file)
@@ -1439,7 +1439,7 @@ static void file_util_start_editor_full(gint n, FileData *source_fd, GList *sour
 
 
 /* FIXME: */
-void file_util_create_dir(const gchar *path, GtkWidget *parent)
+void file_util_create_dir(FileData *dir_fd, GtkWidget *parent)
 {
 }
 
@@ -1536,7 +1536,7 @@ FileData *file_util_delete_dir_empty_path(FileData *fd, gint real_content, gint
                return file_data_ref(fd);
                }
 
-       if (!filelist_read_lstat(fd->path, &flist, &dlist)) file_data_ref(fd);
+       if (!filelist_read_lstat(fd, &flist, &dlist)) file_data_ref(fd);
 
        work = dlist;
        while (work && !fail)
@@ -1738,7 +1738,7 @@ void file_util_delete_dir(FileData *fd, GtkWidget *parent)
                return;
                }
 
-       if (!filelist_read_lstat(fd->path, &flist, &dlist))
+       if (!filelist_read_lstat(fd, &flist, &dlist))
                {
                gchar *text;
 
index a3d6978..5837714 100644 (file)
@@ -39,7 +39,7 @@ void file_util_move(FileData *source_fd, GList *source_list, const gchar *dest_p
 void file_util_copy(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent);
 void file_util_rename(FileData *source_fd, GList *source_list, GtkWidget *parent);
 
-void file_util_create_dir(const gchar *path, GtkWidget *parent);
+void file_util_create_dir(FileData *dir_fd, GtkWidget *parent);
 gint file_util_rename_dir(FileData *source_fd, const gchar *new_path, GtkWidget *parent);
 
 /* these avoid the location entry dialog, list must be files only and
index dff7160..a55f914 100644 (file)
@@ -51,19 +51,19 @@ static void vd_destroy_cb(GtkWidget *widget, gpointer data)
        if (vd->pf) folder_icons_free(vd->pf);
        if (vd->drop_list) filelist_free(vd->drop_list);
 
-       if (vd->path) g_free(vd->path);
+       if (vd->dir_fd) file_data_unref(vd->dir_fd);
        if (vd->info) g_free(vd->info);
 
        g_free(vd);
 }
 
-ViewDir *vd_new(DirViewType type, const gchar *path)
+ViewDir *vd_new(DirViewType type, FileData *dir_fd)
 {
        g_assert(VIEW_DIR_TYPES_COUNT <= G_N_ELEMENTS(menu_view_dir_radio_entries));
 
        ViewDir *vd = g_new0(ViewDir, 1);
 
-       vd->path = NULL;
+       vd->dir_fd = NULL;
        vd->click_fd = NULL;
 
        vd->drop_fd = NULL;
@@ -85,8 +85,8 @@ ViewDir *vd_new(DirViewType type, const gchar *path)
 
        switch(type)
        {
-       case DIRVIEW_LIST: vd = vdlist_new(vd, path); break;
-       case DIRVIEW_TREE: vd = vdtree_new(vd, path); break;
+       case DIRVIEW_LIST: vd = vdlist_new(vd, dir_fd); break;
+       case DIRVIEW_TREE: vd = vdtree_new(vd, dir_fd); break;
        }
 
        gtk_container_add(GTK_CONTAINER(vd->widget), vd->view);
@@ -104,7 +104,7 @@ ViewDir *vd_new(DirViewType type, const gchar *path)
        g_signal_connect(G_OBJECT(vd->view), "button_release_event",
                         G_CALLBACK(vd_release_cb), vd);
 
-       if (path) vd_set_path(vd, path);
+       if (dir_fd) vd_set_fd(vd, dir_fd);
 
        gtk_widget_show(vd->view);
 
@@ -123,14 +123,14 @@ void vd_set_layout(ViewDir *vd, LayoutWindow *layout)
        vd->layout = layout;
 }
 
-gint vd_set_path(ViewDir *vd, const gchar *path)
+gint vd_set_fd(ViewDir *vd, FileData *dir_fd)
 {
        gint ret = FALSE;
 
        switch(vd->type)
        {
-       case DIRVIEW_LIST: ret = vdlist_set_path(vd, path); break;
-       case DIRVIEW_TREE: ret = vdtree_set_path(vd, path); break;
+       case DIRVIEW_LIST: ret = vdlist_set_fd(vd, dir_fd); break;
+       case DIRVIEW_TREE: ret = vdtree_set_fd(vd, dir_fd); break;
        }
 
        return ret;
@@ -216,8 +216,6 @@ static gint vd_rename_cb(TreeEditData *td, const gchar *old, const gchar *new, g
        fd = vd_get_fd_from_tree_path(vd, GTK_TREE_VIEW(vd->view), td->path);
        if (!fd) return FALSE;
 
-       old_path = g_strdup(fd->path);
-
        base = remove_level_from_path(old_path);
        new_path = g_build_filename(base, new, NULL);
        g_free(base);
@@ -225,8 +223,8 @@ static gint vd_rename_cb(TreeEditData *td, const gchar *old, const gchar *new, g
        if (file_util_rename_dir(fd, new_path, vd->view))
                {
 
-               if (vd->type == DIRVIEW_TREE) vdtree_populate_path(vd, new_path, TRUE, TRUE);
-               if (vd->layout && strcmp(vd->path, old_path) == 0)
+               if (vd->type == DIRVIEW_TREE) vdtree_populate_path(vd, fd, TRUE, TRUE);
+               if (vd->layout && vd->dir_fd != fd) /* FIXME */
                        {
                        layout_set_path(vd->layout, new_path);
                        }
@@ -236,7 +234,6 @@ static gint vd_rename_cb(TreeEditData *td, const gchar *old, const gchar *new, g
                        }
                }
 
-       g_free(old_path);
        g_free(new_path);
 
        return FALSE;
@@ -393,8 +390,8 @@ static void vd_pop_menu_up_cb(GtkWidget *widget, gpointer data)
        ViewDir *vd = data;
        gchar *path;
 
-       if (!vd->path || strcmp(vd->path, G_DIR_SEPARATOR_S) == 0) return;
-       path = remove_level_from_path(vd->path);
+       if (!vd->dir_fd || strcmp(vd->dir_fd->path, G_DIR_SEPARATOR_S) == 0) return;
+       path = remove_level_from_path(vd->dir_fd->path);
 
        if (vd->select_func)
                {
@@ -407,14 +404,11 @@ static void vd_pop_menu_up_cb(GtkWidget *widget, gpointer data)
 static void vd_pop_menu_slide_cb(GtkWidget *widget, gpointer data)
 {
        ViewDir *vd = data;
-       gchar *path;
 
        if (!vd->layout) return;
        if (!vd->click_fd) return;
 
-       path = vd->click_fd->path;
-
-       layout_set_path(vd->layout, path);
+       layout_set_fd(vd->layout, vd->click_fd);
        layout_select_none(vd->layout);
        layout_image_slideshow_stop(vd->layout);
        layout_image_slideshow_start(vd->layout);
@@ -423,15 +417,12 @@ static void vd_pop_menu_slide_cb(GtkWidget *widget, gpointer data)
 static void vd_pop_menu_slide_rec_cb(GtkWidget *widget, gpointer data)
 {
        ViewDir *vd = data;
-       gchar *path;
        GList *list;
 
        if (!vd->layout) return;
        if (!vd->click_fd) return;
 
-       path = vd->click_fd->path;
-
-       list = filelist_recursive(path);
+       list = filelist_recursive(vd->click_fd);
 
        layout_image_slideshow_stop(vd->layout);
        layout_image_slideshow_start_from_list(vd->layout, list);
@@ -450,7 +441,7 @@ static void vd_pop_menu_dupe(ViewDir *vd, gint recursive)
                }
        else
                {
-               filelist_read(vd->click_fd->path, &list, NULL);
+               filelist_read(vd->click_fd, &list, NULL);
                list = filelist_filter(list, FALSE);
                }
 
@@ -524,8 +515,8 @@ static void vd_pop_menu_new_cb(GtkWidget *widget, gpointer data)
                {
                case DIRVIEW_LIST:
                        {
-                       if (!vd->path) return;
-                       path = vd->path;
+                       if (!vd->dir_fd) return;
+                       path = vd->dir_fd->path;
                        };
                        break;
                case DIRVIEW_TREE:
@@ -562,7 +553,11 @@ static void vd_pop_menu_new_cb(GtkWidget *widget, gpointer data)
                                };
                                break;
                        case DIRVIEW_TREE:
-                               fd = vdtree_populate_path(vd, new_path, TRUE, TRUE);
+                               {
+                               FileData *new_fd = file_data_new_simple(new_path);
+                               fd = vdtree_populate_path(vd, new_fd, TRUE, TRUE);
+                               file_data_unref(new_fd);
+                               }
                                break;
                        }
                vd_rename_by_data(vd, fd);
@@ -594,7 +589,7 @@ GtkWidget *vd_pop_menu(ViewDir *vd, FileData *fd)
                case DIRVIEW_LIST:
                        {
                        /* check using . (always row 0) */
-                       new_folder_active = (vd->path && access_file(vd->path , W_OK | X_OK));
+                       new_folder_active = (vd->dir_fd && access_file(vd->dir_fd->path , W_OK | X_OK));
 
                        /* ignore .. and . */
                        rename_delete_active = (new_folder_active && fd &&
@@ -622,7 +617,7 @@ GtkWidget *vd_pop_menu(ViewDir *vd, FileData *fd)
                         G_CALLBACK(vd_popup_destroy_cb), vd);
 
        menu_item_add_stock_sensitive(menu, _("_Up to parent"), GTK_STOCK_GO_UP,
-                                     (vd->path && strcmp(vd->path, G_DIR_SEPARATOR_S) != 0),
+                                     (vd->dir_fd && strcmp(vd->dir_fd->path, G_DIR_SEPARATOR_S) != 0),
                                      G_CALLBACK(vd_pop_menu_up_cb), vd);
 
        menu_item_add_divider(menu);
index 8fcfd14..fb55f95 100644 (file)
@@ -23,13 +23,13 @@ enum {
 #define VIEW_DIR_TYPES_COUNT 2
 extern GtkRadioActionEntry menu_view_dir_radio_entries[VIEW_DIR_TYPES_COUNT];
 
-ViewDir *vd_new(DirViewType type, const gchar *path);
+ViewDir *vd_new(DirViewType type, FileData *dir_fd);
 
 void vd_set_select_func(ViewDir *vdl, void (*func)(ViewDir *vdl, const gchar *path, gpointer data), gpointer data);
 
 void vd_set_layout(ViewDir *vdl, LayoutWindow *layout);
 
-gint vd_set_path(ViewDir *vdl, const gchar *path);
+gint vd_set_fd(ViewDir *vdl, FileData *dir_fd);
 void vd_refresh(ViewDir *vdl);
 gint vd_find_row(ViewDir *vd, FileData *fd, GtkTreeIter *iter);
 
index c17bdc6..579a6ac 100644 (file)
@@ -193,41 +193,41 @@ static void vdlist_populate(ViewDir *vd)
        vd->drop_fd = NULL;
 }
 
-gint vdlist_set_path(ViewDir *vd, const gchar *path)
+gint vdlist_set_fd(ViewDir *vd, FileData *dir_fd)
 {
        gint ret;
        FileData *fd;
        gchar *old_path = NULL;
        gchar *filepath;
 
-       if (!path) return FALSE;
-       if (vd->path && strcmp(path, vd->path) == 0) return TRUE;
+       if (!dir_fd) return FALSE;
+       if (vd->dir_fd == dir_fd) return TRUE;
 
-       if (vd->path)
+       if (vd->dir_fd)
                {
                gchar *base;
 
-               base = remove_level_from_path(vd->path);
-               if (strcmp(base, path) == 0)
+               base = remove_level_from_path(vd->dir_fd->path);
+               if (strcmp(base, dir_fd->path) == 0)
                        {
-                       old_path = g_strdup(filename_from_path(vd->path));
+                       old_path = g_strdup(vd->dir_fd->name);
                        }
                g_free(base);
                }
 
-       g_free(vd->path);
-       vd->path = g_strdup(path);
+       file_data_unref(vd->dir_fd);
+       vd->dir_fd = file_data_ref(dir_fd);
 
        filelist_free(VDLIST_INFO(vd, list));
 
-       ret = filelist_read(vd->path, NULL, &VDLIST_INFO(vd, list));
+       ret = filelist_read(vd->dir_fd, NULL, &VDLIST_INFO(vd, list));
        VDLIST_INFO(vd, list) = filelist_sort(VDLIST_INFO(vd, list), SORT_NAME, TRUE);
 
        /* add . and .. */
 
-       if (strcmp(vd->path, G_DIR_SEPARATOR_S) != 0)
+       if (strcmp(vd->dir_fd->path, G_DIR_SEPARATOR_S) != 0)
                {
-               filepath = g_build_filename(vd->path, "..", NULL);
+               filepath = g_build_filename(vd->dir_fd->path, "..", NULL);
                fd = file_data_new_simple(filepath);
                VDLIST_INFO(vd, list) = g_list_prepend(VDLIST_INFO(vd, list), fd);
                g_free(filepath);
@@ -235,7 +235,7 @@ gint vdlist_set_path(ViewDir *vd, const gchar *path)
 
        if (options->file_filter.show_dot_directory)
                {
-               filepath = g_build_filename(vd->path, ".", NULL);
+               filepath = g_build_filename(vd->dir_fd->path, ".", NULL);
                fd = file_data_new_simple(filepath);
                VDLIST_INFO(vd, list) = g_list_prepend(VDLIST_INFO(vd, list), fd);
                g_free(filepath);
@@ -273,12 +273,12 @@ gint vdlist_set_path(ViewDir *vd, const gchar *path)
 
 void vdlist_refresh(ViewDir *vd)
 {
-       gchar *path;
+       FileData *dir_fd;
 
-       path = g_strdup(vd->path);
-       vd->path = NULL;
-       vdlist_set_path(vd, path);
-       g_free(path);
+       dir_fd = vd->dir_fd;
+       vd->dir_fd = NULL;
+       vdlist_set_fd(vd, dir_fd);
+       file_data_unref(dir_fd);
 }
 
 gint vdlist_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
@@ -356,7 +356,7 @@ void vdlist_destroy_cb(GtkWidget *widget, gpointer data)
        filelist_free(VDLIST_INFO(vd, list));
 }
 
-ViewDir *vdlist_new(ViewDir *vd, const gchar *path)
+ViewDir *vdlist_new(ViewDir *vd, FileData *dir_fd)
 {
        GtkListStore *store;
        GtkTreeSelection *selection;
index f114d1c..491180d 100644 (file)
 #define VIEW_DIR_LIST_H
 
 
-ViewDir *vdlist_new(ViewDir *vd, const gchar *path);
+ViewDir *vdlist_new(ViewDir *vd, FileData *dir_fd);
 
 void vdlist_select_row(ViewDir *vd, FileData *fd);
 
-gint vdlist_set_path(ViewDir *vd, const gchar *path);
+gint vdlist_set_fd(ViewDir *vd, FileData *dir_fd);
 void vdlist_refresh(ViewDir *vd);
 
 const gchar *vdlist_row_get_path(ViewDir *vd, gint row);
index 9bc281d..9c57a1f 100644 (file)
@@ -42,7 +42,7 @@ struct _PathData
 
 
 
-static gint vdtree_populate_path_by_iter(ViewDir *vd, GtkTreeIter *iter, gint force, const gchar *target_path);
+static gint vdtree_populate_path_by_iter(ViewDir *vd, GtkTreeIter *iter, gint force, FileData *target_fd);
 
 
 /*
@@ -172,7 +172,7 @@ static gint vdtree_dnd_drop_expand_cb(gpointer data)
 
        if (vd->drop_fd && vd_find_row(vd, vd->drop_fd, &iter))
                {
-               vdtree_populate_path_by_iter(vd, &iter, FALSE, vd->path);
+               vdtree_populate_path_by_iter(vd, &iter, FALSE, vd->dir_fd);
                vdtree_expand_by_data(vd, vd->drop_fd, TRUE);
                }
 
@@ -413,13 +413,13 @@ static void vdtree_add_by_data(ViewDir *vd, FileData *fd, GtkTreeIter *parent)
                    gtk_tree_view_row_expanded(GTK_TREE_VIEW(vd->view), tpath) &&
                    !nd->expanded)
                        {
-                       vdtree_populate_path_by_iter(vd, &child, FALSE, vd->path);
+                       vdtree_populate_path_by_iter(vd, &child, FALSE, vd->dir_fd);
                        }
                gtk_tree_path_free(tpath);
                }
 }
 
-static gint vdtree_populate_path_by_iter(ViewDir *vd, GtkTreeIter *iter, gint force, const gchar *target_path)
+static gint vdtree_populate_path_by_iter(ViewDir *vd, GtkTreeIter *iter, gint force, FileData *target_fd)
 {
        GtkTreeModel *store;
        GList *list;
@@ -452,27 +452,27 @@ static gint vdtree_populate_path_by_iter(ViewDir *vd, GtkTreeIter *iter, gint fo
 
        vdtree_busy_push(vd);
 
-       filelist_read(nd->fd->path, NULL, &list);
+       filelist_read(nd->fd, NULL, &list);
 
        /* when hidden files are not enabled, and the user enters a hidden path,
         * allow the tree to display that path by specifically inserting the hidden entries
         */
        if (!options->file_filter.show_hidden_files &&
-           target_path &&
-           strncmp(nd->fd->path, target_path, strlen(nd->fd->path)) == 0)
+           target_fd &&
+           strncmp(nd->fd->path, target_fd->path, strlen(nd->fd->path)) == 0)
                {
                gint n;
 
                n = strlen(nd->fd->path);
-               if (target_path[n] == G_DIR_SEPARATOR && target_path[n+1] == '.')
+               if (target_fd->path[n] == G_DIR_SEPARATOR && target_fd->path[n+1] == '.')
                        {
                        gchar *name8;
                        struct stat sbuf;
 
                        n++;
 
-                       while (target_path[n] != '\0' && target_path[n] != G_DIR_SEPARATOR) n++;
-                       name8 = g_strndup(target_path, n);
+                       while (target_fd->path[n] != '\0' && target_fd->path[n] != G_DIR_SEPARATOR) n++;
+                       name8 = g_strndup(target_fd->path, n);
 
                        if (stat_utf8(name8, &sbuf))
                                {
@@ -515,7 +515,7 @@ static gint vdtree_populate_path_by_iter(ViewDir *vd, GtkTreeIter *iter, gint fo
                                {
                                old = g_list_remove(old, cnd);
                                if (cnd->expanded && cnd->fd->date != fd->date &&
-                                   vdtree_populate_path_by_iter(vd, &child, FALSE, target_path))
+                                   vdtree_populate_path_by_iter(vd, &child, FALSE, target_fd))
                                        {
                                        cnd->fd->size = fd->size;
                                        cnd->fd->date = fd->date;
@@ -557,17 +557,17 @@ static gint vdtree_populate_path_by_iter(ViewDir *vd, GtkTreeIter *iter, gint fo
        return TRUE;
 }
 
-FileData *vdtree_populate_path(ViewDir *vd, const gchar *path, gint expand, gint force)
+FileData *vdtree_populate_path(ViewDir *vd, FileData *target_fd, gint expand, gint force)
 {
        GList *list;
        GList *work;
        FileData *fd = NULL;
 
-       if (!path) return NULL;
+       if (!target_fd) return NULL;
 
        vdtree_busy_push(vd);
 
-       list = parts_list(path);
+       list = parts_list(target_fd->path);
        list = parts_list_add_node_points(vd, list);
 
        work = list;
@@ -593,7 +593,7 @@ FileData *vdtree_populate_path(ViewDir *vd, const gchar *path, gint expand, gint
                        parent_pd = work->prev->data;
 
                        if (!vd_find_row(vd, parent_pd->node, &parent_iter) ||
-                           !vdtree_populate_path_by_iter(vd, &parent_iter, force, path) ||
+                           !vdtree_populate_path_by_iter(vd, &parent_iter, force, target_fd) ||
                            (nd = vdtree_find_iter_by_name(vd, &parent_iter, pd->name, &iter)) == NULL)
                                {
                                log_printf("vdtree warning, aborted at %s\n", parent_pd->name);
@@ -611,7 +611,7 @@ FileData *vdtree_populate_path(ViewDir *vd, const gchar *path, gint expand, gint
                                        vdtree_expand_by_iter(vd, &parent_iter, TRUE);
                                        vdtree_expand_by_iter(vd, &iter, TRUE);
                                        }
-                               vdtree_populate_path_by_iter(vd, &iter, force, path);
+                               vdtree_populate_path_by_iter(vd, &iter, force, target_fd);
                                }
                        }
                else
@@ -621,7 +621,7 @@ FileData *vdtree_populate_path(ViewDir *vd, const gchar *path, gint expand, gint
                        if (vd_find_row(vd, pd->node, &iter))
                                {
                                if (expand) vdtree_expand_by_iter(vd, &iter, TRUE);
-                               vdtree_populate_path_by_iter(vd, &iter, force, path);
+                               vdtree_populate_path_by_iter(vd, &iter, force, target_fd);
                                }
                        }
 
@@ -668,7 +668,7 @@ void vdtree_select_row(ViewDir *vd, FileData *fd)
        gtk_tree_selection_select_iter(selection, &iter);
        selection_is_ok = FALSE;
 
-       if (!vdtree_populate_path_by_iter(vd, &iter, FALSE, vd->path)) return;
+       if (!vdtree_populate_path_by_iter(vd, &iter, FALSE, vd->dir_fd)) return;
 
        vdtree_expand_by_iter(vd, &iter, TRUE);
 
@@ -678,18 +678,18 @@ void vdtree_select_row(ViewDir *vd, FileData *fd)
                }
 }
 
-gint vdtree_set_path(ViewDir *vd, const gchar *path)
+gint vdtree_set_fd(ViewDir *vd, FileData *dir_fd)
 {
        FileData *fd;
        GtkTreeIter iter;
 
-       if (!path) return FALSE;
-       if (vd->path && strcmp(path, vd->path) == 0) return TRUE;
+       if (!dir_fd) return FALSE;
+       if (vd->dir_fd == dir_fd) return TRUE;
 
-       g_free(vd->path);
-       vd->path = g_strdup(path);
+       file_data_unref(vd->dir_fd);
+       vd->dir_fd = file_data_ref(dir_fd);;
 
-       fd = vdtree_populate_path(vd, vd->path, TRUE, FALSE);
+       fd = vdtree_populate_path(vd, vd->dir_fd, TRUE, FALSE);
 
        if (!fd) return FALSE;
 
@@ -720,7 +720,7 @@ const gchar *vdtree_get_path(ViewDir *vd)
 
 void vdtree_refresh(ViewDir *vd)
 {
-       vdtree_populate_path(vd, vd->path, FALSE, TRUE);
+       vdtree_populate_path(vd, vd->dir_fd, FALSE, TRUE);
 }
 
 const gchar *vdtree_row_get_path(ViewDir *vd, gint row)
@@ -773,7 +773,7 @@ gint vdtree_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
                case GDK_KP_Add:
                        if (fd)
                                {
-                               vdtree_populate_path_by_iter(vd, &iter, FALSE, vd->path);
+                               vdtree_populate_path_by_iter(vd, &iter, FALSE, vd->dir_fd);
                                vdtree_icon_set_by_iter(vd, &iter, vd->pf->open);
                                }
                        break;
@@ -836,7 +836,7 @@ gint vdtree_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
                            !left_of_expander &&
                            !gtk_tree_view_row_expanded(GTK_TREE_VIEW(vd->view), tpath))
                                {
-                               vdtree_populate_path_by_iter(vd, &iter, FALSE, vd->path);
+                               vdtree_populate_path_by_iter(vd, &iter, FALSE, vd->dir_fd);
                                vdtree_icon_set_by_iter(vd, &iter, vd->pf->open);
                                }
 
@@ -902,7 +902,7 @@ static void vdtree_setup_root(ViewDir *vd)
        vdtree_add_by_data(vd, fd, NULL);
 
        vdtree_expand_by_data(vd, fd, TRUE);
-       vdtree_populate_path(vd, path, FALSE, FALSE);
+       vdtree_populate_path(vd, fd, FALSE, FALSE);
 }
 
 static gboolean vdtree_destroy_node_cb(GtkTreeModel *store, GtkTreePath *tpath, GtkTreeIter *iter, gpointer data)
@@ -928,7 +928,7 @@ void vdtree_destroy_cb(GtkWidget *widget, gpointer data)
        gtk_tree_model_foreach(store, vdtree_destroy_node_cb, vd);
 }
 
-ViewDir *vdtree_new(ViewDir *vd, const gchar *path)
+ViewDir *vdtree_new(ViewDir *vd, FileData *dir_fd)
 {
        GtkTreeStore *store;
        GtkTreeSelection *selection;
index 9341ca4..fc2342f 100644 (file)
@@ -21,17 +21,17 @@ struct _NodeData
        time_t last_update;
 };
 
-ViewDir *vdtree_new(ViewDir *vd, const gchar *path);
+ViewDir *vdtree_new(ViewDir *vd, FileData *dir_fd);
 
 void vdtree_select_row(ViewDir *vd, FileData *fd);
 
-gint vdtree_set_path(ViewDir *vd, const gchar *path);
+gint vdtree_set_fd(ViewDir *vd, FileData *dir_fd);
 void vdtree_refresh(ViewDir *vd);
 
 const gchar *vdtree_row_get_path(ViewDir *vd, gint row);
 gint vdtree_find_row(ViewDir *vd, FileData *fd, GtkTreeIter *iter, GtkTreeIter *parent);
 
-FileData *vdtree_populate_path(ViewDir *vd, const gchar *path, gint expand, gint force);
+FileData *vdtree_populate_path(ViewDir *vd, FileData *target_fd, gint expand, gint force);
 void vdtree_rename_by_data(ViewDir *vd, FileData *fd);
 
 gint vdtree_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data);
index 4cf1f5e..b3589f0 100644 (file)
@@ -620,14 +620,14 @@ gint vf_refresh(ViewFile *vf)
        return ret;
 }
 
-gint vf_set_path(ViewFile *vf, const gchar *path)
+gint vf_set_fd(ViewFile *vf, FileData *dir_fd)
 {
        gint ret = FALSE;
 
        switch(vf->type)
        {
-       case FILEVIEW_LIST: ret = vflist_set_path(vf, path); break;
-       case FILEVIEW_ICON: ret = vficon_set_path(vf, path); break;
+       case FILEVIEW_LIST: ret = vflist_set_fd(vf, dir_fd); break;
+       case FILEVIEW_ICON: ret = vficon_set_fd(vf, dir_fd); break;
        }
        
        return ret;
@@ -650,12 +650,12 @@ static void vf_destroy_cb(GtkWidget *widget, gpointer data)
                gtk_widget_destroy(vf->popup);
                }
 
-       g_free(vf->path);
+       file_data_unref(vf->dir_fd);
        g_free(vf->info);
        g_free(vf);
 }
 
-ViewFile *vf_new(FileViewType type, const gchar *path)
+ViewFile *vf_new(FileViewType type, FileData *dir_fd)
 {
        ViewFile *vf;
 
@@ -663,7 +663,7 @@ ViewFile *vf_new(FileViewType type, const gchar *path)
        vf->type = type;
 
        vf->info = NULL;
-       vf->path = NULL;
+       vf->dir_fd = NULL;
        vf->list = NULL;
 
        vf->sort_method = SORT_NAME;
@@ -686,8 +686,8 @@ ViewFile *vf_new(FileViewType type, const gchar *path)
 
        switch(type)
        {
-       case FILEVIEW_LIST: vf = vflist_new(vf, path); break;
-       case FILEVIEW_ICON: vf = vficon_new(vf, path); break;
+       case FILEVIEW_LIST: vf = vflist_new(vf, dir_fd); break;
+       case FILEVIEW_ICON: vf = vficon_new(vf, dir_fd); break;
        }
 
        vf_dnd_init(vf);
@@ -702,7 +702,7 @@ ViewFile *vf_new(FileViewType type, const gchar *path)
        gtk_container_add(GTK_CONTAINER(vf->widget), vf->listview);
        gtk_widget_show(vf->listview);
 
-       if (path) vf_set_path(vf, path);
+       if (dir_fd) vf_set_fd(vf, dir_fd);
 
        return vf;
 }
index 407b97d..06c9c91 100644 (file)
 
 void vf_send_update(ViewFile *vf);
 
-ViewFile *vf_new(FileViewType type, const gchar *path);
+ViewFile *vf_new(FileViewType type, FileData *dir_fd);
 
 void vf_set_status_func(ViewFile *vf, void (*func)(ViewFile *vf, gpointer data), gpointer data);
 void vf_set_thumb_status_func(ViewFile *vf, void (*func)(ViewFile *vf, gdouble val, const gchar *text, gpointer data), gpointer data);
 
 void vf_set_layout(ViewFile *vf, LayoutWindow *layout);
 
-gint vf_set_path(ViewFile *vf, const gchar *path);
+gint vf_set_fd(ViewFile *vf, FileData *fd);
 gint vf_refresh(ViewFile *vf);
 
 void vf_thumb_set(ViewFile *vf, gint enable);
index 3942e5e..76ab7bc 100644 (file)
@@ -84,12 +84,12 @@ static IconData *vficon_icon_data(ViewFile *vf, FileData *fd)
 }
 
 
-static gint iconlist_read(const gchar *path, GList **list)
+static gint iconlist_read(FileData *dir_fd, GList **list)
 {
        GList *temp;
        GList *work;
 
-       if (!filelist_read(path, &temp, NULL)) return FALSE;
+       if (!filelist_read(dir_fd, &temp, NULL)) return FALSE;
 
        work = temp;
        while (work)
@@ -2030,9 +2030,9 @@ static gint vficon_refresh_real(ViewFile *vf, gint keep_position)
        old_list = vf->list;
        vf->list = NULL;
 
-       if (vf->path)
+       if (vf->dir_fd)
                {
-               ret = iconlist_read(vf->path, &vf->list);
+               ret = iconlist_read(vf->dir_fd, &vf->list);
                }
 
        /* check for same files from old_list */
@@ -2203,15 +2203,15 @@ static void vficon_append_column(ViewFile *vf, gint n)
  *-----------------------------------------------------------------------------
  */
 
-gint vficon_set_path(ViewFile *vf, const gchar *path)
+gint vficon_set_fd(ViewFile *vf, FileData *dir_fd)
 {
        gint ret;
 
-       if (!path) return FALSE;
-       if (vf->path && strcmp(path, vf->path) == 0) return TRUE;
+       if (!dir_fd) return FALSE;
+       if (vf->dir_fd == dir_fd) return TRUE;
 
-       g_free(vf->path);
-       vf->path = g_strdup(path);
+       file_data_unref(vf->dir_fd);
+       vf->dir_fd = file_data_ref(dir_fd);
 
        g_list_free(VFICON_INFO(vf, selection));
        VFICON_INFO(vf, selection) = NULL;
@@ -2242,7 +2242,7 @@ void vficon_destroy_cb(GtkWidget *widget, gpointer data)
        g_list_free(VFICON_INFO(vf, selection));
 }
 
-ViewFile *vficon_new(ViewFile *vf, const gchar *path)
+ViewFile *vficon_new(ViewFile *vf, FileData *dir_fd)
 {
        GtkListStore *store;
        GtkTreeSelection *selection;
@@ -2535,11 +2535,11 @@ gint vficon_maint_moved(ViewFile *vf, FileData *fd, GList *ignore_list)
        gint ret = FALSE;
        gchar *buf;
 
-       if (!fd->change->source || !vf->path) return FALSE;
+       if (!fd->change->source || !vf->dir_fd) return FALSE;
 
        buf = remove_level_from_path(fd->change->source);
 
-       if (strcmp(buf, vf->path) == 0)
+       if (strcmp(buf, vf->dir_fd->path) == 0)
                {
                ret = vficon_maint_removed(vf, fd, ignore_list);
                }
index 0bed76a..70b0584 100644 (file)
@@ -20,9 +20,9 @@ gint vficon_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
 void vficon_dnd_init(ViewFile *vf);
 
 void vficon_destroy_cb(GtkWidget *widget, gpointer data);
-ViewFile *vficon_new(ViewFile *vf, const gchar *path);
+ViewFile *vficon_new(ViewFile *vf, FileData *dir_fd);
 
-gint vficon_set_path(ViewFile *vf, const gchar *path);
+gint vficon_set_fd(ViewFile *vf, FileData *dir_fd);
 gint vficon_refresh(ViewFile *vf);
 
 void vficon_sort_set(ViewFile *vf, SortType type, gint ascend);
index 6f2dbe6..0663f6d 100644 (file)
@@ -382,8 +382,8 @@ static gint vflist_row_rename_cb(TreeEditData *td, const gchar *old, const gchar
 
        if (strlen(new) == 0) return FALSE;
 
-       old_path = g_build_filename(vf->path, old, NULL);
-       new_path = g_build_filename(vf->path, new, NULL);
+       old_path = g_build_filename(vf->dir_fd->path, old, NULL);
+       new_path = g_build_filename(vf->dir_fd->path, new, NULL);
 
        if (strchr(new, G_DIR_SEPARATOR) != NULL)
                {
@@ -1561,9 +1561,9 @@ gint vflist_refresh(ViewFile *vf)
        vf->list = NULL;
 
        DEBUG_1("%s vflist_refresh: read dir", get_exec_time());
-       if (vf->path)
+       if (vf->dir_fd)
                {
-               ret = filelist_read(vf->path, &vf->list, NULL);
+               ret = filelist_read(vf->dir_fd, &vf->list, NULL);
 
                DEBUG_1("%s vflist_refresh: sort", get_exec_time());
                vf->list = filelist_sort(vf->list, vf->sort_method, vf->sort_ascend);
@@ -1735,15 +1735,15 @@ static void vflist_listview_add_column_toggle(ViewFile *vf, gint n, const gchar
  *-----------------------------------------------------------------------------
  */
 
-gint vflist_set_path(ViewFile *vf, const gchar *path)
+gint vflist_set_fd(ViewFile *vf, FileData *dir_fd)
 {
        GtkTreeStore *store;
 
-       if (!path) return FALSE;
-       if (vf->path && strcmp(path, vf->path) == 0) return TRUE;
+       if (!dir_fd) return FALSE;
+       if (vf->dir_fd == dir_fd) return TRUE;
 
-       g_free(vf->path);
-       vf->path = g_strdup(path);
+       file_data_unref(vf->dir_fd);
+       vf->dir_fd = file_data_ref(dir_fd);
 
        /* force complete reload */
        store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)));
@@ -1766,7 +1766,7 @@ void vflist_destroy_cb(GtkWidget *widget, gpointer data)
        filelist_free(vf->list);
 }
 
-ViewFile *vflist_new(ViewFile *vf, const gchar *path)
+ViewFile *vflist_new(ViewFile *vf, FileData *dir_fd)
 {
        GtkTreeStore *store;
        GtkTreeSelection *selection;
@@ -1866,19 +1866,26 @@ void vflist_maint(ViewFile *vf, FileData *fd)
 
        if (vf->refresh_idle_id != -1) return;
        
-       refresh = (strcmp(fd->path, vf->path) == 0);
+       refresh = (fd == vf->dir_fd);
 
-       if (!refresh)
+       if (!refresh && fd->change->dest)
+               {
+               gchar *base = remove_level_from_path(fd->path);
+               refresh = (strcmp(base, vf->dir_fd->path) == 0);
+               g_free(base);
+               }
+
+       if (!refresh && fd->change->dest)
                {
                gchar *dest_base = remove_level_from_path(fd->change->dest);
-               refresh = (strcmp(dest_base, vf->path) == 0);
+               refresh = (strcmp(dest_base, vf->dir_fd->path) == 0);
                g_free(dest_base);
                }
 
-       if (!refresh)
+       if (!refresh && fd->change->source)
                {
                gchar *source_base = remove_level_from_path(fd->change->source);
-               refresh = (strcmp(source_base, vf->path) == 0);
+               refresh = (strcmp(source_base, vf->dir_fd->path) == 0);
                g_free(source_base);
                }
        
index 45d30c6..75ca89a 100644 (file)
@@ -23,9 +23,9 @@ gint vflist_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
 void vflist_dnd_init(ViewFile *vf);
 
 void vflist_destroy_cb(GtkWidget *widget, gpointer data);
-ViewFile *vflist_new(ViewFile *vf, const gchar *path);
+ViewFile *vflist_new(ViewFile *vf, FileData *dir_fd);
 
-gint vflist_set_path(ViewFile *vf, const gchar *path);
+gint vflist_set_fd(ViewFile *vf, FileData *dir_fd);
 gint vflist_refresh(ViewFile *vf);
 
 void vflist_thumb_set(ViewFile *vf, gint enable);