summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNelson Benitez Leon <[email protected]>2017-06-03 15:56:04 +0500
committerraveit65 <[email protected]>2017-08-15 14:09:42 +0200
commit79a83766f4ce2f3ee29ada760e0a17f48e7be034 (patch)
tree9784005f86ca3021492f77b4dde362c4cde24308
parent744a1c5e8259773b35600944c28189b98879f937 (diff)
downloadatril-79a83766f4ce2f3ee29ada760e0a17f48e7be034.tar.bz2
atril-79a83766f4ce2f3ee29ada760e0a17f48e7be034.tar.xz
sidebar-thumbnails: keep thumbnails already rendered
Evince renders thumbnails on-the-fly as they get into the scrolling visible area, but at the same time it will remove them as they get out of the visible scrolling area, so when user scrolls back to same position he will notice thumbnails be recreated. In pro of a more icing user experience, let's adopt a mixed approach and keep the thumbnails that the user has already navigated, so when he scrolls back and forth in the same area no thumbnail re-generation will be visible. This also matches behaviour with other pdf readers. https://bugzilla.gnome.org/show_bug.cgi?id=342110 origin commit: https://git.gnome.org/browse/evince/commit/?id=121e4d9
-rw-r--r--shell/ev-sidebar-thumbnails.c35
1 files changed, 12 insertions, 23 deletions
diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c
index f7f92666..22054251 100644
--- a/shell/ev-sidebar-thumbnails.c
+++ b/shell/ev-sidebar-thumbnails.c
@@ -355,16 +355,14 @@ ev_sidebar_thumbnails_get_loading_icon (EvSidebarThumbnails *sidebar_thumbnails,
}
static void
-clear_range (EvSidebarThumbnails *sidebar_thumbnails,
- gint start_page,
- gint end_page)
+cancel_running_jobs (EvSidebarThumbnails *sidebar_thumbnails,
+ gint start_page,
+ gint end_page)
{
EvSidebarThumbnailsPrivate *priv = sidebar_thumbnails->priv;
GtkTreePath *path;
GtkTreeIter iter;
gboolean result;
- gint prev_width = -1;
- gint prev_height = -1;
g_assert (start_page <= end_page);
@@ -373,37 +371,28 @@ clear_range (EvSidebarThumbnails *sidebar_thumbnails,
result && start_page <= end_page;
result = gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->list_store), &iter), start_page ++) {
EvJobThumbnail *job;
-
- GdkPixbuf *loading_icon = NULL;
- gint width, height;
+ gboolean thumbnail_set;
gtk_tree_model_get (GTK_TREE_MODEL (priv->list_store),
&iter,
COLUMN_JOB, &job,
+ COLUMN_THUMBNAIL_SET, &thumbnail_set,
-1);
+ if (thumbnail_set) {
+ g_assert (job == NULL);
+ continue;
+ }
+
if (job) {
g_signal_handlers_disconnect_by_func (job, thumbnail_job_completed_callback, sidebar_thumbnails);
ev_job_cancel (EV_JOB (job));
g_object_unref (job);
}
- ev_thumbnails_size_cache_get_size (priv->size_cache, start_page,
- priv->rotation,
- &width, &height);
- if (!loading_icon || (width != prev_width && height != prev_height)) {
- loading_icon =
- ev_sidebar_thumbnails_get_loading_icon (sidebar_thumbnails,
- width, height);
- }
-
- prev_width = width;
- prev_height = height;
-
gtk_list_store_set (priv->list_store, &iter,
COLUMN_JOB, NULL,
COLUMN_THUMBNAIL_SET, FALSE,
- COLUMN_PIXBUF, loading_icon,
-1);
}
gtk_tree_path_free (path);
@@ -497,10 +486,10 @@ update_visible_range (EvSidebarThumbnails *sidebar_thumbnails,
/* Clear the areas we no longer display */
if (old_start_page >= 0 && old_start_page < start_page)
- clear_range (sidebar_thumbnails, old_start_page, MIN (start_page - 1, old_end_page));
+ cancel_running_jobs (sidebar_thumbnails, old_start_page, MIN (start_page - 1, old_end_page));
if (old_end_page > 0 && old_end_page > end_page)
- clear_range (sidebar_thumbnails, MAX (end_page + 1, old_start_page), old_end_page);
+ cancel_running_jobs (sidebar_thumbnails, MAX (end_page + 1, old_start_page), old_end_page);
add_range (sidebar_thumbnails, start_page, end_page);