[evince] Add allow-links-change-zoom setting
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] Add allow-links-change-zoom setting
- Date: Wed, 3 Sep 2014 16:04:54 +0000 (UTC)
commit 5d8ef0fa9518100a8e8c3212b1990e738682e70c
Author: Eduard Beutel <eb eduardbeutel com>
Date: Sat Aug 30 22:05:30 2014 +0200
Add allow-links-change-zoom setting
When enabled links are not allowed to change the current zoom mode and
level.
https://bugzilla.gnome.org/show_bug.cgi?id=729249
data/org.gnome.Evince.gschema.xml.in | 4 ++
help/C/movingaround.page | 2 +
libview/ev-view-private.h | 1 +
libview/ev-view.c | 63 ++++++++++++++++++++++++++++-----
libview/ev-view.h | 4 ++
shell/ev-window.c | 21 +++++++++++
6 files changed, 85 insertions(+), 10 deletions(-)
---
diff --git a/data/org.gnome.Evince.gschema.xml.in b/data/org.gnome.Evince.gschema.xml.in
index d7181e7..1817a05 100644
--- a/data/org.gnome.Evince.gschema.xml.in
+++ b/data/org.gnome.Evince.gschema.xml.in
@@ -34,6 +34,10 @@
<default>true</default>
<_summary>Show a dialog to confirm that the user wants to activate the caret navigation.</_summary>
</key>
+ <key type="b" name="allow-links-change-zoom">
+ <default>true</default>
+ <_summary>Allow links to change the zoom level.</_summary>
+ </key>
<child name="default" schema="org.gnome.Evince.Default"/>
</schema>
diff --git a/help/C/movingaround.page b/help/C/movingaround.page
index ad42349..4b095d5 100644
--- a/help/C/movingaround.page
+++ b/help/C/movingaround.page
@@ -189,6 +189,8 @@
<p>If you want to see two pages at once, side by side, like in a book,
click the <gui>View options</gui> button in the top-right corner and select
<gui>Dual</gui>.</p>
+ <p>If the allow-links-change-zoom gsetting is set to false, links are blocked
+ from changing your zoom level.</p>
</note>
<p>You can use the whole of your screen to view the document:</p>
diff --git a/libview/ev-view-private.h b/libview/ev-view-private.h
index 2b9e6a7..c5efeaa 100644
--- a/libview/ev-view-private.h
+++ b/libview/ev-view-private.h
@@ -177,6 +177,7 @@ struct _EvView {
EvPageLayout page_layout;
GtkWidget *loading_window;
guint loading_timeout;
+ gboolean allow_links_change_zoom;
/* Common for button press handling */
int pressed_button;
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 5a8b26c..fb40335 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -1834,6 +1834,24 @@ goto_xyz_dest (EvView *view, EvLinkDest *dest)
}
static void
+goto_y_dest (EvView *view, EvLinkDest *dest)
+{
+ gboolean change_top;
+ EvPoint doc_point;
+ gdouble top;
+ int page;
+
+ page = ev_link_dest_get_page (dest);
+ top = ev_link_dest_get_top (dest, &change_top);
+
+ doc_point.x = 0;
+ doc_point.y = change_top ? top : 0;
+ view->pending_point = doc_point;
+
+ ev_view_change_page (view, page);
+}
+
+static void
goto_dest (EvView *view, EvLinkDest *dest)
{
EvLinkDestType type;
@@ -1849,31 +1867,39 @@ goto_dest (EvView *view, EvLinkDest *dest)
type = ev_link_dest_get_dest_type (dest);
- switch (type) {
- case EV_LINK_DEST_TYPE_PAGE:
+ if (view->allow_links_change_zoom == FALSE &&
+ view->sizing_mode == EV_SIZING_FIT_PAGE &&
+ view->continuous == FALSE) {
+ ev_document_model_set_page (view->model, page);
+ } else if (view->allow_links_change_zoom == FALSE) {
+ goto_y_dest (view, dest);
+ } else {
+ switch (type) {
+ case EV_LINK_DEST_TYPE_PAGE:
ev_document_model_set_page (view->model, page);
break;
- case EV_LINK_DEST_TYPE_FIT:
+ case EV_LINK_DEST_TYPE_FIT:
goto_fit_dest (view, dest);
break;
- case EV_LINK_DEST_TYPE_FITH:
+ case EV_LINK_DEST_TYPE_FITH:
goto_fith_dest (view, dest);
break;
- case EV_LINK_DEST_TYPE_FITV:
+ case EV_LINK_DEST_TYPE_FITV:
goto_fitv_dest (view, dest);
break;
- case EV_LINK_DEST_TYPE_FITR:
+ case EV_LINK_DEST_TYPE_FITR:
goto_fitr_dest (view, dest);
break;
- case EV_LINK_DEST_TYPE_XYZ:
+ case EV_LINK_DEST_TYPE_XYZ:
goto_xyz_dest (view, dest);
break;
- case EV_LINK_DEST_TYPE_PAGE_LABEL:
+ case EV_LINK_DEST_TYPE_PAGE_LABEL:
ev_document_model_set_page_by_label (view->model, ev_link_dest_get_page_label (dest));
break;
- default:
+ default:
g_assert_not_reached ();
- }
+ }
+ }
if (current_page != view->current_page)
ev_document_model_set_page (view->model, view->current_page);
@@ -7204,6 +7230,7 @@ ev_view_init (EvView *view)
view->pixbuf_cache_size = DEFAULT_PIXBUF_CACHE_SIZE;
view->caret_enabled = FALSE;
view->cursor_page = 0;
+ view->allow_links_change_zoom = TRUE;
g_signal_connect (view, "notify::scale-factor",
G_CALLBACK (on_notify_scale_factor), NULL);
@@ -8880,3 +8907,19 @@ ev_view_previous_page (EvView *view)
return TRUE;
}
+
+void
+ev_view_set_allow_links_change_zoom (EvView *view, gboolean allowed)
+{
+ g_return_if_fail (EV_IS_VIEW (view));
+
+ view->allow_links_change_zoom = allowed;
+}
+
+gboolean
+ev_view_get_allow_links_change_zoom (EvView *view)
+{
+ g_return_val_if_fail (EV_IS_VIEW (view), FALSE);
+
+ return view->allow_links_change_zoom;
+}
diff --git a/libview/ev-view.h b/libview/ev-view.h
index 9baa97d..cd3ddf6 100644
--- a/libview/ev-view.h
+++ b/libview/ev-view.h
@@ -56,6 +56,10 @@ void ev_view_reload (EvView *view);
void ev_view_set_page_cache_size (EvView *view,
gsize cache_size);
+void ev_view_set_allow_links_change_zoom (EvView *view,
+ gboolean allowed);
+gboolean ev_view_get_allow_links_change_zoom (EvView *view);
+
/* Clipboard */
void ev_view_copy (EvView *view);
void ev_view_copy_link_address (EvView *view,
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 0f6742b..f9bf534 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -255,6 +255,7 @@ struct _EvWindowPrivate {
#define GS_AUTO_RELOAD "auto-reload"
#define GS_LAST_DOCUMENT_DIRECTORY "document-directory"
#define GS_LAST_PICTURES_DIRECTORY "pictures-directory"
+#define GS_ALLOW_LINKS_CHANGE_ZOOM "allow-links-change-zoom"
#define SIDEBAR_DEFAULT_SIZE 132
#define LINKS_SIDEBAR_ID "links"
@@ -1369,6 +1370,16 @@ page_cache_size_changed (GSettings *settings,
}
static void
+allow_links_change_zoom_changed (GSettings *settings,
+ gchar *key,
+ EvWindow *ev_window)
+{
+ gboolean allow_links_change_zoom = g_settings_get_boolean (settings, GS_ALLOW_LINKS_CHANGE_ZOOM);
+
+ ev_view_set_allow_links_change_zoom (EV_VIEW (ev_window->priv->view), allow_links_change_zoom);
+}
+
+static void
ev_window_setup_default (EvWindow *ev_window)
{
EvDocumentModel *model = ev_window->priv->model;
@@ -1485,6 +1496,10 @@ ev_window_ensure_settings (EvWindow *ev_window)
"changed::"GS_PAGE_CACHE_SIZE,
G_CALLBACK (page_cache_size_changed),
ev_window);
+ g_signal_connect (priv->settings,
+ "changed::"GS_ALLOW_LINKS_CHANGE_ZOOM,
+ G_CALLBACK (allow_links_change_zoom_changed),
+ ev_window);
return priv->settings;
}
@@ -4505,6 +4520,7 @@ ev_window_cmd_edit_save_settings (GSimpleAction *action,
EvDocumentModel *model = priv->model;
GSettings *settings = priv->default_settings;
EvSizingMode sizing_mode;
+ EvView *view = EV_VIEW (ev_window->priv->view);
g_settings_set_boolean (settings, "continuous",
ev_document_model_get_continuous (model));
@@ -6803,6 +6819,7 @@ ev_window_init (EvWindow *ev_window)
GtkWidget *overlay;
GObject *mpkeys;
guint page_cache_mb;
+ gboolean allow_links_change_zoom;
#ifdef ENABLE_DBUS
GDBusConnection *connection;
static gint window_id = 0;
@@ -7027,6 +7044,10 @@ ev_window_init (EvWindow *ev_window)
GS_PAGE_CACHE_SIZE);
ev_view_set_page_cache_size (EV_VIEW (ev_window->priv->view),
page_cache_mb * 1024 * 1024);
+ allow_links_change_zoom = g_settings_get_boolean (ev_window_ensure_settings (ev_window),
+ GS_ALLOW_LINKS_CHANGE_ZOOM);
+ ev_view_set_allow_links_change_zoom (EV_VIEW (ev_window->priv->view),
+ allow_links_change_zoom);
ev_view_set_model (EV_VIEW (ev_window->priv->view), ev_window->priv->model);
ev_window->priv->password_view = ev_password_view_new (GTK_WINDOW (ev_window));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]