1
1
mirror of https://gitlab.gnome.org/GNOME/gimp.git synced 2025-10-06 13:42:40 +02:00

2.99 ScriptFu: #10958 Missing color widgets in v3 dialogs

Since PDB now traffics in GeglColor instead of GimpRGB.

Change GimpParamSpecRGB to GeglParamSpecColor when declaring args to procedure.
Declared default is temporarily "black".

Change conversion of gvalue to scheme representation, now from GeglColor.

Incidental change to interpreter to init gegl early,
since now needed during registration phase.
This commit is contained in:
bootchk
2024-03-01 09:27:21 -05:00
parent b4110ec3b2
commit c0ca0b74a9
3 changed files with 34 additions and 17 deletions

View File

@@ -24,6 +24,7 @@
#include "config.h" #include "config.h"
#include <glib.h> #include <glib.h>
#include <libgimp/gimp.h> #include <libgimp/gimp.h>
#include <libgimp/gimpui.h> /* gimp_ui_init */
#include "libscriptfu/script-fu-intl.h" #include "libscriptfu/script-fu-intl.h"
@@ -102,7 +103,8 @@ script_fu_interpreter_class_init (ScriptFuInterpreterClass *klass)
static void static void
script_fu_interpreter_init (ScriptFuInterpreter *script_fu) script_fu_interpreter_init (ScriptFuInterpreter *script_fu)
{ {
/* Nothing to do. */ /* Init ui, gegl, babl. Need gegl color in registration phase of plugin. */
gimp_ui_init ("script-fu-interpreter");
} }

View File

@@ -282,16 +282,14 @@ script_fu_arg_get_param_spec (SFArg *arg,
break; break;
case SF_COLOR: case SF_COLOR:
/* Pass address of default color i.e. instance of GimpRGB. /* Setting the default by name.
* Color is owned by ScriptFu and exists for lifetime of SF process. *
* FIXME: use the default declared by name by script author.
*/ */
pspec = gimp_param_spec_rgb (name, /* G_PARAM_READWRITE instead of GIMP_PARAM_READWRITE, not equal. */
nick, pspec = gegl_param_spec_color_from_string (name, nick, arg->label,
arg->label, "black", /* default */
TRUE, /* is alpha relevant */ G_PARAM_READWRITE);
&arg->default_value.sfa_color,
G_PARAM_READWRITE);
/* FUTURE: Default not now appear in PDB browser, but appears in widgets? */
break; break;
case SF_TOGGLE: case SF_TOGGLE:
@@ -464,13 +462,26 @@ script_fu_arg_append_repr_from_gvalue (SFArg *arg,
case SF_COLOR: case SF_COLOR:
{ {
GimpRGB color; /* Since v3 PDB procedures traffic in GeglColor.
guchar r, g, b; * But ScriptFu still represents as RGB uint8 in a list.
*/
GeglColor *color;
gimp_value_get_rgb (gvalue, &color); color = g_value_get_object (gvalue);
gimp_rgb_get_uchar (&color, &r, &g, &b); if (color)
g_string_append_printf (result_string, "'(%d %d %d)", {
(gint) r, (gint) g, (gint) b); guchar rgb[3] = { 0 };
gegl_color_get_pixel (color, babl_format ("R'G'B' u8"), rgb);
g_string_append_printf (result_string, "'(%d %d %d)",
(gint) rgb[0], (gint) rgb[1], (gint) rgb[2]);
}
else
{
gchar *msg = "Invalid color object in gvalue.";
g_warning ("%s", msg);
g_string_append_printf (result_string, "\"%s\"", msg);
}
} }
break; break;

View File

@@ -50,8 +50,12 @@ typedef struct
gint history; gint history;
} SFEnum; } SFEnum;
/* Resources represented by proxy ID. */
typedef gint32 SFResourceType; typedef gint32 SFResourceType;
/* Color represented by GeglColor */
typedef GeglColor SFColorType;
typedef union typedef union
{ {
gint32 sfa_image; gint32 sfa_image;
@@ -60,7 +64,7 @@ typedef union
gint32 sfa_channel; gint32 sfa_channel;
gint32 sfa_vectors; gint32 sfa_vectors;
gint32 sfa_display; gint32 sfa_display;
GimpRGB sfa_color; SFColorType sfa_color;
gint32 sfa_toggle; gint32 sfa_toggle;
gchar *sfa_value; gchar *sfa_value;
SFAdjustment sfa_adjustment; SFAdjustment sfa_adjustment;