Option to keep horizontal position when following internal links

Added config parameter "link-hadjust" with default value true. When set to false,
following internal links do not change the horizontal position of the page, only
the vertical position.

Also updates page number when following links, now.

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
Abdó Roig-Maranges 2012-08-16 18:41:31 +02:00 committed by Sebastian Ramacher
parent 71680394a7
commit 8e9631946d
4 changed files with 32 additions and 9 deletions

View file

@ -186,6 +186,8 @@ config_load_default(zathura_t* zathura)
bool_value = false;
girara_setting_add(gsession, "zoom-center", &bool_value, BOOLEAN, false, _("Horizontally centered zoom"), NULL, NULL);
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, "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);

22
links.c
View file

@ -4,6 +4,7 @@
#include <glib/gi18n.h>
#include <girara/utils.h>
#include <girara/session.h>
#include <girara/settings.h>
#include "links.h"
#include "zathura.h"
@ -135,11 +136,8 @@ zathura_link_evaluate(zathura_t* zathura, zathura_link_t* link)
return;
}
zathura_document_set_current_page_number(zathura->document, link->target.page_number);
/* get page offset */
page_offset_t offset;
page_calculate_offset(zathura, page, &offset);
page_offset_t offset;
page_calculate_offset(zathura, page, &offset);
if (link->target.destination_type == ZATHURA_LINK_DESTINATION_XYZ) {
if (link->target.left != -1) {
@ -151,8 +149,18 @@ zathura_link_evaluate(zathura_t* zathura, zathura_link_t* link)
}
}
position_set_delayed(zathura, offset.x, offset.y);
statusbar_page_number_update(zathura);
/* jump to the page */
page_set(zathura, link->target.page_number);
/* move to the target position */
bool link_hadjust = true;
girara_setting_get(zathura->ui.session, "link-hadjust", &link_hadjust);
if (link_hadjust == true) {
position_set_delayed(zathura, offset.x, offset.y);
} else {
position_set_delayed(zathura, -1, offset.y);
}
}
break;
case ZATHURA_LINK_GOTO_REMOTE:

View file

@ -1093,8 +1093,14 @@ position_set_delayed_impl(gpointer data)
GtkAdjustment* vadjustment = gtk_scrolled_window_get_vadjustment(window);
GtkAdjustment* hadjustment = gtk_scrolled_window_get_hadjustment(window);
zathura_adjustment_set_value(hadjustment, p->position_x);
zathura_adjustment_set_value(vadjustment, p->position_y);
/* negative values mean: don't set the position */
if (p->position_x >= 0) {
zathura_adjustment_set_value(hadjustment, p->position_x);
}
if (p->position_y >= 0) {
zathura_adjustment_set_value(vadjustment, p->position_y);
}
g_free(p);

View file

@ -640,6 +640,13 @@ Defines if scrolling by half or full pages stops at page boundaries.
* Value type: Boolean
* Default value: false
link-hadjust
^^^^^^^^^^^^
En/Disables aligning to the left internal link targets, for example from the index
* Value type: Boolean
* Default value: true
search-hadjust
^^^^^^^^^^^^^^
En/Disables horizontally centered search results