context.pdb 72.7 KB
Newer Older
1
# GIMP - The GNU Image Manipulation Program
2
3
# Copyright (C) 1995 Spencer Kimball and Peter Mattis

4
# This program is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 3 of the License, or
7
8
9
10
11
12
13
14
# (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
15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

# "Perlized" from C source by Manish Singh <yosh@gimp.org>

sub pdb_misc {
   $author = 'Michael Natterer <mitch@gimp.org> & Sven Neumann <sven@gimp.org>';
   $copyright = 'Michael Natterer & Sven Neumann';
   $date = '2004';
   $since = '2.2';
}

sub context_push {
    $blurb = 'Pushes a context to the top of the plug-in\'s context stack.';

    $help = <<'HELP';
This procedure creates a new context by copying the current context. This
copy becomes the new current context for the calling plug-in until it is
32
popped again using gimp_context_pop().
33
34
35
36
37
38
39
HELP

    &pdb_misc;

    %invoke = (
	code => <<'CODE'
{
40
41
42
43
  GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;

  if (plug_in && plug_in->open)
    success = gimp_plug_in_context_push (plug_in);
44
  else
45
    success = FALSE;
46
47
48
49
50
51
52
53
54
}
CODE
    );
}

sub context_pop {
    $blurb = 'Pops the topmost context from the plug-in\'s context stack.';

    $help = <<'HELP';
55
56
57
This procedure removes the topmost context from the plug-in's context
stack.  The context that was active before the corresponding call to
gimp_context_push() becomes the new current context of the plug-in.
58
59
60
61
62
63
64
HELP

    &pdb_misc;

    %invoke = (
	code => <<'CODE'
{
65
66
67
68
  GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;

  if (plug_in && plug_in->open)
    success = gimp_plug_in_context_pop (plug_in);
69
  else
70
    success = FALSE;
71
72
73
74
75
}
CODE
    );
}

76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
sub context_set_defaults {
    $blurb = 'Reset context settings to their default values.';

    $help = <<'HELP';
This procedure resets context settings used by various procedures to their
default value. This procedure will usually be called after a context push
so that a script which calls procedures affected by context settings will
not be affected by changes in the global context.
HELP

    $author = 'Kevin Cozens <kcozens@svn.gnome.org>';
    $copyright = 'Kevin Cozens';
    $date = '2011';
    $since = '2.8';

    %invoke = (
	code => <<'CODE'
{
    gimp_config_reset (GIMP_CONFIG (context));
}
CODE
    );
}

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
sub context_list_paint_methods {
    $blurb = 'Lists the available paint methods.';

    $help = <<'HELP';
This procedure lists the names of the available paint methods. Any
of the results can be used for gimp_context_set_paint_method().
HELP

    &simon_pdb_misc('2007', '2.4');

    @outargs = (
        { name => 'paint_methods', type => 'stringarray', void_ret => 1,
          desc => 'The names of the available paint methods',
          array => { desc => 'The number of the available paint methods' } }
    );

    %invoke = (
        code => <<'CODE'
{
  paint_methods = gimp_container_get_name_array (gimp->paint_info_list,
                                                 &num_paint_methods);
}
CODE
    );
}

126
127
128
129
130
131
132
sub context_get_paint_method {
    $blurb = 'Retrieve the currently active paint method.';

    $help = <<'HELP';
This procedure returns the name of the currently active paint method.
HELP

133
    &mitch_pdb_misc('2005', '2.4');
134
135

    @outargs = (
136
	{ name  => 'name', type  => 'string',
137
	  desc  => 'The name of the active paint method' }
138
139
140
    );

    %invoke = (
141
142
143
144
145
	code => <<'CODE'
{
  GimpPaintInfo *paint_info = gimp_context_get_paint_info (context);

  if (paint_info)
146
    name = g_strdup (gimp_object_get_name (paint_info));
147
148
149
150
  else
    success = FALSE;
}
CODE
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
    );
}

sub context_set_paint_method {
    $blurb = 'Set the specified paint method as the active paint method.';

    $help = <<'HELP';
This procedure allows the active paint method to be set by specifying
its name.  The name is simply a string which corresponds to one of the
names of the available paint methods. If there is no matching method
found, this procedure will return an error.  Otherwise, the specified
method becomes active and will be used in all subsequent paint
operations.
HELP

166
    &mitch_pdb_misc('2005', '2.4');
167
168

    @inargs = (
169
        { name => 'name', type => 'string', non_empty => 1,
170
171
172
173
174
175
          desc => 'The name of the paint method' }
    );

    %invoke = (
	code => <<'CODE'
{
176
  GimpPaintInfo *paint_info = gimp_pdb_get_paint_info (gimp, name, error);
177
178
179
180
181
182
183
184
185
186

  if (paint_info)
    gimp_context_set_paint_info (context, paint_info);
  else
    success = FALSE;
}
CODE
    );
}

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
sub context_get_stroke_method {
    $blurb = 'Retrieve the currently active stroke method.';

    $help = <<'HELP';
This procedure returns the currently active stroke method.
HELP

    &mitch_pdb_misc('2015', '2.10');

    @outargs = (
	{ name  => 'stroke_method', type  => 'enum GimpStrokeMethod',
	  desc  => 'The active stroke method' }
    );

    %invoke = (
	code => <<'CODE'
{
  GimpStrokeOptions *options =
    gimp_pdb_context_get_stroke_options (GIMP_PDB_CONTEXT (context));

  g_object_get (options,
                "method", &stroke_method,
		NULL);
}
CODE
    );
}

sub context_set_stroke_method {
    $blurb = 'Set the specified stroke method as the active stroke method.';

    $help = <<'HELP';
This procedure set the specified stroke method as the active stroke
method. The new method will be used in all subsequent stroke
operations.
HELP

    &mitch_pdb_misc('2015', '2.10');

    @inargs = (
        { name => 'stroke_method', type => 'enum GimpStrokeMethod',
          desc => 'The new stroke method' }
    );

    %invoke = (
	code => <<'CODE'
{
  GimpStrokeOptions *options =
    gimp_pdb_context_get_stroke_options (GIMP_PDB_CONTEXT (context));

  g_object_set (options,
                "method", stroke_method,
		NULL);
}
CODE
    );
}
244

245
246
247
248
sub context_get_foreground {
    $blurb = "Get the current GIMP foreground color.";

    $help = <<'HELP';
249
This procedure returns the current GIMP foreground color. The foreground
250
251
252
253
254
255
256
color is used in a variety of tools such as paint tools, blending, and bucket
fill.
HELP

    &pdb_misc;

    @outargs = (
257
258
        { name => 'foreground', type => 'color', void_ret => 1,
          desc => 'The foreground color' }
259
260
    );

261
262
263
264
    %invoke = (
	code => <<'CODE'
{
  gimp_context_get_foreground (context, &foreground);
265
  gimp_rgb_set_alpha (&foreground, 1.0);
266
267
268
}
CODE
    );
269
270
271
272
273
274
275
276
277
278
279
280
281
282
}

sub context_set_foreground {
    $blurb = "Set the current GIMP foreground color.";

    $help = <<'HELP';
This procedure sets the current GIMP foreground color. After this is set,
operations which use foreground such as paint tools, blending, and bucket fill
will use the new value.
HELP

    &pdb_misc;

    @inargs = (
283
284
        { name => 'foreground', type => 'color', void_ret => 1,
          desc => 'The foreground color' }
285
286
287
    );

    %invoke = (
288
	code => <<'CODE'
289
{
290
291
  gimp_rgb_set_alpha (&foreground, 1.0);
  gimp_context_set_foreground (context, &foreground);
292
293
294
295
296
297
298
299
300
}
CODE
    );
}

sub context_get_background {
    $blurb = "Get the current GIMP background color.";

    $help = <<'HELP';
301
This procedure returns the current GIMP background color. The background
302
303
304
305
306
307
308
color is used in a variety of tools such as blending, erasing (with non-alpha
images), and image filling.
HELP

    &pdb_misc;

    @outargs = (
309
310
        { name => 'background', type => 'color', void_ret => 1,
          desc => 'The background color' }
311
312
    );

313
314
315
316
    %invoke = (
	code => <<'CODE'
{
  gimp_context_get_background (context, &background);
317
  gimp_rgb_set_alpha (&background, 1.0);
318
319
320
}
CODE
    );
321
322
323
324
325
326
327
328
329
330
331
332
333
334
}

sub context_set_background {
    $blurb = "Set the current GIMP background color.";

    $help = <<'HELP';
This procedure sets the current GIMP background color. After this is set,
operations which use background such as blending, filling images, clearing,
and erasing (in non-alpha images) will use the new value.
HELP

    &pdb_misc;

    @inargs = (
335
336
        { name => 'background', type => 'color', void_ret => 1,
          desc => 'The background color' }
337
338
339
    );

    %invoke = (
340
	code => <<'CODE'
341
{
342
343
  gimp_rgb_set_alpha (&background, 1.0);
  gimp_context_set_background (context, &background);
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
}
CODE
    );
}

sub context_set_default_colors {
    $blurb = <<'BLURB';
Set the current GIMP foreground and background colors to black and white.
BLURB

    $help = <<'HELP';
This procedure sets the current GIMP foreground and background colors to their
initial default values, black and white.
HELP

    &pdb_misc;

361
362
363
364
365
366
367
    %invoke = (
	code => <<'CODE'
{
  gimp_context_set_default_colors (context);
}
CODE
    );
368
369
370
371
372
373
374
375
376
377
}

sub context_swap_colors {
    $blurb = 'Swap the current GIMP foreground and background colors.';

    $help = <<'HELP';
This procedure swaps the current GIMP foreground and background colors, so that
the new foreground color becomes the old background color and vice versa.
HELP

378
    &pdb_misc;
379

380
381
382
383
384
385
386
    %invoke = (
	code => <<'CODE'
{
  gimp_context_swap_colors (context);
}
CODE
    );
387
388
}

389
390
391
392
393
394
395
396
397
398
399
sub context_get_opacity {
    $blurb = 'Get the opacity.';

    $help = <<'HELP';
This procedure returns the opacity setting. The return
value is a floating point number between 0 and 100.
HELP

    &pdb_misc;

    @outargs = (
400
        { name => 'opacity', type => '0 <= float <= 100',
401
          desc => 'The opacity' }
402
403
404
405
406
407
408
409
    );

    %invoke = (
	code => <<'CODE'
{
  opacity = gimp_context_get_opacity (context) * 100.0;
}
CODE
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
    );
}

sub context_set_opacity {
    $blurb = 'Set the opacity.';

    $help = <<'HELP';
This procedure modifies the opacity setting. The value
should be a floating point number between 0 and 100.
HELP

    &pdb_misc;

    @inargs = (
        { name => 'opacity', type => '0 <= float <= 100',
425
          desc => 'The opacity' }
426
427
    );

428
429
430
431
432
433
434
    %invoke = (
	code => <<'CODE'
{
  gimp_context_set_opacity (context, opacity / 100.0);
}
CODE
    );
435
436
437
438
439
440
441
442
443
444
445
446
447
448
}

sub context_get_paint_mode {
    $blurb = 'Get the paint mode.';

    $help = <<'HELP';
This procedure returns the paint-mode setting. The return value
is an integer which corresponds to the values listed in the argument
description.
HELP

    &pdb_misc;

    @outargs = (
449
        { name => 'paint_mode', type => 'enum GimpLayerMode',
450
          default => 'GIMP_LAYER_MODE_NORMAL',
451
          desc => 'The paint mode' }
452
453
454
455
456
457
458
459
    );

    %invoke = (
	code => <<'CODE'
{
  paint_mode = gimp_context_get_paint_mode (context);
}
CODE
460
461
462
463
464
465
466
467
468
469
470
471
472
    );
}

sub context_set_paint_mode {
    $blurb = 'Set the paint mode.';

    $help = <<'HELP';
This procedure modifies the paint_mode setting.
HELP

    &pdb_misc;

    @inargs = (
473
        { name => 'paint_mode', type => 'enum GimpLayerMode',
474
          default => 'GIMP_LAYER_MODE_NORMAL',
475
          desc => 'The paint mode' }
476
477
    );

478
479
480
    %invoke = (
	code => <<'CODE'
{
481
482
  if (paint_mode == GIMP_LAYER_MODE_OVERLAY_LEGACY)
    paint_mode = GIMP_LAYER_MODE_SOFTLIGHT_LEGACY;
483

484
485
486
487
  gimp_context_set_paint_mode (context, paint_mode);
}
CODE
    );
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
sub context_get_line_width {
    $blurb = 'Get the line width setting.';

    $help = <<'HELP';
This procedure returns the line width setting.
HELP

    &mitch_pdb_misc('2015', '2.10');

    @outargs = (
        { name => 'line_width', type => '0.0 <= float <= 2000.0',
          desc => 'The line width setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  GimpStrokeOptions *options =
    gimp_pdb_context_get_stroke_options (GIMP_PDB_CONTEXT (context));

  g_object_get (options,
                "width", &line_width,
                NULL);
}
CODE
    );
}

sub context_set_line_width {
    $blurb = 'Set the line width setting.';

    $help = <<'HELP';
This procedure modifies the line width setting for stroking lines.

This setting affects the following procedures:
gimp_edit_stroke(), gimp_edit_stroke_vectors().
HELP

    &mitch_pdb_misc('2015', '2.10');

    @inargs = (
        { name => 'line_width', type => '0.0 <= float <= 2000.0',
          desc => 'The line width setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  GimpStrokeOptions *options =
    gimp_pdb_context_get_stroke_options (GIMP_PDB_CONTEXT (context));

  g_object_set (options,
                "width", line_width,
                NULL);
}
CODE
    );
}

sub context_get_line_width_unit {
    $blurb = 'Get the line width unit setting.';

    $help = <<'HELP';
This procedure returns the line width unit setting.
HELP

    &mitch_pdb_misc('2015', '2.10');

    @outargs = (
        { name => 'line_width_unit', type => 'unit',
          desc => 'The line width unit setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  GimpStrokeOptions *options =
    gimp_pdb_context_get_stroke_options (GIMP_PDB_CONTEXT (context));

  g_object_get (options,
                "unit", &line_width_unit,
                NULL);
}
CODE
    );
}

sub context_set_line_width_unit {
    $blurb = 'Set the line width unit setting.';

    $help = <<'HELP';
This procedure modifies the line width unit setting for stroking lines.

This setting affects the following procedures:
gimp_edit_stroke(), gimp_edit_stroke_vectors().
HELP

    &mitch_pdb_misc('2015', '2.10');

    @inargs = (
        { name => 'line_width_unit', type => 'unit',
          desc => 'The line width setting unit' }
    );

    %invoke = (
	code => <<'CODE'
{
  GimpStrokeOptions *options =
    gimp_pdb_context_get_stroke_options (GIMP_PDB_CONTEXT (context));

  g_object_set (options,
                "unit", line_width_unit,
                NULL);
}
CODE
    );
}

sub context_get_line_cap_style {
    $blurb = 'Get the line cap style setting.';

    $help = <<'HELP';
This procedure returns the line cap style setting.
HELP

    &mitch_pdb_misc('2015', '2.10');

    @outargs = (
        { name => 'cap_style', type => 'enum GimpCapStyle',
          desc => 'The line cap style setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  GimpStrokeOptions *options =
    gimp_pdb_context_get_stroke_options (GIMP_PDB_CONTEXT (context));

  g_object_get (options,
                "cap-style", &cap_style,
                NULL);
}
CODE
    );
}

sub context_set_line_cap_style {
    $blurb = 'Set the line cap style setting.';

    $help = <<'HELP';
This procedure modifies the line cap style setting for stroking lines.

This setting affects the following procedures:
gimp_edit_stroke(), gimp_edit_stroke_vectors().
HELP

    &mitch_pdb_misc('2015', '2.10');

    @inargs = (
        { name => 'cap_style', type => 'enum GimpCapStyle',
          desc => 'The line cap style setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  GimpStrokeOptions *options =
    gimp_pdb_context_get_stroke_options (GIMP_PDB_CONTEXT (context));

  g_object_set (options,
                "cap-style", cap_style,
                NULL);
}
CODE
    );
}

sub context_get_line_join_style {
    $blurb = 'Get the line join style setting.';

    $help = <<'HELP';
This procedure returns the line join style setting.
HELP

    &mitch_pdb_misc('2015', '2.10');

    @outargs = (
        { name => 'join_style', type => 'enum GimpJoinStyle',
          desc => 'The line join style setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  GimpStrokeOptions *options =
    gimp_pdb_context_get_stroke_options (GIMP_PDB_CONTEXT (context));

  g_object_get (options,
                "join-style", &join_style,
                NULL);
}
CODE
    );
}

sub context_set_line_join_style {
    $blurb = 'Set the line join style setting.';

    $help = <<'HELP';
This procedure modifies the line join style setting for stroking lines.

This setting affects the following procedures:
gimp_edit_stroke(), gimp_edit_stroke_vectors().
HELP

    &mitch_pdb_misc('2015', '2.10');

    @inargs = (
        { name => 'join_style', type => 'enum GimpJoinStyle',
          desc => 'The line join style setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  GimpStrokeOptions *options =
    gimp_pdb_context_get_stroke_options (GIMP_PDB_CONTEXT (context));

  g_object_set (options,
                "join-style", join_style,
                NULL);
}
CODE
    );
}

sub context_get_line_miter_limit {
    $blurb = 'Get the line miter limit setting.';

    $help = <<'HELP';
This procedure returns the line miter limit setting.
HELP

    &mitch_pdb_misc('2015', '2.10');

    @outargs = (
        { name => 'miter_limit', type => '0.0 <= float <= 100.0',
          desc => 'The line miter limit setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  GimpStrokeOptions *options =
    gimp_pdb_context_get_stroke_options (GIMP_PDB_CONTEXT (context));

  g_object_get (options,
                "miter-limit", &miter_limit,
                NULL);
}
CODE
    );
}

sub context_set_line_miter_limit {
    $blurb = 'Set the line miter limit setting.';

    $help = <<'HELP';
This procedure modifies the line miter limit setting for stroking lines.

A mitered join is converted to a bevelled join if the miter would
extend to a distance of more than (miter-limit * line-width) from the
actual join point.

This setting affects the following procedures:
gimp_edit_stroke(), gimp_edit_stroke_vectors().
HELP

    &mitch_pdb_misc('2015', '2.10');

    @inargs = (
        { name => 'miter_limit', type => '0.0 <= float <= 100.0',
          desc => 'The line miter limit setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  GimpStrokeOptions *options =
    gimp_pdb_context_get_stroke_options (GIMP_PDB_CONTEXT (context));

  g_object_set (options,
                "miter-limit", miter_limit,
                NULL);
}
CODE
    );
}

sub context_get_line_dash_offset {
    $blurb = 'Get the line dash offset setting.';

    $help = <<'HELP';
This procedure returns the line dash offset setting.
HELP

    &mitch_pdb_misc('2015', '2.10');

    @outargs = (
        { name => 'dash_offset', type => '0.0 <= float <= 2000.0',
          desc => 'The line dash offset setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  GimpStrokeOptions *options =
    gimp_pdb_context_get_stroke_options (GIMP_PDB_CONTEXT (context));

  g_object_get (options,
                "dash-offset", &dash_offset,
                NULL);
}
CODE
    );
}

sub context_set_line_dash_offset {
    $blurb = 'Set the line dash offset setting.';

    $help = <<'HELP';
This procedure modifies the line dash offset setting for stroking lines.

This setting affects the following procedures:
gimp_edit_stroke(), gimp_edit_stroke_vectors().
HELP

    &mitch_pdb_misc('2015', '2.10');

    @inargs = (
        { name => 'dash_offset', type => '0.0 <= float <= 100.0',
          desc => 'The line dash offset setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  GimpStrokeOptions *options =
    gimp_pdb_context_get_stroke_options (GIMP_PDB_CONTEXT (context));

  g_object_set (options,
                "dash-offset", dash_offset,
                NULL);
}
CODE
    );
}

sub context_get_line_dash_pattern {
    $blurb = 'Get the line dash pattern setting.';

    $help = <<'HELP';
This procedure returns the line dash pattern setting.
HELP

    &mitch_pdb_misc('2015', '2.10');

    @outargs = (
        { name => 'dashes', type => 'floatarray', void_ret => 1,
          desc => 'The line dash pattern setting',
          array => { desc => 'The number of dashes in the dash_pattern array' } }
    );

    %invoke = (
	code => <<'CODE'
{
  GimpStrokeOptions *options =
    gimp_pdb_context_get_stroke_options (GIMP_PDB_CONTEXT (context));

  GArray *pattern = gimp_stroke_options_get_dash_info (options);

  dashes = gimp_dash_pattern_to_double_array (pattern, &num_dashes);
}
CODE
    );
}

sub context_set_line_dash_pattern {
    $blurb = 'Set the line dash pattern setting.';

    $help = <<'HELP';
This procedure modifies the line dash pattern setting for stroking lines.

The unit of the dash pattern segments is the actual line width used
Richard Kreckel's avatar
Richard Kreckel committed
884
for the stroke operation, in other words a segment length of 1.0
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
results in a square segment shape (or gap shape).

This setting affects the following procedures:
gimp_edit_stroke(), gimp_edit_stroke_vectors().
HELP

    &mitch_pdb_misc('2015', '2.10');

    @inargs = (
        { name => 'dashes', type => 'floatarray',
          desc => 'The line dash pattern setting',
          array => { desc => 'The number of dashes in the dash_pattern array' } }
    );

    %invoke = (
	code => <<'CODE'
{
  GimpStrokeOptions *options =
    gimp_pdb_context_get_stroke_options (GIMP_PDB_CONTEXT (context));

  GArray *pattern = NULL;

  if (num_dashes > 0)
    {
      pattern = gimp_dash_pattern_from_double_array (num_dashes, dashes);

      if (! pattern)
        success = FALSE;
    }

  if (success)
    gimp_stroke_options_take_dash_pattern (options, GIMP_DASH_CUSTOM, pattern);
}
CODE
    );
}

922
923
924
925
sub context_get_brush {
    $blurb = 'Retrieve the currently active brush.';

    $help = <<'HELP';
926
This procedure returns the name of the currently active brush.
927
928
929
930
931
932
933
All paint operations and stroke operations use this brush to control
the application of paint to the image.
HELP

    &pdb_misc;

    @outargs = (
934
	{ name  => 'name', type  => 'string',
935
	  desc  => 'The name of the active brush' }
936
937
938
    );

    %invoke = (
939
940
941
942
943
	code => <<'CODE'
{
  GimpBrush *brush = gimp_context_get_brush (context);

  if (brush)
944
    name = g_strdup (gimp_object_get_name (brush));
945
946
947
948
  else
    success = FALSE;
}
CODE
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
    );
}

sub context_set_brush {
    $blurb = 'Set the specified brush as the active brush.';

    $help = <<'HELP';
This procedure allows the active brush to be set by specifying its name.
The name is simply a string which corresponds to one of the names of the
installed brushes. If there is no matching brush found, this procedure will
return an error.  Otherwise, the specified brush becomes active and will be
used in all subsequent paint operations.
HELP

    &pdb_misc;

    @inargs = (
966
        { name => 'name', type => 'string', non_empty => 1,
967
          desc => 'The name of the brush' }
968
969
970
971
972
    );

    %invoke = (
	code => <<'CODE'
{
973
  GimpBrush *brush = gimp_pdb_get_brush (gimp, name, FALSE, error);
974
975
976
977
978
979
980
981
982
983

  if (brush)
    gimp_context_set_brush (context, brush);
  else
    success = FALSE;
}
CODE
    );
}

984
985
986
987
988
989
sub context_get_brush_size {
    $blurb = 'Get brush size in pixels.';
    $help = 'Get the brush size in pixels for brush based paint tools.';

    &ejs_pdb_misc('2012', '2.8');

990
    @outargs = (
991
        { name => "size", type => "0 < float",
992
          desc => "Brush size in pixels" }
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
    );

    %invoke = (
	code => <<'CODE'
{
  /* all options should have the same value, so pick a random one */
  GimpPaintOptions *options =
    gimp_pdb_context_get_paint_options (GIMP_PDB_CONTEXT (context),
                                        "gimp-paintbrush");

  if (options)
    g_object_get (options,
                  "brush-size", &size,
                   NULL);
  else
    success = FALSE;
}
CODE
    );
}

sub context_set_brush_size {
    $blurb = 'Set brush size in pixels.';
    $help = 'Set the brush size in pixels for brush based paint tools.';

    &ejs_pdb_misc('2012', '2.8');

    @inargs = (
1021
        { name => "size", type => "1 <= float <= 10000",
1022
          desc => "Brush size in pixels" }
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
    );

    %invoke = (
	code => <<'CODE'
{
  GList *options;
  GList *list;

  options = gimp_pdb_context_get_brush_options (GIMP_PDB_CONTEXT (context));

  for (list = options; list; list = g_list_next (list))
    g_object_set (list->data,
                  "brush-size", (gdouble) size,
                   NULL);

  g_list_free (options);
}
CODE
    );
}

sub context_set_brush_default_size {
    $blurb = 'Set brush size to its default.';
    $help = <<'HELP';
Set the brush size to the default (max of width and height) for
paintbrush, airbrush, or pencil tools.
HELP

    &ejs_pdb_misc('2012', '2.8');

    %invoke = (
	code => <<'CODE'
{
  GimpBrush *brush = gimp_context_get_brush (context);

  if (brush)
    {
      GList *options;
      GList *list;

      options = gimp_pdb_context_get_brush_options (GIMP_PDB_CONTEXT (context));

      for (list = options; list; list = g_list_next (list))
1066
        gimp_paint_options_set_default_brush_size (list->data, brush);
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086

      g_list_free (options);
    }
  else
    {
      success = FALSE;
    }
}
CODE
    );
}

sub context_set_brush_aspect_ratio {
    $blurb = 'Set brush aspect ratio.';
    $help = 'Set the aspect ratio for brush based paint tools.';

    &ejs_pdb_misc('2012', '2.8');

    @inargs = (
        { name => "aspect", type => "-20 <= float <= 20",
1087
          desc => "Aspect ratio" }
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
    );

    %invoke = (
	code => <<'CODE'
{
  GList *options;
  GList *list;

  options = gimp_pdb_context_get_brush_options (GIMP_PDB_CONTEXT (context));

  for (list = options; list; list = g_list_next (list))
    g_object_set (list->data,
                  "brush-aspect-ratio", (gdouble) aspect,
                   NULL);

  g_list_free (options);
}
CODE
    );
}

sub context_get_brush_aspect_ratio {
    $blurb = 'Get brush aspect ratio.';
    $help = 'Set the aspect ratio for brush based paint tools.';

    &ejs_pdb_misc('2012', '2.8');

1115
    @outargs = (
1116
        { name => "aspect", type => "-20 <= float <= 20",
1117
          desc => "Aspect ratio" }
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
    );

    %invoke = (
	code => <<'CODE'
{
  /* all options should have the same value, so pick a random one */
  GimpPaintOptions *options =
    gimp_pdb_context_get_paint_options (GIMP_PDB_CONTEXT (context),
                                        "gimp-paintbrush");

  if (options)
    g_object_get (options,
                  "brush-aspect-ratio", &aspect,
                  NULL);
  else
    success = FALSE;
}
CODE
    );
}

sub context_set_brush_angle {
    $blurb = 'Set brush angle in degrees.';
    $help = 'Set the angle in degrees for brush based paint tools.';

    &ejs_pdb_misc('2012', '2.8');

    @inargs = (
	{ name => "angle", type => "-180 <= float <= 180",
1147
	  desc => "Angle in degrees" }
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
    );

    %invoke = (
	code => <<'CODE'
{
  GList *options;
  GList *list;

  options = gimp_pdb_context_get_brush_options (GIMP_PDB_CONTEXT (context));

  for (list = options; list; list = g_list_next (list))
    g_object_set (list->data,
                  "brush-angle", (gdouble) angle,
                   NULL);

  g_list_free (options);
}
CODE
    );
}

sub context_get_brush_angle {
    $blurb = 'Get brush angle in degrees.';
    $help = 'Set the angle in degrees for brush based paint tools.';

    &ejs_pdb_misc('2012', '2.8');

1175
    @outargs = (
1176
	{ name => "angle", type => "-180 <= float <= 180",
1177
	  desc => "Angle in degrees" }
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
    );

    %invoke = (
	code => <<'CODE'
{
  /* all options should have the same value, so pick a random one */
  GimpPaintOptions *options =
    gimp_pdb_context_get_paint_options (GIMP_PDB_CONTEXT (context),
                                        "gimp-paintbrush");

  if (options)
    g_object_get (options,
                  "brush-angle", &angle,
                  NULL);
  else
    success = FALSE;
}
CODE
    );
}

1199
1200
1201
1202
sub context_get_brush_spacing {
    $blurb = 'Get brush spacing as percent of size.';
    $help = 'Get the brush spacing as percent of size for brush based paint tools.';

1203
    &adeath_pdb_misc('2014', '2.10');
1204

1205
    @outargs = (
1206
1207
        { name => "spacing", type => "0.01 <= float <= 50.0",
          desc => "Brush spacing as fraction of size" }
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
    );

    %invoke = (
	code => <<'CODE'
{
  /* all options should have the same value, so pick a random one */
  GimpPaintOptions *options =
    gimp_pdb_context_get_paint_options (GIMP_PDB_CONTEXT (context),
                                        "gimp-paintbrush");

  if (options)
    g_object_get (options,
                  "brush-spacing", &spacing,
                   NULL);
  else
    success = FALSE;
}
CODE
    );
}

sub context_set_brush_spacing {
    $blurb = 'Set brush spacing as percent of size.';
    $help = 'Set the brush spacing as percent of size for brush based paint tools.';

    &adeath_pdb_misc('2014', '2.10');

    @inargs = (
1236
1237
        { name => "spacing", type => "0.01 <= float <= 50.0",
          desc => "Brush spacing as fraction of size" }
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
    );

    %invoke = (
	code => <<'CODE'
{
  GList *options;
  GList *list;

  options = gimp_pdb_context_get_brush_options (GIMP_PDB_CONTEXT (context));

  for (list = options; list; list = g_list_next (list))
    g_object_set (list->data,
                  "brush-spacing", (gdouble) spacing,
                   NULL);

  g_list_free (options);
}
CODE
    );
}

sub context_set_brush_default_spacing {
    $blurb = 'Set brush spacing to its default.';
    $help = <<'HELP';
Set the brush spacing to the default  for
paintbrush, airbrush, or pencil tools.
HELP

    &adeath_pdb_misc('2014', '2.10');

    %invoke = (
	code => <<'CODE'
{
  GimpBrush *brush = gimp_context_get_brush (context);

  if (brush)
    {
      GList *options;
      GList *list;

      options = gimp_pdb_context_get_brush_options (GIMP_PDB_CONTEXT (context));

      for (list = options; list; list = g_list_next (list))
        gimp_paint_options_set_default_brush_spacing (list->data, brush);

      g_list_free (options);
    }
  else
    {
      success = FALSE;
    }
}
CODE
    );
}

sub context_get_brush_hardness {
    $blurb = 'Get brush hardness in paint options.';
    $help = 'Get the brush hardness for brush based paint tools.';

    &adeath_pdb_misc('2014', '2.10');

    @outargs = (
1301
1302
        { name => "hardness", type => "0.0 <= float <= 1.0",
          desc => "Brush hardness" }
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
    );

    %invoke = (
	code => <<'CODE'
{
  /* all options should have the same value, so pick a random one */
  GimpPaintOptions *options =
    gimp_pdb_context_get_paint_options (GIMP_PDB_CONTEXT (context),
                                        "gimp-paintbrush");

  if (options)
    g_object_get (options,
                  "brush-hardness", &hardness,
                   NULL);
  else
    success = FALSE;
}
CODE
    );
}

sub context_set_brush_hardness {
    $blurb = 'Set brush hardness.';
    $help = 'Set the brush hardness for brush based paint tools.';

    &adeath_pdb_misc('2014', '2.10');

    @inargs = (
1331
1332
        { name => "hardness", type => "0.0 <= float <= 1.0",
          desc => "Brush hardness" }
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
    );

    %invoke = (
	code => <<'CODE'
{
  GList *options;
  GList *list;

  options = gimp_pdb_context_get_brush_options (GIMP_PDB_CONTEXT (context));

  for (list = options; list; list = g_list_next (list))
    g_object_set (list->data,
1345
                  "brush-hardness", (gdouble) hardness,
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
                   NULL);

  g_list_free (options);
}
CODE
    );
}

sub context_set_brush_default_hardness {
    $blurb = 'Set brush spacing to its default.';
    $help = <<'HELP';
Set the brush spacing to the default  for
paintbrush, airbrush, or pencil tools.
HELP

    &adeath_pdb_misc('2014', '2.10');

    %invoke = (
	code => <<'CODE'
{
  GimpBrush *brush = gimp_context_get_brush (context);

  if (brush)
    {
      GList *options;
      GList *list;

      options = gimp_pdb_context_get_brush_options (GIMP_PDB_CONTEXT (context));

      for (list = options; list; list = g_list_next (list))
        gimp_paint_options_set_default_brush_hardness (list->data, brush);

      g_list_free (options);
    }
  else
    {
      success = FALSE;
    }
}
CODE
    );
}

sub context_get_brush_force {
    $blurb = 'Get brush force in paint options.';
    $help = 'Get the brush application force for brush based paint tools.';

    &adeath_pdb_misc('2014', '2.10');

    @outargs = (
1396
1397
        { name => "force", type => "0.0 <= float <= 1.0",
          desc => "Brush application force" }
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
    );

    %invoke = (
	code => <<'CODE'
{
  /* all options should have the same value, so pick a random one */
  GimpPaintOptions *options =
    gimp_pdb_context_get_paint_options (GIMP_PDB_CONTEXT (context),
                                        "gimp-paintbrush");

  if (options)
    g_object_get (options,
                  "brush-force", &force,
                   NULL);
  else
    success = FALSE;
}
CODE
    );
}

sub context_set_brush_force {
    $blurb = 'Set brush application force.';
    $help = 'Set the brush application force for brush based paint tools.';

    &adeath_pdb_misc('2014', '2.10');

    @inargs = (
1426
1427
        { name => "force", type => "0.0 <= float <= 1.0",
          desc => "Brush application force" }
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
    );

    %invoke = (
	code => <<'CODE'
{
  GList *options;
  GList *list;

  options = gimp_pdb_context_get_brush_options (GIMP_PDB_CONTEXT (context));

  for (list = options; list; list = g_list_next (list))
    g_object_set (list->data,
1440
                  "brush-force", (gdouble) force,
1441
1442
1443
1444
1445
1446
1447
1448
                   NULL);

  g_list_free (options);
}
CODE
    );
}

1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
sub context_get_dynamics {
    $blurb = 'Retrieve the currently active paint dynamics.';

    $help = <<'HELP';
This procedure returns the name of the currently active paint
dynamics.  All paint operations and stroke operations use this paint
dynamics to control the application of paint to the image.
HELP

    &mitch_pdb_misc('2011', '2.8');

    @outargs = (
	{ name  => 'name', type  => 'string',
	  desc  => 'The name of the active paint dynamics' }
    );

    %invoke = (
	code => <<'CODE'
{
  GimpDynamics *dynamics = gimp_context_get_dynamics (context);

  if (dynamics)
    name = g_strdup (gimp_object_get_name (dynamics));
  else
    success = FALSE;
}
CODE
    );
}

sub context_set_dynamics {
    $blurb = 'Set the specified paint dynamics as the active paint dynamics.';

    $help = <<'HELP';
This procedure allows the active paint dynamics to be set by
specifying its name.  The name is simply a string which corresponds to
one of the names of the installed paint dynamics. If there is no
matching paint dynamics found, this procedure will return an error.
Otherwise, the specified paint dynamics becomes active and will be
used in all subsequent paint operations.
HELP

    &mitch_pdb_misc('2011', '2.8');

    @inargs = (
        { name => 'name', type => 'string', non_empty => 1,
          desc => 'The name of the paint dynamics' }
    );

    %invoke = (
	code => <<'CODE'
{
1501
  GimpDynamics *dynamics = gimp_pdb_get_dynamics (gimp, name, GIMP_PDB_DATA_ACCESS_READ, error);
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511

  if (dynamics)
    gimp_context_set_dynamics (context, dynamics);
  else
    success = FALSE;
}
CODE
    );
}

1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
sub context_get_mypaint_brush {
    $blurb = 'Retrieve the currently active MyPaint brush.';

    $help = <<'HELP';
This procedure returns the name of the currently active MyPaint brush.
HELP

    &mitch_pdb_misc('2016', '2.10');

    @outargs = (
	{ name  => 'name', type  => 'string',
	  desc  => 'The name of the active MyPaint brush' }
    );

    %invoke = (
	code => <<'CODE'
{
  GimpMybrush *brush = gimp_context_get_mybrush (context);

  if (brush)
    name = g_strdup (gimp_object_get_name (brush));
  else
    success = FALSE;
}
CODE
    );
}

sub context_set_mypaint_brush {
    $blurb = 'Set the specified MyPaint brush as the active MyPaint brush.';

    $help = <<'HELP';
This procedure allows the active MyPaint brush to be set by
specifying its name.  The name is simply a string which corresponds to
one of the names of the installed MyPaint brushes. If there is no
matching MyPaint brush found, this procedure will return an error.
Otherwise, the specified MyPaint brush becomes active and will be
used in all subsequent MyPaint paint operations.
HELP

    &mitch_pdb_misc('2016', '2.10');

    @inargs = (
        { name => 'name', type => 'string', non_empty => 1,
          desc => 'The name of the MyPaint brush' }
    );

    %invoke = (
	code => <<'CODE'
{
1562
  GimpMybrush *brush = gimp_pdb_get_mybrush (gimp, name, GIMP_PDB_DATA_ACCESS_READ, error);
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572

  if (brush)
    gimp_context_set_mybrush (context, brush);
  else
    success = FALSE;
}
CODE
    );
}

1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
sub context_get_pattern {
    $blurb = 'Retrieve the currently active pattern.';

    $help = <<'HELP';
This procedure returns name of the the currently active pattern.
All clone and bucket-fill operations with patterns will use this
pattern to control the application of paint to the image.
HELP

    &pdb_misc;

    @outargs = (
1585
	{ name  => 'name', type  => 'string',
1586
	  desc  => 'The name of the active pattern' }
1587
1588
1589
    );

    %invoke = (
1590
1591
1592
1593
1594
	code => <<'CODE'
{
  GimpPattern *pattern = gimp_context_get_pattern (context);

  if (pattern)
1595
    name = g_strdup (gimp_object_get_name (pattern));
1596
1597
1598
1599
  else
    success = FALSE;
}
CODE
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
    );
}

sub context_set_pattern {
    $blurb = 'Set the specified pattern as the active pattern.';

    $help = <<'HELP';
This procedure allows the active pattern to be set by specifying its name.
The name is simply a string which corresponds to one of the names of the
installed patterns. If there is no matching pattern found, this procedure will
return an error. Otherwise, the specified pattern becomes active and will be
used in all subsequent paint operations.
HELP

    &pdb_misc;

    @inargs = (
1617
        { name => 'name', type => 'string', non_empty => 1,
1618
1619
1620
1621
1622
1623
          desc => 'The name of the pattern' }
    );

    %invoke = (
	code => <<'CODE'
{
1624
  GimpPattern *pattern = gimp_pdb_get_pattern (gimp, name, error);
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644

  if (pattern)
    gimp_context_set_pattern (context, pattern);
  else
    success = FALSE;
}
CODE
    );
}

sub context_get_gradient {
    $blurb = 'Retrieve the currently active gradient.';

    $help = <<'HELP';
This procedure returns the name of the currently active gradient.
HELP

    &pdb_misc;

    @outargs = (
1645
	{ name  => 'name', type  => 'string',
1646
	  desc  => 'The name of the active gradient' }
1647
1648
1649
    );

    %invoke = (
1650
1651
1652
1653
1654
	code => <<'CODE'
{
  GimpGradient *gradient = gimp_context_get_gradient (context);

  if (gradient)
1655
    name = g_strdup (gimp_object_get_name (gradient));
1656
1657
1658
1659
  else
    success = FALSE;
}
CODE
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
    );
}

sub context_set_gradient {
    $blurb = 'Sets the specified gradient as the active gradient.';

    $help = <<'HELP';
This procedure lets you set the specified gradient as the active or "current"
one. The name is simply a string which corresponds to one of the loaded
gradients. If no matching gradient is found, this
procedure will return an error. Otherwise, the specified gradient will become
active and will be used for subsequent custom gradient operations.
HELP

    &pdb_misc;

    @inargs = (
1677
	{ name => 'name', type => 'string', non_empty => 1,
1678
1679
1680
1681
1682
1683
	  desc => 'The name of the gradient' }
    );

    %invoke = (
        code => <<'CODE'
{
1684
  GimpGradient *gradient = gimp_pdb_get_gradient (gimp, name, FALSE, error);
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704

  if (gradient)
    gimp_context_set_gradient (context, gradient);
  else
    success = FALSE;
}
CODE
    );
}

sub context_get_palette {
    $blurb = 'Retrieve the currently active palette.';

    $help = <<'HELP';
This procedure returns the name of the the currently active palette.
HELP

    &pdb_misc;

    @outargs = (
1705
	{ name  => 'name', type  => 'string',
1706
	  desc  => 'The name of the active palette' }
1707
1708
1709
    );

    %invoke = (
1710
1711
1712
1713
1714
        code => <<'CODE'
{
  GimpPalette *palette = gimp_context_get_palette (context);

  if (palette)
1715
    name = g_strdup (gimp_object_get_name (palette));
1716
1717
1718
1719
  else
    success = FALSE;
}
CODE
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
    );
}

sub context_set_palette {
    $blurb = 'Set the specified palette as the active palette.';

    $help = <<'HELP';
This procedure allows the active palette to be set by specifying its name.
The name is simply a string which corresponds to one of the names of the
installed palettes. If no matching palette is found, this procedure will
return an error. Otherwise, the specified palette becomes active and will be
used in all subsequent palette operations.
HELP

    &pdb_misc;

    @inargs = (
1737
	{ name => 'name', type => 'string', non_empty => 1,
1738
1739
1740
1741
1742
1743
	  desc => 'The name of the palette' }
    );

    %invoke = (
        code => <<'CODE'
{
1744
  GimpPalette *palette = gimp_pdb_get_palette (gimp, name, FALSE, error);
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764

  if (palette)
    gimp_context_set_palette (context, palette);
  else
    success = FALSE;
}
CODE
    );
}

sub context_get_font {
    $blurb = 'Retrieve the currently active font.';

    $help = <<'HELP';
This procedure returns the name of the currently active font.
HELP

    &pdb_misc;

    @outargs = (
1765
	{ name  => 'name', type  => 'string',
1766
	  desc  => 'The name of the active font' }
1767
1768
1769
    );

    %invoke = (
1770
1771
1772
1773
1774
        code => <<'CODE'
{
  GimpFont *font = gimp_context_get_font (context);

  if (font)
1775
    name = g_strdup (gimp_object_get_name (font));
1776
1777
1778
1779
  else
    success = FALSE;
}
CODE
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
    );
}

sub context_set_font {
    $blurb = 'Set the specified font as the active font.';

    $help = <<'HELP';
This procedure allows the active font to be set by specifying its name.
The name is simply a string which corresponds to one of the names of the
installed fonts. If no matching font is found, this procedure will
return an error. Otherwise, the specified font becomes active and will be
used in all subsequent font operations.
HELP

    &pdb_misc;

    @inargs = (
1797
	{ name => 'name', type => 'string', non_empty => 1,
1798
1799
1800
1801
1802
1803
	  desc => 'The name of the font' }
    );

    %invoke = (
        code => <<'CODE'
{
1804
  GimpFont *font = gimp_pdb_get_font (gimp, name, error);
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814

  if (font)
    gimp_context_set_font (context, font);
  else
    success = FALSE;
}
CODE
    );
}

1815
1816
1817
1818
1819
1820
1821
sub context_get_antialias {
    $blurb = 'Get the antialias setting.';

    $help = <<'HELP';
This procedure returns the antialias setting.
HELP

Michael Natterer's avatar
Michael Natterer committed
1822
    &mitch_pdb_misc('2010', '2.8');
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843

    @outargs = (
        { name => 'antialias', type => 'boolean',
          desc => 'The antialias setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  g_object_get (context,
                "antialias", &antialias,
                NULL);
}
CODE
    );
}

sub context_set_antialias {
    $blurb = 'Set the antialias setting.';

    $help = <<'HELP';
1844
1845
1846
1847
This procedure modifies the antialias setting. If antialiasing is
turned on, the edges of selected region will contain intermediate
values which give the appearance of a sharper, less pixelized edge.
This should be set as TRUE most of the time unless a binary-only
1848
1849
selection is wanted.

1850
This setting affects the following procedures:
1851
1852
1853
gimp_image_select_color(), gimp_image_select_contiguous_color(),
gimp_image_select_round_rectangle(), gimp_image_select_ellipse(),
gimp_image_select_polygon(), gimp_image_select_item().
1854
1855
HELP

Michael Natterer's avatar
Michael Natterer committed
1856
    &mitch_pdb_misc('2010', '2.8');
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880

    @inargs = (
        { name => 'antialias', type => 'boolean',
          desc => 'The antialias setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  g_object_set (context,
                "antialias", antialias,
                NULL);
}
CODE
    );
}

sub context_get_feather {
    $blurb = 'Get the feather setting.';

    $help = <<'HELP';
This procedure returns the feather setting.
HELP

Michael Natterer's avatar
Michael Natterer committed
1881
    &mitch_pdb_misc('2010', '2.8');
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902

    @outargs = (
        { name => 'feather', type => 'boolean',
          desc => 'The feather setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  g_object_get (context,
                "feather", &feather,
                NULL);
}
CODE
    );
}

sub context_set_feather {
    $blurb = 'Set the feather setting.';

    $help = <<'HELP';
1903
1904
1905
This procedure modifies the feather setting. If the feather option is
enabled, selections will be blurred before combining. The blur is a
gaussian blur; its radii can be controlled using
1906
1907
1908
gimp_context_set_feather_radius().

This setting affects the following procedures:
1909
gimp_image_select_color(), gimp_image_select_contiguous_color(),
1910
gimp_image_select_rectangle(), gimp_image_select_round_rectangle(),
1911
gimp_image_select_ellipse(), gimp_image_select_polygon(),
1912
gimp_image_select_item().
1913
1914
HELP

Michael Natterer's avatar
Michael Natterer committed
1915
    &mitch_pdb_misc('2010', '2.8');
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939

    @inargs = (
        { name => 'feather', type => 'boolean',
          desc => 'The feather setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  g_object_set (context,
                "feather", feather,
                NULL);
}
CODE
    );
}

sub context_get_feather_radius {
    $blurb = 'Get the feather radius setting.';

    $help = <<'HELP';
This procedure returns the feather radius setting.
HELP

Michael Natterer's avatar
Michael Natterer committed
1940
    &mitch_pdb_misc('2010', '2.8');
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964

    @outargs = (
        { name => 'feather_radius_x', type => '0 <= float <= 1000', void_ret => 1,
          desc => 'The horizontal feather radius' },
        { name => 'feather_radius_y', type => '0 <= float <= 1000',
          desc => 'The vertical feather radius' }
    );

    %invoke = (
	code => <<'CODE'
{
  g_object_get (context,
                "feather-radius-x", &feather_radius_x,
                "feather-radius-y", &feather_radius_y,
                NULL);
}
CODE
    );
}

sub context_set_feather_radius {
    $blurb = 'Set the feather radius setting.';

    $help = <<'HELP';
1965
1966
This procedure modifies the feather radius setting.

1967
This setting affects all procedures that are affected
1968
by gimp_context_set_feather().
1969
1970
HELP

Michael Natterer's avatar
Michael Natterer committed
1971
    &mitch_pdb_misc('2010', '2.8');
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990

    @inargs = (
        { name => 'feather_radius_x', type => '0 <= float <= 1000',
          desc => 'The horizontal feather radius' },
        { name => 'feather_radius_y', type => '0 <= float <= 1000',
          desc => 'The vertical feather radius' }
    );

    %invoke = (
	code => <<'CODE'
{
  g_object_set (context,
                "feather-radius-x", feather_radius_x,
                "feather-radius-y", feather_radius_y,
                NULL);
}
CODE
    );
}
1991

1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
sub context_get_sample_merged {
    $blurb = 'Get the sample merged setting.';

    $help = <<'HELP';
This procedure returns the sample merged setting.
HELP

    &mitch_pdb_misc('2011', '2.8');

    @outargs = (
        { name => 'sample_merged', type => 'boolean',
          desc => 'The sample merged setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  g_object_get (context,
                "sample-merged", &sample_merged,
                NULL);
}
CODE
    );
}

sub context_set_sample_merged {
    $blurb = 'Set the sample merged setting.';

    $help = <<'HELP';
This procedure modifies the sample merged setting. If an operation
depends on the colors of the pixels present in a drawable, like when
doing a seed fill, this setting controls whether the pixel data from
the specified drawable is used ('sample-merged' is FALSE), or the
pixel data from the composite image ('sample-merged' is TRUE. This is
2026
2027
2028
equivalent to sampling for colors after merging all visible layers).

This setting affects the following procedures:
2029
gimp_image_select_color(), gimp_image_select_contiguous_color().
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
HELP

    &mitch_pdb_misc('2011', '2.8');

    @inargs = (
        { name => 'sample_merged', type => 'boolean',
          desc => 'The sample merged setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  g_object_set (context,
                "sample-merged", sample_merged,
                NULL);
}
CODE
    );
}

2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
sub context_get_sample_criterion {
    $blurb = 'Get the sample criterion setting.';

    $help = <<'HELP';
This procedure returns the sample criterion setting.
HELP

    &mitch_pdb_misc('2011', '2.8');

    @outargs = (
        { name => 'sample_criterion', type => 'enum GimpSelectCriterion',
          desc => 'The sample criterion setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  g_object_get (context,
                "sample-criterion", &sample_criterion,
                NULL);
}
CODE
    );
}

sub context_set_sample_criterion {
2076
    $blurb = 'Set the sample criterion setting.';
2077
2078
2079
2080
2081

    $help = <<'HELP';
This procedure modifies the sample criterion setting. If an operation
depends on the colors of the pixels present in a drawable, like when
doing a seed fill, this setting controls how color similarity is
2082
2083
2084
determined. SELECT_CRITERION_COMPOSITE is the default value.

This setting affects the following procedures:
2085
gimp_image_select_color(), gimp_image_select_contiguous_color().
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
HELP

    &mitch_pdb_misc('2011', '2.8');

    @inargs = (
        { name => 'sample_criterion', type => 'enum GimpSelectCriterion',
          desc => 'The sample criterion setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  g_object_set (context,
                "sample-criterion", sample_criterion,
                NULL);
}
CODE
    );
}

2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
sub context_get_sample_threshold {
    $blurb = 'Get the sample threshold setting.';

    $help = <<'HELP';
This procedure returns the sample threshold setting.
HELP

    &mitch_pdb_misc('2011', '2.8');

    @outargs = (
        { name => 'sample_threshold', type => '0.0 <= float <= 1.0',
          desc => 'The sample threshold setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  g_object_get (context,
                "sample-threshold", &sample_threshold,
                NULL);
}
CODE
    );
}

sub context_set_sample_threshold {
    $blurb = 'Set the sample threshold setting.';

    $help = <<'HELP';
This procedure modifies the sample threshold setting. If an operation
depends on the colors of the pixels present in a drawable, like when
doing a seed fill, this setting controls what is "sufficiently close"
to be considered a similar color. If the sample threshold has not been
set explicitly, the default threshold set in gimprc will be used.
2140
2141

This setting affects the following procedures:
2142
gimp_image_select_color(), gimp_image_select_contiguous_color().
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
HELP

    &mitch_pdb_misc('2011', '2.8');

    @inargs = (
        { name => 'sample_threshold', type => '0.0 <= float <= 1.0',
          desc => 'The sample threshold setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  g_object_set (context,
                "sample-threshold", sample_threshold,
                NULL);
}
CODE
    );
}

sub context_get_sample_threshold_int {
    $blurb = 'Get the sample threshold setting as an integer value.';

    $help = <<'HELP';
2167
2168
This procedure returns the sample threshold setting as an integer
value. See gimp_context_get_sample_threshold().
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
HELP

    &mitch_pdb_misc('2011', '2.8');

    @outargs = (
        { name => 'sample_threshold', type => '0 <= int32 <= 255',
          desc => 'The sample threshold setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  gdouble threshold;

  g_object_get (context,
                "sample-threshold", &threshold,
                NULL);

  sample_threshold = (gint) (threshold * 255.99);
}
CODE
    );
}

sub context_set_sample_threshold_int {
    $blurb = 'Set the sample threshold setting as an integer value.';

    $help = <<'HELP';
2197
2198
This procedure modifies the sample threshold setting as an integer
value. See gimp_context_set_sample_threshold().
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
HELP

    &mitch_pdb_misc('2011', '2.8');

    @inargs = (
        { name => 'sample_threshold', type => '0 <= int32 <= 255',
          desc => 'The sample threshold setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  g_object_set (context,
                "sample-threshold", (gdouble) sample_threshold / 255.0,
                NULL);
}
CODE
    );
}

2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
sub context_get_sample_transparent {
    $blurb = 'Get the sample transparent setting.';

    $help = <<'HELP';
This procedure returns the sample transparent setting.
HELP

    &mitch_pdb_misc('2011', '2.8');

    @outargs = (
        { name => 'sample_transparent', type => 'boolean',
          desc => 'The sample transparent setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  g_object_get (context,
                "sample-transparent", &sample_transparent,
                NULL);
}
CODE
    );
}

sub context_set_sample_transparent {
    $blurb = 'Set the sample transparent setting.';

    $help = <<'HELP';
This procedure modifies the sample transparent setting. If an
operation depends on the colors of the pixels present in a drawable,
like when doing a seed fill, this setting controls whether
transparency is considered to be a unique selectable color. When this
2252
2253
2254
setting is TRUE, transparent areas can be selected or filled.

This setting affects the following procedures:
2255
gimp_image_select_color(), gimp_image_select_contiguous_color().
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
HELP

    &mitch_pdb_misc('2011', '2.8');

    @inargs = (
        { name => 'sample_transparent', type => 'boolean',
          desc => 'The sample transparent setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  g_object_set (context,
                "sample-transparent", sample_transparent,
                NULL);
}
CODE
    );
}

2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
sub context_get_diagonal_neighbors {
    $blurb = 'Get the diagonal neighbors setting.';

    $help = <<'HELP';
This procedure returns the diagonal neighbors setting.
HELP

    $author = 'Ell';
    $copyright = 'Ell';
    $date = '2016';
    $since = '2.10';

    @outargs = (
        { name => 'diagonal_neighbors', type => 'boolean',
          desc => 'The diagonal neighbors setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  g_object_get (context,
                "diagonal-neighbors", &diagonal_neighbors,
                NULL);
}
CODE
    );
}

sub context_set_diagonal_neighbors {
    $blurb = 'Set the diagonal neighbors setting.';

    $help = <<'HELP';
This procedure modifies the diagonal neighbors setting. If the affected
region of an operation is based on a seed point, like when doing a seed
fill, then, when this setting is TRUE, all eight neighbors of each pixel
are considered when calculating the affected region; in contrast, when
Richard Kreckel's avatar
Richard Kreckel committed
2312
this setting is FALSE, only the four orthogonal neighbors of each pixel
2313
are considered.
2314
2315
2316

This setting affects the following procedures:
gimp_image_select_contiguous_color().
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
HELP

    $author = 'Ell';
    $copyright = 'Ell';
    $date = '2016';
    $since = '2.10';

    @inargs = (
        { name => 'diagonal_neighbors', type => 'boolean',
          desc => 'The diagonal neighbors setting' }
    );

    %invoke = (
	code => <<'CODE'
{
  g_object_set (context,
                "diagonal-neighbors", diagonal_neighbors,
                NULL);
}
CODE
    );
}

2340
2341
2342
2343
2344
2345
sub context_get_interpolation {
    $blurb = 'Get the interpolation type.';

    $help = <<'HELP';
This procedure returns the interpolation setting. The return value
is an integer which corresponds to the values listed in the argument
2346
2347
2348
description. If the interpolation has not been set explicitly by
gimp_context_set_interpolation(), the default interpolation set in
gimprc will be used.
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
HELP

    &mitch_pdb_misc('2010', '2.8');

    @outargs = (
        { name => 'interpolation', type => 'enum GimpInterpolationType',
          desc => 'The interpolation type' }
    );

    %invoke = (
	code => <<'CODE'
{
  g_object_get (context,
                "interpolation", &interpolation,
                NULL);
}
CODE
    );
}

sub context_set_interpolation {
    $blurb = 'Set the interpolation type.';

    $help = <<'HELP';
2373
2374
2375
2376
2377
2378
2379
This procedure modifies the interpolation setting.

This setting affects affects the following procedures:
gimp_item_transform_flip(), gimp_item_transform_perspective(),
gimp_item_transform_rotate(), gimp_item_transform_scale(),
gimp_item_transform_shear(), gimp_item_transform_2d(),
gimp_item_transform_matrix(), gimp_image_scale(), gimp_layer_scale().
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
HELP

    &mitch_pdb_misc('2010', '2.8');

    @inargs = (
        { name => 'interpolation', type => 'enum GimpInterpolationType',
          desc => 'The interpolation type' }
    );

    %invoke = (
	code => <<'CODE'
{
  g_object_set (context,
                "interpolation", interpolation,
                NULL);
}
CODE
    );
}

sub context_get_transform_direction {
    $blurb = 'Get the transform direction.';

    $help = <<'HELP';
This procedure returns the transform direction. The return value
is an integer which corresponds to the values listed in the argument
description.
HELP

    &mitch_pdb_misc('2010', '2.8');

    @outargs = (
        { name => 'transform_direction', type => 'enum GimpTransformDirection',
          desc => 'The transform direction' }
    );

    %invoke = (
	code => <<'CODE'
{
  g_object_get (context,
                "transform-direction", &transform_direction,
                NULL);
}
CODE
    );
}

sub context_set_transform_direction {
    $blurb = 'Set the transform direction.';

    $help = <<'HELP';
This procedure modifies the transform direction setting.
2432
2433
2434
2435
2436
2437

This setting affects affects the following procedures:
gimp_item_transform_flip(), gimp_item_transform_perspective(),
gimp_item_transform_rotate(), gimp_item_transform_scale(),
gimp_item_transform_shear(), gimp_item_transform_2d(),
gimp_item_transform_matrix().
2438
2439
2440