From c998ad32b14ade58d84760790b91c1e8311ace22 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sat, 30 Nov 2019 11:35:33 +0100 Subject: [PATCH] Keep track of all supported content types --- zathura/plugin.c | 31 +++++++++++++++++++------------ zathura/plugin.h | 8 ++++++++ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/zathura/plugin.c b/zathura/plugin.c index f72ff39..0ccbac5 100644 --- a/zathura/plugin.c +++ b/zathura/plugin.c @@ -37,6 +37,7 @@ struct zathura_plugin_manager_s { girara_list_t* plugins; /**< List of plugins */ girara_list_t* path; /**< List of plugin paths */ girara_list_t* type_plugin_mapping; /**< List of type -> plugin mappings */ + girara_list_t* content_types; /**< List of all registered content types */ }; static void plugin_add_mimetype(zathura_plugin_t* plugin, const char* mime_type); @@ -56,10 +57,12 @@ zathura_plugin_manager_new(void) plugin_manager->plugins = girara_list_new2((girara_free_function_t) zathura_plugin_free); plugin_manager->path = girara_list_new2(g_free); plugin_manager->type_plugin_mapping = girara_list_new2((girara_free_function_t)zathura_type_plugin_mapping_free); + plugin_manager->content_types = girara_list_new2(g_free); if (plugin_manager->plugins == NULL || plugin_manager->path == NULL - || plugin_manager->type_plugin_mapping == NULL) { + || plugin_manager->type_plugin_mapping == NULL + || plugin_manager->content_types == NULL) { zathura_plugin_manager_free(plugin_manager); return NULL; } @@ -231,6 +234,16 @@ zathura_plugin_manager_get_plugins(zathura_plugin_manager_t* plugin_manager) return plugin_manager->plugins; } +girara_list_t* +zathura_plugin_manager_get_content_types(zathura_plugin_manager_t* plugin_manager) +{ + if (plugin_manager == NULL) { + return NULL; + } + + return plugin_manager->content_types; +} + void zathura_plugin_manager_free(zathura_plugin_manager_t* plugin_manager) { @@ -238,17 +251,10 @@ zathura_plugin_manager_free(zathura_plugin_manager_t* plugin_manager) return; } - if (plugin_manager->plugins != NULL) { - girara_list_free(plugin_manager->plugins); - } - - if (plugin_manager->path != NULL) { - girara_list_free(plugin_manager->path); - } - - if (plugin_manager->type_plugin_mapping != NULL) { - girara_list_free(plugin_manager->type_plugin_mapping); - } + girara_list_free(plugin_manager->content_types); + girara_list_free(plugin_manager->type_plugin_mapping); + girara_list_free(plugin_manager->path); + girara_list_free(plugin_manager->plugins); g_free(plugin_manager); } @@ -308,6 +314,7 @@ plugin_mapping_new(zathura_plugin_manager_t* plugin_manager, const gchar* type, mapping->type = g_strdup(type); mapping->plugin = plugin; girara_list_append(plugin_manager->type_plugin_mapping, mapping); + girara_list_append(plugin_manager->content_types, g_strdup(type)); return true; } diff --git a/zathura/plugin.h b/zathura/plugin.h index 68e359f..d7b0b70 100644 --- a/zathura/plugin.h +++ b/zathura/plugin.h @@ -57,6 +57,14 @@ zathura_plugin_t* zathura_plugin_manager_get_plugin(zathura_plugin_manager_t* pl */ girara_list_t* zathura_plugin_manager_get_plugins(zathura_plugin_manager_t* plugin_manager); +/** + * Return a list of supported content types + * + * @param plugin_manager The plugin manager + * @return List of plugins or NULL + */ +girara_list_t* zathura_plugin_manager_get_content_types(zathura_plugin_manager_t* plugin_manager); + /** * Returns the plugin functions *