app, libgimp, pdb, plug-ins: add ability to default to context for all resource args.

Also fixes the passing of the resource param definitions through PDB.
There was some weird assumption, with a comment, in commit 73733335c8
that this was unneeded, which meant that we were not able to properly
recreate the right param spec over the wire.
This commit is contained in:
Jehan 2024-09-06 13:38:43 +02:00
parent 6f8231eee6
commit 75a50ce87b
34 changed files with 452 additions and 148 deletions

View File

@ -24,8 +24,11 @@
#include "core-types.h"
#include "gimpcoreapp.h"
#include "gimp.h"
#include "gimpbrush.h"
#include "gimpcontext.h"
#include "gimpdisplay.h"
#include "gimpgradient.h"
#include "gimpgrouplayer.h"

View File

@ -794,6 +794,7 @@ register_brush_procs (GimpPDB *pdb)
"The brush",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -825,6 +826,7 @@ register_brush_procs (GimpPDB *pdb)
"The brush",
TRUE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -849,6 +851,7 @@ register_brush_procs (GimpPDB *pdb)
"The brush",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_boolean ("generated",
@ -879,6 +882,7 @@ register_brush_procs (GimpPDB *pdb)
"The brush",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_int ("width",
@ -927,6 +931,7 @@ register_brush_procs (GimpPDB *pdb)
"The brush",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_int ("width",
@ -987,6 +992,7 @@ register_brush_procs (GimpPDB *pdb)
"The brush",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_int ("spacing",
@ -1017,6 +1023,7 @@ register_brush_procs (GimpPDB *pdb)
"The brush",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("spacing",
@ -1047,6 +1054,7 @@ register_brush_procs (GimpPDB *pdb)
"The brush",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_enum ("shape",
@ -1078,6 +1086,7 @@ register_brush_procs (GimpPDB *pdb)
"The brush",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("shape-in",
@ -1116,6 +1125,7 @@ register_brush_procs (GimpPDB *pdb)
"The brush",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_double ("radius",
@ -1146,6 +1156,7 @@ register_brush_procs (GimpPDB *pdb)
"The brush",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("radius-in",
@ -1182,6 +1193,7 @@ register_brush_procs (GimpPDB *pdb)
"The brush",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_int ("spikes",
@ -1212,6 +1224,7 @@ register_brush_procs (GimpPDB *pdb)
"The brush",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("spikes-in",
@ -1248,6 +1261,7 @@ register_brush_procs (GimpPDB *pdb)
"The brush",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_double ("hardness",
@ -1278,6 +1292,7 @@ register_brush_procs (GimpPDB *pdb)
"The brush",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("hardness-in",
@ -1314,6 +1329,7 @@ register_brush_procs (GimpPDB *pdb)
"The brush",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_double ("aspect-ratio",
@ -1344,6 +1360,7 @@ register_brush_procs (GimpPDB *pdb)
"The brush",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("aspect-ratio-in",
@ -1380,6 +1397,7 @@ register_brush_procs (GimpPDB *pdb)
"The brush",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_double ("angle",
@ -1410,6 +1428,7 @@ register_brush_procs (GimpPDB *pdb)
"The brush",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("angle-in",

View File

@ -175,6 +175,7 @@ register_brush_select_procs (GimpPDB *pdb)
"The brush to set as the initial choice",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_boxed ("parent-window",
@ -236,6 +237,7 @@ register_brush_select_procs (GimpPDB *pdb)
"The brush to set as selected",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);

View File

@ -3844,6 +3844,7 @@ register_context_procs (GimpPDB *pdb)
"The active brush",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -3868,6 +3869,7 @@ register_context_procs (GimpPDB *pdb)
"The brush",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -4362,6 +4364,7 @@ register_context_procs (GimpPDB *pdb)
"The active pattern",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -4386,6 +4389,7 @@ register_context_procs (GimpPDB *pdb)
"The pattern",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -4410,6 +4414,7 @@ register_context_procs (GimpPDB *pdb)
"The active gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -4434,6 +4439,7 @@ register_context_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -4668,6 +4674,7 @@ register_context_procs (GimpPDB *pdb)
"The active palette",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -4692,6 +4699,7 @@ register_context_procs (GimpPDB *pdb)
"The palette",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -4716,6 +4724,7 @@ register_context_procs (GimpPDB *pdb)
"The active font",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -4740,6 +4749,7 @@ register_context_procs (GimpPDB *pdb)
"The font",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -5786,6 +5796,7 @@ register_context_procs (GimpPDB *pdb)
GIMP_TYPE_RESOURCE,
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);

View File

@ -175,6 +175,7 @@ register_font_procs (GimpPDB *pdb)
"GimpFont object",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_string ("lookup-name",
@ -215,6 +216,7 @@ register_font_procs (GimpPDB *pdb)
"The font",
TRUE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);

View File

@ -177,6 +177,7 @@ register_font_select_procs (GimpPDB *pdb)
"The name of the initial font choice.",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_boxed ("parent-window",
@ -238,6 +239,7 @@ register_font_select_procs (GimpPDB *pdb)
"The font to set as selected",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);

View File

@ -1285,6 +1285,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -1316,6 +1317,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
TRUE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -1340,6 +1342,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_int ("num-segments",
@ -1370,6 +1373,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("num-samples",
@ -1417,6 +1421,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("num-samples",
@ -1470,6 +1475,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("segment",
@ -1508,6 +1514,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("segment",
@ -1546,6 +1553,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("segment",
@ -1584,6 +1592,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("segment",
@ -1622,6 +1631,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("segment",
@ -1659,6 +1669,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("segment",
@ -1702,6 +1713,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("segment",
@ -1739,6 +1751,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("segment",
@ -1782,6 +1795,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("segment",
@ -1819,6 +1833,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("segment",
@ -1862,6 +1877,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("segment",
@ -1900,6 +1916,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("segment",
@ -1938,6 +1955,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("start-segment",
@ -1982,6 +2000,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("start-segment",
@ -2026,6 +2045,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("start-segment",
@ -2063,6 +2083,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("start-segment",
@ -2106,6 +2127,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("start-segment",
@ -2143,6 +2165,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("start-segment",
@ -2186,6 +2209,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("start-segment",
@ -2223,6 +2247,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("start-segment",
@ -2260,6 +2285,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("start-segment",
@ -2297,6 +2323,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("start-segment",
@ -2334,6 +2361,7 @@ register_gradient_procs (GimpPDB *pdb)
"The gradient",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("start-segment",

View File

@ -181,6 +181,7 @@ register_gradient_select_procs (GimpPDB *pdb)
"The initial gradient choice",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_boxed ("parent-window",
@ -242,6 +243,7 @@ register_gradient_select_procs (GimpPDB *pdb)
"The gradient to set as selected",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);

View File

@ -4332,6 +4332,7 @@ register_image_procs (GimpPDB *pdb)
"The image's colormap.",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);

View File

@ -485,6 +485,7 @@ register_palette_procs (GimpPDB *pdb)
"The palette",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -516,6 +517,7 @@ register_palette_procs (GimpPDB *pdb)
"The palette",
TRUE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -540,6 +542,7 @@ register_palette_procs (GimpPDB *pdb)
"The palette",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_int ("num-colors",
@ -570,6 +573,7 @@ register_palette_procs (GimpPDB *pdb)
"The palette",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_boxed ("colors",
@ -600,6 +604,7 @@ register_palette_procs (GimpPDB *pdb)
"The palette",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_int ("num-columns",
@ -630,6 +635,7 @@ register_palette_procs (GimpPDB *pdb)
"The palette",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("columns",
@ -660,6 +666,7 @@ register_palette_procs (GimpPDB *pdb)
"The palette",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("entry-name",
@ -705,6 +712,7 @@ register_palette_procs (GimpPDB *pdb)
"The palette",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("entry-num",
@ -735,6 +743,7 @@ register_palette_procs (GimpPDB *pdb)
"The palette",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("entry-num",
@ -772,6 +781,7 @@ register_palette_procs (GimpPDB *pdb)
"The palette",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("entry-num",
@ -809,6 +819,7 @@ register_palette_procs (GimpPDB *pdb)
"The palette",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("entry-num",
@ -846,6 +857,7 @@ register_palette_procs (GimpPDB *pdb)
"The palette",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("entry-num",

View File

@ -175,6 +175,7 @@ register_palette_select_procs (GimpPDB *pdb)
"The palette to set as the initial choice.",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_boxed ("parent-window",
@ -236,6 +237,7 @@ register_palette_select_procs (GimpPDB *pdb)
"The palette to set as selected",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);

View File

@ -200,6 +200,7 @@ register_pattern_procs (GimpPDB *pdb)
"The pattern",
TRUE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -224,6 +225,7 @@ register_pattern_procs (GimpPDB *pdb)
"The pattern",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_int ("width",
@ -266,6 +268,7 @@ register_pattern_procs (GimpPDB *pdb)
"The pattern",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_int ("width",

View File

@ -175,6 +175,7 @@ register_pattern_select_procs (GimpPDB *pdb)
"The pattern to set as the initial choice",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_boxed ("parent-window",
@ -236,6 +237,7 @@ register_pattern_select_procs (GimpPDB *pdb)
"The pattern to set as selected",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);

View File

@ -545,6 +545,7 @@ register_resource_procs (GimpPDB *pdb)
GIMP_TYPE_RESOURCE,
TRUE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -597,6 +598,7 @@ register_resource_procs (GimpPDB *pdb)
GIMP_TYPE_RESOURCE,
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -798,6 +800,7 @@ register_resource_procs (GimpPDB *pdb)
GIMP_TYPE_RESOURCE,
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_string ("name",
@ -832,6 +835,7 @@ register_resource_procs (GimpPDB *pdb)
GIMP_TYPE_RESOURCE,
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_boolean ("is-internal",
@ -877,6 +881,7 @@ register_resource_procs (GimpPDB *pdb)
GIMP_TYPE_RESOURCE,
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_boolean ("editable",
@ -908,6 +913,7 @@ register_resource_procs (GimpPDB *pdb)
GIMP_TYPE_RESOURCE,
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_resource ("resource-copy",
@ -916,6 +922,7 @@ register_resource_procs (GimpPDB *pdb)
GIMP_TYPE_RESOURCE,
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -941,6 +948,7 @@ register_resource_procs (GimpPDB *pdb)
GIMP_TYPE_RESOURCE,
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("new-name",
@ -973,6 +981,7 @@ register_resource_procs (GimpPDB *pdb)
GIMP_TYPE_RESOURCE,
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);

View File

@ -1029,6 +1029,7 @@ register_text_layer_procs (GimpPDB *pdb)
"The font to write the text with",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("size",
@ -1200,6 +1201,7 @@ register_text_layer_procs (GimpPDB *pdb)
"The font which is used in the specified text layer.",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -1230,6 +1232,7 @@ register_text_layer_procs (GimpPDB *pdb)
"The new font to use",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);

View File

@ -217,6 +217,7 @@ register_text_tool_procs (GimpPDB *pdb)
"The font",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_layer ("text-layer",
@ -262,6 +263,7 @@ register_text_tool_procs (GimpPDB *pdb)
"The name of the font",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_int ("width",

View File

@ -1007,6 +1007,20 @@ plug_in_proc_arg_deserialize (GScanner *scanner,
goto error;
}
break;
case GP_PARAM_DEF_TYPE_RESOURCE:
if (! gimp_scanner_parse_int (scanner,
&param_def.meta.m_resource.none_ok) ||
! gimp_scanner_parse_int (scanner,
&param_def.meta.m_resource.default_to_context) ||
! gimp_scanner_parse_int (scanner,
&param_def.meta.m_resource.default_resource_id))
{
token = G_TOKEN_INT;
goto error;
}
break;
break;
}
if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN))
@ -1071,6 +1085,9 @@ plug_in_proc_arg_deserialize (GScanner *scanner,
case GP_PARAM_DEF_TYPE_EXPORT_OPTIONS:
break;
case GP_PARAM_DEF_TYPE_RESOURCE:
break;
}
return token;
@ -1257,6 +1274,13 @@ plug_in_rc_write_proc_arg (GimpConfigWriter *writer,
gimp_config_writer_printf (writer, "%d",
param_def.meta.m_export_options.capabilities);
break;
case GP_PARAM_DEF_TYPE_RESOURCE:
gimp_config_writer_printf (writer, "%d %d %d",
param_def.meta.m_resource.none_ok,
param_def.meta.m_resource.default_to_context,
param_def.meta.m_resource.default_resource_id);
break;
}
gimp_config_writer_close (writer);

View File

@ -25,6 +25,18 @@
* app/plug-in/gimpgpparams.c
*/
static GimpImage * get_image_by_id (gpointer gimp,
gint id);
static GimpItem * get_item_by_id (gpointer gimp,
gint id);
static GimpDisplay * get_display_by_id (gpointer gimp,
gint id);
static GObject * get_resource_by_id (gint id);
static gint get_resource_id (GObject *resource);
static GimpUnit * get_unit_by_id (gpointer gimp,
gint id);
GParamSpec *
_gimp_gp_param_def_to_param_spec (const GPParamDef *param_def)
{
@ -262,34 +274,6 @@ _gimp_gp_param_def_to_param_spec (const GPParamDef *param_def)
return gimp_param_spec_path (name, nick, blurb,
param_def->meta.m_id.none_ok,
flags);
/* When send GimpParamResource or subclass over wire, pass NULL name_of_default.
* Neither core nor libgimp seems to use it.
* Args to PDB procedures are not sent as GimpParamResource crossing wire.
*/
if (! strcmp (param_def->type_name, "GimpParamResource"))
return gimp_param_spec_resource (name, nick, blurb, GIMP_TYPE_RESOURCE,
param_def->meta.m_id.none_ok, NULL, flags);
if (! strcmp (param_def->type_name, "GimpParamBrush"))
return gimp_param_spec_brush (name, nick, blurb,
param_def->meta.m_id.none_ok, NULL, flags);
if (! strcmp (param_def->type_name, "GimpParamFont"))
return gimp_param_spec_font (name, nick, blurb,
param_def->meta.m_id.none_ok, NULL, flags);
if (! strcmp (param_def->type_name, "GimpParamGradient"))
return gimp_param_spec_gradient (name, nick, blurb,
param_def->meta.m_id.none_ok, NULL, flags);
if (! strcmp (param_def->type_name, "GimpParamPalette"))
return gimp_param_spec_palette (name, nick, blurb,
param_def->meta.m_id.none_ok, NULL, flags);
if (! strcmp (param_def->type_name, "GimpParamPattern"))
return gimp_param_spec_pattern (name, nick, blurb,
param_def->meta.m_id.none_ok, NULL, flags);
break;
case GP_PARAM_DEF_TYPE_ID_ARRAY:
@ -297,6 +281,7 @@ _gimp_gp_param_def_to_param_spec (const GPParamDef *param_def)
return gimp_param_spec_object_array (name, nick, blurb,
g_type_from_name (param_def->meta.m_id_array.type_name),
flags);
break;
case GP_PARAM_DEF_TYPE_EXPORT_OPTIONS:
if (! strcmp (param_def->type_name, "GimpParamExportOptions"))
@ -306,6 +291,18 @@ _gimp_gp_param_def_to_param_spec (const GPParamDef *param_def)
flags);
}
break;
case GP_PARAM_DEF_TYPE_RESOURCE:
if (g_type_from_name (param_def->type_name) != 0 &&
g_type_is_a (g_type_from_name (param_def->type_name), GIMP_TYPE_PARAM_RESOURCE))
return gimp_param_spec_resource (name, nick, blurb, g_type_from_name (param_def->type_name),
param_def->meta.m_resource.none_ok,
param_def->meta.m_resource.default_to_context ?
NULL : GIMP_RESOURCE (get_resource_by_id (param_def->meta.m_resource.default_resource_id)),
param_def->meta.m_resource.default_to_context,
flags);
break;
}
g_warning ("%s: GParamSpec type unsupported '%s'", G_STRFUNC,
@ -497,11 +494,20 @@ _gimp_param_spec_to_gp_param_def (GParamSpec *pspec,
}
else if (GIMP_IS_PARAM_SPEC_RESOURCE (pspec))
{
GimpParamSpecResource *rspec = GIMP_PARAM_SPEC_RESOURCE (pspec);
GimpParamSpecResource *rspec = GIMP_PARAM_SPEC_RESOURCE (pspec);
GObject *default_value = NULL;
param_def->param_def_type = GP_PARAM_DEF_TYPE_ID;
param_def->param_def_type = GP_PARAM_DEF_TYPE_RESOURCE;
param_def->meta.m_id.none_ok = rspec->none_ok;
if (gimp_param_spec_object_has_default (pspec))
default_value = gimp_param_spec_object_get_default (pspec);
param_def->meta.m_resource.none_ok = rspec->none_ok;
param_def->meta.m_resource.default_to_context = rspec->default_to_context;
if (default_value != NULL && ! rspec->default_to_context)
param_def->meta.m_resource.default_resource_id = get_resource_id (default_value);
else
param_def->meta.m_resource.default_resource_id = 0;
}
else if (GIMP_IS_PARAM_SPEC_OBJECT_ARRAY (pspec))
{

View File

@ -989,11 +989,12 @@ gimp_param_spec_display (const gchar *name,
* GIMP_TYPE_PARAM_RESOURCE
*/
static void gimp_param_resource_class_init (GimpParamSpecObjectClass *klass);
static void gimp_param_resource_init (GParamSpec *pspec);
static GParamSpec * gimp_param_resource_duplicate (GParamSpec *pspec);
static gboolean gimp_param_resource_validate (GParamSpec *pspec,
GValue *value);
static void gimp_param_resource_class_init (GimpParamSpecObjectClass *klass);
static void gimp_param_resource_init (GParamSpec *pspec);
static GParamSpec * gimp_param_resource_duplicate (GParamSpec *pspec);
static GObject * gimp_param_resource_get_default (GParamSpec *pspec);
static gboolean gimp_param_resource_validate (GParamSpec *pspec,
GValue *value);
GType
@ -1026,6 +1027,7 @@ gimp_param_resource_class_init (GimpParamSpecObjectClass *klass)
GParamSpecClass *pclass = G_PARAM_SPEC_CLASS (klass);
klass->duplicate = gimp_param_resource_duplicate;
klass->get_default = gimp_param_resource_get_default;
pclass->value_type = GIMP_TYPE_RESOURCE;
pclass->value_validate = gimp_param_resource_validate;
@ -1043,20 +1045,65 @@ static GParamSpec *
gimp_param_resource_duplicate (GParamSpec *pspec)
{
GParamSpec *duplicate;
GObject *default_value = NULL;
g_return_val_if_fail (GIMP_IS_PARAM_SPEC_RESOURCE (pspec), NULL);
if (gimp_param_spec_object_has_default (pspec) &&
! GIMP_PARAM_SPEC_RESOURCE (pspec)->default_to_context)
default_value = gimp_param_spec_object_get_default (pspec);
duplicate = gimp_param_spec_resource (pspec->name,
g_param_spec_get_nick (pspec),
g_param_spec_get_blurb (pspec),
pspec->value_type,
GIMP_PARAM_SPEC_RESOURCE (pspec)->none_ok,
GIMP_RESOURCE (gimp_param_spec_object_get_default (pspec)),
GIMP_RESOURCE (default_value),
GIMP_PARAM_SPEC_RESOURCE (pspec)->default_to_context,
pspec->flags);
return duplicate;
}
#ifdef LIBGIMP_COMPILATION
#define GIMP_USER_CONTEXT
#else
#define GIMP_USER_CONTEXT gimp_get_user_context (gimp_core_app_get_gimp (GIMP_CORE_APP (g_application_get_default ())))
#endif
static GObject *
gimp_param_resource_get_default (GParamSpec *pspec)
{
GimpParamSpecResource *rspec;
GimpParamSpecObjectClass *parent_class = g_type_class_peek (GIMP_TYPE_PARAM_OBJECT);
g_return_val_if_fail (GIMP_IS_PARAM_SPEC_RESOURCE (pspec), NULL);
rspec = GIMP_PARAM_SPEC_RESOURCE (pspec);
if (rspec->default_to_context)
{
if (GIMP_IS_PARAM_SPEC_BRUSH (pspec))
return G_OBJECT (gimp_context_get_brush (GIMP_USER_CONTEXT));
else if (GIMP_IS_PARAM_SPEC_PATTERN (pspec))
return G_OBJECT (gimp_context_get_pattern (GIMP_USER_CONTEXT));
else if (GIMP_IS_PARAM_SPEC_GRADIENT (pspec))
return G_OBJECT (gimp_context_get_gradient (GIMP_USER_CONTEXT));
else if (GIMP_IS_PARAM_SPEC_PALETTE (pspec))
return G_OBJECT (gimp_context_get_palette (GIMP_USER_CONTEXT));
else if (GIMP_IS_PARAM_SPEC_FONT (pspec))
return G_OBJECT (gimp_context_get_font (GIMP_USER_CONTEXT));
else
g_return_val_if_reached (NULL);
}
else
{
return parent_class->get_default (pspec);
}
}
#undef GIMP_USER_CONTEXT
static gboolean
gimp_param_resource_validate (GParamSpec *pspec,
GValue *value)
@ -1064,8 +1111,18 @@ gimp_param_resource_validate (GParamSpec *pspec,
GimpParamSpecResource *rspec = GIMP_PARAM_SPEC_RESOURCE (pspec);
GObject *resource = value->data[0].v_pointer;
if (resource == gimp_param_resource_get_default (pspec))
/* This handles in particular the particular case where none_ok is
* FALSE yet the context's default is NULL. We let this
* near-inconsistency pass.
*/
return FALSE;
if (! rspec->none_ok && resource == NULL)
return TRUE;
{
g_set_object (&value->data[0].v_pointer, gimp_param_resource_get_default (pspec));
return TRUE;
}
if (resource && (! g_type_is_a (G_OBJECT_TYPE (resource), pspec->value_type) ||
! gimp_resource_is_valid ((gpointer) resource)))
@ -1083,28 +1140,23 @@ gimp_param_resource_validate (GParamSpec *pspec,
* @name: Canonical name of the property specified.
* @nick: Nick name of the property specified.
* @blurb: Description of the property specified.
* @resource_type: a %GType, subtype of [class@Gimp.Resource].
* @none_ok: Whether %NULL is a valid value.
* @default_value: (nullable): default resource
* @default_value: (nullable): Default resource.
* @default_to_context: Whether the context is the context's resource
* for the given @resource_type.
* @flags: Flags for the property specified.
*
* Creates a new #GimpParamSpecResource specifying a
* [type@Resource] property.
* Creates a new #GimpParamSpecResource specifying a [type@Resource] property.
* See [func@GObject.ParamSpec.internal] for details on property names.
*
* See g_param_spec_internal() for details on property names.
* @default_to_context cannot be %TRUE for a @resource_type of value
* [class@Gimp.Resource], but only for specific subtypes. If it is
* %TRUE, @default_value must be %NULL. Instead of a fixed default,
* whatever is the context's resource for the given type at run time
* will be used as dynamic default.
*
* The default_value is mainly used when declaring interactive plugin args.
* When such a param spec has a NULL default_value,
* a GimpResource chooser widget in the plugin's dialog
* will initially show a value from the context,
* and not have a choice such as "None", and will return a non-NULL value.
* Also plugins that are in the context menu of a resource browser (dockable)
* should declare a NULL default_value.
* Then the value will be the user selected item in the browser.
*
* For declaring args for non-interactive use, none_ok TRUE means
* the procedure receiving the argument will handle NULL gracefully.
*
* Returns: (transfer full): The newly created #GimpParamSpecResource.
* Returns: (transfer floating): The newly created #GimpParamSpecResource.
*
* Since: 3.0
**/
@ -1115,34 +1167,48 @@ gimp_param_spec_resource (const gchar *name,
GType resource_type,
gboolean none_ok,
GimpResource *default_value,
gboolean default_to_context,
GParamFlags flags)
{
GimpParamSpecResource *rspec;
GType param_type;
if (resource_type == GIMP_TYPE_RESOURCE ||
resource_type == G_TYPE_NONE)
param_type = GIMP_TYPE_PARAM_RESOURCE;
else if (resource_type == GIMP_TYPE_BRUSH)
param_type = GIMP_TYPE_PARAM_BRUSH;
else if (resource_type == GIMP_TYPE_PATTERN)
param_type = GIMP_TYPE_PARAM_PATTERN;
else if (resource_type == GIMP_TYPE_GRADIENT)
param_type = GIMP_TYPE_PARAM_GRADIENT;
else if (resource_type == GIMP_TYPE_PALETTE)
param_type = GIMP_TYPE_PARAM_PALETTE;
else if (resource_type == GIMP_TYPE_FONT)
param_type = GIMP_TYPE_PARAM_FONT;
g_return_val_if_fail (g_type_is_a (resource_type, GIMP_TYPE_RESOURCE) ||
g_type_is_a (resource_type, GIMP_TYPE_PARAM_RESOURCE), NULL);
if (! g_type_is_a (resource_type, GIMP_TYPE_PARAM_RESOURCE))
{
if (resource_type == GIMP_TYPE_RESOURCE ||
resource_type == G_TYPE_NONE)
param_type = GIMP_TYPE_PARAM_RESOURCE;
else if (resource_type == GIMP_TYPE_BRUSH)
param_type = GIMP_TYPE_PARAM_BRUSH;
else if (resource_type == GIMP_TYPE_PATTERN)
param_type = GIMP_TYPE_PARAM_PATTERN;
else if (resource_type == GIMP_TYPE_GRADIENT)
param_type = GIMP_TYPE_PARAM_GRADIENT;
else if (resource_type == GIMP_TYPE_PALETTE)
param_type = GIMP_TYPE_PARAM_PALETTE;
else if (resource_type == GIMP_TYPE_FONT)
param_type = GIMP_TYPE_PARAM_FONT;
else
g_return_val_if_reached (NULL);
}
else
g_return_val_if_reached (NULL);
{
param_type = resource_type;
}
g_return_val_if_fail (param_type != GIMP_TYPE_RESOURCE || ! default_to_context, NULL);
rspec = g_param_spec_internal (param_type, name, nick, blurb, flags);
g_return_val_if_fail (rspec, NULL);
rspec->none_ok = none_ok ? TRUE : FALSE;
rspec->none_ok = none_ok ? TRUE : FALSE;
rspec->default_to_context = default_to_context ? TRUE : FALSE;
gimp_param_spec_object_set_default (G_PARAM_SPEC (rspec), G_OBJECT (default_value));
if (! rspec->default_to_context)
gimp_param_spec_object_set_default (G_PARAM_SPEC (rspec), G_OBJECT (default_value));
return G_PARAM_SPEC (rspec);
}
@ -1197,17 +1263,14 @@ gimp_param_brush_init (GParamSpec *pspec)
* @nick: Nick name of the property specified.
* @blurb: Description of the property specified.
* @none_ok: Whether %NULL is a valid value.
* @default_value: (nullable): default brush
* @default_value: (nullable): Default brush.
* @default_to_context: Whether the context is the context's brush.
* @flags: Flags for the property specified.
*
* Creates a new #GimpParamSpecBrush specifying a
* [type@Brush] property.
* [type@Brush] property. See also [func@Gimp.param_spec_resource].
*
* See g_param_spec_internal() for details on property names.
* See gimp_param_spec_resource() for details on none-ok
* and NULL default_value.
*
* Returns: (transfer full): The newly created #GimpParamSpecBrush.
* Returns: (transfer floating): The newly created #GimpParamSpecBrush.
*
* Since: 3.0
**/
@ -1217,11 +1280,12 @@ gimp_param_spec_brush (const gchar *name,
const gchar *blurb,
gboolean none_ok,
GimpBrush *default_value,
gboolean default_to_context,
GParamFlags flags)
{
return gimp_param_spec_resource (name, nick, blurb, GIMP_TYPE_BRUSH,
none_ok, GIMP_RESOURCE (default_value),
flags);
default_to_context, flags);
}
@ -1274,17 +1338,14 @@ gimp_param_pattern_init (GParamSpec *pspec)
* @nick: Nick name of the property specified.
* @blurb: Description of the property specified.
* @none_ok: Whether %NULL is a valid value.
* @default_value: (nullable): default pattern
* @default_value: (nullable): Default pattern.
* @default_to_context: Whether the context is the context's pattern.
* @flags: Flags for the property specified.
*
* Creates a new #GimpParamSpecPattern specifying a
* [type@Pattern] property.
* [type@Pattern] property. See also [func@Gimp.param_spec_resource].
*
* See g_param_spec_internal() for details on property names.
* See gimp_param_spec_resource() for details on none-ok
* and NULL default_value.
*
* Returns: (transfer full): The newly created #GimpParamSpecPattern.
* Returns: (transfer floating): The newly created #GimpParamSpecPattern.
*
* Since: 3.0
**/
@ -1294,11 +1355,12 @@ gimp_param_spec_pattern (const gchar *name,
const gchar *blurb,
gboolean none_ok,
GimpPattern *default_value,
gboolean default_to_context,
GParamFlags flags)
{
return gimp_param_spec_resource (name, nick, blurb, GIMP_TYPE_PATTERN,
none_ok, GIMP_RESOURCE (default_value),
flags);
default_to_context, flags);
}
@ -1351,17 +1413,14 @@ gimp_param_gradient_init (GParamSpec *pspec)
* @nick: Nick name of the property specified.
* @blurb: Description of the property specified.
* @none_ok: Whether %NULL is a valid value.
* @default_value: (nullable): default gradient
* @default_value: (nullable): Default gradient.
* @default_to_context: Whether the context is the context's gradient.
* @flags: Flags for the property specified.
*
* Creates a new #GimpParamSpecGradient specifying a
* [type@Gradient] property.
* [type@Gradient] property. See also [func@Gimp.param_spec_resource].
*
* See g_param_spec_internal() for details on property names.
* See gimp_param_spec_resource() for details on none-ok
* and NULL default_value.
*
* Returns: (transfer full): The newly created #GimpParamSpecGradient.
* Returns: (transfer floating): The newly created #GimpParamSpecGradient.
*
* Since: 3.0
**/
@ -1371,11 +1430,12 @@ gimp_param_spec_gradient (const gchar *name,
const gchar *blurb,
gboolean none_ok,
GimpGradient *default_value,
gboolean default_to_context,
GParamFlags flags)
{
return gimp_param_spec_resource (name, nick, blurb, GIMP_TYPE_GRADIENT,
none_ok, GIMP_RESOURCE (default_value),
flags);
default_to_context, flags);
}
@ -1428,17 +1488,14 @@ gimp_param_palette_init (GParamSpec *pspec)
* @nick: Nick name of the property specified.
* @blurb: Description of the property specified.
* @none_ok: Whether %NULL is a valid value.
* @default_value: (nullable): default palette
* @default_value: (nullable): Default palette.
* @default_to_context: Whether the context is the context's palette.
* @flags: Flags for the property specified.
*
* Creates a new #GimpParamSpecPalette specifying a
* [type@Palette] property.
* [type@Palette] property. See also [func@Gimp.param_spec_resource].
*
* See g_param_spec_internal() for details on property names.
* See gimp_param_spec_resource() for details on none-ok
* and NULL default_value.
*
* Returns: (transfer full): The newly created #GimpParamSpecPalette.
* Returns: (transfer floating): The newly created #GimpParamSpecPalette.
*
* Since: 3.0
**/
@ -1448,11 +1505,12 @@ gimp_param_spec_palette (const gchar *name,
const gchar *blurb,
gboolean none_ok,
GimpPalette *default_value,
gboolean default_to_context,
GParamFlags flags)
{
return gimp_param_spec_resource (name, nick, blurb, GIMP_TYPE_PALETTE,
none_ok, GIMP_RESOURCE (default_value),
flags);
default_to_context, flags);
}
@ -1505,17 +1563,14 @@ gimp_param_font_init (GParamSpec *pspec)
* @nick: Nick name of the property specified.
* @blurb: Description of the property specified.
* @none_ok: Whether %NULL is a valid value.
* @default_value: (nullable): default font
* @default_value: (nullable): Default font.
* @default_to_context: Whether the context is the context's font.
* @flags: Flags for the property specified.
*
* Creates a new #GimpParamSpecFont specifying a
* [type@Font] property.
* [type@Font] property. See also [func@Gimp.param_spec_resource].
*
* See g_param_spec_internal() for details on property names.
* See gimp_param_spec_resource() for details on none-ok
* and NULL default_value.
*
* Returns: (transfer full): The newly created #GimpParamSpecFont.
* Returns: (transfer floating): The newly created #GimpParamSpecFont.
*
* Since: 3.0
**/
@ -1525,9 +1580,10 @@ gimp_param_spec_font (const gchar *name,
const gchar *blurb,
gboolean none_ok,
GimpFont *default_value,
gboolean default_to_context,
GParamFlags flags)
{
return gimp_param_spec_resource (name, nick, blurb, GIMP_TYPE_FONT,
none_ok, GIMP_RESOURCE (default_value),
flags);
default_to_context, flags);
}

View File

@ -350,6 +350,7 @@ struct _GimpParamSpecResource
GimpParamSpecObject parent_instance;
gboolean none_ok;
gboolean default_to_context;
};
GType gimp_param_resource_get_type (void) G_GNUC_CONST;
@ -360,6 +361,7 @@ GParamSpec * gimp_param_spec_resource (const gchar *name,
GType resource_type,
gboolean none_ok,
GimpResource *default_value,
gboolean default_to_context,
GParamFlags flags);
@ -388,6 +390,7 @@ GParamSpec * gimp_param_spec_brush (const gchar *name,
const gchar *blurb,
gboolean none_ok,
GimpBrush *default_value,
gboolean default_to_context,
GParamFlags flags);
@ -416,6 +419,7 @@ GParamSpec * gimp_param_spec_pattern (const gchar *name,
const gchar *blurb,
gboolean none_ok,
GimpPattern *default_value,
gboolean default_to_context,
GParamFlags flags);
@ -444,6 +448,7 @@ GParamSpec * gimp_param_spec_gradient (const gchar *name,
const gchar *blurb,
gboolean none_ok,
GimpGradient *default_value,
gboolean default_to_context,
GParamFlags flags);
@ -472,6 +477,7 @@ GParamSpec * gimp_param_spec_palette (const gchar *name,
const gchar *blurb,
gboolean none_ok,
GimpPalette *default_value,
gboolean default_to_context,
GParamFlags flags);
@ -500,6 +506,7 @@ GParamSpec * gimp_param_spec_font (const gchar *name,
const gchar *blurb,
gboolean none_ok,
GimpFont *default_value,
gboolean default_to_context,
GParamFlags flags);

View File

@ -2353,7 +2353,7 @@ gimp_procedure_add_file_return_value (GimpProcedure *procedure,
* @nick: the label used in #GimpProcedureDialog.
* @blurb: a more detailed help description.
* @none_ok: whether %NULL is a valid value.
* @default_value: (nullable): default value
* @default_value: (nullable): default value.
* @flags: argument flags.
*
* Add a new #GimpResource argument to @procedure.
@ -2374,6 +2374,7 @@ gimp_procedure_add_resource_argument (GimpProcedure *procedure,
GIMP_TYPE_RESOURCE,
none_ok,
default_value,
FALSE,
flags));
}
@ -2383,7 +2384,7 @@ gimp_procedure_add_resource_argument (GimpProcedure *procedure,
* @name: the name of the argument to be created.
* @nick: the label used in #GimpProcedureDialog.
* @blurb: a more detailed help description.
* @default_value: (nullable): default value
* @default_value: (nullable): default value.
* @flags: argument flags.
*
* Add a new #GimpResource auxiliary argument to @procedure.
@ -2403,6 +2404,7 @@ gimp_procedure_add_resource_aux_argument (GimpProcedure *procedure,
GIMP_TYPE_RESOURCE,
TRUE,
default_value,
FALSE,
flags));
}
@ -2428,7 +2430,7 @@ gimp_procedure_add_resource_return_value (GimpProcedure *procedure,
_gimp_procedure_add_return_value (procedure,
gimp_param_spec_resource (name, nick, blurb,
GIMP_TYPE_RESOURCE,
TRUE, NULL, flags));
TRUE, NULL, FALSE, flags));
}
/**
@ -2439,6 +2441,7 @@ gimp_procedure_add_resource_return_value (GimpProcedure *procedure,
* @blurb: a more detailed help description.
* @none_ok: whether %NULL is a valid value.
* @default_value: (nullable): default value
* @default_to_context: Use the context's brush as default value.
* @flags: argument flags.
*
* Add a new #GimpBrush argument to @procedure.
@ -2452,12 +2455,14 @@ gimp_procedure_add_brush_argument (GimpProcedure *procedure,
const gchar *blurb,
gboolean none_ok,
GimpBrush *default_value,
gboolean default_to_context,
GParamFlags flags)
{
_gimp_procedure_add_argument (procedure,
gimp_param_spec_brush (name, nick, blurb,
none_ok,
default_value,
default_to_context,
flags));
}
@ -2468,6 +2473,7 @@ gimp_procedure_add_brush_argument (GimpProcedure *procedure,
* @nick: the label used in #GimpProcedureDialog.
* @blurb: a more detailed help description.
* @default_value: (nullable): default value
* @default_to_context: Use the context's brush as default value.
* @flags: argument flags.
*
* Add a new #GimpBrush auxiliary argument to @procedure.
@ -2480,12 +2486,14 @@ gimp_procedure_add_brush_aux_argument (GimpProcedure *procedure,
const gchar *nick,
const gchar *blurb,
GimpBrush *default_value,
gboolean default_to_context,
GParamFlags flags)
{
_gimp_procedure_add_aux_argument (procedure,
gimp_param_spec_brush (name, nick, blurb,
TRUE,
default_value,
default_to_context,
flags));
}
@ -2510,7 +2518,7 @@ gimp_procedure_add_brush_return_value (GimpProcedure *procedure,
{
_gimp_procedure_add_return_value (procedure,
gimp_param_spec_brush (name, nick, blurb,
TRUE, NULL, flags));
TRUE, NULL, FALSE, flags));
}
/**
@ -2521,6 +2529,7 @@ gimp_procedure_add_brush_return_value (GimpProcedure *procedure,
* @blurb: a more detailed help description.
* @none_ok: whether %NULL is a valid value.
* @default_value: (nullable): default value
* @default_to_context: Use the context's font as default value.
* @flags: argument flags.
*
* Add a new #GimpFont argument to @procedure.
@ -2534,12 +2543,14 @@ gimp_procedure_add_font_argument (GimpProcedure *procedure,
const gchar *blurb,
gboolean none_ok,
GimpFont *default_value,
gboolean default_to_context,
GParamFlags flags)
{
_gimp_procedure_add_argument (procedure,
gimp_param_spec_font (name, nick, blurb,
none_ok,
default_value,
default_to_context,
flags));
}
@ -2550,6 +2561,7 @@ gimp_procedure_add_font_argument (GimpProcedure *procedure,
* @nick: the label used in #GimpProcedureDialog.
* @blurb: a more detailed help description.
* @default_value: (nullable): default value
* @default_to_context: Use the context's font as default value.
* @flags: argument flags.
*
* Add a new #GimpFont auxiliary argument to @procedure.
@ -2562,12 +2574,14 @@ gimp_procedure_add_font_aux_argument (GimpProcedure *procedure,
const gchar *nick,
const gchar *blurb,
GimpFont *default_value,
gboolean default_to_context,
GParamFlags flags)
{
_gimp_procedure_add_aux_argument (procedure,
gimp_param_spec_font (name, nick, blurb,
TRUE,
default_value,
default_to_context,
flags));
}
@ -2592,7 +2606,7 @@ gimp_procedure_add_font_return_value (GimpProcedure *procedure,
{
_gimp_procedure_add_return_value (procedure,
gimp_param_spec_font (name, nick, blurb,
TRUE, NULL, flags));
TRUE, NULL, FALSE, flags));
}
/**
@ -2603,6 +2617,7 @@ gimp_procedure_add_font_return_value (GimpProcedure *procedure,
* @blurb: a more detailed help description.
* @none_ok: whether %NULL is a valid value.
* @default_value: (nullable): default value
* @default_to_context: Use the context's gradient as default value.
* @flags: argument flags.
*
* Add a new #GimpGradient argument to @procedure.
@ -2616,12 +2631,14 @@ gimp_procedure_add_gradient_argument (GimpProcedure *procedure,
const gchar *blurb,
gboolean none_ok,
GimpGradient *default_value,
gboolean default_to_context,
GParamFlags flags)
{
_gimp_procedure_add_argument (procedure,
gimp_param_spec_gradient (name, nick, blurb,
none_ok,
default_value,
default_to_context,
flags));
}
@ -2632,6 +2649,7 @@ gimp_procedure_add_gradient_argument (GimpProcedure *procedure,
* @nick: the label used in #GimpProcedureDialog.
* @blurb: a more detailed help description.
* @default_value: (nullable): default value
* @default_to_context: Use the context's gradient as default value.
* @flags: argument flags.
*
* Add a new #GimpGradient auxiliary argument to @procedure.
@ -2644,12 +2662,14 @@ gimp_procedure_add_gradient_aux_argument (GimpProcedure *procedure,
const gchar *nick,
const gchar *blurb,
GimpGradient *default_value,
gboolean default_to_context,
GParamFlags flags)
{
_gimp_procedure_add_aux_argument (procedure,
gimp_param_spec_gradient (name, nick, blurb,
TRUE,
default_value,
default_to_context,
flags));
}
@ -2674,7 +2694,7 @@ gimp_procedure_add_gradient_return_value (GimpProcedure *procedure,
{
_gimp_procedure_add_return_value (procedure,
gimp_param_spec_gradient (name, nick, blurb,
TRUE, NULL, flags));
TRUE, NULL, FALSE, flags));
}
/**
@ -2685,6 +2705,7 @@ gimp_procedure_add_gradient_return_value (GimpProcedure *procedure,
* @blurb: a more detailed help description.
* @none_ok: whether %NULL is a valid value.
* @default_value: (nullable): default value
* @default_to_context: Use the context's palette as default value.
* @flags: argument flags.
*
* Add a new #GimpPalette argument to @procedure.
@ -2698,12 +2719,14 @@ gimp_procedure_add_palette_argument (GimpProcedure *procedure,
const gchar *blurb,
gboolean none_ok,
GimpPalette *default_value,
gboolean default_to_context,
GParamFlags flags)
{
_gimp_procedure_add_argument (procedure,
gimp_param_spec_palette (name, nick, blurb,
none_ok,
default_value,
default_to_context,
flags));
}
@ -2714,6 +2737,7 @@ gimp_procedure_add_palette_argument (GimpProcedure *procedure,
* @nick: the label used in #GimpProcedureDialog.
* @blurb: a more detailed help description.
* @default_value: (nullable): default value
* @default_to_context: Use the context's palette as default value.
* @flags: argument flags.
*
* Add a new #GimpPalette auxiliary argument to @procedure.
@ -2726,12 +2750,14 @@ gimp_procedure_add_palette_aux_argument (GimpProcedure *procedure,
const gchar *nick,
const gchar *blurb,
GimpPalette *default_value,
gboolean default_to_context,
GParamFlags flags)
{
_gimp_procedure_add_aux_argument (procedure,
gimp_param_spec_palette (name, nick, blurb,
TRUE,
default_value,
default_to_context,
flags));
}
@ -2756,7 +2782,7 @@ gimp_procedure_add_palette_return_value (GimpProcedure *procedure,
{
_gimp_procedure_add_return_value (procedure,
gimp_param_spec_palette (name, nick, blurb,
TRUE, NULL, flags));
TRUE, NULL, FALSE, flags));
}
/**
@ -2767,6 +2793,7 @@ gimp_procedure_add_palette_return_value (GimpProcedure *procedure,
* @blurb: a more detailed help description.
* @none_ok: whether %NULL is a valid value.
* @default_value: (nullable): default value
* @default_to_context: Use the context's pattern as default value.
* @flags: argument flags.
*
* Add a new #GimpPattern argument to @procedure.
@ -2780,12 +2807,14 @@ gimp_procedure_add_pattern_argument (GimpProcedure *procedure,
const gchar *blurb,
gboolean none_ok,
GimpPattern *default_value,
gboolean default_to_context,
GParamFlags flags)
{
_gimp_procedure_add_argument (procedure,
gimp_param_spec_pattern (name, nick, blurb,
none_ok,
default_value,
default_to_context,
flags));
}
@ -2796,6 +2825,7 @@ gimp_procedure_add_pattern_argument (GimpProcedure *procedure,
* @nick: the label used in #GimpProcedureDialog.
* @blurb: a more detailed help description.
* @default_value: (nullable): default value
* @default_to_context: Use the context's pattern as default value.
* @flags: argument flags.
*
* Add a new #GimpPattern auxiliary argument to @procedure.
@ -2808,12 +2838,14 @@ gimp_procedure_add_pattern_aux_argument (GimpProcedure *procedure,
const gchar *nick,
const gchar *blurb,
GimpPattern *default_value,
gboolean default_to_context,
GParamFlags flags)
{
_gimp_procedure_add_aux_argument (procedure,
gimp_param_spec_pattern (name, nick, blurb,
TRUE,
default_value,
default_to_context,
flags));
}
@ -2838,5 +2870,5 @@ gimp_procedure_add_pattern_return_value (GimpProcedure *procedure,
{
_gimp_procedure_add_return_value (procedure,
gimp_param_spec_pattern (name, nick, blurb,
TRUE, NULL, flags));
TRUE, NULL, FALSE, flags));
}

View File

@ -1025,12 +1025,14 @@ void gimp_procedure_add_brush_argument (GimpProcedure *procedure
const gchar *blurb,
gboolean none_ok,
GimpBrush *default_value,
gboolean default_to_context,
GParamFlags flags);
void gimp_procedure_add_brush_aux_argument (GimpProcedure *procedure,
const gchar *name,
const gchar *nick,
const gchar *blurb,
GimpBrush *default_value,
gboolean default_to_context,
GParamFlags flags);
void gimp_procedure_add_brush_return_value (GimpProcedure *procedure,
const gchar *name,
@ -1044,12 +1046,14 @@ void gimp_procedure_add_font_argument (GimpProcedure *procedure
const gchar *blurb,
gboolean none_ok,
GimpFont *default_value,
gboolean default_to_context,
GParamFlags flags);
void gimp_procedure_add_font_aux_argument (GimpProcedure *procedure,
const gchar *name,
const gchar *nick,
const gchar *blurb,
GimpFont *default_value,
gboolean default_to_context,
GParamFlags flags);
void gimp_procedure_add_font_return_value (GimpProcedure *procedure,
const gchar *name,
@ -1063,12 +1067,14 @@ void gimp_procedure_add_gradient_argument (GimpProcedure *procedure
const gchar *blurb,
gboolean none_ok,
GimpGradient *default_value,
gboolean default_to_context,
GParamFlags flags);
void gimp_procedure_add_gradient_aux_argument (GimpProcedure *procedure,
const gchar *name,
const gchar *nick,
const gchar *blurb,
GimpGradient *default_value,
gboolean default_to_context,
GParamFlags flags);
void gimp_procedure_add_gradient_return_value (GimpProcedure *procedure,
const gchar *name,
@ -1082,12 +1088,14 @@ void gimp_procedure_add_palette_argument (GimpProcedure *procedure
const gchar *blurb,
gboolean none_ok,
GimpPalette *default_value,
gboolean default_to_context,
GParamFlags flags);
void gimp_procedure_add_palette_aux_argument (GimpProcedure *procedure,
const gchar *name,
const gchar *nick,
const gchar *blurb,
GimpPalette *default_value,
gboolean default_to_context,
GParamFlags flags);
void gimp_procedure_add_palette_return_value (GimpProcedure *procedure,
const gchar *name,
@ -1101,12 +1109,14 @@ void gimp_procedure_add_pattern_argument (GimpProcedure *procedure
const gchar *blurb,
gboolean none_ok,
GimpPattern *default_value,
gboolean default_to_context,
GParamFlags flags);
void gimp_procedure_add_pattern_aux_argument (GimpProcedure *procedure,
const gchar *name,
const gchar *nick,
const gchar *blurb,
GimpPattern *default_value,
gboolean default_to_context,
GParamFlags flags);
void gimp_procedure_add_pattern_return_value (GimpProcedure *procedure,
const gchar *name,

View File

@ -191,6 +191,7 @@ gimp_resource_chooser_class_init (GimpResourceChooserClass *klass)
GIMP_TYPE_RESOURCE,
TRUE, /* none_ok */
NULL, /* no default for this property. */
FALSE,
GIMP_PARAM_READWRITE);
g_object_class_install_properties (object_class,

View File

@ -195,13 +195,14 @@ gimp_param_spec_choice (const gchar *name,
* GIMP_TYPE_PARAM_OBJECT
*/
static void gimp_param_object_class_init (GimpParamSpecObjectClass *klass);
static void gimp_param_object_init (GimpParamSpecObject *pspec);
static void gimp_param_object_finalize (GParamSpec *pspec);
static void gimp_param_object_value_set_default (GParamSpec *pspec,
GValue *value);
static void gimp_param_object_class_init (GimpParamSpecObjectClass *klass);
static void gimp_param_object_init (GimpParamSpecObject *pspec);
static void gimp_param_object_finalize (GParamSpec *pspec);
static void gimp_param_object_value_set_default (GParamSpec *pspec,
GValue *value);
static GParamSpec * gimp_param_spec_object_real_duplicate (GParamSpec *pspec);
static GParamSpec * gimp_param_spec_object_real_duplicate (GParamSpec *pspec);
static GObject * gimp_param_spec_object_real_get_default (GParamSpec *pspec);
GType
@ -235,6 +236,7 @@ gimp_param_object_class_init (GimpParamSpecObjectClass *klass)
GParamSpecClass *pclass = G_PARAM_SPEC_CLASS (klass);
klass->duplicate = gimp_param_spec_object_real_duplicate;
klass->get_default = gimp_param_spec_object_real_get_default;
pclass->value_type = G_TYPE_OBJECT;
pclass->finalize = gimp_param_object_finalize;
@ -262,9 +264,12 @@ static void
gimp_param_object_value_set_default (GParamSpec *pspec,
GValue *value)
{
GObject *default_value;
g_return_if_fail (GIMP_IS_PARAM_SPEC_OBJECT (pspec));
g_value_set_object (value, GIMP_PARAM_SPEC_OBJECT (pspec)->_default_value);
default_value = gimp_param_spec_object_get_default (pspec);
g_value_set_object (value, default_value);
}
static GParamSpec *
@ -288,25 +293,34 @@ gimp_param_spec_object_real_duplicate (GParamSpec *pspec)
return G_PARAM_SPEC (duplicate);
}
static GObject *
gimp_param_spec_object_real_get_default (GParamSpec *pspec)
{
g_return_val_if_fail (GIMP_IS_PARAM_SPEC_OBJECT (pspec), NULL);
g_return_val_if_fail (GIMP_PARAM_SPEC_OBJECT (pspec)->_has_default, NULL);
return GIMP_PARAM_SPEC_OBJECT (pspec)->_default_value;
}
/**
* gimp_param_spec_object_get_default:
* @pspec: a #GObject #GParamSpec
*
* Get the default object value of the param spec.
*
* It is a programming error to call this on a
* [struct@Gimp.ParamSpecObject] with no default value. You should
* verify first with [func@Gimp.ParamSpecObject.has_default].
* If the @pspec has been registered with a specific default (which can
* be verified with [func@Gimp.ParamSpecObject.has_default]), it will be
* returned, though some specific subtypes may support returning dynamic
* default (e.g. based on context).
*
* Returns: (transfer none): the default value.
*/
GObject *
gimp_param_spec_object_get_default (GParamSpec *pspec)
gimp_param_spec_object_get_default (GParamSpec *pspec)
{
g_return_val_if_fail (GIMP_IS_PARAM_SPEC_OBJECT (pspec), NULL);
g_return_val_if_fail (GIMP_PARAM_SPEC_OBJECT (pspec)->_has_default, NULL);
return GIMP_PARAM_SPEC_OBJECT (pspec)->_default_value;
return GIMP_PARAM_SPEC_OBJECT_GET_CLASS (pspec)->get_default (pspec);
}
/**

View File

@ -154,7 +154,8 @@ struct _GimpParamSpecObjectClass
/*< private >*/
GParamSpecClass parent_class;
GParamSpec * (* duplicate) (GParamSpec *pspec);
GParamSpec * (* duplicate) (GParamSpec *pspec);
GObject * (* get_default) (GParamSpec *pspec);
/* Padding for future expansion */
void (*_gimp_reserved0) (void);

View File

@ -1285,6 +1285,21 @@ _gp_param_def_read (GIOChannel *channel,
user_data))
return FALSE;
break;
case GP_PARAM_DEF_TYPE_RESOURCE:
if (! _gimp_wire_read_int32 (channel,
(guint32 *) &param_def->meta.m_resource.none_ok, 1,
user_data))
return FALSE;
if (! _gimp_wire_read_int32 (channel,
(guint32 *) &param_def->meta.m_resource.default_to_context, 1,
user_data))
return FALSE;
if (! _gimp_wire_read_int32 (channel,
(guint32 *) &param_def->meta.m_resource.default_resource_id, 1,
user_data))
return FALSE;
break;
}
return TRUE;
@ -1338,6 +1353,9 @@ _gp_param_def_destroy (GPParamDef *param_def)
case GP_PARAM_DEF_TYPE_EXPORT_OPTIONS:
break;
case GP_PARAM_DEF_TYPE_RESOURCE:
break;
}
}
@ -1621,6 +1639,21 @@ _gp_param_def_write (GIOChannel *channel,
user_data))
return FALSE;
break;
case GP_PARAM_DEF_TYPE_RESOURCE:
if (! _gimp_wire_write_int32 (channel,
(guint32 *) &param_def->meta.m_resource.none_ok, 1,
user_data))
return FALSE;
if (! _gimp_wire_write_int32 (channel,
(guint32 *) &param_def->meta.m_resource.default_to_context, 1,
user_data))
return FALSE;
if (! _gimp_wire_write_int32 (channel,
(guint32 *) &param_def->meta.m_resource.default_resource_id, 1,
user_data))
return FALSE;
break;
}
return TRUE;

View File

@ -59,7 +59,8 @@ typedef enum
GP_PARAM_DEF_TYPE_GEGL_COLOR,
GP_PARAM_DEF_TYPE_ID,
GP_PARAM_DEF_TYPE_ID_ARRAY,
GP_PARAM_DEF_TYPE_EXPORT_OPTIONS
GP_PARAM_DEF_TYPE_EXPORT_OPTIONS,
GP_PARAM_DEF_TYPE_RESOURCE
} GPParamDefType;
typedef enum
@ -97,6 +98,7 @@ typedef struct _GPParamDefGeglColor GPParamDefGeglColor;
typedef struct _GPParamDefID GPParamDefID;
typedef struct _GPParamDefIDArray GPParamDefIDArray;
typedef struct _GPParamDefExportOptions GPParamDefExportOptions;
typedef struct _GPParamDefResource GPParamDefResource;
typedef struct _GPParam GPParam;
typedef struct _GPParamArray GPParamArray;
typedef struct _GPParamIDArray GPParamIDArray;
@ -232,6 +234,13 @@ struct _GPParamDefExportOptions
gint capabilities;
};
struct _GPParamDefResource
{
gint32 none_ok;
gint32 default_to_context;
gint32 default_resource_id;
};
struct _GPParamDef
{
GPParamDefType param_def_type;
@ -255,6 +264,7 @@ struct _GPParamDef
GPParamDefIDArray m_id_array;
GPParamDefChoice m_choice;
GPParamDefExportOptions m_export_options;
GPParamDefResource m_resource;
} meta;
};

View File

@ -249,66 +249,77 @@ gimp_param_spec_resource ("$name",
GIMP_TYPE_RESOURCE,
$none_ok,
$default,
FALSE,
$flags)
CODE
}
elsif ($pdbtype eq 'brush') {
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
$default = exists $arg->{default} ? $arg->{default} : NULL;
$default_to_context = exists $arg->{default_to_context} ? 'TRUE' : 'FALSE';
$pspec = <<CODE;
gimp_param_spec_brush ("$name",
"$nick",
"$blurb",
$none_ok,
$default,
$default_to_context,
$flags)
CODE
}
elsif ($pdbtype eq 'font') {
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
$default = exists $arg->{default} ? $arg->{default} : NULL;
$default_to_context = exists $arg->{default_to_context} ? 'TRUE' : 'FALSE';
$pspec = <<CODE;
gimp_param_spec_font ("$name",
"$nick",
"$blurb",
$none_ok,
$default,
$default_to_context,
$flags)
CODE
}
elsif ($pdbtype eq 'gradient') {
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
$default = exists $arg->{default} ? $arg->{default} : NULL;
$default_to_context = exists $arg->{default_to_context} ? 'TRUE' : 'FALSE';
$pspec = <<CODE;
gimp_param_spec_gradient ("$name",
"$nick",
"$blurb",
$none_ok,
$default,
$default_to_context,
$flags)
CODE
}
elsif ($pdbtype eq 'palette') {
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
$default = exists $arg->{default} ? $arg->{default} : NULL;
$default_to_context = exists $arg->{default_to_context} ? 'TRUE' : 'FALSE';
$pspec = <<CODE;
gimp_param_spec_palette ("$name",
"$nick",
"$blurb",
$none_ok,
$default,
$default_to_context,
$flags)
CODE
}
elsif ($pdbtype eq 'pattern') {
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
$default = exists $arg->{default} ? $arg->{default} : NULL;
$default_to_context = exists $arg->{default_to_context} ? 'TRUE' : 'FALSE';
$pspec = <<CODE;
gimp_param_spec_pattern ("$name",
"$nick",
"$blurb",
$none_ok,
$default,
$default_to_context,
$flags)
CODE
}

View File

@ -165,15 +165,12 @@ film_create_procedure (GimpPlugIn *plug_in,
GeglColor *default_film_color;
GeglColor *default_number_color;
gdouble default_number_rgb[4] = { 0.93, 0.61, 0.0, 1.0 };
GimpFont *default_font = NULL;
gegl_init (NULL, NULL);
default_film_color = gegl_color_new ("black");
default_number_color = gegl_color_new (NULL);
gegl_color_set_pixel (default_number_color, babl_format ("R'G'B'A double"), default_number_rgb);
default_font = gimp_font_get_by_name ("Serif");
if (! strcmp (name, PLUG_IN_PROC))
{
procedure = gimp_image_procedure_new (plug_in, name,
@ -220,8 +217,7 @@ film_create_procedure (GimpPlugIn *plug_in,
gimp_procedure_add_font_argument (procedure, "number-font",
_("Number _font"),
_("Font for drawing numbers"),
FALSE, /* none_ok */
default_font,
FALSE, NULL, TRUE,
G_PARAM_READWRITE);
gimp_procedure_add_color_argument (procedure, "number-color",

View File

@ -204,7 +204,7 @@ class GradientsSaveAsCSS (Gimp.PlugIn):
GObject.ParamFlags.READWRITE)
procedure.add_gradient_argument ("gradient", _("_Gradient to use"),
"", True,
None, # Default to context.
None, True, # Default to context.
GObject.ParamFlags.READWRITE)
procedure.add_file_argument ("file", _("_File"),
"", GObject.ParamFlags.READWRITE)

View File

@ -58,7 +58,7 @@ class PaletteOffset (Gimp.PlugIn):
GObject.ParamFlags.READWRITE)
procedure.add_palette_argument ("palette", _("_Palette"),
_("Palette"), True,
None, # Default to context.
None, True, # Default to context.
GObject.ParamFlags.READWRITE)
procedure.add_int_argument ("amount", _("O_ffset"), _("Offset"),
1, GLib.MAXINT, 1, GObject.ParamFlags.READWRITE)

View File

@ -357,7 +357,7 @@ class PaletteSort (Gimp.PlugIn):
GObject.ParamFlags.READWRITE)
procedure.add_palette_argument ("palette", _("_Palette"),
_("Palette"), True,
None, # Default to context.
None, True, # Default to context.
GObject.ParamFlags.READWRITE)
selection_choice = Gimp.Choice.new()

View File

@ -146,7 +146,7 @@ class PaletteToGradient (Gimp.PlugIn):
GObject.ParamFlags.READWRITE)
procedure.add_palette_argument ("palette", _("_Palette"),
_("Palette"), True,
None, # Default to context.
None, True, # Default to context.
GObject.ParamFlags.READWRITE)
procedure.add_gradient_return_value ("new-gradient", _("The newly created gradient"),
_("The newly created gradient"),

View File

@ -334,14 +334,14 @@ script_fu_arg_add_argument (SFArg *arg,
gimp_procedure_add_font_argument (procedure, name,
nick, arg->label,
FALSE, /* none OK */
gimp_font_get_by_name ("Serif"),
NULL, TRUE,
G_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE);
break;
case SF_PALETTE:
gimp_procedure_add_palette_argument (procedure, name,
nick, arg->label,
FALSE, /* none OK */
gimp_palette_get_by_name ("Default"),
NULL, TRUE,
G_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE);
break;
@ -349,7 +349,7 @@ script_fu_arg_add_argument (SFArg *arg,
gimp_procedure_add_pattern_argument (procedure, name,
nick, arg->label,
FALSE, /* none OK */
gimp_pattern_get_by_name ("Paper"),
NULL, TRUE,
G_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE);
break;
@ -357,7 +357,7 @@ script_fu_arg_add_argument (SFArg *arg,
gimp_procedure_add_gradient_argument (procedure, name,
nick, arg->label,
FALSE, /* none OK */
gimp_gradient_get_by_name ("Incandescent"),
NULL, TRUE,
G_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE);
break;
@ -365,7 +365,7 @@ script_fu_arg_add_argument (SFArg *arg,
gimp_procedure_add_brush_argument (procedure, name,
nick, arg->label,
FALSE, /* none OK */
gimp_brush_get_by_name ("2. Hardness 025"),
NULL, TRUE,
G_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE);
break;