context-actions.c 27.6 KB
Newer Older
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
/* The GIMP -- an 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 2 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#include "config.h"

#include <gtk/gtk.h>

#include "libgimpwidgets/gimpwidgets.h"

#include "actions-types.h"

#include "core/gimp.h"
#include "core/gimpbrushgenerated.h"
#include "core/gimpcontext.h"
#include "core/gimplist.h"

#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"

#include "actions.h"
#include "context-actions.h"
#include "context-commands.h"

#include "gimp-intl.h"


/*  local function prototypes  */

static GimpActionEntry context_actions[] =
{
46 47 48 49
  { "context-menu",            NULL,                      N_("_Context")    },
  { "context-colors-menu",     GIMP_STOCK_DEFAULT_COLORS, N_("_Colors")     },
  { "context-opacity-menu",    GIMP_STOCK_TRANSPARENCY,   N_("_Opacity")    },
  { "context-paint-mode-menu", GIMP_STOCK_TOOL_PENCIL,    N_("Paint _Mode") },
50
  { "context-tool-menu",       GIMP_STOCK_TOOLS,          N_("_Tool")       },
51 52 53 54 55 56 57 58 59 60 61 62
  { "context-brush-menu",      GIMP_STOCK_BRUSH,          N_("_Brush")      },
  { "context-pattern-menu",    GIMP_STOCK_PATTERN,        N_("_Pattern")    },
  { "context-palette-menu",    GIMP_STOCK_PALETTE,        N_("_Palette")    },
  { "context-gradient-menu",   GIMP_STOCK_GRADIENT,       N_("_Gradient")   },
  { "context-font-menu",       GIMP_STOCK_FONT,           N_("_Font")       },

  { "context-brush-shape-menu",    NULL,                  N_("_Shape")      },
  { "context-brush-radius-menu",   NULL,                  N_("_Radius")     },
  { "context-brush-spikes-menu",   NULL,                  N_("S_pikes")     },
  { "context-brush-hardness-menu", NULL,                  N_("_Hardness")   },
  { "context-brush-aspect-menu",   NULL,                  N_("_Aspect")     },
  { "context-brush-angle-menu",    NULL,                  N_("A_ngle")      },
63

64 65 66 67 68 69 70 71 72 73 74
  { "context-colors-default", GIMP_STOCK_DEFAULT_COLORS,
    N_("_Default Colors"), "D", NULL,
    G_CALLBACK (context_colors_default_cmd_callback),
    GIMP_HELP_TOOLBOX_DEFAULT_COLORS },

  { "context-colors-swap", GIMP_STOCK_SWAP_COLORS,
    N_("S_wap Colors"), "X", NULL,
    G_CALLBACK (context_colors_swap_cmd_callback),
    GIMP_HELP_TOOLBOX_SWAP_COLORS }
};

75 76
static GimpEnumActionEntry context_foreground_red_actions[] =
{
77
  { "context-foreground-red-set", GIMP_STOCK_CHANNEL_RED,
78
    "Foreground Red Set", NULL, NULL,
79
    GIMP_ACTION_SELECT_SET,
80
    NULL },
81
  { "context-foreground-red-minimum", GIMP_STOCK_CHANNEL_RED,
82
    "Foreground Red Minimum", NULL, NULL,
83
    GIMP_ACTION_SELECT_FIRST,
84
    NULL },
85
  { "context-foreground-red-maximum", GIMP_STOCK_CHANNEL_RED,
86
    "Foreground Red Maximum", NULL, NULL,
87
    GIMP_ACTION_SELECT_LAST,
88
    NULL },
89
  { "context-foreground-red-decrease", GIMP_STOCK_CHANNEL_RED,
90
    "Foreground Red Decrease", NULL, NULL,
91
    GIMP_ACTION_SELECT_PREVIOUS,
92
    NULL },
93
  { "context-foreground-red-increase", GIMP_STOCK_CHANNEL_RED,
94
    "Foreground Red Increase", NULL, NULL,
95
    GIMP_ACTION_SELECT_NEXT,
96
    NULL },
97
  { "context-foreground-red-decrease-skip", GIMP_STOCK_CHANNEL_RED,
98
    "Foreground Red Decrease 10%", NULL, NULL,
99
    GIMP_ACTION_SELECT_SKIP_PREVIOUS,
100
    NULL },
101
  { "context-foreground-red-increase-skip", GIMP_STOCK_CHANNEL_RED,
102
    "Foreground Red Increase 10%", NULL, NULL,
103
    GIMP_ACTION_SELECT_SKIP_NEXT,
104 105 106 107 108
    NULL }
};

static GimpEnumActionEntry context_foreground_green_actions[] =
{
109
  { "context-foreground-green-set", GIMP_STOCK_CHANNEL_GREEN,
110
    "Foreground Green Set", NULL, NULL,
111
    GIMP_ACTION_SELECT_SET,
112
    NULL },
113
  { "context-foreground-green-minimum", GIMP_STOCK_CHANNEL_GREEN,
114
    "Foreground Green Minimum", NULL, NULL,
115
    GIMP_ACTION_SELECT_FIRST,
116
    NULL },
117
  { "context-foreground-green-maximum", GIMP_STOCK_CHANNEL_GREEN,
118
    "Foreground Green Maximum", NULL, NULL,
119
    GIMP_ACTION_SELECT_LAST,
120
    NULL },
121
  { "context-foreground-green-decrease", GIMP_STOCK_CHANNEL_GREEN,
122
    "Foreground Green Decrease", NULL, NULL,
123
    GIMP_ACTION_SELECT_PREVIOUS,
124
    NULL },
125
  { "context-foreground-green-increase", GIMP_STOCK_CHANNEL_GREEN,
126
    "Foreground Green Increase", NULL, NULL,
127
    GIMP_ACTION_SELECT_NEXT,
128
    NULL },
129
  { "context-foreground-green-decrease-skip", GIMP_STOCK_CHANNEL_GREEN,
130
    "Foreground Green Decrease 10%", NULL, NULL,
131
    GIMP_ACTION_SELECT_SKIP_PREVIOUS,
132
    NULL },
133
  { "context-foreground-green-increase-skip", GIMP_STOCK_CHANNEL_GREEN,
134
    "Foreground Green Increase 10%", NULL, NULL,
135
    GIMP_ACTION_SELECT_SKIP_NEXT,
136 137 138 139 140
    NULL }
};

static GimpEnumActionEntry context_foreground_blue_actions[] =
{
141
  { "context-foreground-blue-set", GIMP_STOCK_CHANNEL_BLUE,
142
    "Foreground Blue Set", NULL, NULL,
143
    GIMP_ACTION_SELECT_SET,
144
    NULL },
145
  { "context-foreground-blue-minimum", GIMP_STOCK_CHANNEL_BLUE,
146
    "Foreground Blue Minimum", NULL, NULL,
147
    GIMP_ACTION_SELECT_FIRST,
148
    NULL },
149
  { "context-foreground-blue-maximum", GIMP_STOCK_CHANNEL_BLUE,
150
    "Foreground Blue Maximum", NULL, NULL,
151
    GIMP_ACTION_SELECT_LAST,
152
    NULL },
153
  { "context-foreground-blue-decrease", GIMP_STOCK_CHANNEL_BLUE,
154
    "Foreground Blue Decrease", NULL, NULL,
155
    GIMP_ACTION_SELECT_PREVIOUS,
156
    NULL },
157
  { "context-foreground-blue-increase", GIMP_STOCK_CHANNEL_BLUE,
158
    "Foreground Blue Increase", NULL, NULL,
159
    GIMP_ACTION_SELECT_NEXT,
160
    NULL },
161
  { "context-foreground-blue-decrease-skip", GIMP_STOCK_CHANNEL_BLUE,
162
    "Foreground Blue Decrease 10%", NULL, NULL,
163
    GIMP_ACTION_SELECT_SKIP_PREVIOUS,
164
    NULL },
165
  { "context-foreground-blue-increase-skip", GIMP_STOCK_CHANNEL_BLUE,
166
    "Foreground Blue Increase 10%", NULL, NULL,
167
    GIMP_ACTION_SELECT_SKIP_NEXT,
168 169 170 171 172
    NULL }
};

static GimpEnumActionEntry context_background_red_actions[] =
{
173
  { "context-background-red-set", GIMP_STOCK_CHANNEL_RED,
174
    "Background Red Set", NULL, NULL,
175
    GIMP_ACTION_SELECT_SET,
176
    NULL },
177
  { "context-background-red-minimum", GIMP_STOCK_CHANNEL_RED,
178
    "Background Red Minimum", NULL, NULL,
179
    GIMP_ACTION_SELECT_FIRST,
180
    NULL },
181
  { "context-background-red-maximum", GIMP_STOCK_CHANNEL_RED,
182
    "Background Red Maximum", NULL, NULL,
183
    GIMP_ACTION_SELECT_LAST,
184
    NULL },
185
  { "context-background-red-decrease", GIMP_STOCK_CHANNEL_RED,
186
    "Background Red Decrease", NULL, NULL,
187
    GIMP_ACTION_SELECT_PREVIOUS,
188
    NULL },
189
  { "context-background-red-increase", GIMP_STOCK_CHANNEL_RED,
190
    "Background Red Increase", NULL, NULL,
191
    GIMP_ACTION_SELECT_NEXT,
192
    NULL },
193
  { "context-background-red-decrease-skip", GIMP_STOCK_CHANNEL_RED,
194
    "Background Red Decrease 10%", NULL, NULL,
195
    GIMP_ACTION_SELECT_SKIP_PREVIOUS,
196
    NULL },
197
  { "context-background-red-increase-skip", GIMP_STOCK_CHANNEL_RED,
198
    "Background Red Increase 10%", NULL, NULL,
199
    GIMP_ACTION_SELECT_SKIP_NEXT,
200 201 202 203 204
    NULL }
};

static GimpEnumActionEntry context_background_green_actions[] =
{
205
  { "context-background-green-set", GIMP_STOCK_CHANNEL_GREEN,
206
    "Background Green Set", NULL, NULL,
207
    GIMP_ACTION_SELECT_SET,
208
    NULL },
209
  { "context-background-green-minimum", GIMP_STOCK_CHANNEL_GREEN,
210
    "Background Green Minimum", NULL, NULL,
211
    GIMP_ACTION_SELECT_FIRST,
212
    NULL },
213
  { "context-background-green-maximum", GIMP_STOCK_CHANNEL_GREEN,
214
    "Background Green Maximum", NULL, NULL,
215
    GIMP_ACTION_SELECT_LAST,
216
    NULL },
217
  { "context-background-green-decrease", GIMP_STOCK_CHANNEL_GREEN,
218
    "Background Green Decrease", NULL, NULL,
219
    GIMP_ACTION_SELECT_PREVIOUS,
220
    NULL },
221
  { "context-background-green-increase", GIMP_STOCK_CHANNEL_GREEN,
222
    "Background Green Increase", NULL, NULL,
223
    GIMP_ACTION_SELECT_NEXT,
224
    NULL },
225
  { "context-background-green-decrease-skip", GIMP_STOCK_CHANNEL_GREEN,
226
    "Background Green Decrease 10%", NULL, NULL,
227
    GIMP_ACTION_SELECT_SKIP_PREVIOUS,
228
    NULL },
229
  { "context-background-green-increase-skip", GIMP_STOCK_CHANNEL_GREEN,
230
    "Background Green Increase 10%", NULL, NULL,
231
    GIMP_ACTION_SELECT_SKIP_NEXT,
232 233 234 235 236
    NULL }
};

static GimpEnumActionEntry context_background_blue_actions[] =
{
237
  { "context-background-blue-set", GIMP_STOCK_CHANNEL_BLUE,
238
    "Background Blue Set", NULL, NULL,
239
    GIMP_ACTION_SELECT_SET,
240
    NULL },
241
  { "context-background-blue-minimum", GIMP_STOCK_CHANNEL_BLUE,
242
    "Background Blue Minimum", NULL, NULL,
243
    GIMP_ACTION_SELECT_FIRST,
244
    NULL },
245
  { "context-background-blue-maximum", GIMP_STOCK_CHANNEL_BLUE,
246
    "Background Blue Maximum", NULL, NULL,
247
    GIMP_ACTION_SELECT_LAST,
248
    NULL },
249
  { "context-background-blue-decrease", GIMP_STOCK_CHANNEL_BLUE,
250
    "Background Blue Decrease", NULL, NULL,
251
    GIMP_ACTION_SELECT_PREVIOUS,
252
    NULL },
253
  { "context-background-blue-increase", GIMP_STOCK_CHANNEL_BLUE,
254
    "Background Blue Increase", NULL, NULL,
255
    GIMP_ACTION_SELECT_NEXT,
256
    NULL },
257
  { "context-background-blue-decrease-skip", GIMP_STOCK_CHANNEL_BLUE,
258
    "Background Blue Decrease 10%", NULL, NULL,
259
    GIMP_ACTION_SELECT_SKIP_PREVIOUS,
260
    NULL },
261
  { "context-background-blue-increase-skip", GIMP_STOCK_CHANNEL_BLUE,
262
    "Background Blue Increase 10%", NULL, NULL,
263
    GIMP_ACTION_SELECT_SKIP_NEXT,
264 265 266
    NULL }
};

267 268
static GimpEnumActionEntry context_opacity_actions[] =
{
269
  { "context-opacity-set", GIMP_STOCK_TRANSPARENCY,
270
    "Set Transparency", NULL, NULL,
271
    GIMP_ACTION_SELECT_SET,
272
    NULL },
273
  { "context-opacity-transparent", GIMP_STOCK_TRANSPARENCY,
274
    "Completely Transparent", NULL, NULL,
275
    GIMP_ACTION_SELECT_FIRST,
276
    NULL },
277
  { "context-opacity-opaque", GIMP_STOCK_TRANSPARENCY,
278
    "Completely Opaque", NULL, NULL,
279
    GIMP_ACTION_SELECT_LAST,
280
    NULL },
281
  { "context-opacity-decrease", GIMP_STOCK_TRANSPARENCY,
282
    "More Transparent", NULL, NULL,
283
    GIMP_ACTION_SELECT_PREVIOUS,
284
    NULL },
285
  { "context-opacity-increase", GIMP_STOCK_TRANSPARENCY,
286
    "More Opaque", NULL, NULL,
287
    GIMP_ACTION_SELECT_NEXT,
288
    NULL },
289
  { "context-opacity-decrease-skip", GIMP_STOCK_TRANSPARENCY,
290
    "10% More Transparent", NULL, NULL,
291
    GIMP_ACTION_SELECT_SKIP_PREVIOUS,
292
    NULL },
293
  { "context-opacity-increase-skip", GIMP_STOCK_TRANSPARENCY,
294
    "10% More Opaque", NULL, NULL,
295
    GIMP_ACTION_SELECT_SKIP_NEXT,
296 297 298
    NULL }
};

299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
static GimpEnumActionEntry context_paint_mode_actions[] =
{
  { "context-paint-mode-first", GIMP_STOCK_TOOL_PENCIL,
    "First Paint Mode", NULL, NULL,
    GIMP_ACTION_SELECT_FIRST,
    NULL },
  { "context-paint-mode-last", GIMP_STOCK_TOOL_PENCIL,
    "Last Paint Mode", NULL, NULL,
    GIMP_ACTION_SELECT_LAST,
    NULL },
  { "context-paint-mode-previous", GIMP_STOCK_TOOL_PENCIL,
    "Previous Paint Mode", NULL, NULL,
    GIMP_ACTION_SELECT_PREVIOUS,
    NULL },
  { "context-paint-mode-next", GIMP_STOCK_TOOL_PENCIL,
    "Next Paint Mode", NULL, NULL,
    GIMP_ACTION_SELECT_NEXT,
    NULL }
};

319 320
static GimpEnumActionEntry context_tool_select_actions[] =
{
321
  { "context-tool-select-first", GIMP_STOCK_TOOLS,
322
    "First Tool", NULL, NULL,
323
    GIMP_ACTION_SELECT_FIRST,
324
    NULL },
325
  { "context-tool-select-last", GIMP_STOCK_TOOLS,
326
    "Last Tool", NULL, NULL,
327
    GIMP_ACTION_SELECT_LAST,
328
    NULL },
329
  { "context-tool-select-previous", GIMP_STOCK_TOOLS,
330
    "Previous Tool", NULL, NULL,
331
    GIMP_ACTION_SELECT_PREVIOUS,
332
    NULL },
333
  { "context-tool-select-next", GIMP_STOCK_TOOLS,
334
    "Next Tool", NULL, NULL,
335
    GIMP_ACTION_SELECT_NEXT,
336 337 338
    NULL }
};

339 340
static GimpEnumActionEntry context_brush_select_actions[] =
{
341
  { "context-brush-select-first", GIMP_STOCK_BRUSH,
342
    "First Brush", NULL, NULL,
343
    GIMP_ACTION_SELECT_FIRST,
344
    NULL },
345
  { "context-brush-select-last", GIMP_STOCK_BRUSH,
346
    "Last Brush", NULL, NULL,
347
    GIMP_ACTION_SELECT_LAST,
348
    NULL },
349
  { "context-brush-select-previous", GIMP_STOCK_BRUSH,
350
    "Previous Brush", NULL, NULL,
351
    GIMP_ACTION_SELECT_PREVIOUS,
352
    NULL },
353
  { "context-brush-select-next", GIMP_STOCK_BRUSH,
354
    "Next Brush", NULL, NULL,
355
    GIMP_ACTION_SELECT_NEXT,
356 357 358 359 360
    NULL }
};

static GimpEnumActionEntry context_pattern_select_actions[] =
{
361
  { "context-pattern-select-first", GIMP_STOCK_PATTERN,
362
    "First Pattern", NULL, NULL,
363
    GIMP_ACTION_SELECT_FIRST,
364
    NULL },
365
  { "context-pattern-select-last", GIMP_STOCK_PATTERN,
366
    "Last Pattern", NULL, NULL,
367
    GIMP_ACTION_SELECT_LAST,
368
    NULL },
369
  { "context-pattern-select-previous", GIMP_STOCK_PATTERN,
370
    "Previous Pattern", NULL, NULL,
371
    GIMP_ACTION_SELECT_PREVIOUS,
372
    NULL },
373
  { "context-pattern-select-next", GIMP_STOCK_PATTERN,
374
    "Next Pattern", NULL, NULL,
375
    GIMP_ACTION_SELECT_NEXT,
376 377 378 379 380
    NULL }
};

static GimpEnumActionEntry context_palette_select_actions[] =
{
381
  { "context-palette-select-first", GIMP_STOCK_PALETTE,
382
    "First Palette", NULL, NULL,
383
    GIMP_ACTION_SELECT_FIRST,
384
    NULL },
385
  { "context-palette-select-last", GIMP_STOCK_PALETTE,
386
    "Last Palette", NULL, NULL,
387
    GIMP_ACTION_SELECT_LAST,
388
    NULL },
389
  { "context-palette-select-previous", GIMP_STOCK_PALETTE,
390
    "Previous Palette", NULL, NULL,
391
    GIMP_ACTION_SELECT_PREVIOUS,
392
    NULL },
393
  { "context-palette-select-next", GIMP_STOCK_PALETTE,
394
    "Next Palette", NULL, NULL,
395
    GIMP_ACTION_SELECT_NEXT,
396 397 398 399 400
    NULL }
};

static GimpEnumActionEntry context_gradient_select_actions[] =
{
401
  { "context-gradient-select-first", GIMP_STOCK_GRADIENT,
402
    "First Gradient", NULL, NULL,
403
    GIMP_ACTION_SELECT_FIRST,
404
    NULL },
405
  { "context-gradient-select-last", GIMP_STOCK_GRADIENT,
406
    "Last Gradient", NULL, NULL,
407
    GIMP_ACTION_SELECT_LAST,
408
    NULL },
409
  { "context-gradient-select-previous", GIMP_STOCK_GRADIENT,
410
    "Previous Gradient", NULL, NULL,
411
    GIMP_ACTION_SELECT_PREVIOUS,
412
    NULL },
413
  { "context-gradient-select-next", GIMP_STOCK_GRADIENT,
414
    "Next Gradient", NULL, NULL,
415
    GIMP_ACTION_SELECT_NEXT,
416 417 418 419 420
    NULL }
};

static GimpEnumActionEntry context_font_select_actions[] =
{
421
  { "context-font-select-first", GIMP_STOCK_FONT,
422
    "First Font", NULL, NULL,
423
    GIMP_ACTION_SELECT_FIRST,
424
    NULL },
425
  { "context-font-select-last", GIMP_STOCK_FONT,
426
    "Last Font", NULL, NULL,
427
    GIMP_ACTION_SELECT_LAST,
428
    NULL },
429
  { "context-font-select-previous", GIMP_STOCK_FONT,
430
    "Previous Font", NULL, NULL,
431
    GIMP_ACTION_SELECT_PREVIOUS,
432
    NULL },
433
  { "context-font-select-next", GIMP_STOCK_FONT,
434
    "Next Font", NULL, NULL,
435
    GIMP_ACTION_SELECT_NEXT,
436 437 438
    NULL }
};

439 440
static GimpEnumActionEntry context_brush_shape_actions[] =
{
441 442
  { "context-brush-shape-circle", GIMP_STOCK_BRUSH,
    "Circular Brush", NULL, NULL,
443 444
    GIMP_BRUSH_GENERATED_CIRCLE,
    NULL },
445 446
  { "context-brush-shape-square", GIMP_STOCK_BRUSH,
    "Square Brush", NULL, NULL,
447 448
    GIMP_BRUSH_GENERATED_SQUARE,
    NULL },
449 450
  { "context-brush-shape-diamond", GIMP_STOCK_BRUSH,
    "Diamond Brush", NULL, NULL,
451 452 453 454
    GIMP_BRUSH_GENERATED_DIAMOND,
    NULL }
};

455 456
static GimpEnumActionEntry context_brush_radius_actions[] =
{
457
  { "context-brush-radius-set", GIMP_STOCK_BRUSH,
458 459 460
    "Set Brush Radius", NULL, NULL,
    GIMP_ACTION_SELECT_SET,
    NULL },
461
  { "context-brush-radius-minimum", GIMP_STOCK_BRUSH,
462
    "Minumum Radius", NULL, NULL,
463
    GIMP_ACTION_SELECT_FIRST,
464
    NULL },
465
  { "context-brush-radius-maximum", GIMP_STOCK_BRUSH,
466
    "Maximum Radius", NULL, NULL,
467
    GIMP_ACTION_SELECT_LAST,
468
    NULL },
469
  { "context-brush-radius-decrease", GIMP_STOCK_BRUSH,
470
    "Decrease Radius", NULL, NULL,
471
    GIMP_ACTION_SELECT_PREVIOUS,
472
    NULL },
473
  { "context-brush-radius-increase", GIMP_STOCK_BRUSH,
474
    "Increase Radius", NULL, NULL,
475
    GIMP_ACTION_SELECT_NEXT,
476
    NULL },
477
  { "context-brush-radius-decrease-skip", GIMP_STOCK_BRUSH,
478
    "Decrease Radius More", NULL, NULL,
479
    GIMP_ACTION_SELECT_SKIP_PREVIOUS,
480
    NULL },
481
  { "context-brush-radius-increase-skip", GIMP_STOCK_BRUSH,
482
    "Increase Radius More", NULL, NULL,
483
    GIMP_ACTION_SELECT_SKIP_NEXT,
484 485 486
    NULL },
};

487 488
static GimpEnumActionEntry context_brush_spikes_actions[] =
{
489
  { "context-brush-spikes-set", GIMP_STOCK_BRUSH,
490 491 492
    "Set Brush Spikes", NULL, NULL,
    GIMP_ACTION_SELECT_SET,
    NULL },
493
  { "context-brush-spikes-minimum", GIMP_STOCK_BRUSH,
494 495 496
    "Minumum Spikes", NULL, NULL,
    GIMP_ACTION_SELECT_FIRST,
    NULL },
497
  { "context-brush-spikes-maximum", GIMP_STOCK_BRUSH,
498 499 500
    "Maximum Spikes", NULL, NULL,
    GIMP_ACTION_SELECT_LAST,
    NULL },
501
  { "context-brush-spikes-decrease", GIMP_STOCK_BRUSH,
502 503 504
    "Decrease Spikes", NULL, NULL,
    GIMP_ACTION_SELECT_PREVIOUS,
    NULL },
505
  { "context-brush-spikes-increase", GIMP_STOCK_BRUSH,
506 507 508
    "Increase Spikes", NULL, NULL,
    GIMP_ACTION_SELECT_NEXT,
    NULL },
509
  { "context-brush-spikes-decrease-skip", GIMP_STOCK_BRUSH,
510 511 512
    "Decrease Spikes More", NULL, NULL,
    GIMP_ACTION_SELECT_SKIP_PREVIOUS,
    NULL },
513
  { "context-brush-spikes-increase-skip", GIMP_STOCK_BRUSH,
514 515 516 517 518
    "Increase Spikes More", NULL, NULL,
    GIMP_ACTION_SELECT_SKIP_NEXT,
    NULL },
};

519 520
static GimpEnumActionEntry context_brush_hardness_actions[] =
{
521
  { "context-brush-hardness-set", GIMP_STOCK_BRUSH,
522 523 524
    "Set Brush Hardness", NULL, NULL,
    GIMP_ACTION_SELECT_SET,
    NULL },
525
  { "context-brush-hardness-minimum", GIMP_STOCK_BRUSH,
526
    "Minumum Hardness", NULL, NULL,
527
    GIMP_ACTION_SELECT_FIRST,
528
    NULL },
529
  { "context-brush-hardness-maximum", GIMP_STOCK_BRUSH,
530
    "Maximum Hardness", NULL, NULL,
531
    GIMP_ACTION_SELECT_LAST,
532
    NULL },
533
  { "context-brush-hardness-decrease", GIMP_STOCK_BRUSH,
534
    "Decrease Hardness", NULL, NULL,
535
    GIMP_ACTION_SELECT_PREVIOUS,
536
    NULL },
537
  { "context-brush-hardness-increase", GIMP_STOCK_BRUSH,
538
    "Increase Hardness", NULL, NULL,
539
    GIMP_ACTION_SELECT_NEXT,
540
    NULL },
541
  { "context-brush-hardness-decrease-skip", GIMP_STOCK_BRUSH,
542
    "Decrease Hardness More", NULL, NULL,
543
    GIMP_ACTION_SELECT_SKIP_PREVIOUS,
544
    NULL },
545
  { "context-brush-hardness-increase-skip", GIMP_STOCK_BRUSH,
546
    "Increase Hardness More", NULL, NULL,
547
    GIMP_ACTION_SELECT_SKIP_NEXT,
548 549 550 551 552
    NULL },
};

static GimpEnumActionEntry context_brush_aspect_actions[] =
{
553
  { "context-brush-aspect-set", GIMP_STOCK_BRUSH,
554 555 556
    "Set Brush Aspect", NULL, NULL,
    GIMP_ACTION_SELECT_SET,
    NULL },
557
  { "context-brush-aspect-minimum", GIMP_STOCK_BRUSH,
558
    "Minumum Aspect", NULL, NULL,
559
    GIMP_ACTION_SELECT_FIRST,
560
    NULL },
561
  { "context-brush-aspect-maximum", GIMP_STOCK_BRUSH,
562
    "Maximum Aspect", NULL, NULL,
563
    GIMP_ACTION_SELECT_LAST,
564
    NULL },
565
  { "context-brush-aspect-decrease", GIMP_STOCK_BRUSH,
566
    "Decrease Aspect", NULL, NULL,
567
    GIMP_ACTION_SELECT_PREVIOUS,
568
    NULL },
569
  { "context-brush-aspect-increase", GIMP_STOCK_BRUSH,
570
    "Increase Aspect", NULL, NULL,
571
    GIMP_ACTION_SELECT_NEXT,
572
    NULL },
573
  { "context-brush-aspect-decrease-skip", GIMP_STOCK_BRUSH,
574
    "Decrease Aspect More", NULL, NULL,
575
    GIMP_ACTION_SELECT_SKIP_PREVIOUS,
576
    NULL },
577
  { "context-brush-aspect-increase-skip", GIMP_STOCK_BRUSH,
578
    "Increase Aspect More", NULL, NULL,
579
    GIMP_ACTION_SELECT_SKIP_NEXT,
580 581 582 583 584
    NULL },
};

static GimpEnumActionEntry context_brush_angle_actions[] =
{
585
  { "context-brush-angle-set", GIMP_STOCK_BRUSH,
586 587 588
    "Set Brush Angle", NULL, NULL,
    GIMP_ACTION_SELECT_SET,
    NULL },
589
  { "context-brush-angle-minimum", GIMP_STOCK_BRUSH,
590
    "Horizontal", NULL, NULL,
591
    GIMP_ACTION_SELECT_FIRST,
592
    NULL },
593
  { "context-brush-angle-maximum", GIMP_STOCK_BRUSH,
594
    "Vertical", NULL, NULL,
595
    GIMP_ACTION_SELECT_LAST,
596
    NULL },
597
  { "context-brush-angle-decrease", GIMP_STOCK_BRUSH,
598
    "Rotate Right", NULL, NULL,
599
    GIMP_ACTION_SELECT_PREVIOUS,
600
    NULL },
601
  { "context-brush-angle-increase", GIMP_STOCK_BRUSH,
602
    "Rotate Left", NULL, NULL,
603
    GIMP_ACTION_SELECT_NEXT,
604
    NULL },
605
  { "context-brush-angle-decrease-skip", GIMP_STOCK_BRUSH,
606
    "Rotate Right 15 degrees", NULL, NULL,
607
    GIMP_ACTION_SELECT_SKIP_PREVIOUS,
608
    NULL },
609
  { "context-brush-angle-increase-skip", GIMP_STOCK_BRUSH,
610
    "Rotate Left 15 degrees", NULL, NULL,
611
    GIMP_ACTION_SELECT_SKIP_NEXT,
612 613 614 615 616 617 618 619 620 621 622
    NULL },
};


void
context_actions_setup (GimpActionGroup *group)
{
  gimp_action_group_add_actions (group,
                                 context_actions,
                                 G_N_ELEMENTS (context_actions));

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
  gimp_action_group_add_enum_actions (group,
                                      context_foreground_red_actions,
                                      G_N_ELEMENTS (context_foreground_red_actions),
                                      G_CALLBACK (context_foreground_red_cmd_callback));
  gimp_action_group_add_enum_actions (group,
                                      context_foreground_green_actions,
                                      G_N_ELEMENTS (context_foreground_green_actions),
                                      G_CALLBACK (context_foreground_green_cmd_callback));
  gimp_action_group_add_enum_actions (group,
                                      context_foreground_blue_actions,
                                      G_N_ELEMENTS (context_foreground_blue_actions),
                                      G_CALLBACK (context_foreground_blue_cmd_callback));

  gimp_action_group_add_enum_actions (group,
                                      context_background_red_actions,
                                      G_N_ELEMENTS (context_background_red_actions),
                                      G_CALLBACK (context_background_red_cmd_callback));
  gimp_action_group_add_enum_actions (group,
                                      context_background_green_actions,
                                      G_N_ELEMENTS (context_background_green_actions),
                                      G_CALLBACK (context_background_green_cmd_callback));
  gimp_action_group_add_enum_actions (group,
                                      context_background_blue_actions,
                                      G_N_ELEMENTS (context_background_blue_actions),
                                      G_CALLBACK (context_background_blue_cmd_callback));

649 650 651 652
  gimp_action_group_add_enum_actions (group,
                                      context_opacity_actions,
                                      G_N_ELEMENTS (context_opacity_actions),
                                      G_CALLBACK (context_opacity_cmd_callback));
653 654 655 656
  gimp_action_group_add_enum_actions (group,
                                      context_paint_mode_actions,
                                      G_N_ELEMENTS (context_paint_mode_actions),
                                      G_CALLBACK (context_paint_mode_cmd_callback));
657

658 659 660 661
  gimp_action_group_add_enum_actions (group,
                                      context_tool_select_actions,
                                      G_N_ELEMENTS (context_tool_select_actions),
                                      G_CALLBACK (context_tool_select_cmd_callback));
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682
  gimp_action_group_add_enum_actions (group,
                                      context_brush_select_actions,
                                      G_N_ELEMENTS (context_brush_select_actions),
                                      G_CALLBACK (context_brush_select_cmd_callback));
  gimp_action_group_add_enum_actions (group,
                                      context_pattern_select_actions,
                                      G_N_ELEMENTS (context_pattern_select_actions),
                                      G_CALLBACK (context_pattern_select_cmd_callback));
  gimp_action_group_add_enum_actions (group,
                                      context_palette_select_actions,
                                      G_N_ELEMENTS (context_palette_select_actions),
                                      G_CALLBACK (context_palette_select_cmd_callback));
  gimp_action_group_add_enum_actions (group,
                                      context_gradient_select_actions,
                                      G_N_ELEMENTS (context_gradient_select_actions),
                                      G_CALLBACK (context_gradient_select_cmd_callback));
  gimp_action_group_add_enum_actions (group,
                                      context_font_select_actions,
                                      G_N_ELEMENTS (context_font_select_actions),
                                      G_CALLBACK (context_font_select_cmd_callback));

683 684 685 686
  gimp_action_group_add_enum_actions (group,
                                      context_brush_shape_actions,
                                      G_N_ELEMENTS (context_brush_shape_actions),
                                      G_CALLBACK (context_brush_shape_cmd_callback));
687 688 689 690
  gimp_action_group_add_enum_actions (group,
                                      context_brush_radius_actions,
                                      G_N_ELEMENTS (context_brush_radius_actions),
                                      G_CALLBACK (context_brush_radius_cmd_callback));
691 692 693 694
  gimp_action_group_add_enum_actions (group,
                                      context_brush_spikes_actions,
                                      G_N_ELEMENTS (context_brush_spikes_actions),
                                      G_CALLBACK (context_brush_spikes_cmd_callback));
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712
  gimp_action_group_add_enum_actions (group,
                                      context_brush_hardness_actions,
                                      G_N_ELEMENTS (context_brush_hardness_actions),
                                      G_CALLBACK (context_brush_hardness_cmd_callback));
  gimp_action_group_add_enum_actions (group,
                                      context_brush_aspect_actions,
                                      G_N_ELEMENTS (context_brush_aspect_actions),
                                      G_CALLBACK (context_brush_aspect_cmd_callback));
  gimp_action_group_add_enum_actions (group,
                                      context_brush_angle_actions,
                                      G_N_ELEMENTS (context_brush_angle_actions),
                                      G_CALLBACK (context_brush_angle_cmd_callback));
}

void
context_actions_update (GimpActionGroup *group,
                        gpointer         data)
{
713
  GimpContext *context   = action_data_get_context (data);
714
  gboolean     generated = FALSE;
715 716 717 718 719
  gdouble      radius    = 0.0;
  gint         spikes    = 0;
  gdouble      hardness  = 0.0;
  gdouble      aspect    = 0.0;
  gdouble      angle     = 0.0;
720 721 722 723 724 725 726 727 728 729 730 731

  if (context)
    {
      GimpBrush *brush = gimp_context_get_brush (context);

      if (GIMP_IS_BRUSH_GENERATED (brush))
        {
          GimpBrushGenerated *gen = GIMP_BRUSH_GENERATED (brush);

          generated = TRUE;

          radius   = gimp_brush_generated_get_radius       (gen);
732
          spikes   = gimp_brush_generated_get_spikes       (gen);
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
          hardness = gimp_brush_generated_get_hardness     (gen);
          aspect   = gimp_brush_generated_get_aspect_ratio (gen);
          angle    = gimp_brush_generated_get_angle        (gen);
        }
    }

#define SET_SENSITIVE(action,condition) \
        gimp_action_group_set_action_sensitive (group, "context-" action, (condition) != 0)

#if 0
  SET_SENSITIVE ("brush-radius-minimum",       generated && radius > 1.0);
  SET_SENSITIVE ("brush-radius-decrease",      generated && radius > 1.0);
  SET_SENSITIVE ("brush-radius-decrease-skip", generated && radius > 1.0);

  SET_SENSITIVE ("brush-radius-maximum",       generated && radius < 4096.0);
  SET_SENSITIVE ("brush-radius-increase",      generated && radius < 4096.0);
  SET_SENSITIVE ("brush-radius-increase-skip", generated && radius < 4096.0);

  SET_SENSITIVE ("brush-angle-minimum",       generated);
  SET_SENSITIVE ("brush-angle-decrease",      generated);
  SET_SENSITIVE ("brush-angle-decrease-skip", generated);

  SET_SENSITIVE ("brush-angle-maximum",       generated);
  SET_SENSITIVE ("brush-angle-increase",      generated);
  SET_SENSITIVE ("brush-angle-increase-skip", generated);
#endif

#undef SET_SENSITIVE
}