plug-ins: Fix Foggify color property

Since the color space invasion, GimpRGB
properties do not create widgets anymore.
For Python plug-ins, we need to add
GeglColor properties as GObjects with
GeglColor value types as a workaround.
This patch does this and updates the
Foggify plug-in with the new datatype.
This commit is contained in:
Alx Sa 2024-02-25 15:18:05 +00:00
parent 705fbebc55
commit 7e6dc23ac1
3 changed files with 27 additions and 5 deletions

View File

@ -563,6 +563,10 @@ _gimp_param_spec_to_gp_param_def (GParamSpec *pspec,
{
type_name = "GimpParamPattern";
}
else if (value_type == GEGL_TYPE_COLOR)
{
type_name = "GeglParamColor";
}
if (type_name)
{

View File

@ -288,6 +288,20 @@ gimp_config_param_spec_duplicate (GParamSpec *pspec)
color = g_value_dup_object (&value);
g_value_unset (&value);
copy = gegl_param_spec_color (name, nick, blurb,
/*TRUE,*/
color, flags);
g_clear_object (&color);
}
else if (G_IS_PARAM_SPEC_OBJECT (pspec) &&
G_PARAM_SPEC_VALUE_TYPE (pspec) == GEGL_TYPE_COLOR)
{
GValue *value;
GeglColor *color;
value = (GValue *) g_param_spec_get_default_value (pspec);
color = g_value_dup_object (value);
copy = gegl_param_spec_color (name, nick, blurb,
/*TRUE,*/
color, flags);

View File

@ -19,6 +19,8 @@ gi.require_version('Gimp', '3.0')
from gi.repository import Gimp
gi.require_version('GimpUi', '3.0')
from gi.repository import GimpUi
gi.require_version('Gegl', '0.4')
from gi.repository import Gegl
from gi.repository import GObject
from gi.repository import GLib
from gi.repository import Gio
@ -28,11 +30,12 @@ import sys
def N_(message): return message
def _(message): return GLib.dgettext(None, message)
_color = Gimp.RGB()
_color.set_uchar(240, 0, 0)
_color.set_alpha(1.0)
def foggify(procedure, run_mode, image, n_drawables, drawables, config, data):
Gegl.init(None)
_color = Gegl.Color.new("black")
_color.set_rgba(0.94, 0, 0, 1.0)
# Work around not being able to set default color by only setting it
# when color in our config is None. This won't help when resetting to
# factory default. This also fixes a critical when running without
@ -43,6 +46,7 @@ def foggify(procedure, run_mode, image, n_drawables, drawables, config, data):
if run_mode == Gimp.RunMode.INTERACTIVE:
GimpUi.init('python-fu-foggify')
dialog = GimpUi.ProcedureDialog(procedure=procedure, config=config)
dialog.fill(None)
if not dialog.run():
@ -123,7 +127,7 @@ class Foggify (Gimp.PlugIn):
# supposed to allow setting a default, except it doesn't seem to
# work. I still leave it this way for now until we figure this out
# as it should be the better syntax.
color = GObject.Property(type =Gimp.RGB, default=_color,
color = GObject.Property(type =Gegl.Color, default=None,
nick =_("_Fog color"),
blurb=_("Fog color"))