summaryrefslogtreecommitdiff
path: root/tumblerd
diff options
context:
space:
mode:
authorGaël Bonithon <gael@xfce.org>2021-12-29 10:48:14 +0100
committerGaël Bonithon <gael@xfce.org>2021-12-29 13:09:43 +0100
commit7fdab65f7a2144a7cae4d49bea13cea3644dfc3c (patch)
tree8bf0045d59c05be0f26d78ffb4756e4e9ddfa997 /tumblerd
parent270289b3a3f2f9ac7891f26135bae6d5e574c868 (diff)
downloadtumbler-7fdab65f7a2144a7cae4d49bea13cea3644dfc3c.tar.gz
desktop-thumbnailer: Allow to override configuration in desktop files
The "X-Tumbler Settings" group is searched in each desktop file with the same keys as in `tumbler.rc`, where the default configuration is now. Closes #52.
Diffstat (limited to 'tumblerd')
-rw-r--r--tumblerd/main.c71
-rw-r--r--tumblerd/tumbler.rc16
2 files changed, 38 insertions, 49 deletions
diff --git a/tumblerd/main.c b/tumblerd/main.c
index 58efe81..9289a97 100644
--- a/tumblerd/main.c
+++ b/tumblerd/main.c
@@ -46,8 +46,6 @@
#include <tumblerd/tumbler-registry.h>
#include <tumblerd/tumbler-service.h>
-#include <libxfce4util/libxfce4util.h>
-
static void
@@ -63,26 +61,6 @@ shutdown_tumbler (TumblerLifecycleManager *lifecycle_manager,
-static GSList *
-locations_from_strv (gchar **array)
-{
- GSList *locations = NULL;
- guint n;
- gchar *path;
-
- if (array == NULL)
- return NULL;
-
- for (n = 0; array[n] != NULL; n++)
- {
- path = xfce_expand_variables (array[n], NULL);
- locations = g_slist_prepend (locations, g_file_new_for_commandline_arg (path));
- g_free (path);
- }
-
- return locations;
-}
-
static void
on_dbus_name_lost (GDBusConnection *connection,
const gchar *name,
@@ -172,37 +150,36 @@ main (int argc,
/* add all thumbnailers to the registry */
for (tp = thumbnailers; tp != NULL; tp = tp->next)
{
- /* set settings from rc file */
- type_name = G_OBJECT_TYPE_NAME (tp->data);
- priority = g_key_file_get_integer (rc, type_name, "Priority", NULL);
- file_size = g_key_file_get_int64 (rc, type_name, "MaxFileSize", NULL);
-
- paths = g_key_file_get_string_list (rc, type_name, "Locations", NULL, NULL);
- 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);
+ /* desktop thumbnailers are set up per desktop file */
+ if (g_object_class_find_property (G_OBJECT_GET_CLASS (tp->data), "exec") == NULL)
+ {
+ /* set settings from rc file */
+ type_name = G_OBJECT_TYPE_NAME (tp->data);
+ priority = g_key_file_get_integer (rc, type_name, "Priority", NULL);
+ file_size = g_key_file_get_int64 (rc, type_name, "MaxFileSize", NULL);
+
+ paths = g_key_file_get_string_list (rc, type_name, "Locations", NULL, NULL);
+ locations = tumbler_util_locations_from_strv (paths);
+ g_strfreev (paths);
+
+ paths = g_key_file_get_string_list (rc, type_name, "Excludes", NULL, NULL);
+ excludes = tumbler_util_locations_from_strv (paths);
+ g_strfreev (paths);
+
+ g_object_set (tp->data, "priority", priority, "max-file-size", file_size,
+ "locations", locations, "excludes", excludes, NULL);
+
+ /* cleanup */
+ g_slist_free_full (locations, g_object_unref);
+ g_slist_free_full (excludes, g_object_unref);
+ }
/* ready for usage */
tumbler_registry_add (registry, tp->data);
-
- /* cleanup */
- g_object_unref (tp->data);
- g_slist_free_full (locations, g_object_unref);
- g_slist_free_full (excludes, g_object_unref);
}
/* free the thumbnailer list */
- g_list_free (thumbnailers);
+ g_list_free_full (thumbnailers, g_object_unref);
}
g_key_file_free (rc);
diff --git a/tumblerd/tumbler.rc b/tumblerd/tumbler.rc
index bda93b1..0fdef47 100644
--- a/tumblerd/tumbler.rc
+++ b/tumblerd/tumbler.rc
@@ -122,12 +122,24 @@ MaxFileSize=0
# External Thumbnailers
###
-# Thumbnailers provided by .thumbnailer desktop files.
+# Thumbnailers provided by .thumbnailer desktop files located in $XDG_HOME_DIR/thumbnailers/ and
+# $XDG_DATA_DIRS/thumbnailers/
+#
# They can handle any mime type, depending on the contents of each particular desktop file.
-# Their priority is defined globally and by default lower than that of all internal thumbnailers.
+# Their priority is defined here globally and by default lower than that of all internal
+# thumbnailers.
# These priorities should in any case remain different, otherwise there is no way to know in
# advance which of the internal or external thumbnailer will be prioritized in case of a mime type
# match.
+#
+# In case of several desktop files with the same name in the thumbnailer directories, the one
+# placed in the highest priority directory override all the others.
+#
+# All the properties below can be overridden per desktop file, in the "X-Tumbler Settings" group,
+# for example:
+# [X-Tumbler Settings]
+# Priority=4
+# MaxFileSize=104857600
[DesktopThumbnailer]
Disabled=false
Priority=0