#include "editors.h"
#include "layout.h"
#include "menu.h"
+#include "thumb.h"
#include "ui_menu.h"
#include "ui_fileops.h"
#include "utilops.h"
return menu;
}
-void vf_thumb_update(ViewFile *vf)
-{
- switch (vf->type)
- {
- case FILEVIEW_LIST: vflist_thumb_update(vf); break;
- case FILEVIEW_ICON: vficon_thumb_update(vf); break;
- }
-}
-
gboolean vf_refresh(ViewFile *vf)
{
gboolean ret = FALSE;
}
}
+
+static gboolean vf_thumb_next(ViewFile *vf);
+
+static gdouble vf_thumb_progress(ViewFile *vf)
+{
+ gint count = 0;
+ gint done = 0;
+
+ switch (vf->type)
+ {
+ case FILEVIEW_LIST: vflist_thumb_progress_count(vf->list, &count, &done); break;
+ case FILEVIEW_ICON: vficon_thumb_progress_count(vf->list, &count, &done); break;
+ }
+
+ DEBUG_1("thumb progress: %d of %d", done, count);
+ return (gdouble)done / count;
+}
+
+static void vf_set_thumb_fd(ViewFile *vf, FileData *fd)
+{
+ switch (vf->type)
+ {
+ case FILEVIEW_LIST: vflist_set_thumb_fd(vf, fd); break;
+ case FILEVIEW_ICON: vficon_set_thumb_fd(vf, fd); break;
+ }
+}
+
+static void vf_thumb_status(ViewFile *vf, gdouble val, const gchar *text)
+{
+ if (vf->func_thumb_status)
+ {
+ vf->func_thumb_status(vf, val, text, vf->data_thumb_status);
+ }
+}
+
+static void vf_thumb_do(ViewFile *vf, FileData *fd)
+{
+ if (!fd) return;
+
+ vf_set_thumb_fd(vf, fd);
+ vf_thumb_status(vf, vf_thumb_progress(vf), _("Loading thumbs..."));
+}
+
+void vf_thumb_cleanup(ViewFile *vf)
+{
+ vf_thumb_status(vf, 0.0, NULL);
+
+ vf->thumbs_running = FALSE;
+
+ thumb_loader_free(vf->thumbs_loader);
+ vf->thumbs_loader = NULL;
+
+ vf->thumbs_filedata = NULL;
+}
+
+void vf_thumb_stop(ViewFile *vf)
+{
+ if (vf->thumbs_running) vf_thumb_cleanup(vf);
+}
+
+static void vf_thumb_common_cb(ThumbLoader *tl, gpointer data)
+{
+ ViewFile *vf = data;
+
+ if (vf->thumbs_filedata && vf->thumbs_loader == tl)
+ {
+ vf_thumb_do(vf, vf->thumbs_filedata);
+ }
+
+ while (vf_thumb_next(vf));
+}
+
+static void vf_thumb_error_cb(ThumbLoader *tl, gpointer data)
+{
+ vf_thumb_common_cb(tl, data);
+}
+
+static void vf_thumb_done_cb(ThumbLoader *tl, gpointer data)
+{
+ vf_thumb_common_cb(tl, data);
+}
+
+static gboolean vf_thumb_next(ViewFile *vf)
+{
+ FileData *fd = NULL;
+ gint ret;
+
+ if (!GTK_WIDGET_REALIZED(vf->listview))
+ {
+ vf_thumb_status(vf, 0.0, NULL);
+ return FALSE;
+ }
+
+ switch (vf->type)
+ {
+ case FILEVIEW_LIST: fd = vflist_thumb_next_fd(vf); break;
+ case FILEVIEW_ICON: fd = vficon_thumb_next_fd(vf); break;
+ }
+
+ if (!fd)
+ {
+ /* done */
+ vf_thumb_cleanup(vf);
+ return FALSE;
+ }
+
+ vf->thumbs_filedata = fd;
+
+ thumb_loader_free(vf->thumbs_loader);
+
+ vf->thumbs_loader = thumb_loader_new(options->thumbnails.max_width, options->thumbnails.max_height);
+ thumb_loader_set_callbacks(vf->thumbs_loader,
+ vf_thumb_done_cb,
+ vf_thumb_error_cb,
+ NULL,
+ vf);
+
+ if (!thumb_loader_start(vf->thumbs_loader, fd))
+ {
+ /* set icon to unknown, continue */
+ DEBUG_1("thumb loader start failed %s", fd->path);
+ vf_thumb_do(vf, fd);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void vf_thumb_reset_all(ViewFile *vf)
+{
+ switch (vf->type)
+ {
+ case FILEVIEW_LIST: vflist_thumb_reset_all(vf); break;
+ case FILEVIEW_ICON: vficon_thumb_reset_all(vf); break;
+ }
+}
+
+void vf_thumb_update(ViewFile *vf)
+{
+ vf_thumb_stop(vf);
+
+ if (vf->type == FILEVIEW_LIST && !VFLIST(vf)->thumbs_enabled) return;
+
+ vf_thumb_status(vf, 0.0, _("Loading thumbs..."));
+ vf->thumbs_running = TRUE;
+
+ if (thumb_format_changed)
+ {
+ vf_thumb_reset_all(vf);
+ thumb_format_changed = FALSE;
+ }
+
+ while (vf_thumb_next(vf));
+}
+
+
void vf_marks_set(ViewFile *vf, gboolean enable)
{
if (vf->marks_enabled == enable) return;
void vf_notify_cb(FileData *fd, NotifyType type, gpointer data);
void vf_thumb_update(ViewFile *vf);
+void vf_thumb_cleanup(ViewFile *vf);
+void vf_thumb_stop(ViewFile *vf);
#endif /* VIEW_FILE_H */
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
gtk_list_store_clear(GTK_LIST_STORE(store));
}
-static void vficon_set_thumb(ViewFile *vf, FileData *fd)
-{
- GtkTreeModel *store;
- GtkTreeIter iter;
- GList *list;
-
- if (!vficon_find_iter(vf, vficon_icon_data(vf, fd), &iter, NULL)) return;
-
- store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
-
- gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1);
- gtk_list_store_set(GTK_LIST_STORE(store), &iter, FILE_COLUMN_POINTER, list, -1);
-}
-
static GList *vficon_add_row(ViewFile *vf, GtkTreeIter *iter)
{
GtkListStore *store;
vf_send_update(vf);
- vficon_thumb_update(vf);
+ vf_thumb_update(vf);
}
static void vficon_populate_at_new_size(ViewFile *vf, gint w, gint h, gboolean force)
*-----------------------------------------------------------------------------
*/
-static gboolean vficon_thumb_next(ViewFile *vf);
-
-static gdouble vficon_thumb_progress(ViewFile *vf)
+void vficon_thumb_progress_count(GList *list, gint *count, gint *done)
{
- gint count = 0;
- gint done = 0;
-
- GList *work = vf->list;
+ GList *work = list;
while (work)
{
IconData *id = work->data;
FileData *fd = id->fd;
work = work->next;
- if (fd->thumb_pixbuf) done++;
- count++;
- }
- DEBUG_1("thumb progress: %d of %d", done, count);
- return (gdouble)done / count;
-}
-
-static void vficon_thumb_status(ViewFile *vf, gdouble val, const gchar *text)
-{
- if (vf->func_thumb_status)
- {
- vf->func_thumb_status(vf, val, text, vf->data_thumb_status);
+ if (fd->thumb_pixbuf) (*done)++;
+ (*count)++;
}
}
-static void vficon_thumb_cleanup(ViewFile *vf)
+void vficon_set_thumb_fd(ViewFile *vf, FileData *fd)
{
- vficon_thumb_status(vf, 0.0, NULL);
-
- vf->thumbs_running = FALSE;
-
- thumb_loader_free(vf->thumbs_loader);
- vf->thumbs_loader = NULL;
-
- vf->thumbs_filedata = NULL;
-}
-
-static void vficon_thumb_stop(ViewFile *vf)
-{
- if (vf->thumbs_running) vficon_thumb_cleanup(vf);
-}
-
-static void vficon_thumb_do(ViewFile *vf, ThumbLoader *tl, FileData *fd)
-{
- if (!fd) return;
-
- vficon_set_thumb(vf, fd);
-
- vficon_thumb_status(vf, vficon_thumb_progress(vf), _("Loading thumbs..."));
-}
+ GtkTreeModel *store;
+ GtkTreeIter iter;
+ GList *list;
-static void vficon_thumb_error_cb(ThumbLoader *tl, gpointer data)
-{
- ViewFile *vf = data;
+ if (!vficon_find_iter(vf, vficon_icon_data(vf, fd), &iter, NULL)) return;
- if (vf->thumbs_filedata && vf->thumbs_loader == tl)
- {
- vficon_thumb_do(vf, tl, vf->thumbs_filedata);
- }
+ store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
- while (vficon_thumb_next(vf));
+ gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1);
+ gtk_list_store_set(GTK_LIST_STORE(store), &iter, FILE_COLUMN_POINTER, list, -1);
}
-static void vficon_thumb_done_cb(ThumbLoader *tl, gpointer data)
-{
- ViewFile *vf = data;
-
- if (vf->thumbs_filedata && vf->thumbs_loader == tl)
- {
- vficon_thumb_do(vf, tl, vf->thumbs_filedata);
- }
-
- while (vficon_thumb_next(vf));
-}
-static gboolean vficon_thumb_next(ViewFile *vf)
+FileData *vficon_thumb_next_fd(ViewFile *vf)
{
GtkTreePath *tpath;
FileData *fd = NULL;
- if (!GTK_WIDGET_REALIZED(vf->listview))
- {
- vficon_thumb_status(vf, 0.0, NULL);
- return FALSE;
- }
-
if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL))
{
GtkTreeModel *store;
}
}
- if (!fd)
- {
- /* done */
- vficon_thumb_cleanup(vf);
- return FALSE;
- }
-
- vf->thumbs_filedata = fd;
-
- thumb_loader_free(vf->thumbs_loader);
-
- vf->thumbs_loader = thumb_loader_new(options->thumbnails.max_width, options->thumbnails.max_height);
- thumb_loader_set_callbacks(vf->thumbs_loader,
- vficon_thumb_done_cb,
- vficon_thumb_error_cb,
- NULL,
- vf);
-
- if (!thumb_loader_start(vf->thumbs_loader, fd))
- {
- /* set icon to unknown, continue */
- DEBUG_1("thumb loader start failed %s", fd->path);
- vficon_thumb_do(vf, vf->thumbs_loader, fd);
-
- return TRUE;
- }
-
- return FALSE;
+ return fd;
}
-void vficon_thumb_update(ViewFile *vf)
+void vficon_thumb_reset_all(ViewFile *vf)
{
- vficon_thumb_stop(vf);
+ GList *work = vf->list;
- vficon_thumb_status(vf, 0.0, _("Loading thumbs..."));
- vf->thumbs_running = TRUE;
-
- if (thumb_format_changed)
+ while (work)
{
- GList *work = vf->list;
- while (work)
+ IconData *id = work->data;
+ FileData *fd = id->fd;
+ if (fd->thumb_pixbuf)
{
- IconData *id = work->data;
- FileData *fd = id->fd;
- if (fd->thumb_pixbuf)
- {
- g_object_unref(fd->thumb_pixbuf);
- fd->thumb_pixbuf = NULL;
- }
- work = work->next;
+ g_object_unref(fd->thumb_pixbuf);
+ fd->thumb_pixbuf = NULL;
}
-
- thumb_format_changed = FALSE;
+ work = work->next;
}
-
- while (vficon_thumb_next(vf));
}
+
/*
*-----------------------------------------------------------------------------
* row stuff
tip_unschedule(vf);
- vficon_thumb_cleanup(vf);
+ vf_thumb_cleanup(vf);
iconlist_free(vf->list);
g_list_free(VFICON(vf)->selection);
void vficon_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode);
void vficon_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode);
-void vficon_thumb_update(ViewFile *vf);
+
+void vficon_thumb_progress_count(GList *list, gint *count, gint *done);
+void vficon_set_thumb_fd(ViewFile *vf, FileData *fd);
+FileData *vficon_thumb_next_fd(ViewFile *vf);
+void vficon_thumb_reset_all(ViewFile *vf);
#endif
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
*-----------------------------------------------------------------------------
*/
-static gboolean vflist_thumb_next(ViewFile *vf);
-static void vflist_thumb_progress_count(GList *list, gint *count, gint *done)
+void vflist_thumb_progress_count(GList *list, gint *count, gint *done)
{
GList *work = list;
while (work)
}
}
-static gdouble vflist_thumb_progress(ViewFile *vf)
-{
- gint count = 0;
- gint done = 0;
-
- vflist_thumb_progress_count(vf->list, &count, &done);
-
- DEBUG_1("thumb progress: %d of %d", done, count);
- return (gdouble)done / count;
-}
-
-
-static void vflist_thumb_status(ViewFile *vf, gdouble val, const gchar *text)
-{
- if (vf->func_thumb_status)
- {
- vf->func_thumb_status(vf, val, text, vf->data_thumb_status);
- }
-}
-
-static void vflist_thumb_cleanup(ViewFile *vf)
-{
- vflist_thumb_status(vf, 0.0, NULL);
-
- vf->thumbs_running = FALSE;
-
- thumb_loader_free(vf->thumbs_loader);
- vf->thumbs_loader = NULL;
-
- vf->thumbs_filedata = NULL;
-}
-
-static void vflist_thumb_stop(ViewFile *vf)
-{
- if (vf->thumbs_running) vflist_thumb_cleanup(vf);
-}
-
-static void vflist_thumb_do(ViewFile *vf, ThumbLoader *tl, FileData *fd)
+void vflist_set_thumb_fd(ViewFile *vf, FileData *fd)
{
GtkTreeStore *store;
GtkTreeIter iter;
store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)));
gtk_tree_store_set(store, &iter, FILE_COLUMN_THUMB, fd->thumb_pixbuf, -1);
-
- vflist_thumb_status(vf, vflist_thumb_progress(vf), _("Loading thumbs..."));
-}
-
-static void vflist_thumb_error_cb(ThumbLoader *tl, gpointer data)
-{
- ViewFile *vf = data;
-
- if (vf->thumbs_filedata && vf->thumbs_loader == tl)
- {
- vflist_thumb_do(vf, tl, vf->thumbs_filedata);
- }
-
- while (vflist_thumb_next(vf));
}
-static void vflist_thumb_done_cb(ThumbLoader *tl, gpointer data)
-{
- ViewFile *vf = data;
-
- if (vf->thumbs_filedata && vf->thumbs_loader == tl)
- {
- vflist_thumb_do(vf, tl, vf->thumbs_filedata);
- }
-
- while (vflist_thumb_next(vf));
-}
-
-static gboolean vflist_thumb_next(ViewFile *vf)
+FileData *vflist_thumb_next_fd(ViewFile *vf)
{
GtkTreePath *tpath;
FileData *fd = NULL;
/* first check the visible files */
- if (GTK_WIDGET_REALIZED(vf->listview) &&
- gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL))
+ if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL))
{
GtkTreeModel *store;
GtkTreeIter iter;
}
}
- if (!fd)
- {
- /* done */
- vflist_thumb_cleanup(vf);
- return FALSE;
- }
-
- vf->thumbs_filedata = fd;
-
- thumb_loader_free(vf->thumbs_loader);
-
- vf->thumbs_loader = thumb_loader_new(options->thumbnails.max_width, options->thumbnails.max_height);
- thumb_loader_set_callbacks(vf->thumbs_loader,
- vflist_thumb_done_cb,
- vflist_thumb_error_cb,
- NULL,
- vf);
-
- if (!thumb_loader_start(vf->thumbs_loader, fd))
- {
- /* set icon to unknown, continue */
- DEBUG_1("thumb loader start failed %s", fd->path);
- vflist_thumb_do(vf, vf->thumbs_loader, fd);
-
- return TRUE;
- }
-
- return FALSE;
+ return fd;
}
-void vflist_thumb_update(ViewFile *vf)
-{
- vflist_thumb_stop(vf);
- if (!VFLIST(vf)->thumbs_enabled) return;
-
- vflist_thumb_status(vf, 0.0, _("Loading thumbs..."));
- vf->thumbs_running = TRUE;
- if (thumb_format_changed)
+void vflist_thumb_reset_all(ViewFile *vf)
+{
+ GList *work = vf->list;
+ while (work)
{
- GList *work = vf->list;
- while (work)
+ FileData *fd = work->data;
+ if (fd->thumb_pixbuf)
{
- FileData *fd = work->data;
- if (fd->thumb_pixbuf)
- {
- g_object_unref(fd->thumb_pixbuf);
- fd->thumb_pixbuf = NULL;
- }
- work = work->next;
+ g_object_unref(fd->thumb_pixbuf);
+ fd->thumb_pixbuf = NULL;
}
-
- thumb_format_changed = FALSE;
+ work = work->next;
}
-
- while (vflist_thumb_next(vf));
}
/*
store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)));
thumbs_enabled = VFLIST(vf)->thumbs_enabled;
- vflist_thumb_stop(vf);
+ vf_thumb_stop(vf);
if (!vf->list)
{
filelist_free(selected);
vf_send_update(vf);
- vflist_thumb_update(vf);
+ vf_thumb_update(vf);
}
gboolean vflist_refresh(ViewFile *vf)
vflist_select_idle_cancel(vf);
vf_refresh_idle_cancel(vf);
- vflist_thumb_stop(vf);
+ vf_thumb_stop(vf);
filelist_free(vf->list);
}
void vflist_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode);
void vflist_color_set(ViewFile *vf, FileData *fd, gboolean color_set);
-void vflist_thumb_update(ViewFile *vf);
+
+void vflist_thumb_progress_count(GList *list, gint *count, gint *done);
+void vflist_set_thumb_fd(ViewFile *vf, FileData *fd);
+FileData *vflist_thumb_next_fd(ViewFile *vf);
+void vflist_thumb_reset_all(ViewFile *vf);
#endif
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */