1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956
|
# GIMP - The GNU Image Manipulation Program
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
sub drawable_filter_id_is_valid {
$blurb = 'Returns %TRUE if the drawable filter ID is valid.';
$help = <<'HELP';
This procedure checks if the given drawable filter ID is valid and refers to an
existing filter.
HELP
&jehan_pdb_misc('2024', '3.0');
@inargs = (
{ name => 'filter_id', type => 'int32',
desc => 'The filter ID to check' }
);
@outargs = (
{ name => 'valid', type => 'boolean',
desc => 'Whether the filter ID is valid' }
);
%invoke = (
code => <<'CODE'
{
valid = (gimp_drawable_filter_get_by_id (gimp, filter_id) != NULL);
}
CODE
);
}
sub drawable_filter_new {
$blurb = 'Create a new drawable filter.';
$help = <<'HELP';
This procedure creates a new filter for the specified operation on @drawable.
The new effect still needs to be either added or merged to @drawable later.
Add the effect non-destructively with [method@Gimp.Drawable.append_filter].
Currently only layers can have non-destructive effects. The effects must be merged for all other types of drawable.
HELP
&jehan_pdb_misc('2024', '3.0');
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' },
{ name => 'operation_name', type => 'string',
desc => "The GEGL operation's name" },
{ name => 'name', type => 'string',
desc => 'The effect name', none_ok => 0 },
);
@outargs = (
{ name => 'filter', type => 'filter',
desc => 'The newly created filter' }
);
%invoke = (
code => <<'CODE'
{
if (gimp_gegl_op_nde_allowed (operation_name, error))
{
GeglNode *operation = gegl_node_new ();
gegl_node_set (operation,
"operation", operation_name,
NULL);
if (gimp_operation_config_is_custom (gimp, operation_name))
{
GParamSpec *pspec = gegl_node_find_property (operation, "config");
GType otype = pspec->value_type;
GObject *config = g_object_new (otype, NULL);
gegl_node_set (operation, "config", config, NULL);
g_object_unref (config);
}
filter = gimp_drawable_filter_new (drawable, name, operation, NULL);
/* We don't have a libgimp function for setting the clipping
* behavior. I want to look further into the whole logic first.
* In the meantime if all API-made filters must have a single
* clipping behavior, I believe that not-clipping (adjusting) is
* the nicer default.
*/
gimp_drawable_filter_set_clip (filter, FALSE);
g_clear_object (&operation);
}
else
{
success = FALSE;
}
}
CODE
);
}
sub drawable_filter_get_name {
$blurb = 'Get a drawable filter\'s name.';
$help = <<'HELP';
This procedure returns the specified filter's name.
Since it is not possible to set a drawable filter's name yet, this will
be the operation's name. Eventually this filter's name will be a free
form field so do not rely on this information for any processing.
HELP
&jehan_pdb_misc('2024', '3.0');
@inargs = (
{ name => 'filter', type => 'filter',
desc => 'The filter whose name you want' }
);
@outargs = (
{ name => 'name', type => 'string',
desc => "The filter's name" }
);
%invoke = (
code => <<'CODE'
{
name = g_strdup (gimp_object_get_name (GIMP_OBJECT (filter)));
}
CODE
);
}
sub drawable_filter_get_operation_name {
$blurb = 'Get a drawable filter\'s operation name.';
$help = <<'HELP';
This procedure returns the specified filter's operation name.
HELP
&jehan_pdb_misc('2024', '3.0');
@inargs = (
{ name => 'filter', type => 'filter',
desc => 'The filter whose operation name you want' }
);
@outargs = (
{ name => 'name', type => 'string',
desc => "The filter's operation name" }
);
%invoke = (
code => <<'CODE'
{
GeglNode *node;
node = gimp_drawable_filter_get_operation (filter);
name = g_strdup (gegl_node_get_operation (node));
}
CODE
);
}
sub drawable_filter_get_visible {
$blurb = "Get the visibility of the specified filter.";
$help = "This procedure returns the specified filter's visibility.";
&jehan_pdb_misc('2024', '3.0');
@inargs = (
{ name => 'filter', type => 'filter',
desc => 'The filter' }
);
@outargs = (
{ name => 'visible', type => 'boolean',
desc => "The filter visibility" }
);
%invoke = (
code => <<'CODE'
{
visible = gimp_filter_get_active (GIMP_FILTER (filter));
}
CODE
);
}
sub drawable_filter_set_visible {
$blurb = "Set the visibility of the specified filter.";
$help = <<'HELP';
This procedure sets the specified filter's visibility.
The drawable won't be immediately rendered. Use [method@Gimp.Drawable.update] to trigger an update.
HELP
&jehan_pdb_misc('2024', '3.0');
@inargs = (
{ name => 'filter', type => 'filter',
desc => 'The filter' },
{ name => 'visible', type => 'boolean',
desc => "The new filter visibility" }
);
%invoke = (
code => <<'CODE'
{
gimp_filter_set_active (GIMP_FILTER (filter), visible);
}
CODE
);
}
sub drawable_filter_get_opacity {
$blurb = "Get the opacity of the specified filter.";
$help = "This procedure returns the specified filter's opacity.";
&jehan_pdb_misc('2024', '3.0');
@inargs = (
{ name => 'filter', type => 'filter',
desc => 'The filter' }
);
@outargs = (
{ name => 'opacity', type => 'double',
desc => "The filter's opacity" }
);
%invoke = (
code => <<'CODE'
{
opacity = gimp_drawable_filter_get_opacity (filter);
}
CODE
);
}
sub drawable_filter_get_blend_mode {
$blurb = "Get the blending mode of the specified filter.";
$help = "This procedure returns the specified filter's mode.";
&jehan_pdb_misc('2024', '3.0');
@inargs = (
{ name => 'filter', type => 'filter',
desc => 'The filter' }
);
@outargs = (
{ name => 'mode', type => 'enum GimpLayerMode',
desc => 'The effect blending mode' },
);
%invoke = (
code => <<'CODE'
{
mode = gimp_drawable_filter_get_paint_mode (filter);
}
CODE
);
}
sub drawable_filter_update {
$blurb = "Update the settings of the specified filter.";
$help = <<'HELP';
This procedure updates the settings of the specified filter all at once.
In particular, update will be frozen and will happen only once for all changed settings.
This PDB function is internal, meant to be private and its arguments will likely change as filters evolve.
It should not be used.
HELP
&jehan_pdb_misc('2024', '3.0');
$lib_private = 1;
@inargs = (
{ name => 'filter', type => 'filter',
desc => 'The filter' },
{ name => 'propnames', type => 'strv',
desc => 'Array of property names' },
{ name => 'propvalues', type => 'valuearray',
desc => 'Array of values, one per property in propnames' },
{ name => 'opacity', type => '0 <= double <= 100',
desc => "The filter's opacity" },
{ name => 'blend_mode', type => 'enum GimpLayerMode',
default => 'GIMP_LAYER_MODE_NORMAL',
desc => 'The effect blending mode' },
{ name => 'blend_space', type => 'enum GimpLayerColorSpace',
default => 'GIMP_LAYER_COLOR_SPACE_AUTO',
desc => 'The effect blending space' },
{ name => 'composite_mode', type => 'enum GimpLayerCompositeMode',
default => 'GIMP_LAYER_COMPOSITE_AUTO',
desc => 'The layer composite mode' },
{ name => 'composite_space', type => 'enum GimpLayerColorSpace',
default => 'GIMP_LAYER_COLOR_SPACE_AUTO',
desc => 'The effect composite space' },
{ name => 'auxinputnames', type => 'strv',
desc => 'Array of aux input pads' },
{ name => 'auxinputs', type => 'drawablearray', no_validate => 1,
desc => 'Array of drawables, one per auxinputnames' },
);
%invoke = (
code => <<'CODE'
{
success = gimp_drawable_filter_update (filter, propnames, propvalues,
opacity,
blend_mode, blend_space,
composite_mode, composite_space,
auxinputnames, auxinputs,
error);
}
CODE
);
}
sub drawable_filter_get_number_arguments {
$blurb = <<'BLURB';
Queries for the number of arguments on the specified filter.
BLURB
$help = <<'HELP';
This procedure returns the number of arguments on the specified filter.
For specific information on each input argument, use gimp_drawable_filter_get_argument().
HELP
&jehan_pdb_misc('2024', '3.0');
$lib_private = 1;
@inargs = (
{ name => 'filter', type => 'filter',
desc => 'The filter' }
);
@outargs = (
{ name => 'num_args', type => 'int32',
desc => 'The number of input arguments' },
);
%invoke = (
code => <<'CODE'
{
GeglNode *node;
const gchar *opname;
node = gimp_drawable_filter_get_operation (filter);
opname = gegl_node_get_operation (node);
if (gegl_has_operation (opname))
{
guint n_properties;
if (gimp_operation_config_is_custom (gimp, opname))
{
GimpObject *settings = NULL;
GObjectClass *klass;
GObjectClass *parent_klass;
guint n_parent_properties;
gegl_node_get (node,
"config", &settings,
NULL);
klass = G_OBJECT_GET_CLASS (settings);
parent_klass = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
g_free (g_object_class_list_properties (parent_klass, &n_parent_properties));
g_free (g_object_class_list_properties (klass, &n_properties));
g_clear_object (&settings);
n_properties -= n_parent_properties;
}
else
{
g_free (gegl_operation_list_properties (opname, &n_properties));
}
num_args = (gint) n_properties;
}
else
{
success = FALSE;
}
}
CODE
);
}
sub drawable_filter_get_pspec {
$blurb = <<BLURB;
Queries for information on the specified filter's argument.
BLURB
$help = <<HELP;
This procedure returns the #GParamSpec of filter's argument.
HELP
&jehan_pdb_misc('2024', '3.0');
$lib_private = 1;
@inargs = (
{ name => 'filter', type => 'filter',
desc => 'The filter' },
{ name => 'arg_num', type => 'int32',
desc => 'The argument number' }
);
@outargs = (
{ name => 'param_spec', type => 'param',
desc => "The GParamSpec of the argument" }
);
%invoke = (
code => <<'CODE'
{
GimpObject *settings = NULL;
GeglNode *node;
const gchar *opname;
node = gimp_drawable_filter_get_operation (filter);
opname = gegl_node_get_operation (node);
if (gegl_has_operation (opname))
{
GParamSpec **specs;
guint n_properties;
guint n_parent_properties = 0;
if (gimp_operation_config_is_custom (gimp, opname))
{
GObjectClass *klass;
GObjectClass *parent_klass;
gegl_node_get (node,
"config", &settings,
NULL);
klass = G_OBJECT_GET_CLASS (settings);
parent_klass = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
g_free (g_object_class_list_properties (parent_klass, &n_parent_properties));
}
if (settings != NULL)
specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (settings), &n_properties);
else
specs = gegl_operation_list_properties (opname, &n_properties);
if (arg_num >= 0 && n_parent_properties + arg_num < n_properties)
{
param_spec = g_param_spec_ref (specs[n_parent_properties + arg_num]);
}
else
{
success = FALSE;
}
g_free (specs);
}
else
{
success = FALSE;
}
g_clear_object (&settings);
}
CODE
);
}
sub drawable_filter_get_arguments {
$blurb = <<BLURB;
Returns the currently set filter arguments.
BLURB
$help = <<HELP;
This procedure returns the filter's arguments.
HELP
&jehan_pdb_misc('2024', '3.0');
$lib_private = 1;
@inargs = (
{ name => 'filter', type => 'filter', desc => 'The filter' },
);
@outargs = (
{ name => 'argnames', type => 'strv',
desc => "The names of the arguments" },
{ name => 'values', type => 'valuearray',
desc => "The values of the arguments in same order" }
);
%invoke = (
code => <<'CODE'
{
GeglNode *node;
const gchar *opname;
GParamSpec **specs;
guint n_specs;
guint n_parent_properties = 0;
GStrvBuilder *names_builder;
GimpObject *settings = NULL;
node = gimp_drawable_filter_get_operation (filter);
opname = gegl_node_get_operation (node);
if (gegl_has_operation (opname) &&
gimp_operation_config_is_custom (gimp, opname))
{
GObjectClass *klass;
GObjectClass *parent_klass;
gegl_node_get (node,
"config", &settings,
NULL);
klass = G_OBJECT_GET_CLASS (settings);
parent_klass = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
g_free (g_object_class_list_properties (parent_klass, &n_parent_properties));
}
if (settings != NULL)
{
specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (settings), &n_specs);
n_specs -= n_parent_properties;
}
else
{
specs = gegl_operation_list_properties (opname, &n_specs);
}
names_builder = g_strv_builder_new ();
values = gimp_value_array_new (n_specs);
for (gint i = 0; i < n_specs; i++)
{
GParamSpec *pspec = specs[n_parent_properties + i];
GValue value = G_VALUE_INIT;
g_value_init (&value, pspec->value_type);
if (settings != NULL)
g_object_get_property (G_OBJECT (settings), pspec->name, &value);
else
gegl_node_get_property (node, pspec->name, &value);
if (GEGL_IS_PARAM_SPEC_ENUM (pspec))
{
/* Special-casing GeglParamEnum which are passed as string to
* libgimp.
*/
GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);
GEnumClass *enum_class = espec->enum_class;
GValue string_value = G_VALUE_INIT;
gint int_enum = g_value_get_enum (&value);
g_value_init (&string_value, G_TYPE_STRING);
for (gint j = 0; j < enum_class->n_values; j++)
{
GEnumValue enum_value = enum_class->values[j];
if (enum_value.value < enum_class->minimum || enum_value.value > enum_class->maximum)
continue;
if (enum_value.value == espec->default_value)
g_value_set_string (&string_value, enum_value.value_nick);
}
for (gint j = 0; j < enum_class->n_values; j++)
{
GEnumValue enum_value = enum_class->values[j];
if (enum_value.value == int_enum)
g_value_set_string (&string_value, enum_value.value_nick);
}
gimp_value_array_append (values, &string_value);
g_value_unset (&string_value);
}
else
{
gimp_value_array_append (values, &value);
}
g_strv_builder_add (names_builder, pspec->name);
g_value_unset (&value);
}
argnames = g_strv_builder_end (names_builder);
g_strv_builder_unref (names_builder);
g_free (specs);
g_clear_object (&settings);
}
CODE
);
}
sub drawable_filter_delete {
$blurb = 'Delete a drawable filter.';
$help = <<'HELP';
This procedure deletes the specified filter. This must not be done if the
drawable whose this filter was applied to was already deleted or if the
drawable was already removed from the image.
Do not use anymore the @filter object after having deleted it.
HELP
&jehan_pdb_misc('2024', '3.0');
@inargs = (
{ name => 'filter', type => 'filter',
desc => 'The filter to delete' }
);
%invoke = (
code => <<'CODE'
{
GimpDrawable *drawable = gimp_drawable_filter_get_drawable (filter);
if (drawable && gimp_drawable_has_filter (drawable, GIMP_FILTER (filter)))
{
gimp_image_undo_push_filter_remove (gimp_item_get_image (GIMP_ITEM (drawable)),
_("Remove filter"), drawable, filter);
gimp_drawable_filter_abort (filter);
}
else
{
g_clear_object (&filter);
}
}
CODE
);
}
sub drawable_filter_operation_get_available {
$blurb = 'Get a list of all available GEGL operation names for drawable filters.';
$help = <<'HELP';
This procedure returns a list of all GEGL operation names available for use
with drawable filters.
HELP
&martymichal_pdb_misc('2025', '3.2');
@outargs = (
{
name => 'names', type => 'strv',
desc => 'The list of GEGL operation names',
}
);
%invoke = (
code => <<'CODE'
{
GList *ops = NULL;
GStrvBuilder *builder = NULL;
ops = gimp_gegl_get_op_classes (FALSE);
builder = g_strv_builder_new ();
for (GList *op = ops; op != NULL; op = op->next)
{
GeglOperationClass *op_klass = op->data;
g_strv_builder_add (builder, op_klass->name);
}
names = g_strv_builder_end (builder);
g_list_free (ops);
g_strv_builder_unref (builder);
}
CODE
);
}
sub drawable_filter_operation_get_details {
$blurb = 'Get information about a GEGL operation.';
$help = <<'HELP';
This procedure returns information about a GEGL operation. The content of the
list of information can vary across versions and currently can contain:
- a human-readable title of the operation,
- a description of the operation's behaviour,
- the categories the operation belongs to, and
- the license of the operation.
An operation can belong to no categories or to multiple categories. Multiple
categories are separated by the ':' character.
Some operation's license is not specifically set. In such cases, the returned
license is 'unknown'.
HELP
&martymichal_pdb_misc('2025', '3.2');
@inargs = (
{
name => 'operation_name', type => 'string',
desc => 'The GEGL operation\'s name',
}
);
@outargs = (
{
name => 'propnames', type => 'strv', void_ret => 1,
desc => 'The names of properties',
},
{
name => 'propvalues', type => 'valuearray',
desc => 'The values of properties in the same order',
},
);
%invoke = (
code => <<'CODE'
{
if (gimp_gegl_op_nde_allowed (operation_name, error))
{
GStrvBuilder *names_builder = NULL;
GeglOperationClass *klass = NULL;
gchar *license = NULL;
GType op_type;
GValue value = G_VALUE_INIT;
/* Comes from gegl/operation/gegl-operations.h which is not public. */
GType gegl_operation_gtype_from_name (const gchar *name);
names_builder = g_strv_builder_new ();
propvalues = gimp_value_array_new (0);
op_type = gegl_operation_gtype_from_name (operation_name);
klass = g_type_class_ref (op_type);
g_value_init (&value, G_TYPE_STRING);
g_strv_builder_add (names_builder, "title");
g_value_take_string (&value, g_strdup (gegl_operation_class_get_key (klass, "title")));
gimp_value_array_append (propvalues, &value);
g_strv_builder_add (names_builder, "description");
g_value_take_string (&value, g_strdup (gegl_operation_class_get_key (klass, "description")));
gimp_value_array_append (propvalues, &value);
g_strv_builder_add (names_builder, "categories");
g_value_take_string (&value, g_strdup (gegl_operation_class_get_key (klass, "categories")));
gimp_value_array_append (propvalues, &value);
license = g_strdup (gegl_operation_class_get_key (klass, "license"));
if (license == NULL)
license = g_strdup ("unknown");
g_strv_builder_add (names_builder, "license");
g_value_take_string (&value, license);
gimp_value_array_append (propvalues, &value);
propnames = g_strv_builder_end (names_builder);
g_strv_builder_unref (names_builder);
}
else
{
success = FALSE;
}
}
CODE
);
}
sub drawable_filter_operation_get_pspecs {
$blurb = 'Get information for all parameters of a GEGL operation.';
$help = <<'HELP';
This procedure returns a list of all parameters used to configure a GEGL
operation.
Each parameter is represented by GParamSpec.
HELP
&martymichal_pdb_misc('2025', '3.2');
@inargs = (
{
name => 'operation_name', type => 'string',
desc => 'The GEGL operation\'s name',
}
);
@outargs = (
{
name => 'pspecs', type => 'valuearray',
desc => "List of all parameters of the GEGL operation",
}
);
%invoke = (
code => <<'CODE'
{
if (gimp_gegl_op_nde_allowed (operation_name, error))
{
GParamSpec **specs = NULL;
guint n_specs = 0;
guint n_parent_specs = 0;
if (gimp_operation_config_is_custom (gimp, operation_name))
{
GObjectClass *op_config_klass = NULL;
GObjectClass *op_parent_klass = NULL;
GType op_config_type;
GType op_parent_type;
op_config_type = gimp_operation_config_get_type (gimp, operation_name, NULL, GIMP_TYPE_OPERATION_SETTINGS);
op_config_klass = g_type_class_ref (op_config_type);
specs = g_object_class_list_properties (op_config_klass, &n_specs);
g_type_class_unref (op_config_klass);
op_parent_type = g_type_parent (op_config_type);
op_parent_klass = g_type_class_ref (op_parent_type);
g_free (g_object_class_list_properties (op_parent_klass, &n_parent_specs));
g_type_class_unref (op_parent_klass);
n_specs -= n_parent_specs;
}
else
{
specs = gegl_operation_list_properties (operation_name, &n_specs);
}
pspecs = gimp_value_array_new (n_specs);
for (gint i = 0; i < n_specs; i++)
{
GParamSpec *pspec = specs[n_parent_specs + i];
GPParamDef param_def = { 0, };
GValue value = G_VALUE_INIT;
g_value_init (&value, G_TYPE_PARAM);
/* Make sure we do not try to send param specs over the wire
* if we don't support sending their type.
*/
if (! _gimp_param_spec_to_gp_param_def (pspec, ¶m_def, TRUE))
{
/* This is not technically a bug if an operation has
* unsupported argument types, because we cannot possibly
* support everything (third-party operations could have any
* kind of arguments; and even official ops have types
* such as audio fragment which we may never support).
* So this should not generate any WARNING. Yet we still
* want to softly notify developers, in case we can
* actually do something about some types.
*/
g_printerr ("%s: replacing argument '%s' of procedure '%s' with a placeholder. "
"Unsupported argument type '%s'.\n",
G_STRFUNC, pspec->name, operation_name,
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
g_value_set_param (&value, g_param_spec_param (
"unknown", "Unknown",
g_strdup_printf ("placeholder for unsupported type:%s:%s:%s",
pspec->name,
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
g_param_spec_get_blurb (pspec)),
G_TYPE_PARAM, G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
}
else
{
g_value_set_param (&value, g_param_spec_ref (pspec));
}
gimp_value_array_append (pspecs, &value);
g_value_unset (&value);
}
g_free (specs);
}
else
{
success = FALSE;
}
}
CODE
);
}
@headers = qw(<gegl.h>
<gegl-plugin.h>
"libgimpbase/gimpbase.h"
"libgimpbase/gimpprotocol.h"
"libgimpbase/gimpwire.h"
"libgimp/gimpgpparams.h"
"core/gimpcontainer.h"
"core/gimpdrawablefilter.h"
"core/gimpdrawable-filters.h"
"core/gimpimage-undo-push.h"
"core/gimpitem.h"
"gegl/gimp-gegl-utils.h"
"operations/gimp-operation-config.h"
"operations/gimpoperationsettings.h"
"gimppdberror.h"
"gimp-intl.h");
@procs = qw(drawable_filter_id_is_valid
drawable_filter_new
drawable_filter_get_name
drawable_filter_get_operation_name
drawable_filter_get_visible
drawable_filter_set_visible
drawable_filter_get_opacity
drawable_filter_get_blend_mode
drawable_filter_update
drawable_filter_get_number_arguments
drawable_filter_get_pspec
drawable_filter_get_arguments
drawable_filter_delete
drawable_filter_operation_get_available
drawable_filter_operation_get_details
drawable_filter_operation_get_pspecs);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Drawable Filter';
$doc_title = 'gimpdrawablefilter';
$doc_short_desc = 'Operations on drawable filters.';
$doc_long_desc = 'Operations on drawable filters: creation, editing.';
1;
|