From 8b317416d7d84725db8f634cf4e9e7c18f1f6691 Mon Sep 17 00:00:00 2001 From: "Nickolay V. Shmyrev" Date: Tue, 12 Apr 2005 06:51:05 +0000 Subject: [PATCH] Fix for bugs 300233,173184,300094. Problems with page index started at 0 and scrolling up with Shift + Space --- ChangeLog | 24 ++++++++++++++++++ backend/ev-page-cache.c | 2 +- shell/ev-sidebar-thumbnails.c | 46 ++++++++++++++++++++++++++++++++++- shell/ev-view.c | 41 ++++++++++++++++++++++--------- shell/ev-window.c | 13 ++++------ 5 files changed, 104 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index aa84c474..fbd7672d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2005-04-12 Nikolay V. Shmyrev + + * backend/ev-page-cache.c: (ev_page_cache_next_page): + + Fix for #300233. Next page correctly handles document end. + + * shell/ev-sidebar-thumbnails.c: (ev_sidebar_thumbnails_dispose), + (ev_sidebar_thumbnails_class_init), + (ev_sidebar_thumbnails_set_document), + (ev_sidebar_thumbnails_clear_job), + (ev_sidebar_thumbnails_clear_model): + + Cleanup thumbnail jobs on document changes. + + * shell/ev-view.c: (add_scroll_binding_keypad), + (add_scroll_binding_shifted), (ev_view_class_init): + + Shift + Space scrolls up. Fix for #173184 + + * shell/ev-window.c: (ev_window_open_page), + (ev_window_cmd_view_reload): + + Fix reload (Bug #300094) + 2005-04-09 Nickolay V. Shmyrev diff --git a/backend/ev-page-cache.c b/backend/ev-page-cache.c index 7f6622a8..4d64ee2e 100644 --- a/backend/ev-page-cache.c +++ b/backend/ev-page-cache.c @@ -290,7 +290,7 @@ ev_page_cache_next_page (EvPageCache *page_cache) { g_return_val_if_fail (EV_IS_PAGE_CACHE (page_cache), FALSE); - if (page_cache->current_page >= page_cache->n_pages) + if (page_cache->current_page >= page_cache->n_pages - 1) return FALSE; ev_page_cache_set_current_page (page_cache, page_cache->current_page + 1); diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c index b439e4bf..e9ff4453 100644 --- a/shell/ev-sidebar-thumbnails.c +++ b/shell/ev-sidebar-thumbnails.c @@ -63,6 +63,19 @@ G_DEFINE_TYPE (EvSidebarThumbnails, ev_sidebar_thumbnails, GTK_TYPE_VBOX); #define EV_SIDEBAR_THUMBNAILS_GET_PRIVATE(object) \ (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_SIDEBAR_THUMBNAILS, EvSidebarThumbnailsPrivate)); +static void +ev_sidebar_thumbnails_clear_model (EvSidebarThumbnails *sidebar); + +static void +ev_sidebar_thumbnails_dispose (GObject *object) +{ + EvSidebarThumbnails *sidebar_thumbnails = EV_SIDEBAR_THUMBNAILS (object); + + ev_sidebar_thumbnails_clear_model (sidebar_thumbnails); + + G_OBJECT_CLASS (ev_sidebar_thumbnails_parent_class)->dispose (object); +} + static void ev_sidebar_thumbnails_class_init (EvSidebarThumbnailsClass *ev_sidebar_thumbnails_class) { @@ -72,6 +85,8 @@ ev_sidebar_thumbnails_class_init (EvSidebarThumbnailsClass *ev_sidebar_thumbnail g_object_class = G_OBJECT_CLASS (ev_sidebar_thumbnails_class); gtk_object_class = GTK_OBJECT_CLASS (ev_sidebar_thumbnails_class); + g_object_class->dispose = ev_sidebar_thumbnails_dispose; + g_type_class_add_private (g_object_class, sizeof (EvSidebarThumbnailsPrivate)); } @@ -245,7 +260,7 @@ ev_sidebar_thumbnails_set_document (EvSidebarThumbnails *sidebar_thumbnails, loading_icon = ev_document_misc_get_thumbnail_frame (width, height, NULL); - gtk_list_store_clear (priv->list_store); + ev_sidebar_thumbnails_clear_model (sidebar_thumbnails); for (i = 0; i < n_pages; i++) { EvJob *job; gchar *page_label; @@ -281,3 +296,32 @@ ev_sidebar_thumbnails_set_document (EvSidebarThumbnails *sidebar_thumbnails, } +static gboolean +ev_sidebar_thumbnails_clear_job (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data) +{ + EvJob *job; + + gtk_tree_model_get (model, iter, COLUMN_JOB, &job, -1); + + if (job != NULL) { + ev_job_queue_remove_job (job); + g_signal_handlers_disconnect_by_func (job, thumbnail_job_completed_callback, data); + g_object_unref (job); + } + + return FALSE; +} + +static void +ev_sidebar_thumbnails_clear_model (EvSidebarThumbnails *sidebar_thumbnails) +{ + EvSidebarThumbnailsPrivate *priv = sidebar_thumbnails->priv; + + gtk_tree_model_foreach (GTK_TREE_MODEL (priv->list_store), ev_sidebar_thumbnails_clear_job, sidebar_thumbnails); + gtk_list_store_clear (priv->list_store); +} + + diff --git a/shell/ev-view.c b/shell/ev-view.c index 636e0f56..5678fc28 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -969,10 +969,10 @@ ev_view_set_scroll_adjustments (EvView *view, } static void -add_scroll_binding (GtkBindingSet *binding_set, - guint keyval, - GtkScrollType scroll, - gboolean horizontal) +add_scroll_binding_keypad (GtkBindingSet *binding_set, + guint keyval, + GtkScrollType scroll, + gboolean horizontal) { guint keypad_keyval = keyval - GDK_Left + GDK_KP_Left; @@ -986,6 +986,23 @@ add_scroll_binding (GtkBindingSet *binding_set, G_TYPE_BOOLEAN, horizontal); } +static void +add_scroll_binding_shifted (GtkBindingSet *binding_set, + guint keyval, + GtkScrollType scroll_normal, + GtkScrollType scroll_shifted, + gboolean horizontal) +{ + gtk_binding_entry_add_signal (binding_set, keyval, 0, + "scroll_view", 2, + GTK_TYPE_SCROLL_TYPE, scroll_normal, + G_TYPE_BOOLEAN, horizontal); + gtk_binding_entry_add_signal (binding_set, keyval, GDK_SHIFT_MASK, + "scroll_view", 2, + GTK_TYPE_SCROLL_TYPE, scroll_shifted, + G_TYPE_BOOLEAN, horizontal); +} + static void ev_view_jump (EvView *view, GtkScrollType scroll) @@ -1178,16 +1195,16 @@ ev_view_class_init (EvViewClass *class) binding_set = gtk_binding_set_by_class (class); - add_scroll_binding (binding_set, GDK_Left, GTK_SCROLL_STEP_BACKWARD, TRUE); - add_scroll_binding (binding_set, GDK_Right, GTK_SCROLL_STEP_FORWARD, TRUE); - add_scroll_binding (binding_set, GDK_Up, GTK_SCROLL_STEP_BACKWARD, FALSE); - add_scroll_binding (binding_set, GDK_Down, GTK_SCROLL_STEP_FORWARD, FALSE); + add_scroll_binding_keypad (binding_set, GDK_Left, GTK_SCROLL_STEP_BACKWARD, TRUE); + add_scroll_binding_keypad (binding_set, GDK_Right, GTK_SCROLL_STEP_FORWARD, TRUE); + add_scroll_binding_keypad (binding_set, GDK_Up, GTK_SCROLL_STEP_BACKWARD, FALSE); + add_scroll_binding_keypad (binding_set, GDK_Down, GTK_SCROLL_STEP_FORWARD, FALSE); - add_scroll_binding (binding_set, GDK_Page_Up, GTK_SCROLL_PAGE_BACKWARD, FALSE); - add_scroll_binding (binding_set, GDK_Page_Down, GTK_SCROLL_PAGE_FORWARD, FALSE); + add_scroll_binding_keypad (binding_set, GDK_Page_Up, GTK_SCROLL_PAGE_BACKWARD, FALSE); + add_scroll_binding_keypad (binding_set, GDK_Page_Down, GTK_SCROLL_PAGE_FORWARD, FALSE); - add_scroll_binding (binding_set, GDK_space, EV_SCROLL_PAGE_FORWARD, FALSE); - add_scroll_binding (binding_set, GDK_BackSpace, EV_SCROLL_PAGE_BACKWARD, FALSE); + add_scroll_binding_shifted (binding_set, GDK_space, EV_SCROLL_PAGE_FORWARD, EV_SCROLL_PAGE_BACKWARD, FALSE); + add_scroll_binding_shifted (binding_set, GDK_BackSpace, EV_SCROLL_PAGE_BACKWARD, EV_SCROLL_PAGE_FORWARD, FALSE); } static void diff --git a/shell/ev-window.c b/shell/ev-window.c index d5d876b2..8dd0d6f9 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -366,8 +366,10 @@ update_sizing_buttons (EvWindow *window) void ev_window_open_page (EvWindow *ev_window, int page) { - if (ev_window->priv->page_cache) - ev_page_cache_set_current_page (ev_window->priv->page_cache, page); + if (ev_window->priv->page_cache) { + page = CLAMP (page, 0, ev_page_cache_get_n_pages (ev_window->priv->page_cache)); + ev_page_cache_set_current_page (ev_window->priv->page_cache, page); + } } void @@ -1626,12 +1628,7 @@ ev_window_cmd_view_reload (GtkAction *action, EvWindow *ev_window) g_return_if_fail (EV_IS_WINDOW (ev_window)); -#if 0 - /* FIXME: uncomment when this is written.*/ - page = ev_page_cache_get_page (ev_window->priv->page_cache); -#else - page = 1; -#endif + page = ev_page_cache_get_current_page (ev_window->priv->page_cache); uri = g_strdup (ev_window->priv->uri); ev_window_open (ev_window, uri); -- 2.43.5