diff options
author | Ali Abdallah <aabdallah@suse.de> | 2020-05-01 13:21:39 +0200 |
---|---|---|
committer | Ali Abdallah <aabdallah@suse.de> | 2020-05-01 13:39:12 +0200 |
commit | 3520322eb453ee1349b14b080a0f7d23e4040b16 (patch) | |
tree | d6acd0b797fe99d3a326b27e7426d3535c76c3bf /tumbler | |
parent | 4626d3a97a04dab06925053ac5b80c6f7be5f2f2 (diff) | |
download | tumbler-3520322eb453ee1349b14b080a0f7d23e4040b16.tar.gz |
This commit implements Excludes paths
Any path found in a plugin Excludes will be ignored,
code contributed by Markus Kolb xfce@tower-net.de Bug #16130.
Diffstat (limited to 'tumbler')
-rw-r--r-- | tumbler/tumbler-abstract-thumbnailer.c | 20 | ||||
-rw-r--r-- | tumbler/tumbler-thumbnailer.c | 32 |
2 files changed, 45 insertions, 7 deletions
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..c390e8a 100644 --- a/tumbler/tumbler-thumbnailer.c +++ b/tumbler/tumbler-thumbnailer.c @@ -9,11 +9,11 @@ * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * - * You should have received a copy of the GNU Library General - * Public License along with this library; if not, write to the + * You should have received a copy of the GNU Library General + * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ @@ -51,7 +51,7 @@ GType tumbler_thumbnailer_get_type (void) { static volatile gsize g_define_type_id__volatile = 0; - + if (g_once_init_enter (&g_define_type_id__volatile)) { GType g_define_type_id = @@ -117,7 +117,13 @@ tumbler_thumbnailer_class_init (TumblerThumbnailerIface *klass) "locations", G_PARAM_READWRITE)); - tumbler_thumbnailer_signals[SIGNAL_READY] = + 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, G_SIGNAL_RUN_LAST, @@ -242,12 +248,26 @@ gboolean tumbler_thumbnailer_supports_location (TumblerThumbnailer *thumbnailer, GFile *file) { - GSList *locations, *lp; + GSList *locations, *excludes, *lp, *ep; gboolean supported = FALSE; + gboolean excluded = 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; !excluded && ep != NULL; ep = ep->next) + if (g_file_has_prefix (file, G_FILE (ep->data))) + excluded = TRUE; + } + + /* Path is excluded */ + if (excluded) + return FALSE; + /* we're cool if no locations are set */ g_object_get (thumbnailer, "locations", &locations, NULL); if (locations == NULL) |