From 3c56c907636ecdd5fea2e9696809610678a647d5 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Sun, 3 Nov 2024 16:21:16 +0000 Subject: [PATCH] plug-ins: Use more of the GIMP-specific darktable API In a28b1bad, we ported the darktable detection code to use their new API for darktable 4.6.1. However, the image and thumbnail loading code was not ported as it still worked fine in that version. This patch continues the port by making the the image and thumbnail functions use the new API if darktable 4.6+ is installed. --- plug-ins/file-raw/file-darktable.c | 192 +++++++++++++++++++++++------ 1 file changed, 153 insertions(+), 39 deletions(-) diff --git a/plug-ins/file-raw/file-darktable.c b/plug-ins/file-raw/file-darktable.c index 0c091dbfe5..f585e9c9b6 100644 --- a/plug-ins/file-raw/file-darktable.c +++ b/plug-ins/file-raw/file-darktable.c @@ -87,6 +87,9 @@ GIMP_MAIN (DARKTABLE_TYPE) DEFINE_STD_SET_I18N +static gboolean before_darktable_4_6 = FALSE; + + static void darktable_class_init (DarktableClass *klass) { @@ -145,7 +148,10 @@ darktable_init_procedures (GimpPlugIn *plug_in) if (! error) { if (! (darktable_stderr && *darktable_stderr)) - have_darktable = TRUE; + { + have_darktable = TRUE; + before_darktable_4_6 = FALSE; + } } } else if (debug_prints) @@ -201,7 +207,8 @@ darktable_init_procedures (GimpPlugIn *plug_in) if (g_strstr_len (darktable_stdout, -1, "Lua support enabled")) { - have_darktable = TRUE; + have_darktable = TRUE; + before_darktable_4_6 = TRUE; } } } @@ -434,7 +441,15 @@ load_image (GFile *file, "org.darktable", REGISTRY_KEY_BASE, &search_path); - gchar *argv[] = + gchar *argv[] = + { + exec_path, + "--gimp", + "file", + (gchar *) g_file_peek_path (file), + NULL + }; + gchar *argv_pre_4_6[] = { exec_path, "--library", ":memory:", @@ -468,20 +483,64 @@ load_image (GFile *file, g_strfreev (environ_) ; } - if (g_spawn_sync (NULL, - argv, - NULL, - /*G_SPAWN_STDOUT_TO_DEV_NULL |*/ - /*G_SPAWN_STDERR_TO_DEV_NULL |*/ - (search_path ? G_SPAWN_SEARCH_PATH : 0), - NULL, - NULL, - &darktable_stdout, - &darktable_stderr, - NULL, - error)) + if (! before_darktable_4_6) { - image = gimp_file_load (run_mode, file_out); + if (g_spawn_sync (NULL, + argv, + NULL, + /*G_SPAWN_STDOUT_TO_DEV_NULL |*/ + /*G_SPAWN_STDERR_TO_DEV_NULL |*/ + (search_path ? G_SPAWN_SEARCH_PATH : 0), + NULL, + NULL, + &darktable_stdout, + &darktable_stderr, + NULL, + error)) + { + gchar **response = NULL; + + gimp_progress_update (0.5); + + response = g_strsplit (darktable_stdout, "\n", 0); + + if (response != NULL) + { + GFile *darktable_file; + + for (gint i = 0; response[i] != NULL; i++) + { + if (g_strrstr (response[i], "<