From c9b1ce8fa9004cc0caf930825a01da51d53587c3 Mon Sep 17 00:00:00 2001 From: Jehan Date: Sat, 14 Jan 2023 20:17:57 +0100 Subject: [PATCH] plug-ins: make test-dialog runnable even with no image. It's a test plug-in which doesn't actually need an image to work, so it's annoying that it currently requires one (making testing more cumbersome). Also cleaning up a bit the coding style. --- plug-ins/python/test-dialog.py | 42 +++++++++++++--------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/plug-ins/python/test-dialog.py b/plug-ins/python/test-dialog.py index 76266edce4..313a65711a 100644 --- a/plug-ins/python/test-dialog.py +++ b/plug-ins/python/test-dialog.py @@ -77,11 +77,9 @@ def process_args(brush, font, gradient, palette, pattern): print("pattern id is:", id) Gimp.message(id) - return - def test_dialog(procedure, run_mode, image, n_drawables, drawables, args, data): ''' Just a standard shell for a plugin. @@ -107,13 +105,11 @@ def test_dialog(procedure, run_mode, image, n_drawables, drawables, args, data): pattern = config.get_property('pattern') Gimp.context_push() - image.undo_group_start() process_args(brush, font, gradient, palette, pattern) Gimp.displays_flush() - image.undo_group_end() Gimp.context_pop() config.end_run(Gimp.PDBStatusType.SUCCESS) @@ -121,29 +117,25 @@ def test_dialog(procedure, run_mode, image, n_drawables, drawables, args, data): return procedure.new_return_values(Gimp.PDBStatusType.SUCCESS, GLib.Error()) - class TestDialogPlugin (Gimp.PlugIn): ## Parameters ## - __gproperties__ = { - - } # See comments about this in foggify.py, from which we borrowed - brush = GObject.Property(type =Gimp.Brush, - nick ="Brush", - blurb="Brush") - font = GObject.Property(type =Gimp.Font, - nick ="Font", - blurb="Font") - gradient = GObject.Property(type =Gimp.Gradient, - nick ="Gradient", - blurb="Gradient") - palette = GObject.Property(type =Gimp.Palette, - nick ="Palette", - blurb="Palette") - pattern = GObject.Property(type =Gimp.Pattern, - nick ="Pattern", - blurb="Pattern") + brush = GObject.Property(type = Gimp.Brush, + nick = "_Brush", + blurb = "Brush") + font = GObject.Property(type = Gimp.Font, + nick = "_Font", + blurb = "Font") + gradient = GObject.Property(type = Gimp.Gradient, + nick = "_Gradient", + blurb = "Gradient") + palette = GObject.Property(type = Gimp.Palette, + nick = "_Palette", + blurb = "Palette") + pattern = GObject.Property(type = Gimp.Pattern, + nick = "Pa_ttern", + blurb = "Pattern") # FUTURE all other Gimp classes that have GimpParamSpecs @@ -158,9 +150,7 @@ class TestDialogPlugin (Gimp.PlugIn): procedure = Gimp.ImageProcedure.new(self, name, Gimp.PDBProcType.PLUGIN, test_dialog, None) - procedure.set_image_types("*"); - procedure.set_sensitivity_mask (Gimp.ProcedureSensitivityMask.DRAWABLE | - Gimp.ProcedureSensitivityMask.DRAWABLES) + procedure.set_sensitivity_mask (Gimp.ProcedureSensitivityMask.NO_IMAGE) procedure.set_documentation ("Test dialog", "Test dialog", name)