diff --git a/config.c b/config.c index 3d01099..d56d385 100644 --- a/config.c +++ b/config.c @@ -292,6 +292,7 @@ config_load_default(zathura_t* zathura) girara_shortcut_add(gsession, 0, GDK_KEY_F5, NULL, sc_toggle_fullscreen, FULLSCREEN, 0, NULL); girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_n, NULL, girara_sc_toggle_statusbar, NORMAL, 0, NULL); girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_m, NULL, girara_sc_toggle_inputbar, NORMAL, 0, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_d, NULL, sc_toggle_page_mode, NORMAL, 0, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_q, NULL, sc_quit, NORMAL, 0, NULL); diff --git a/shortcuts.c b/shortcuts.c index c9bcaa4..d7d8fe9 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -1008,6 +1008,35 @@ error_ret: return false; } +bool +sc_toggle_page_mode(girara_session_t* session, girara_argument_t* + UNUSED(argument), girara_event_t* UNUSED(event), unsigned int UNUSED(t)) +{ + g_return_val_if_fail(session != NULL, false); + g_return_val_if_fail(session->global.data != NULL, false); + zathura_t* zathura = session->global.data; + + if (zathura->document == NULL) { + girara_notify(session, GIRARA_WARNING, _("No document opened.")); + return false; + } + + int pages_per_row = 1; + girara_setting_get(zathura->ui.session, "pages-per-row", &pages_per_row); + + static int tmp = 2; + int value = 1; + if (pages_per_row == 1) { + value = tmp; + } else { + tmp = pages_per_row; + } + + girara_setting_set(zathura->ui.session, "pages-per-row", &value); + + return true; +} + bool sc_toggle_fullscreen(girara_session_t* session, girara_argument_t* UNUSED(argument), girara_event_t* UNUSED(event), unsigned int UNUSED(t)) diff --git a/shortcuts.h b/shortcuts.h index 362c243..d623d3e 100644 --- a/shortcuts.h +++ b/shortcuts.h @@ -204,6 +204,17 @@ bool sc_navigate_index(girara_session_t* session, girara_argument_t* argument, g */ bool sc_toggle_index(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); +/** + * Toggle multi page mode + * + * @param session The used girara session + * @param argument The used argument + * @param event Girara event + * @param t Number of executions + * @return true if no error occured otherwise false + */ +bool sc_toggle_page_mode(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); + /** * Toggle fullscreen mode *