Hi,

I encountered a weird pdf that wants to zoom out every time I follow a link from
the index. I attach a patch that makes this "feature" configurable.

Also I attach an other small patch that gets rid of a GTK deprecation warning.

Abdó.

>From d0c58face294de46915dc5de9fe553f0e31386ad Mon Sep 17 00:00:00 2001
From: Abdo Roig-Maranges <abdo.r...@gmail.com>
Date: Mon, 21 Oct 2013 18:01:04 +0200
Subject: [PATCH] add a config setting to prevent link_evaluate from changing
 scale

---
 config.c        | 2 ++
 links.c         | 5 ++++-
 zathurarc.5.rst | 7 +++++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/config.c b/config.c
index e14d7e2..fb126a4 100644
--- a/config.c
+++ b/config.c
@@ -199,6 +199,8 @@ config_load_default(zathura_t* zathura)
   bool_value = true;
   girara_setting_add(gsession, "link-hadjust",           &bool_value,  BOOLEAN, false, _("Align link target to the left"), NULL, NULL);
   bool_value = true;
+  girara_setting_add(gsession, "link-zoom",              &bool_value,  BOOLEAN, false, _("Let zoom be changed when following links"), NULL, NULL);
+  bool_value = true;
   girara_setting_add(gsession, "search-hadjust",         &bool_value,  BOOLEAN, false, _("Center result horizontally"), NULL, NULL);
   float_value = 0.5;
   girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT,   false, _("Transparency for highlighting"), NULL, NULL);
diff --git a/links.c b/links.c
index 981c446..929e678 100644
--- a/links.c
+++ b/links.c
@@ -122,10 +122,13 @@ zathura_link_evaluate(zathura_t* zathura, zathura_link_t* link)
     return;
   }
 
+  bool link_zoom = true;
+  girara_setting_get(zathura->ui.session, "link-zoom", &link_zoom);
+
   switch (link->type) {
     case ZATHURA_LINK_GOTO_DEST:
       if (link->target.destination_type != ZATHURA_LINK_DESTINATION_UNKNOWN) {
-        if (link->target.scale != 0) {
+        if (link->target.scale != 0 && link_zoom) {
           zathura_document_set_scale(zathura->document, link->target.scale);
         }
 
diff --git a/zathurarc.5.rst b/zathurarc.5.rst
index 260b993..8a4208d 100644
--- a/zathurarc.5.rst
+++ b/zathurarc.5.rst
@@ -690,6 +690,13 @@ Defines if scrolling by half or full pages stops at page boundaries.
 * Value type: Boolean
 * Default value: false
 
+link-zoom
+^^^^^^^^^
+En/Disables the hability of changing zoom when following links.
+
+* Value type: Boolean
+* Default value: true
+
 link-hadjust
 ^^^^^^^^^^^^
 En/Disables aligning to the left internal link targets, for example from the index
-- 
1.8.4.1

>From de1cf97d4b87134aee8178cbceb683b88488d481 Mon Sep 17 00:00:00 2001
From: Abdo Roig-Maranges <abdo.r...@gmail.com>
Date: Sun, 20 Oct 2013 03:03:54 +0200
Subject: [PATCH] fix gtk_widget_get_requisition deprecation warning in GTK3

---
 shortcuts.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/shortcuts.c b/shortcuts.c
index 1820a98..b9336ff 100644
--- a/shortcuts.c
+++ b/shortcuts.c
@@ -169,10 +169,16 @@ sc_adjust_window(girara_session_t* session, girara_argument_t* argument,
             GTK_SCROLLED_WINDOW(session->gtk.view));
 
         if (vscrollbar != NULL) {
+            int scroll_width;
+#if (GTK_MAJOR_VERSION == 3)
+            gtk_widget_get_preferred_width(GTK_WIDGET(vscrollbar), NULL, &scroll_width);
+#else
           GtkRequisition requisition;
           gtk_widget_get_requisition(vscrollbar, &requisition);
-          if (0 < requisition.width && (unsigned)requisition.width < width) {
-            width -= requisition.width;
+          scroll_width = requisition.width;
+#endif
+          if (0 < scroll_width && (unsigned)scroll_width < width) {
+            width -= scroll_width;
             scale = (double)(width - (pages_per_row - 1) * padding) /
                     (double)(pages_per_row * cell_width);
             zathura_document_set_scale(zathura->document, scale);
-- 
1.8.4.1

_______________________________________________
zathura mailing list
zathura@lists.pwmt.org
http://lists.pwmt.org/mailman/listinfo/zathura

Reply via email to