Added 'scroll-wrap' for sc_navigate

This commit is contained in:
Moritz Lipp 2012-03-14 17:44:36 +01:00
parent 81b86d8b7b
commit 0474235483
2 changed files with 24 additions and 6 deletions

View File

@ -89,6 +89,8 @@ config_load_default(zathura_t* zathura)
bool_value = false;
girara_setting_add(gsession, "recolor", &bool_value, BOOLEAN, false, _("Recolor pages"), cb_setting_recolor_change, NULL);
bool_value = false;
girara_setting_add(gsession, "scroll-wrap", &bool_value, BOOLEAN, false, _("Wrap scrolling"), NULL, NULL);
float_value = 0.5;
girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, _("Transparency for highlighting"), NULL, NULL);
bool_value = true;

View File

@ -342,11 +342,26 @@ sc_navigate(girara_session_t* session, girara_argument_t* argument,
unsigned int number_of_pages = zathura->document->number_of_pages;
unsigned int new_page = zathura->document->current_page_number;
bool scroll_wrap = false;
girara_setting_get(session, "scroll-wrap", &scroll_wrap);
t = (t == 0) ? 1 : t;
if (argument->n == NEXT) {
new_page = (new_page + t) % number_of_pages;
if (scroll_wrap == true) {
new_page = new_page + t;
} else {
new_page = (new_page + t) % number_of_pages;
}
} else if (argument->n == PREVIOUS) {
new_page = (new_page + number_of_pages - t) % number_of_pages;
if (scroll_wrap == true) {
new_page = new_page - t;
} else {
new_page = (new_page + number_of_pages - t) % number_of_pages;
}
}
if (scroll_wrap == true && (new_page < 0 || new_page >= number_of_pages)) {
return false;
}
page_set(zathura, new_page);
@ -431,10 +446,11 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument,
adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view));
}
gdouble view_size = gtk_adjustment_get_page_size(adjustment);
gdouble value = gtk_adjustment_get_value(adjustment);
gdouble max = gtk_adjustment_get_upper(adjustment) - view_size;
unsigned int padding = zathura->global.page_padding;
gdouble view_size = gtk_adjustment_get_page_size(adjustment);
gdouble value = gtk_adjustment_get_value(adjustment);
gdouble max = gtk_adjustment_get_upper(adjustment) - view_size;
unsigned int padding = zathura->global.page_padding;
zathura->global.update_page_number = true;
float scroll_step = 40;