]> www.fi.muni.cz Git - evince.git/commitdiff
Fix for bugs 300233,173184,300094. Problems with page index started at 0
authorNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Tue, 12 Apr 2005 06:51:05 +0000 (06:51 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Tue, 12 Apr 2005 06:51:05 +0000 (06:51 +0000)
and scrolling up with Shift + Space

ChangeLog
backend/ev-page-cache.c
shell/ev-sidebar-thumbnails.c
shell/ev-view.c
shell/ev-window.c

index aa84c47420da6fbcdd5f7a71d3509aedffa17695..fbd7672d6df475c9322d9b8f53003ba712467fa7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2005-04-12  Nikolay V. Shmyrev  <nshmyrev@yandex.ru>
+
+       * 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  <nshmyrev@yandex.ru>
 
        
index 7f6622a853a5e0c6e481d8353d3f40f37828ea47..4d64ee2e53740a30e2221421506d7350654c841a 100644 (file)
@@ -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);
index b439e4bf7f78337cb6bed7c5c27cd4f12c9c2eb3..e9ff445328b330581fce026620a67748786772cb 100644 (file)
@@ -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);
+}
+
+
index 636e0f566b4dfe04b163fc666d6efccfa35a7176..5678fc28e24c9c7d6f6b58e2f6fcd6ca4e95fc2f 100644 (file)
@@ -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
index d5d876b2aba984e55b29178926cf1db153414339..8dd0d6f927d24bebdb77a51dd9cec041befcc705 100644 (file)
@@ -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);