[evince] history: Add links when jumping to first or last page.
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] history: Add links when jumping to first or last page.
- Date: Sat, 27 Jun 2020 04:49:12 +0000 (UTC)
commit d247e9f102929b68993f46430553a7f7b1e2d0f3
Author: Casey Jao <casey jao gmail com>
Date: Tue Sep 5 10:11:35 2017 -0400
history: Add links when jumping to first or last page.
shell/ev-window.c:
* Listen to "scroll" and "scroll-child" of EvView and
GtkScrolledWindow instances, respectively, and add
appropriate pages to history.
* Add pages to history when jumping via window commands.
https://bugzilla.gnome.org/show_bug.cgi?id=785627
Partially fixes #810 (3/5)
shell/ev-window.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 89 insertions(+)
---
diff --git a/shell/ev-window.c b/shell/ev-window.c
index a0741500..bf482441 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -369,6 +369,14 @@ static void bookmark_activated_cb (EvSidebarBookmarks
*sidebar_bookmar
gint old_page,
gint page,
EvWindow *window);
+static void scroll_history_cb (EvView *view,
+ GtkScrollType scroll,
+ gboolean horizontal,
+ EvWindow *window);
+static void scroll_child_history_cb (GtkScrolledWindow *scrolled_window,
+ GtkScrollType scroll,
+ gboolean horizontal,
+ EvWindow *window);
static void activate_link_cb (GObject *object,
EvLink *link,
EvWindow *window);
@@ -970,6 +978,67 @@ bookmark_activated_cb (EvSidebarBookmarks *sidebar_bookmarks,
ev_history_add_page (window->priv->history, page);
}
+static void
+scroll_history_cb (EvView *view,
+ GtkScrollType scroll,
+ gboolean horizontal,
+ EvWindow *window)
+{
+ if (!window->priv->document)
+ return;
+
+ gint old_page = -1;
+ gint new_page = -1;
+ switch (scroll) {
+ case GTK_SCROLL_START:
+ old_page = ev_document_model_get_page (window->priv->model);
+ new_page = 0;
+ break;
+ case GTK_SCROLL_END:
+ old_page = ev_document_model_get_page (window->priv->model);
+ new_page = ev_document_get_n_pages (window->priv->document) - 1;
+ break;
+ default:
+ break;
+ }
+ if (old_page >= 0 && new_page >= 0) {
+ ev_history_add_page (window->priv->history, old_page);
+ ev_history_add_page (window->priv->history, new_page);
+ }
+}
+
+static void
+scroll_child_history_cb (GtkScrolledWindow *scrolled_window,
+ GtkScrollType scroll,
+ gboolean horizontal,
+ EvWindow *window)
+{
+ if (!window->priv->document)
+ return;
+
+ if (ev_document_model_get_continuous (window->priv->model) && !horizontal) {
+ gint old_page = -1;
+ gint new_page = -1;
+ switch (scroll) {
+ case GTK_SCROLL_START:
+ old_page = ev_document_model_get_page (window->priv->model);
+ new_page = 0;
+ break;
+ case GTK_SCROLL_END:
+ old_page = ev_document_model_get_page (window->priv->model);
+ new_page = ev_document_get_n_pages (window->priv->document) - 1;
+ break;
+ default:
+ break;
+ }
+ if (old_page >= 0 && new_page >= 0) {
+ ev_history_add_page (window->priv->history, old_page);
+ ev_history_add_page (window->priv->history, new_page);
+
+ }
+ }
+}
+
static void
view_selection_changed_cb (EvView *view,
EvWindow *window)
@@ -5047,7 +5116,13 @@ ev_window_cmd_go_first_page (GSimpleAction *action,
EvWindow *window = user_data;
EvWindowPrivate *priv = GET_PRIVATE (window);
+ gint old_page = ev_document_model_get_page (priv->model);
+ gint new_page = 0;
ev_document_model_set_page (priv->model, 0);
+ if (old_page >= 0) {
+ ev_history_add_page (priv->history, old_page);
+ ev_history_add_page (priv->history, new_page);
+ }
}
static void
@@ -5058,8 +5133,16 @@ ev_window_cmd_go_last_page (GSimpleAction *action,
EvWindow *window = user_data;
EvWindowPrivate *priv = GET_PRIVATE (window);
+ gint old_page = ev_document_model_get_page (priv->model);
+ gint new_page = ev_document_get_n_pages (priv->document) - 1;
+
ev_document_model_set_page (priv->model,
ev_document_get_n_pages (priv->document) - 1);
+ if (old_page >= 0 && new_page >= 0) {
+ ev_history_add_page (priv->history, old_page);
+ ev_history_add_page (priv->history, new_page);
+ }
+
}
static void
@@ -7701,6 +7784,12 @@ ev_window_init (EvWindow *ev_window)
g_signal_connect_object (priv->sidebar_bookmarks, "bookmark-activated",
G_CALLBACK (bookmark_activated_cb),
ev_window, 0);
+ g_signal_connect_object (priv->view, "scroll",
+ G_CALLBACK (scroll_history_cb),
+ ev_window, 0);
+ g_signal_connect_object (priv->scrolled_window, "scroll-child",
+ G_CALLBACK (scroll_child_history_cb),
+ ev_window, 0);
g_signal_connect_object (priv->view, "annot-added",
G_CALLBACK (view_annot_added),
ev_window, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]