From 395ecfab682198b95d9130571ebbd6c0f58ce83f Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 8 May 2022 16:44:37 +0200 Subject: [PATCH] Print better error message if no plugins are available (fixes #284) --- zathura/plugin.c | 5 +++-- zathura/plugin.h | 3 ++- zathura/zathura.c | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/zathura/plugin.c b/zathura/plugin.c index 0ccbac5..2c758d2 100644 --- a/zathura/plugin.c +++ b/zathura/plugin.c @@ -195,15 +195,16 @@ load_dir(void* data, void* userdata) } } -void +bool zathura_plugin_manager_load(zathura_plugin_manager_t* plugin_manager) { if (plugin_manager == NULL || plugin_manager->path == NULL) { - return; + return false; } /* read all files in the plugin directory */ girara_list_foreach(plugin_manager->path, load_dir, plugin_manager); + return girara_list_size(plugin_manager->plugins) > 0; } zathura_plugin_t* diff --git a/zathura/plugin.h b/zathura/plugin.h index d7b0b70..85a5816 100644 --- a/zathura/plugin.h +++ b/zathura/plugin.h @@ -37,8 +37,9 @@ void zathura_plugin_manager_add_dir(zathura_plugin_manager_t* plugin_manager, co * Loads all plugins available in the previously given directories * * @param plugin_manager The plugin manager + * @return Success if some plugins have been loaded, false otherwise */ -void zathura_plugin_manager_load(zathura_plugin_manager_t* plugin_manager); +bool zathura_plugin_manager_load(zathura_plugin_manager_t* plugin_manager); /** * Returns the (if available) associated plugin diff --git a/zathura/zathura.c b/zathura/zathura.c index b2ccc4b..e1ed652 100644 --- a/zathura/zathura.c +++ b/zathura/zathura.c @@ -430,7 +430,9 @@ zathura_init(zathura_t* zathura) g_set_prgname("org.pwmt.zathura"); /* load plugins */ - zathura_plugin_manager_load(zathura->plugins.manager); + if (zathura_plugin_manager_load(zathura->plugins.manager) == false) { + girara_error("Found no plugins. Please install at least one plugin."); + } /* configuration */ config_load_default(zathura);