diff --git a/tumbler/tumbler-abstract-thumbnailer.c b/tumbler/tumbler-abstract-thumbnailer.c index f0db13a..3e81a49 100644 --- a/tumbler/tumbler-abstract-thumbnailer.c +++ b/tumbler/tumbler-abstract-thumbnailer.c @@ -40,7 +40,8 @@ enum PROP_HASH_KEYS, PROP_PRIORITY, PROP_MAX_FILE_SIZE, - PROP_LOCATIONS + PROP_LOCATIONS, + PROP_EXCLUDES }; @@ -70,6 +71,7 @@ struct _TumblerAbstractThumbnailerPrivate gint priority; gint64 max_file_size; GSList *locations; + GSList *excludes; }; @@ -101,6 +103,7 @@ tumbler_abstract_thumbnailer_class_init (TumblerAbstractThumbnailerClass *klass) g_object_class_override_property (gobject_class, PROP_PRIORITY, "priority"); g_object_class_override_property (gobject_class, PROP_MAX_FILE_SIZE, "max-file-size"); g_object_class_override_property (gobject_class, PROP_LOCATIONS, "locations"); + g_object_class_override_property (gobject_class, PROP_EXCLUDES, "excludes"); } @@ -180,6 +183,9 @@ tumbler_abstract_thumbnailer_finalize (GObject *object) g_slist_foreach (thumbnailer->priv->locations, (GFunc) g_object_unref, NULL); g_slist_free (thumbnailer->priv->locations); + g_slist_foreach (thumbnailer->priv->excludes, (GFunc) g_object_unref, NULL); + g_slist_free (thumbnailer->priv->excludes); + (*G_OBJECT_CLASS (tumbler_abstract_thumbnailer_parent_class)->finalize) (object); } @@ -222,6 +228,12 @@ tumbler_abstract_thumbnailer_get_property (GObject *object, g_value_set_pointer (value, dup); break; + case PROP_EXCLUDES: + dup = g_slist_copy (thumbnailer->priv->excludes); + g_slist_foreach (dup, (GFunc) g_object_ref, NULL); + g_value_set_pointer (value, dup); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -267,6 +279,12 @@ tumbler_abstract_thumbnailer_set_property (GObject *object, thumbnailer->priv->locations = dup; break; + case PROP_EXCLUDES: + dup = g_slist_copy (g_value_get_pointer (value)); + g_slist_foreach (dup, (GFunc) g_object_ref, NULL); + thumbnailer->priv->excludes = dup; + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; diff --git a/tumbler/tumbler-thumbnailer.c b/tumbler/tumbler-thumbnailer.c index 887b6de..728ea34 100644 --- a/tumbler/tumbler-thumbnailer.c +++ b/tumbler/tumbler-thumbnailer.c @@ -117,6 +117,12 @@ tumbler_thumbnailer_class_init (TumblerThumbnailerIface *klass) "locations", G_PARAM_READWRITE)); + g_object_interface_install_property (klass, + g_param_spec_pointer ("excludes", + "excludes", + "excludes", + G_PARAM_READWRITE)); + tumbler_thumbnailer_signals[SIGNAL_READY] = g_signal_new ("ready", TUMBLER_TYPE_THUMBNAILER, @@ -242,12 +248,24 @@ gboolean tumbler_thumbnailer_supports_location (TumblerThumbnailer *thumbnailer, GFile *file) { - GSList *locations, *lp; + GSList *locations, *excludes, *lp, *ep; gboolean supported = FALSE; g_return_val_if_fail (TUMBLER_IS_THUMBNAILER (thumbnailer), FALSE); g_return_val_if_fail (G_IS_FILE (file), FALSE); + /* check first if file is excluded */ + g_object_get (thumbnailer, "excludes", &excludes, NULL); + if (excludes != NULL) + { + for (ep = excludes; !supported && ep != NULL; ep = ep->next) + if (g_file_has_prefix (file, G_FILE (ep->data))) + supported = TRUE; + /* supported reused here for detecting exclude situation */ + if (supported) + return FALSE; + } + /* we're cool if no locations are set */ g_object_get (thumbnailer, "locations", &locations, NULL); if (locations == NULL) diff --git a/tumblerd/main.c b/tumblerd/main.c index 73b5af2..2c2d8da 100644 --- a/tumblerd/main.c +++ b/tumblerd/main.c @@ -249,6 +249,7 @@ main (int argc, const gchar *type_name; gchar **paths; GSList *locations; + GSList *excludes; /* set the program name */ g_set_prgname (G_LOG_DOMAIN); @@ -322,10 +323,15 @@ main (int argc, locations = locations_from_strv (paths); g_strfreev (paths); + paths = g_key_file_get_string_list (rc, type_name, "Excludes", NULL, NULL); + excludes = locations_from_strv (paths); + g_strfreev (paths); + g_object_set (G_OBJECT (tp->data), "priority", priority, "max-file-size", file_size, "locations", locations, + "excludes", excludes, NULL); /* ready for usage */ @@ -335,6 +341,8 @@ main (int argc, g_object_unref (tp->data); g_slist_foreach (locations, (GFunc) g_object_unref, NULL); g_slist_free (locations); + g_slist_foreach (excludes, (GFunc) g_object_unref, NULL); + g_slist_free (excludes); } /* free the thumbnailer list */ diff --git a/tumblerd/tumbler.rc b/tumblerd/tumbler.rc index 3e92911..87b7169 100644 --- a/tumblerd/tumbler.rc +++ b/tumblerd/tumbler.rc @@ -10,6 +10,9 @@ # priority will be tried. # Absolute paths, environement variables, ~/ and ~username/ # are allowed. Leave empty to allow all locations. +# Excludes: ;-separated path list the plugin will not be used in. +# Absolute paths, environement variables, ~/ and ~username/ +# are allowed. Leave empty to exclude nothing. # MaxFileSize: Maximum size of the source file the plugin will still # try to generate a plugin for. The size is in bytes, # 0 disabled the check. @@ -53,6 +56,7 @@ MaxFileSize=209715200 Disabled=true Priority=3 Locations=~/movies +Excludes= MaxFileSize=0 #APIKey=your-api-key-from-themoviedb.org @@ -61,6 +65,7 @@ MaxFileSize=0 Disabled=false Priority=2 Locations= +Excludes= MaxFileSize=2147483648 # GStreamer plugin @@ -68,6 +73,7 @@ MaxFileSize=2147483648 Disabled=false Priority=1 Locations= +Excludes= MaxFileSize=2147483648 ### @@ -79,6 +85,7 @@ MaxFileSize=2147483648 Disabled=false Priority=1 Locations= +Excludes= MaxFileSize=209715200 @@ -87,6 +94,7 @@ MaxFileSize=209715200 Disabled=false Priority=1 Locations= +Excludes= MaxFileSize=209715200 # Open document thumbnailer (ODF) @@ -94,6 +102,7 @@ MaxFileSize=209715200 Disabled=false Priority=1 Locations= +Excludes= MaxFileSize=209715200 # thumbnailers provided by .thumbnailer desktop files @@ -101,4 +110,5 @@ MaxFileSize=209715200 Disabled=false Priority=1 Locations= -MaxFileSize=2147483648 \ No newline at end of file +Excludes= +MaxFileSize=2147483648