mirror of https://github.com/GNOME/gimp.git
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.
This commit is contained in:
parent
fb5e72fbbf
commit
3c56c90763
|
@ -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;
|
||||
before_darktable_4_6 = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (debug_prints)
|
||||
|
@ -202,6 +208,7 @@ darktable_init_procedures (GimpPlugIn *plug_in)
|
|||
"Lua support enabled"))
|
||||
{
|
||||
have_darktable = TRUE;
|
||||
before_darktable_4_6 = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -435,6 +442,14 @@ load_image (GFile *file,
|
|||
REGISTRY_KEY_BASE,
|
||||
&search_path);
|
||||
gchar *argv[] =
|
||||
{
|
||||
exec_path,
|
||||
"--gimp",
|
||||
"file",
|
||||
(gchar *) g_file_peek_path (file),
|
||||
NULL
|
||||
};
|
||||
gchar *argv_pre_4_6[] =
|
||||
{
|
||||
exec_path,
|
||||
"--library", ":memory:",
|
||||
|
@ -468,6 +483,8 @@ load_image (GFile *file,
|
|||
g_strfreev (environ_) ;
|
||||
}
|
||||
|
||||
if (! before_darktable_4_6)
|
||||
{
|
||||
if (g_spawn_sync (NULL,
|
||||
argv,
|
||||
NULL,
|
||||
|
@ -480,9 +497,51 @@ load_image (GFile *file,
|
|||
&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], "<<gimp") != NULL &&
|
||||
response[i + 1] != NULL)
|
||||
{
|
||||
darktable_file = g_file_new_for_path (response[i + 1]);
|
||||
image = gimp_file_load (run_mode, darktable_file);
|
||||
|
||||
g_object_unref (darktable_file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_strfreev (response);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_spawn_sync (NULL,
|
||||
argv_pre_4_6,
|
||||
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))
|
||||
{
|
||||
image = gimp_file_load (run_mode, file_out);
|
||||
}
|
||||
}
|
||||
|
||||
if (debug_prints)
|
||||
{
|
||||
|
@ -532,6 +591,15 @@ load_thumbnail_image (GFile *file,
|
|||
REGISTRY_KEY_BASE,
|
||||
&search_path);
|
||||
gchar *argv[] =
|
||||
{
|
||||
exec_path,
|
||||
"--gimp",
|
||||
"thumb",
|
||||
(gchar *) g_file_peek_path (file),
|
||||
size,
|
||||
NULL
|
||||
};
|
||||
gchar *argv_pre_4_6[] =
|
||||
{
|
||||
exec_path,
|
||||
(gchar *) g_file_peek_path (file),
|
||||
|
@ -554,6 +622,8 @@ load_thumbnail_image (GFile *file,
|
|||
|
||||
*width = *height = 0;
|
||||
|
||||
if (! before_darktable_4_6)
|
||||
{
|
||||
if (g_spawn_sync (NULL,
|
||||
argv,
|
||||
NULL,
|
||||
|
@ -566,7 +636,50 @@ load_thumbnail_image (GFile *file,
|
|||
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], "<<gimp") != NULL &&
|
||||
response[i + 2] != NULL)
|
||||
{
|
||||
darktable_file = g_file_new_for_path (response[i + 1]);
|
||||
image = gimp_file_load (GIMP_RUN_NONINTERACTIVE,
|
||||
darktable_file);
|
||||
sscanf (response[i + 2], "%d %d", width, height);
|
||||
|
||||
g_object_unref (darktable_file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_strfreev (response);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_spawn_sync (NULL,
|
||||
argv_pre_4_6,
|
||||
NULL,
|
||||
G_SPAWN_STDERR_TO_DEV_NULL |
|
||||
(search_path ? G_SPAWN_SEARCH_PATH : 0),
|
||||
NULL,
|
||||
NULL,
|
||||
&darktable_stdout,
|
||||
NULL,
|
||||
NULL,
|
||||
error))
|
||||
{
|
||||
gimp_progress_update (0.5);
|
||||
|
||||
image = gimp_file_load (GIMP_RUN_NONINTERACTIVE, file_out);
|
||||
if (image)
|
||||
{
|
||||
|
@ -580,6 +693,7 @@ load_thumbnail_image (GFile *file,
|
|||
sscanf (start_of_size, "[dt4gimp] %d %d", width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gimp_progress_update (1.0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue