diff --git a/config.c b/config.c index e305e52..702c8a6 100644 --- a/config.c +++ b/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); diff --git a/shortcuts.c b/shortcuts.c index d5bf8e1..26bd6d5 100644 --- a/shortcuts.c +++ b/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; }