From 08c1fdc719b3e594f68115ce276046d2b4ff355c Mon Sep 17 00:00:00 2001 From: Kamil Burda <123164-kamilburda@users.noreply.gitlab.gnome.org> Date: Tue, 6 Feb 2024 19:58:57 +0100 Subject: [PATCH] plug-ins: Replace guchar PDB parameters with more appropriate types For improved readability, int or boolean types are used in place of guchar for PDB parameters where the parameter description better fits one or the other type. This change affects `plug-in-alienmap2` and `plug-in-maze`. Also, the problem with `guchar` parameters is that they currently cannot be modified via `GimpProcedureConfig` due to the type not being supported. --- app/pdb/plug-in-compat-cmds.c | 84 +++++++++++++++++------------------ pdb/groups/plug_in_compat.pdb | 20 ++++----- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/app/pdb/plug-in-compat-cmds.c b/app/pdb/plug-in-compat-cmds.c index d65bf85717..b12044c8dd 100644 --- a/app/pdb/plug-in-compat-cmds.c +++ b/app/pdb/plug-in-compat-cmds.c @@ -442,10 +442,10 @@ plug_in_alienmap2_invoker (GimpProcedure *procedure, gdouble greenangle; gdouble bluefrequency; gdouble blueangle; - guchar colormodel; - guchar redmode; - guchar greenmode; - guchar bluemode; + gint colormodel; + gboolean redmode; + gboolean greenmode; + gboolean bluemode; drawable = g_value_get_object (gimp_value_array_index (args, 2)); redfrequency = g_value_get_double (gimp_value_array_index (args, 3)); @@ -454,10 +454,10 @@ plug_in_alienmap2_invoker (GimpProcedure *procedure, greenangle = g_value_get_double (gimp_value_array_index (args, 6)); bluefrequency = g_value_get_double (gimp_value_array_index (args, 7)); blueangle = g_value_get_double (gimp_value_array_index (args, 8)); - colormodel = g_value_get_uchar (gimp_value_array_index (args, 9)); - redmode = g_value_get_uchar (gimp_value_array_index (args, 10)); - greenmode = g_value_get_uchar (gimp_value_array_index (args, 11)); - bluemode = g_value_get_uchar (gimp_value_array_index (args, 12)); + colormodel = g_value_get_int (gimp_value_array_index (args, 9)); + redmode = g_value_get_boolean (gimp_value_array_index (args, 10)); + greenmode = g_value_get_boolean (gimp_value_array_index (args, 11)); + bluemode = g_value_get_boolean (gimp_value_array_index (args, 12)); if (success) { @@ -2383,15 +2383,15 @@ plug_in_maze_invoker (GimpProcedure *procedure, GimpDrawable *drawable; gint width; gint height; - guchar tileable; - guchar algorithm; + gboolean tileable; + gint algorithm; gint seed; drawable = g_value_get_object (gimp_value_array_index (args, 2)); width = g_value_get_int (gimp_value_array_index (args, 3)); height = g_value_get_int (gimp_value_array_index (args, 4)); - tileable = g_value_get_uchar (gimp_value_array_index (args, 5)); - algorithm = g_value_get_uchar (gimp_value_array_index (args, 6)); + tileable = g_value_get_boolean (gimp_value_array_index (args, 5)); + algorithm = g_value_get_int (gimp_value_array_index (args, 6)); seed = g_value_get_int (gimp_value_array_index (args, 7)); if (success) @@ -4921,29 +4921,29 @@ register_plug_in_compat_procs (GimpPDB *pdb) 0, 360, 0, GIMP_PARAM_READWRITE)); gimp_procedure_add_argument (procedure, - g_param_spec_uchar ("colormodel", - "colormodel", - "Color model { RGB-MODEL (0), HSL-MODEL (1) }", - 0, 1, 0, - GIMP_PARAM_READWRITE)); + g_param_spec_int ("colormodel", + "colormodel", + "Color model { RGB-MODEL (0), HSL-MODEL (1) }", + 0, 1, 0, + GIMP_PARAM_READWRITE)); gimp_procedure_add_argument (procedure, - g_param_spec_uchar ("redmode", - "redmode", - "Red/hue application mode { TRUE, FALSE }", - 0, 1, 0, - GIMP_PARAM_READWRITE)); + g_param_spec_boolean ("redmode", + "redmode", + "Red/hue application mode", + FALSE, + GIMP_PARAM_READWRITE)); gimp_procedure_add_argument (procedure, - g_param_spec_uchar ("greenmode", - "greenmode", - "Green/saturation application mode { TRUE, FALSE }", - 0, 1, 0, - GIMP_PARAM_READWRITE)); + g_param_spec_boolean ("greenmode", + "greenmode", + "Green/saturation application mode", + FALSE, + GIMP_PARAM_READWRITE)); gimp_procedure_add_argument (procedure, - g_param_spec_uchar ("bluemode", - "bluemode", - "Blue/luminance application mode { TRUE, FALSE }", - 0, 1, 0, - GIMP_PARAM_READWRITE)); + g_param_spec_boolean ("bluemode", + "bluemode", + "Blue/luminance application mode", + FALSE, + GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); @@ -7105,17 +7105,17 @@ register_plug_in_compat_procs (GimpPDB *pdb) 1, 1024, 1, GIMP_PARAM_READWRITE)); gimp_procedure_add_argument (procedure, - g_param_spec_uchar ("tileable", - "tileable", - "Tileable maze? (TRUE or FALSE)", - 0, 1, 0, - GIMP_PARAM_READWRITE)); + g_param_spec_boolean ("tileable", + "tileable", + "Tileable maze?", + FALSE, + GIMP_PARAM_READWRITE)); gimp_procedure_add_argument (procedure, - g_param_spec_uchar ("algorithm", - "algorithm", - "Generation algorithm (0 = DEPTH FIRST, 1 = PRIM'S ALGORITHM)", - 0, 1, 0, - GIMP_PARAM_READWRITE)); + g_param_spec_int ("algorithm", + "algorithm", + "Generation algorithm (0 = DEPTH FIRST, 1 = PRIM'S ALGORITHM)", + 0, 1, 0, + GIMP_PARAM_READWRITE)); gimp_procedure_add_argument (procedure, g_param_spec_int ("seed", "seed", diff --git a/pdb/groups/plug_in_compat.pdb b/pdb/groups/plug_in_compat.pdb index b2b519c835..50219eaab1 100644 --- a/pdb/groups/plug_in_compat.pdb +++ b/pdb/groups/plug_in_compat.pdb @@ -45,14 +45,14 @@ HELP desc => 'Blue/luminance component frequency factor' }, { name => 'blueangle', type => '0 <= float <= 360', desc => 'Blue/luminance component angle factor (0-360)' }, - { name => 'colormodel', type => '0 <= uchar <= 1', + { name => 'colormodel', type => '0 <= int32 <= 1', desc => 'Color model { RGB-MODEL (0), HSL-MODEL (1) }' }, - { name => 'redmode', type => '0 <= uchar <= 1', - desc => 'Red/hue application mode { TRUE, FALSE }' }, - { name => 'greenmode', type => '0 <= uchar <= 1', - desc => 'Green/saturation application mode { TRUE, FALSE }' }, - { name => 'bluemode', type => '0 <= uchar <= 1', - desc => 'Blue/luminance application mode { TRUE, FALSE }' } + { name => 'redmode', type => 'boolean', + desc => 'Red/hue application mode' }, + { name => 'greenmode', type => 'boolean', + desc => 'Green/saturation application mode' }, + { name => 'bluemode', type => 'boolean', + desc => 'Blue/luminance application mode' } ); %invoke = ( @@ -2276,9 +2276,9 @@ HELP desc => 'Width of the passages' }, { name => 'height', type => '1 <= int32 <= 1024', desc => 'Height of the passages' }, - { name => 'tileable', type => '0 <= uchar <= 1', - desc => 'Tileable maze? (TRUE or FALSE)' }, - { name => 'algorithm', type => '0 <= uchar <= 1', + { name => 'tileable', type => 'boolean', + desc => 'Tileable maze?' }, + { name => 'algorithm', type => '0 <= int32 <= 1', desc => 'Generation algorithm (0 = DEPTH FIRST, 1 = PRIM\'S ALGORITHM)' }, { name => 'seed', type => 'int32', desc => 'Random Seed' },