From: Marco Pesenti Gritti Date: Thu, 20 Jan 2005 11:35:19 +0000 (+0000) Subject: Ensure thumbnails selection, toolbar page control and current page are in X-Git-Tag: EVINCE_0_1_1~32 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=a601c252dae06def4379c838ed176955903b34c9;p=evince.git Ensure thumbnails selection, toolbar page control and current page are in 2005-01-20 Marco Pesenti Gritti * 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. --- diff --git a/ChangeLog b/ChangeLog index e5863890..32ad1e15 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2005-01-20 Marco Pesenti Gritti + + * 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 * pdf/xpdf/XRef.cc: diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c index 88d70036..217c862f 100644 --- a/shell/ev-sidebar-thumbnails.c +++ b/shell/ev-sidebar-thumbnails.c @@ -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) diff --git a/shell/ev-sidebar-thumbnails.h b/shell/ev-sidebar-thumbnails.h index 45f68fce..0d7a4704 100644 --- a/shell/ev-sidebar-thumbnails.h +++ b/shell/ev-sidebar-thumbnails.h @@ -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 diff --git a/shell/ev-view.c b/shell/ev-view.c index 7ca3630b..2033962a 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -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); diff --git a/shell/ev-window.c b/shell/ev-window.c index 532efae1..ed1e4788 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -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); diff --git a/shell/ev-window.h b/shell/ev-window.h index 97e0e020..06880db7 100644 --- a/shell/ev-window.h +++ b/shell/ev-window.h @@ -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