summaryrefslogtreecommitdiff
path: root/tumbler/tumbler-thumbnailer.c
diff options
context:
space:
mode:
authorNick Schermer <nick@xfce.org>2012-12-16 15:30:09 +0100
committerNick Schermer <nick@xfce.org>2012-12-27 11:28:27 +0100
commit8913e999caed579d62b0021f32db6dfef65ff7f4 (patch)
tree1315cca4400154e20ca4def7908ab7f0759b8544 /tumbler/tumbler-thumbnailer.c
parentf7a3eda07ec55d43f92dd2ebbe717cb5c1ddd81c (diff)
downloadtumbler-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-thumbnailer.c')
-rw-r--r--tumbler/tumbler-thumbnailer.c74
1 files changed, 73 insertions, 1 deletions
diff --git a/tumbler/tumbler-thumbnailer.c b/tumbler/tumbler-thumbnailer.c
index 4c4d928..14e2b71 100644
--- a/tumbler/tumbler-thumbnailer.c
+++ b/tumbler/tumbler-thumbnailer.c
@@ -94,7 +94,28 @@ tumbler_thumbnailer_class_init (TumblerThumbnailerIface *klass)
g_param_spec_pointer ("hash-keys",
"hash-keys",
"hash-keys",
- G_PARAM_READABLE));
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE));
+
+ g_object_interface_install_property (klass,
+ g_param_spec_int ("priority",
+ "priority",
+ "priority",
+ 0, G_MAXINT, 0,
+ G_PARAM_READWRITE));
+
+ g_object_interface_install_property (klass,
+ g_param_spec_int64 ("max-file-size",
+ "max-file-size",
+ "max-file-size",
+ 0, G_MAXINT64, 0,
+ G_PARAM_READWRITE));
+
+ g_object_interface_install_property (klass,
+ g_param_spec_pointer ("locations",
+ "locations",
+ "locations",
+ G_PARAM_READWRITE));
tumbler_thumbnailer_signals[SIGNAL_READY] =
g_signal_new ("ready",
@@ -191,6 +212,57 @@ tumbler_thumbnailer_get_uri_schemes (TumblerThumbnailer *thumbnailer)
+gint
+tumbler_thumbnailer_get_priority (TumblerThumbnailer *thumbnailer)
+{
+ gint priority;
+
+ g_return_val_if_fail (TUMBLER_IS_THUMBNAILER (thumbnailer), 0);
+
+ g_object_get (thumbnailer, "priority", &priority, NULL);
+ return priority;
+}
+
+
+
+gint64
+tumbler_thumbnailer_get_max_file_size (TumblerThumbnailer *thumbnailer)
+{
+ gint max_file_size;
+
+ g_return_val_if_fail (TUMBLER_IS_THUMBNAILER (thumbnailer), 0);
+
+ g_object_get (thumbnailer, "max-file-size", &max_file_size, NULL);
+ return max_file_size;
+}
+
+
+
+gboolean
+tumbler_thumbnailer_supports_location (TumblerThumbnailer *thumbnailer,
+ GFile *file)
+{
+ GSList *locations, *lp;
+ gboolean supported = FALSE;
+
+ /* we're cool if no locations are set */
+ g_object_get (thumbnailer, "locations", &locations, NULL);
+ if (locations == NULL)
+ return TRUE;
+
+ /*check if the prefix is supported */
+ for (lp = locations; !supported && lp != NULL; lp = lp->next)
+ if (g_file_has_prefix (file, G_FILE (lp->data)))
+ supported = TRUE;
+
+ g_slist_foreach (locations, (GFunc) g_object_unref, NULL);
+ g_slist_free (locations);
+
+ return supported;
+}
+
+
+
gboolean
tumbler_thumbnailer_supports_hash_key (TumblerThumbnailer *thumbnailer,
const gchar *hash_key)