mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-16 18:15:40 +01:00
Experimental implementation of sc_goto
This commit is contained in:
parent
a97cda9176
commit
498a1c31e4
2 changed files with 28 additions and 2 deletions
4
config.c
4
config.c
|
@ -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);
|
||||
|
|
26
shortcuts.c
26
shortcuts.c
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue