Commit 498a1c31 authored by Moritz Lipp's avatar Moritz Lipp
Browse files

Experimental implementation of sc_goto

parent a97cda91
......@@ -30,8 +30,8 @@ config_load_default(void)
girara_shortcut_add(Zathura.UI.session, 0, GDK_o, NULL, sc_focus_inputbar, NORMAL, 0, &(":open "));
girara_shortcut_add(Zathura.UI.session, 0, GDK_O, NULL, sc_focus_inputbar, NORMAL, APPEND_FILEPATH, &(":open "));
girara_shortcut_add(Zathura.UI.session, 0, GDK_f, NULL, sc_follow, NORMAL, 0, NULL);
girara_shortcut_add(Zathura.UI.session, 0, 0, "gg", sc_goto, NORMAL | FULLSCREEN, 0, NULL);
girara_shortcut_add(Zathura.UI.session, 0, 0, "G", sc_goto, NORMAL | FULLSCREEN, 0, NULL);
girara_shortcut_add(Zathura.UI.session, 0, 0, "gg", sc_goto, NORMAL | FULLSCREEN, TOP, NULL);
girara_shortcut_add(Zathura.UI.session, 0, 0, "G", sc_goto, NORMAL | FULLSCREEN, BOTTOM, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_J, NULL, sc_navigate, NORMAL, NEXT, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_K, NULL, sc_navigate, NORMAL, PREVIOUS, NULL);
girara_shortcut_add(Zathura.UI.session, GDK_MOD1_MASK, GDK_Right, NULL, sc_navigate, NORMAL, NEXT, NULL);
......
......@@ -66,6 +66,32 @@ sc_follow(girara_session_t* session, girara_argument_t* argument, unsigned int t
bool
sc_goto(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{
if (!session || !argument) {
return false;
}
if (argument->n == TOP) {
girara_argument_t arg = { TOP, NULL };
sc_scroll(session, &arg, 0);
return false;
} else {
if (t == 0) {
girara_argument_t arg = { BOTTOM, NULL };
sc_scroll(session, &arg, 0);
return true;
}
unsigned int number_of_pages = Zathura.document->number_of_pages;
if (t > 0 && t <= number_of_pages) {
GtkAdjustment* adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(Zathura.UI.session->gtk.view));
unsigned int offset = Zathura.document->pages[t - 1]->offset * Zathura.document->scale;
gtk_adjustment_set_value(adjustment, offset);
}
}
return false;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment