Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/ev-sidebar-thumbnails.c
diff options
context:
space:
mode:
authorJonathan Blandford <jrb@redhat.com>2005-01-03 22:25:25 (GMT)
committer Jonathan Blandford <jrb@src.gnome.org>2005-01-03 22:25:25 (GMT)
commitebc72ce5deb2057b5c1445c6618262e23a63a9ac (patch)
tree66e3c6e73c56051f4ea45e2d5536d847e0d43ef6 /shell/ev-sidebar-thumbnails.c
parent4bf6aeea517b56401a4977da7022bd46611368e6 (diff)
move the thumbnail code into a time-based idle as well. Also, turn off the
Mon Jan 3 17:22:25 2005 Jonathan Blandford <jrb@redhat.com> * shell/ev-sidebar-thumbnails.c (do_one_iteration): move the thumbnail code into a time-based idle as well. Also, turn off the shadow temporarily as it's really slow.
Diffstat (limited to 'shell/ev-sidebar-thumbnails.c')
-rw-r--r--shell/ev-sidebar-thumbnails.c48
1 files changed, 42 insertions, 6 deletions
diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c
index c727abf..3d41db1 100644
--- a/shell/ev-sidebar-thumbnails.c
+++ b/shell/ev-sidebar-thumbnails.c
@@ -34,6 +34,8 @@
#include "ev-utils.h"
#define THUMBNAIL_WIDTH 96
+/* Amount of time we devote to each iteration of the idle, in microseconds */
+#define IDLE_WORK_LENGTH 5000
struct _EvSidebarThumbnailsPrivate {
GtkWidget *tree_view;
@@ -133,21 +135,23 @@ ev_sidebar_thumbnails_new (void)
}
static gboolean
-populate_thumbnails (gpointer data)
+do_one_iteration (EvSidebarThumbnails *ev_sidebar_thumbnails)
{
- EvSidebarThumbnails *ev_sidebar_thumbnails = EV_SIDEBAR_THUMBNAILS (data);
EvSidebarThumbnailsPrivate *priv = ev_sidebar_thumbnails->priv;
GdkPixbuf *tmp, *pixbuf;
GtkTreePath *path;
GtkTreeIter iter;
-
+
tmp = ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (priv->document),
priv->current_page, THUMBNAIL_WIDTH);
-
+#if 1
+ /* Don't add the shadow for now, as it's really slow */
+ pixbuf = g_object_ref (tmp);
+#else
/* Add shadow */
pixbuf = ev_pixbuf_add_shadow (tmp, 5, 0, 0, 0.5);
-
+#endif
path = gtk_tree_path_new_from_indices (priv->current_page, -1);
gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->list_store), &iter, path);
gtk_tree_path_free (path);
@@ -167,6 +171,38 @@ populate_thumbnails (gpointer data)
return TRUE;
}
+static gboolean
+populate_thumbnails_idle (gpointer data)
+{
+ GTimer *timer;
+ gint i;
+ gulong microseconds = 0;
+
+ EvSidebarThumbnails *ev_sidebar_thumbnails = EV_SIDEBAR_THUMBNAILS (data);
+ EvSidebarThumbnailsPrivate *priv = ev_sidebar_thumbnails->priv;
+
+ if (priv->current_page == priv->n_pages) {
+ priv->idle_id = 0;
+ return FALSE;
+ }
+
+ timer = g_timer_new ();
+ i = 0;
+ g_timer_start (timer);
+ while (do_one_iteration (ev_sidebar_thumbnails)) {
+ i++;
+ g_timer_elapsed (timer, &microseconds);
+ if (microseconds > IDLE_WORK_LENGTH)
+ break;
+ }
+ g_timer_destroy (timer);
+#if 1
+ g_print ("%d rows done this idle in %d\n", i, (int)microseconds);
+#endif
+
+ return TRUE;
+}
+
void
ev_sidebar_thumbnails_set_document (EvSidebarThumbnails *sidebar_thumbnails,
EvDocument *document)
@@ -205,7 +241,7 @@ ev_sidebar_thumbnails_set_document (EvSidebarThumbnails *sidebar_thumbnails,
}
priv->document = document;
- priv->idle_id = g_idle_add (populate_thumbnails, sidebar_thumbnails);
+ priv->idle_id = g_idle_add (populate_thumbnails_idle, sidebar_thumbnails);
priv->n_pages = n_pages;
priv->current_page = 0;
}