+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:
#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
EvSidebarThumbnails *ev_sidebar_thumbnails)
{
EvSidebarThumbnailsPrivate *priv;
+ GtkWidget *window;
GtkTreePath *path;
GtkTreeIter iter;
int page;
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
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)
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
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,
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);
}
}
{
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);
{
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);
GtkWidget *main_box;
GtkWidget *hpaned;
GtkWidget *sidebar;
+ GtkWidget *thumbs_sidebar;
GtkWidget *find_bar;
GtkWidget *view;
GtkActionGroup *action_group;
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)
{
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);
}
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);
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);
}
_("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);
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