summaryrefslogtreecommitdiff
path: root/tumbler/tumbler-util.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-util.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-util.c')
-rw-r--r--tumbler/tumbler-util.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/tumbler/tumbler-util.c b/tumbler/tumbler-util.c
index bb36be4..9d656d5 100644
--- a/tumbler/tumbler-util.c
+++ b/tumbler/tumbler-util.c
@@ -75,3 +75,58 @@ tumbler_util_get_supported_uri_schemes (void)
return uri_schemes;
}
+
+
+static gchar *
+tumbler_util_get_settings_filename (void)
+{
+ gchar *path;
+ const gchar filename[] = "tumbler" G_DIR_SEPARATOR_S "tumbler.rc";
+ const gchar * const *dirs;
+ guint n;
+
+ /* check user directory */
+ path = g_build_filename (g_get_user_config_dir (), filename, NULL);
+ if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
+ return path;
+ g_free (path);
+
+ dirs = g_get_system_config_dirs ();
+ if (G_UNLIKELY (dirs == NULL))
+ return FALSE;
+
+ /* look in system config dirs */
+ for (n = 0; dirs[n] != NULL; n++)
+ {
+ path = g_build_filename (dirs[n], filename, NULL);
+ if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
+ return path;
+ g_free (path);
+ }
+
+ return NULL;
+}
+
+
+
+GKeyFile *
+tumbler_util_get_settings (void)
+{
+ GKeyFile *settings;
+ GError *err = NULL;
+ gchar *filename;
+
+ settings = g_key_file_new ();
+ filename = tumbler_util_get_settings_filename ();
+
+ if (filename != NULL
+ && !g_key_file_load_from_file (settings, filename, 0, &err))
+ {
+ g_critical ("Unable to load settings from \"%s\": %s", filename, err->message);
+ g_error_free (err);
+ }
+
+ g_free (filename);
+
+ return settings;
+}