static void bar_sort_collection_list_build(GtkWidget *bookmarks)
{
gchar *collect_path;
+ FileData *dir_fd;
GList *list;
GList *work;
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);
{
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;
CMData *cm;
GList *dlist;
gchar *base;
+ FileData *dir_fd;
const gchar *msg;
const gchar *cache_folder;
GtkWidget *hbox;
}
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;
gchar *base;
gint base_length;
GList *dlist = NULL;
+ FileData *dir_fd;
GList *flist = NULL;
gint still_have_a_file = FALSE;
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;
filelist_free(dlist);
filelist_free(flist);
- g_free(base);
+ file_data_unref(dir_fd);
return still_have_a_file;
}
/* 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)
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) ||
}
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)
{
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);
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);
}
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);
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));
}
CleanData *cd = data;
GList *list;
gchar *path;
+ FileData *dir_fd;
if (cd->list || !GTK_WIDGET_SENSITIVE(cd->button_start)) return;
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);
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;
*-------------------------------------------------------------------
*/
-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);
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;
}
{
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);
}
else if (isdir(fd->path) && recurse)
{
GList *f, *d;
-
- if (filelist_read(fd->path, &f, &d))
+ if (filelist_read(fd, &f, &d))
{
GList *work;
{
GList *list;
- filelist_read(fd->path, &list, NULL);
+ filelist_read(fd, &list, NULL);
list = filelist_filter(list, FALSE);
if (list)
{
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;
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);
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)
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);
}
}
-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);
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);
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);
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))
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);
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;
}
{
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);
}
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);
}
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;
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 */
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));
}
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);
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;
}
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)
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);
{
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);
}
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);
void layout_style_set(LayoutWindow *lw, gint style, const gchar *order)
{
- gchar *path;
+ FileData *dir_fd;
gint i;
if (!layout_valid(&lw)) return;
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;
/* 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)
gtk_widget_destroy(lw->window);
- g_free(lw->path);
+ file_data_unref(lw->dir_fd);
g_free(lw);
}
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;
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
{
}
/* 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)
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)
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);
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);
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);
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);
}
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)
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;
}
{
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);
}
else if (isdir(fd->path))
{
- layout_set_path(lw, fd->path);
+ layout_set_fd(lw, fd);
layout_image_set_fd(lw, NULL);
}
}
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)
{
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));
}
/*
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)
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)
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;
if (fd)
{
// layout_list_sync_path(lw, path);
- layout_set_path(lw, fd->path);
+ layout_set_fd(lw, fd);
}
}
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),
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)
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)
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)
{
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)
{
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)
{
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;
}
g_free(path_parsed);
+ file_data_unref(dir_fd);
}
static void parse_command_line_process_dir(const gchar *dir, gchar **path, gchar **file,
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;
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)
{
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;
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,
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);
}
}
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;
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)
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);
*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,
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;
}
}
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;
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;
#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;
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)
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;
#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;
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)
{
gint overlay_id;
- gchar *path;
+ FileData *dir_fd;
PanLayoutType layout;
PanImageSize size;
gint thumb_size;
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);
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
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;
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);
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)
{
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);
*-----------------------------------------------------------------------------
*/
-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)
{
{
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;
}
{
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..."));
}
}
- 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);
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);
}
}
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);
pan_window_items_free(pw);
pan_cache_free(pw);
- g_free(pw->path);
+ file_data_unref(pw->dir_fd);
g_free(pw);
}
return TRUE;
}
-static void pan_window_new_real(const gchar *path)
+static void pan_window_new_real(FileData *dir_fd)
{
PanWindow *pw;
GtkWidget *vbox;
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;
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);
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)
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;
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;
}
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);
*-----------------------------------------------------------------------------
*/
-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);
}
{
FileData *fd = list->data;
- pan_layout_set_path(pw, fd->path);
+ pan_layout_set_fd(pw, fd);
}
filelist_free(list);
#define PAN_VIEW_H
-void pan_window_new(const gchar *path);
+void pan_window_new(FileData *dir_fd);
#endif
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);
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;
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;
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)
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);
}
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);
}
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);
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);
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;
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;
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;
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);
#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);
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);
gint slideshow_should_continue(SlideShowData *ss)
{
FileData *imd_fd;
- const gchar *path;
+ FileData *dir_fd;
if (!ss) return FALSE;
}
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;
ss->filelist = filelist;
ss->cd = cd;
ss->layout = lw;
- ss->layout_path = NULL;
+ ss->dir_fd = NULL;
ss->list = NULL;
ss->list_done = NULL;
/* 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);
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)
struct _LayoutWindow
{
- gchar *path;
+ FileData *dir_fd;
/* base */
/* directory update check */
gint last_time_id;
- time_t last_time;
+ gint last_version;
/* misc */
GtkWidget *widget;
GtkWidget *view;
- gchar *path;
+ FileData *dir_fd;
FileData *click_fd;
GtkWidget *widget;
GtkWidget *listview;
- gchar *path;
+ FileData *dir_fd;
GList *list;
SortType sort_method;
GList *filelist;
CollectionData *cd;
- gchar *layout_path;
+ FileData *dir_fd;
LayoutWindow *layout;
GList *list;
/* FIXME: */
-void file_util_create_dir(const gchar *path, GtkWidget *parent)
+void file_util_create_dir(FileData *dir_fd, GtkWidget *parent)
{
}
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)
return;
}
- if (!filelist_read_lstat(fd->path, &flist, &dlist))
+ if (!filelist_read_lstat(fd, &flist, &dlist))
{
gchar *text;
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
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;
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);
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);
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;
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);
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);
}
}
}
- g_free(old_path);
g_free(new_path);
return FALSE;
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)
{
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);
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);
}
else
{
- filelist_read(vd->click_fd->path, &list, NULL);
+ filelist_read(vd->click_fd, &list, NULL);
list = filelist_filter(list, FALSE);
}
{
case DIRVIEW_LIST:
{
- if (!vd->path) return;
- path = vd->path;
+ if (!vd->dir_fd) return;
+ path = vd->dir_fd->path;
};
break;
case DIRVIEW_TREE:
};
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);
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 &&
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);
#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);
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);
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);
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)
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;
#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);
-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);
/*
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);
}
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;
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))
{
{
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;
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;
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);
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
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);
}
}
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);
}
}
-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;
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)
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;
!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);
}
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)
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;
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);
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;
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;
vf->type = type;
vf->info = NULL;
- vf->path = NULL;
+ vf->dir_fd = NULL;
vf->list = NULL;
vf->sort_method = SORT_NAME;
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);
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;
}
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);
}
-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)
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 */
*-----------------------------------------------------------------------------
*/
-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;
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;
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);
}
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);
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)
{
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);
*-----------------------------------------------------------------------------
*/
-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)));
filelist_free(vf->list);
}
-ViewFile *vflist_new(ViewFile *vf, const gchar *path)
+ViewFile *vflist_new(ViewFile *vf, FileData *dir_fd)
{
GtkTreeStore *store;
GtkTreeSelection *selection;
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);
}
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);