plug-ins: improve default color handling of foggify

- To set color values in the 0-255 range we now have to use set_uchar.
- Because setting a default color is not working, the color in config
  could be None, which if the color wasn't changed caused a CRITICAL.

Let's check for None and if that is the case then manually set our
default color.
This commit is contained in:
Jacob Boerema 2024-01-08 18:11:20 -05:00
parent c44819f58b
commit 45ea994e89
1 changed files with 11 additions and 3 deletions

View File

@ -28,8 +28,19 @@ 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):
# 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
# changing the color away from None.
color = config.get_property('color')
if color is None:
config.set_property('color', _color)
if run_mode == Gimp.RunMode.INTERACTIVE:
GimpUi.init('python-fu-foggify')
dialog = GimpUi.ProcedureDialog(procedure=procedure, config=config)
@ -89,9 +100,6 @@ def foggify(procedure, run_mode, image, n_drawables, drawables, config, data):
return procedure.new_return_values(Gimp.PDBStatusType.SUCCESS, GLib.Error())
_color = Gimp.RGB()
_color.set(240.0, 0, 0)
class Foggify (Gimp.PlugIn):
## Parameters ##
__gproperties__ = {