From 24b9a24a66abcc9214b119d5546b6dc7ebc7cdac Mon Sep 17 00:00:00 2001 From: Tobias Ellinghaus Date: Thu, 21 Apr 2016 11:40:45 +0200 Subject: [PATCH] plug-ins: Only enable darktable loading when it's installed For now we only check if darktable is in PATH, of the right version and supporting the featuers we need (i.e., Lua scripting). We still want to have a way to manually specify the path to the darktable installation in preferences I guess. --- plug-ins/file-darktable/file-darktable.c | 29 ++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/plug-ins/file-darktable/file-darktable.c b/plug-ins/file-darktable/file-darktable.c index d778e35db5..d90a36c6be 100644 --- a/plug-ins/file-darktable/file-darktable.c +++ b/plug-ins/file-darktable/file-darktable.c @@ -111,8 +111,33 @@ query (void) gint i; - // TODO: check if darktable is installed - gboolean have_darktable = TRUE; + /* check if darktable is installed */ + /* TODO: allow setting the location of the executable in preferences */ + gboolean have_darktable = FALSE; + gchar *argv[] = { "darktable", "--version", NULL }; + gchar *darktable_stdout = NULL; + + if (g_spawn_sync (NULL, + argv, + NULL, + G_SPAWN_STDERR_TO_DEV_NULL | + G_SPAWN_SEARCH_PATH, + NULL, + NULL, + &darktable_stdout, + NULL, + NULL, + NULL)) + { + int n, major, minor, patch; + char *lua_support; + n = sscanf (darktable_stdout, "this is darktable %d.%d.%d", &major, &minor, &patch); + lua_support = g_strstr_len (darktable_stdout, -1, "Lua support enabled"); + if (n == 3 && ((major == 1 && minor >= 7) || major >= 2) && lua_support) + have_darktable = TRUE; + } + + g_free (darktable_stdout); if (! have_darktable) return;