diff --git a/commands.c b/commands.c index dbd46ea..706b718 100644 --- a/commands.c +++ b/commands.c @@ -252,7 +252,7 @@ cmd_print(girara_session_t* session, girara_list_t* UNUSED(argument_list)) return false; } - print((zathura_t*) session->global.data); + print(zathura); return true; } diff --git a/config.c b/config.c index 8b386b3..e41da3c 100644 --- a/config.c +++ b/config.c @@ -195,6 +195,8 @@ config_load_default(zathura_t* zathura) girara_shortcut_add(gsession, 0, GDK_KEY_space, NULL, sc_navigate_index, INDEX, SELECT, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_Return, NULL, sc_navigate_index, INDEX, SELECT, NULL); + girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_p, NULL, sc_print, NORMAL, 0, NULL); + girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_i, NULL, sc_recolor, NORMAL, 0, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_R, NULL, sc_reload, NORMAL, 0, NULL); @@ -290,6 +292,7 @@ config_load_default(zathura_t* zathura) girara_shortcut_mapping_add(gsession, "goto", sc_goto); girara_shortcut_mapping_add(gsession, "navigate_index", sc_navigate_index); girara_shortcut_mapping_add(gsession, "navigate", sc_navigate); + girara_shortcut_mapping_add(gsession, "print", sc_print); girara_shortcut_mapping_add(gsession, "quit", sc_quit); girara_shortcut_mapping_add(gsession, "recolor", sc_recolor); girara_shortcut_mapping_add(gsession, "reload", sc_reload); diff --git a/shortcuts.c b/shortcuts.c index 49b4231..0e9c91c 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -15,6 +15,7 @@ #include "render.h" #include "utils.h" #include "page.h" +#include "print.h" #include "page-widget.h" bool @@ -427,6 +428,24 @@ sc_navigate(girara_session_t* session, girara_argument_t* argument, return false; } +bool +sc_print(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_ERROR, _("No document opened.")); + return false; + } + + print(zathura); + + return true; +} + bool sc_recolor(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 56bed86..191c1af 100644 --- a/shortcuts.h +++ b/shortcuts.h @@ -105,6 +105,17 @@ bool sc_mouse_zoom(girara_session_t* session, girara_argument_t* argument, girar */ bool sc_navigate(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); +/** + * Calls the print dialog + * + * @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_print(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); + /** * Recolor the pages *