diff --git a/commands.c b/commands.c index 706b718..8c248c0 100644 --- a/commands.c +++ b/commands.c @@ -15,6 +15,7 @@ #include "utils.h" #include "page-widget.h" #include "page.h" +#include "plugin.h" #include "internal.h" #include "render.h" @@ -518,3 +519,43 @@ cmd_offset(girara_session_t* session, girara_list_t* argument_list) return true; } + +bool +cmd_version(girara_session_t* session, girara_list_t* UNUSED(argument_list)) +{ + g_return_val_if_fail(session != NULL, false); + g_return_val_if_fail(session->global.data != NULL, false); + zathura_t* zathura = session->global.data; + + GString* string = g_string_new(NULL); + + /* zathura version */ + char* zathura_version = g_strdup_printf("zathura %d.%d.%d", ZATHURA_VERSION_MAJOR, ZATHURA_VERSION_MINOR, ZATHURA_VERSION_REV); + g_string_append(string, zathura_version); + g_free(zathura_version); + + /* plugin information */ + girara_list_t* plugins = zathura_plugin_manager_get_plugins(zathura->plugins.manager); + if (plugins != NULL) { + GIRARA_LIST_FOREACH(plugins, zathura_plugin_t*, iter, plugin) + char* name = zathura_plugin_get_name(plugin); + zathura_plugin_version_t version = zathura_plugin_get_version(plugin); + char* text = g_strdup_printf("\n(plugin) %s (%d.%d.%d) (%s)", + (name == NULL) ? "-" : name, + version.major, + version.minor, + version.rev, + zathura_plugin_get_path(plugin) + ); + g_string_append(string, text); + g_free(text); + GIRARA_LIST_FOREACH_END(plugins, zathura_plugin_t*, iter, plugin); + } + + /* display information */ + girara_notify(session, GIRARA_INFO, "%s", string->str); + + g_string_free(string, TRUE); + + return true; +} diff --git a/commands.h b/commands.h index 6e6a1a0..e22fa86 100644 --- a/commands.h +++ b/commands.h @@ -151,4 +151,13 @@ bool cmd_export(girara_session_t* session, girara_list_t* argument_list); */ bool cmd_offset(girara_session_t* session, girara_list_t* argument_list); +/** + * Shows version information + * + * @param session The used girara session + * @param argument_list List of passed arguments + * @return true if no error occured + */ +bool cmd_version(girara_session_t* session, girara_list_t* argument_list); + #endif // COMMANDS_H diff --git a/config.c b/config.c index 6c7c801..cd60fa3 100644 --- a/config.c +++ b/config.c @@ -282,6 +282,7 @@ config_load_default(zathura_t* zathura) girara_inputbar_command_add(gsession, "delmarks", "delm", cmd_marks_delete, NULL, _("Delete the specified marks")); girara_inputbar_command_add(gsession, "nohlsearch", "nohl", cmd_nohlsearch, NULL, _("Don't highlight current search results")); girara_inputbar_command_add(gsession, "hlsearch", NULL, cmd_hlsearch, NULL, _("Highlight current search results")); + girara_inputbar_command_add(gsession, "version", NULL, cmd_version, NULL, _("Show version information")); girara_special_command_add(gsession, '/', cmd_search, true, FORWARD, NULL); girara_special_command_add(gsession, '?', cmd_search, true, BACKWARD, NULL);