Experimental implementation of sc_goto

This commit is contained in:
Moritz Lipp 2011-02-10 00:12:09 +08:00
parent a97cda9176
commit 498a1c31e4
2 changed files with 28 additions and 2 deletions

View file

@ -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);

View file

@ -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;
}