Revision: 1706
http://geeqie.svn.sourceforge.net/geeqie/?rev=1706&view=rev
Author: zas_
Date: 2009-05-14 20:32:14 +0000 (Thu, 14 May 2009)
Log Message:
-----------
Merge common thumb code from view_file_list and view_file_icon to view_file.
Modified Paths:
--------------
trunk/src/view_file.c
trunk/src/view_file.h
trunk/src/view_file_icon.c
trunk/src/view_file_icon.h
trunk/src/view_file_list.c
trunk/src/view_file_list.h
Modified: trunk/src/view_file.c
===================================================================
--- trunk/src/view_file.c 2009-05-13 19:29:27 UTC (rev 1705)
+++ trunk/src/view_file.c 2009-05-14 20:32:14 UTC (rev 1706)
@@ -15,6 +15,7 @@
#include "editors.h"
#include "layout.h"
#include "menu.h"
+#include "thumb.h"
#include "ui_menu.h"
#include "ui_fileops.h"
#include "utilops.h"
@@ -633,15 +634,6 @@
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;
@@ -788,6 +780,163 @@
}
}
+
+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;
Modified: trunk/src/view_file.h
===================================================================
--- trunk/src/view_file.h 2009-05-13 19:29:27 UTC (rev 1705)
+++ trunk/src/view_file.h 2009-05-14 20:32:14 UTC (rev 1706)
@@ -61,6 +61,8 @@
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: */
Modified: trunk/src/view_file_icon.c
===================================================================
--- trunk/src/view_file_icon.c 2009-05-13 19:29:27 UTC (rev 1705)
+++ trunk/src/view_file_icon.c 2009-05-14 20:32:14 UTC (rev 1706)
@@ -1561,20 +1561,6 @@
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;
@@ -1727,7 +1713,7 @@
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)
@@ -1864,96 +1850,40 @@
*-----------------------------------------------------------------------------
*/
-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++;
+ 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)
+void vficon_set_thumb_fd(ViewFile *vf, FileData *fd)
{
- if (vf->func_thumb_status)
- {
- vf->func_thumb_status(vf, val, text, vf->data_thumb_status);
- }
-}
+ GtkTreeModel *store;
+ GtkTreeIter iter;
+ GList *list;
-static void vficon_thumb_cleanup(ViewFile *vf)
-{
- vficon_thumb_status(vf, 0.0, NULL);
+ if (!vficon_find_iter(vf, vficon_icon_data(vf, fd), &iter, NULL))
return;
- vf->thumbs_running = FALSE;
+ store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
- thumb_loader_free(vf->thumbs_loader);
- vf->thumbs_loader = NULL;
-
- vf->thumbs_filedata = NULL;
+ 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_stop(ViewFile *vf)
-{
- if (vf->thumbs_running) vficon_thumb_cleanup(vf);
-}
-static void vficon_thumb_do(ViewFile *vf, ThumbLoader *tl, FileData *fd)
+FileData *vficon_thumb_next_fd(ViewFile *vf)
{
- if (!fd) return;
-
- vficon_set_thumb(vf, fd);
-
- vficon_thumb_status(vf, vficon_thumb_progress(vf), _("Loading
thumbs..."));
-}
-
-static void vficon_thumb_error_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 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)
-{
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;
@@ -1996,64 +1926,27 @@
}
}
- 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
@@ -2456,7 +2349,7 @@
tip_unschedule(vf);
- vficon_thumb_cleanup(vf);
+ vf_thumb_cleanup(vf);
iconlist_free(vf->list);
g_list_free(VFICON(vf)->selection);
Modified: trunk/src/view_file_icon.h
===================================================================
--- trunk/src/view_file_icon.h 2009-05-13 19:29:27 UTC (rev 1705)
+++ trunk/src/view_file_icon.h 2009-05-14 20:32:14 UTC (rev 1706)
@@ -54,7 +54,11 @@
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: */
Modified: trunk/src/view_file_list.c
===================================================================
--- trunk/src/view_file_list.c 2009-05-13 19:29:27 UTC (rev 1705)
+++ trunk/src/view_file_list.c 2009-05-14 20:32:14 UTC (rev 1706)
@@ -1023,9 +1023,8 @@
*-----------------------------------------------------------------------------
*/
-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)
@@ -1043,45 +1042,8 @@
}
}
-static gdouble vflist_thumb_progress(ViewFile *vf)
+void vflist_set_thumb_fd(ViewFile *vf, FileData *fd)
{
- 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)
-{
GtkTreeStore *store;
GtkTreeIter iter;
@@ -1089,43 +1051,16 @@
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)
+FileData *vflist_thumb_next_fd(ViewFile *vf)
{
- 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)
-{
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;
@@ -1172,62 +1107,23 @@
}
}
- 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));
}
/*
@@ -1732,7 +1628,7 @@
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)
{
@@ -1756,7 +1652,7 @@
filelist_free(selected);
vf_send_update(vf);
- vflist_thumb_update(vf);
+ vf_thumb_update(vf);
}
gboolean vflist_refresh(ViewFile *vf)
@@ -1969,7 +1865,7 @@
vflist_select_idle_cancel(vf);
vf_refresh_idle_cancel(vf);
- vflist_thumb_stop(vf);
+ vf_thumb_stop(vf);
filelist_free(vf->list);
}
Modified: trunk/src/view_file_list.h
===================================================================
--- trunk/src/view_file_list.h 2009-05-13 19:29:27 UTC (rev 1705)
+++ trunk/src/view_file_list.h 2009-05-14 20:32:14 UTC (rev 1706)
@@ -58,7 +58,11 @@
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: */
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Geeqie-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geeqie-svn