diff options
author | Nick Schermer <nick@xfce.org> | 2012-12-16 15:30:09 +0100 |
---|---|---|
committer | Nick Schermer <nick@xfce.org> | 2012-12-27 11:28:27 +0100 |
commit | 8913e999caed579d62b0021f32db6dfef65ff7f4 (patch) | |
tree | 1315cca4400154e20ca4def7908ab7f0759b8544 /tumbler/tumbler-provider-factory.c | |
parent | f7a3eda07ec55d43f92dd2ebbe717cb5c1ddd81c (diff) | |
download | tumbler-8913e999caed579d62b0021f32db6dfef65ff7f4.tar.gz |
Add config file system to control thumbnailing plugin.
Settings that allow to change the plugin priority, max file
size to act on, white-listed locations or completely disable
them.
Diffstat (limited to 'tumbler/tumbler-provider-factory.c')
-rw-r--r-- | tumbler/tumbler-provider-factory.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/tumbler/tumbler-provider-factory.c b/tumbler/tumbler-provider-factory.c index afa47e3..5c67147 100644 --- a/tumbler/tumbler-provider-factory.c +++ b/tumbler/tumbler-provider-factory.c @@ -22,11 +22,16 @@ #include <config.h> #endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif + #include <glib.h> #include <glib-object.h> #include <tumbler/tumbler-provider-factory.h> #include <tumbler/tumbler-provider-plugin.h> +#include <tumbler/tumbler-util.h> @@ -253,17 +258,34 @@ tumbler_provider_factory_get_providers (TumblerProviderFactory *factory, GList *plugins; GList *providers = NULL; guint n; + const gchar *type_name; + gchar *name; + gboolean disabled; + GKeyFile *rc; G_LOCK (factory_lock); /* load available plugins */ plugins = tumbler_provider_factory_load_plugins (factory); + /* rc file */ + rc = tumbler_util_get_settings (); + /* iterate over all provider infos */ for (n = 0; n < factory->provider_infos->len; ++n) { info = factory->provider_infos->pdata[n]; + /* check if this plugin is disabled with the assumption + * the provider only provides 1 type */ + type_name = g_type_name (info->type); + g_assert (g_str_has_suffix (type_name, "Provider")); + name = g_strndup (type_name, strlen (type_name) - 8); + disabled = g_key_file_get_boolean (rc, name, "Disabled", NULL); + g_free (name); + if (disabled) + continue; + /* check if the provider type implements the given type */ if (G_LIKELY (g_type_is_a (info->type, type))) { @@ -271,8 +293,8 @@ tumbler_provider_factory_get_providers (TumblerProviderFactory *factory, if (info->provider == NULL) info->provider = g_object_new (info->type, NULL); - /* append the provider to the list */ - providers = g_list_append (providers, g_object_ref (info->provider)); + /* add the provider to the list */ + providers = g_list_prepend (providers, g_object_ref (info->provider)); } } @@ -281,6 +303,8 @@ tumbler_provider_factory_get_providers (TumblerProviderFactory *factory, g_type_module_unuse (G_TYPE_MODULE (lp->data)); g_list_free (plugins); + g_key_file_free (rc); + G_UNLOCK (factory_lock); return providers; |