]> www.fi.muni.cz Git - evince.git/commitdiff
Ensure thumbnails selection, toolbar page control and current page are in
authorMarco Pesenti Gritti <marco@gnome.org>
Thu, 20 Jan 2005 11:35:19 +0000 (11:35 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Thu, 20 Jan 2005 11:35:19 +0000 (11:35 +0000)
2005-01-20  Marco Pesenti Gritti  <marco@gnome.org>

        * shell/ev-sidebar-thumbnails.c:
        (ev_sidebar_tree_selection_changed),
        (ev_sidebar_thumbnails_select_page):
        * shell/ev-sidebar-thumbnails.h:
        * shell/ev-view.c: (ev_view_set_document), (ev_view_can_go_back),
        (ev_view_can_go_forward):
        * shell/ev-window.c: (ev_window_open_page),
        (ev_window_setup_document), (update_current_page),
        (view_page_changed_cb), (ev_window_init):
        * shell/ev-window.h:

        Ensure thumbnails selection, toolbar page control and
        current page are in sync.

ChangeLog
shell/ev-sidebar-thumbnails.c
shell/ev-sidebar-thumbnails.h
shell/ev-view.c
shell/ev-window.c
shell/ev-window.h

index e5863890371adb00364bb0b41e1294f7ede85cb0..32ad1e1552890606f02593eb04d959da0dd52200 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2005-01-20  Marco Pesenti Gritti  <marco@gnome.org>
+
+       * shell/ev-sidebar-thumbnails.c:
+       (ev_sidebar_tree_selection_changed),
+       (ev_sidebar_thumbnails_select_page):
+       * shell/ev-sidebar-thumbnails.h:
+       * shell/ev-view.c: (ev_view_set_document), (ev_view_can_go_back),
+       (ev_view_can_go_forward):
+       * shell/ev-window.c: (ev_window_open_page),
+       (ev_window_setup_document), (update_current_page),
+       (view_page_changed_cb), (ev_window_init):
+       * shell/ev-window.h:
+
+       Ensure thumbnails selection, toolbar page control and
+       current page are in sync.
+
 2005-01-19  Marco Pesenti Gritti  <marco@gnome.org>
 
        * pdf/xpdf/XRef.cc:
index 88d70036abf4d717647ae094faf171f8f1b144ac..217c862fbdcb249d6b42fabc45b028b5aec208b4 100644 (file)
@@ -32,6 +32,7 @@
 #include "ev-sidebar-thumbnails.h"
 #include "ev-document-thumbnails.h"
 #include "ev-document-misc.h"
+#include "ev-window.h"
 #include "ev-utils.h"
 
 #define THUMBNAIL_WIDTH 75
@@ -133,6 +134,7 @@ ev_sidebar_tree_selection_changed (GtkTreeSelection *selection,
                                   EvSidebarThumbnails *ev_sidebar_thumbnails)
 {
        EvSidebarThumbnailsPrivate *priv;
+       GtkWidget *window;
        GtkTreePath *path;
        GtkTreeIter iter;
        int page;
@@ -149,7 +151,11 @@ ev_sidebar_tree_selection_changed (GtkTreeSelection *selection,
 
        gtk_tree_path_free (path);
 
-       ev_document_set_page (priv->document, page);
+       window = gtk_widget_get_ancestor (GTK_WIDGET (ev_sidebar_thumbnails),
+                                         EV_TYPE_WINDOW);
+       if (window && ev_document_get_page (priv->document) != page) {
+               ev_window_open_page (EV_WINDOW (window), page);
+       }
 }
 
 static void
@@ -303,6 +309,24 @@ populate_thumbnails_idle (gpointer data)
        return TRUE;
 }
 
+void
+ev_sidebar_thumbnails_select_page (EvSidebarThumbnails *sidebar,
+                                  int                  page)
+{
+       GtkTreePath *path;
+       GtkTreeSelection *selection;
+
+       path = gtk_tree_path_new_from_indices (page - 1, -1);
+       selection = gtk_tree_view_get_selection
+                       (GTK_TREE_VIEW (sidebar->priv->tree_view));
+
+       if (path) {
+               gtk_tree_selection_select_path (selection, path);
+               gtk_tree_path_free (path);      
+       }
+}
+
+
 void
 ev_sidebar_thumbnails_set_document (EvSidebarThumbnails *sidebar_thumbnails,
                                    EvDocument          *document)
index 45f68fce2c69a3504ca33bae4293930d8c3ac2d3..0d7a4704d36a63146d9089f824f51b33dd7343c5 100644 (file)
@@ -56,6 +56,8 @@ GtkWidget *ev_sidebar_thumbnails_new      (void);
 
 void ev_sidebar_thumbnails_set_document (EvSidebarThumbnails *sidebar_thumbnails,
                                         EvDocument          *document);
+void ev_sidebar_thumbnails_select_page  (EvSidebarThumbnails *sidebar_thumbnails,
+                                        int                  page);
 
 G_END_DECLS
 
index 7ca3630bc8903191a8102564a0efe49dc0d58fba..2033962ae1842ebb88f0341ece27bf8ea4c543d0 100644 (file)
@@ -1060,8 +1060,6 @@ ev_view_set_document (EvView     *view,
        g_return_if_fail (EV_IS_VIEW (view));
 
        if (document != view->document) {
-               int old_page = ev_view_get_page (view);
-               
                if (view->document) {
                         g_signal_handlers_disconnect_by_func (view->document,
                                                               found_results_callback,
@@ -1093,8 +1091,7 @@ ev_view_set_document (EvView     *view,
                
                gtk_widget_queue_resize (GTK_WIDGET (view));
                
-               if (old_page != ev_view_get_page (view))
-                       g_signal_emit (view, page_changed_signal, 0);
+               g_signal_emit (view, page_changed_signal, 0);
        }
 }
 
@@ -1166,7 +1163,9 @@ ev_view_can_go_back (EvView *view)
 {
        int index, n;
 
-       g_return_val_if_fail (EV_IS_HISTORY (view->history), FALSE);
+       if (view->history == NULL) {
+               return FALSE;
+       }
 
        index = ev_history_get_current_index (view->history);
        n = ev_history_get_n_links (view->history);
@@ -1199,7 +1198,9 @@ ev_view_can_go_forward (EvView *view)
 {
        int index, n;
 
-       g_return_val_if_fail (EV_IS_HISTORY (view->history), FALSE);
+       if (view->history == NULL) {
+               return FALSE;
+       }
 
        index = ev_history_get_current_index (view->history);
        n = ev_history_get_n_links (view->history);
index 532efae1fd6c13dc3223cf807fba0ea6907e9f95..ed1e4788c183331f83ac8c32f70b6887bd894280 100644 (file)
@@ -70,6 +70,7 @@ struct _EvWindowPrivate {
        GtkWidget *main_box;
        GtkWidget *hpaned;
        GtkWidget *sidebar;
+       GtkWidget *thumbs_sidebar;
        GtkWidget *find_bar;
        GtkWidget *view;
        GtkActionGroup *action_group;
@@ -249,6 +250,12 @@ update_action_sensitivity (EvWindow *ev_window)
        set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, document!=NULL);
 }
 
+void
+ev_window_open_page (EvWindow *ev_window, int page)
+{
+       ev_view_set_page (EV_VIEW (ev_window->priv->view), page);
+}
+
 void
 ev_window_open_link (EvWindow *ev_window, EvLink *link)
 {
@@ -363,8 +370,8 @@ ev_window_setup_document (EvWindow *ev_window)
 
        document = ev_window->priv->document;
 
-       ev_view_set_document (view, document);
        ev_sidebar_set_document (sidebar, document);
+       ev_view_set_document (view, document);
 
        history = ev_history_new ();
        ev_view_set_history (view, history);
@@ -1202,10 +1209,15 @@ disconnect_proxy_cb (GtkUIManager *ui_manager, GtkAction *action,
 }
 
 static void
-update_current_page (EvWindow *ev_window)
+update_current_page (EvWindow *ev_window,
+                    EvView   *view)
 {
        int page;
        GtkAction *action;
+       EvSidebarThumbnails *thumbs;
+
+       thumbs = EV_SIDEBAR_THUMBNAILS (ev_window->priv->thumbs_sidebar);
+       ev_sidebar_thumbnails_select_page (thumbs, ev_view_get_page (view));
 
        action = gtk_action_group_get_action
                (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
@@ -1218,7 +1230,7 @@ static void
 view_page_changed_cb (EvView   *view,
                      EvWindow *ev_window)
 {
-       update_current_page (ev_window);
+       update_current_page (ev_window, view);
        update_action_sensitivity (ev_window);
 }
 
@@ -1611,12 +1623,12 @@ ev_window_init (EvWindow *ev_window)
                             _("Index"),
                             sidebar_widget);
 
-       sidebar_widget = ev_sidebar_thumbnails_new ();
-       gtk_widget_show (sidebar_widget);
+       ev_window->priv->thumbs_sidebar = ev_sidebar_thumbnails_new ();
+       gtk_widget_show (ev_window->priv->thumbs_sidebar);
        ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
                             "thumbnails",
                             _("Thumbnails"),
-                            sidebar_widget);
+                            ev_window->priv->thumbs_sidebar);
 
        scrolled_window = gtk_scrolled_window_new (NULL, NULL);
        gtk_widget_show (scrolled_window);
index 97e0e020658914582cee2208e8f579e98997d0b9..06880db73d52b3d174c2d1466b7711dce663a41a 100644 (file)
@@ -59,6 +59,8 @@ void          ev_window_open          (EvWindow       *ev_window,
                                         const char     *uri);
 void           ev_window_open_link     (EvWindow       *ev_window,
                                         EvLink         *link);
+void           ev_window_open_page     (EvWindow       *ev_window,
+                                        int             page);
 gboolean       ev_window_is_empty      (const EvWindow *ev_window);
 
 G_END_DECLS