context-actions.c 29.2 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, TRUE,
80
    NULL },
81
  { "context-foreground-red-minimum", GIMP_STOCK_CHANNEL_RED,
82
    "Foreground Red Minimum", NULL, NULL,
83
    GIMP_ACTION_SELECT_FIRST, FALSE,
84
    NULL },
85
  { "context-foreground-red-maximum", GIMP_STOCK_CHANNEL_RED,
86
    "Foreground Red Maximum", NULL, NULL,
87
    GIMP_ACTION_SELECT_LAST, FALSE,
88
    NULL },
89
  { "context-foreground-red-decrease", GIMP_STOCK_CHANNEL_RED,
90
    "Foreground Red Decrease", NULL, NULL,
91
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
92
    NULL },
93
  { "context-foreground-red-increase", GIMP_STOCK_CHANNEL_RED,
94
    "Foreground Red Increase", NULL, NULL,
95
    GIMP_ACTION_SELECT_NEXT, FALSE,
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, FALSE,
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, FALSE,
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, TRUE,
112
    NULL },
113
  { "context-foreground-green-minimum", GIMP_STOCK_CHANNEL_GREEN,
114
    "Foreground Green Minimum", NULL, NULL,
115
    GIMP_ACTION_SELECT_FIRST, FALSE,
116
    NULL },
117
  { "context-foreground-green-maximum", GIMP_STOCK_CHANNEL_GREEN,
118
    "Foreground Green Maximum", NULL, NULL,
119
    GIMP_ACTION_SELECT_LAST, FALSE,
120
    NULL },
121
  { "context-foreground-green-decrease", GIMP_STOCK_CHANNEL_GREEN,
122
    "Foreground Green Decrease", NULL, NULL,
123
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
124
    NULL },
125
  { "context-foreground-green-increase", GIMP_STOCK_CHANNEL_GREEN,
126
    "Foreground Green Increase", NULL, NULL,
127
    GIMP_ACTION_SELECT_NEXT, FALSE,
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, FALSE,
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, FALSE,
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, TRUE,
144
    NULL },
145
  { "context-foreground-blue-minimum", GIMP_STOCK_CHANNEL_BLUE,
146
    "Foreground Blue Minimum", NULL, NULL,
147
    GIMP_ACTION_SELECT_FIRST, FALSE,
148
    NULL },
149
  { "context-foreground-blue-maximum", GIMP_STOCK_CHANNEL_BLUE,
150
    "Foreground Blue Maximum", NULL, NULL,
151
    GIMP_ACTION_SELECT_LAST, FALSE,
152
    NULL },
153
  { "context-foreground-blue-decrease", GIMP_STOCK_CHANNEL_BLUE,
154
    "Foreground Blue Decrease", NULL, NULL,
155
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
156
    NULL },
157
  { "context-foreground-blue-increase", GIMP_STOCK_CHANNEL_BLUE,
158
    "Foreground Blue Increase", NULL, NULL,
159
    GIMP_ACTION_SELECT_NEXT, FALSE,
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, FALSE,
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, FALSE,
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, TRUE,
176
    NULL },
177
  { "context-background-red-minimum", GIMP_STOCK_CHANNEL_RED,
178
    "Background Red Minimum", NULL, NULL,
179
    GIMP_ACTION_SELECT_FIRST, FALSE,
180
    NULL },
181
  { "context-background-red-maximum", GIMP_STOCK_CHANNEL_RED,
182
    "Background Red Maximum", NULL, NULL,
183
    GIMP_ACTION_SELECT_LAST, FALSE,
184
    NULL },
185
  { "context-background-red-decrease", GIMP_STOCK_CHANNEL_RED,
186
    "Background Red Decrease", NULL, NULL,
187
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
188
    NULL },
189
  { "context-background-red-increase", GIMP_STOCK_CHANNEL_RED,
190
    "Background Red Increase", NULL, NULL,
191
    GIMP_ACTION_SELECT_NEXT, FALSE,
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, FALSE,
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, FALSE,
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, TRUE,
208
    NULL },
209
  { "context-background-green-minimum", GIMP_STOCK_CHANNEL_GREEN,
210
    "Background Green Minimum", NULL, NULL,
211
    GIMP_ACTION_SELECT_FIRST, FALSE,
212
    NULL },
213
  { "context-background-green-maximum", GIMP_STOCK_CHANNEL_GREEN,
214
    "Background Green Maximum", NULL, NULL,
215
    GIMP_ACTION_SELECT_LAST, FALSE,
216
    NULL },
217
  { "context-background-green-decrease", GIMP_STOCK_CHANNEL_GREEN,
218
    "Background Green Decrease", NULL, NULL,
219
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
220
    NULL },
221
  { "context-background-green-increase", GIMP_STOCK_CHANNEL_GREEN,
222
    "Background Green Increase", NULL, NULL,
223
    GIMP_ACTION_SELECT_NEXT, FALSE,
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, FALSE,
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, FALSE,
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, TRUE,
240
    NULL },
241
  { "context-background-blue-minimum", GIMP_STOCK_CHANNEL_BLUE,
242
    "Background Blue Minimum", NULL, NULL,
243
    GIMP_ACTION_SELECT_FIRST, FALSE,
244
    NULL },
245
  { "context-background-blue-maximum", GIMP_STOCK_CHANNEL_BLUE,
246
    "Background Blue Maximum", NULL, NULL,
247
    GIMP_ACTION_SELECT_LAST, FALSE,
248
    NULL },
249
  { "context-background-blue-decrease", GIMP_STOCK_CHANNEL_BLUE,
250
    "Background Blue Decrease", NULL, NULL,
251
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
252
    NULL },
253
  { "context-background-blue-increase", GIMP_STOCK_CHANNEL_BLUE,
254
    "Background Blue Increase", NULL, NULL,
255
    GIMP_ACTION_SELECT_NEXT, FALSE,
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, FALSE,
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, FALSE,
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, TRUE,
272
    NULL },
273
  { "context-opacity-transparent", GIMP_STOCK_TRANSPARENCY,
274
    "Completely Transparent", NULL, NULL,
275
    GIMP_ACTION_SELECT_FIRST, FALSE,
276
    NULL },
277
  { "context-opacity-opaque", GIMP_STOCK_TRANSPARENCY,
278
    "Completely Opaque", NULL, NULL,
279
    GIMP_ACTION_SELECT_LAST, FALSE,
280
    NULL },
281
  { "context-opacity-decrease", GIMP_STOCK_TRANSPARENCY,
282
    "More Transparent", NULL, NULL,
283
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
284
    NULL },
285
  { "context-opacity-increase", GIMP_STOCK_TRANSPARENCY,
286
    "More Opaque", NULL, NULL,
287
    GIMP_ACTION_SELECT_NEXT, FALSE,
288
    NULL },
289
  { "context-opacity-decrease-skip", GIMP_STOCK_TRANSPARENCY,
290
    "10% More Transparent", NULL, NULL,
291
    GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
292
    NULL },
293
  { "context-opacity-increase-skip", GIMP_STOCK_TRANSPARENCY,
294
    "10% More Opaque", NULL, NULL,
295
    GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
296 297 298
    NULL }
};

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

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

343 344
static GimpEnumActionEntry context_brush_select_actions[] =
{
345 346 347 348
  { "context-brush-select-set", GIMP_STOCK_BRUSH,
    "Select Brush by Index", NULL, NULL,
    GIMP_ACTION_SELECT_SET, TRUE,
    NULL },
349
  { "context-brush-select-first", GIMP_STOCK_BRUSH,
350
    "First Brush", NULL, NULL,
351
    GIMP_ACTION_SELECT_FIRST, FALSE,
352
    NULL },
353
  { "context-brush-select-last", GIMP_STOCK_BRUSH,
354
    "Last Brush", NULL, NULL,
355
    GIMP_ACTION_SELECT_LAST, FALSE,
356
    NULL },
357
  { "context-brush-select-previous", GIMP_STOCK_BRUSH,
358
    "Previous Brush", NULL, NULL,
359
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
360
    NULL },
361
  { "context-brush-select-next", GIMP_STOCK_BRUSH,
362
    "Next Brush", NULL, NULL,
363
    GIMP_ACTION_SELECT_NEXT, FALSE,
364 365 366 367 368
    NULL }
};

static GimpEnumActionEntry context_pattern_select_actions[] =
{
369 370 371 372
  { "context-pattern-select-set", GIMP_STOCK_PATTERN,
    "Select Pattern by Index", NULL, NULL,
    GIMP_ACTION_SELECT_SET, TRUE,
    NULL },
373
  { "context-pattern-select-first", GIMP_STOCK_PATTERN,
374
    "First Pattern", NULL, NULL,
375
    GIMP_ACTION_SELECT_FIRST, FALSE,
376
    NULL },
377
  { "context-pattern-select-last", GIMP_STOCK_PATTERN,
378
    "Last Pattern", NULL, NULL,
379
    GIMP_ACTION_SELECT_LAST, FALSE,
380
    NULL },
381
  { "context-pattern-select-previous", GIMP_STOCK_PATTERN,
382
    "Previous Pattern", NULL, NULL,
383
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
384
    NULL },
385
  { "context-pattern-select-next", GIMP_STOCK_PATTERN,
386
    "Next Pattern", NULL, NULL,
387
    GIMP_ACTION_SELECT_NEXT, FALSE,
388 389 390 391 392
    NULL }
};

static GimpEnumActionEntry context_palette_select_actions[] =
{
393 394 395 396
  { "context-palette-select-set", GIMP_STOCK_PALETTE,
    "Select Palette by Index", NULL, NULL,
    GIMP_ACTION_SELECT_SET, TRUE,
    NULL },
397
  { "context-palette-select-first", GIMP_STOCK_PALETTE,
398
    "First Palette", NULL, NULL,
399
    GIMP_ACTION_SELECT_FIRST, FALSE,
400
    NULL },
401
  { "context-palette-select-last", GIMP_STOCK_PALETTE,
402
    "Last Palette", NULL, NULL,
403
    GIMP_ACTION_SELECT_LAST, FALSE,
404
    NULL },
405
  { "context-palette-select-previous", GIMP_STOCK_PALETTE,
406
    "Previous Palette", NULL, NULL,
407
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
408
    NULL },
409
  { "context-palette-select-next", GIMP_STOCK_PALETTE,
410
    "Next Palette", NULL, NULL,
411
    GIMP_ACTION_SELECT_NEXT, FALSE,
412 413 414 415 416
    NULL }
};

static GimpEnumActionEntry context_gradient_select_actions[] =
{
417 418 419 420
  { "context-gradient-select-set", GIMP_STOCK_GRADIENT,
    "Select Gradient by Index", NULL, NULL,
    GIMP_ACTION_SELECT_SET, TRUE,
    NULL },
421
  { "context-gradient-select-first", GIMP_STOCK_GRADIENT,
422
    "First Gradient", NULL, NULL,
423
    GIMP_ACTION_SELECT_FIRST, FALSE,
424
    NULL },
425
  { "context-gradient-select-last", GIMP_STOCK_GRADIENT,
426
    "Last Gradient", NULL, NULL,
427
    GIMP_ACTION_SELECT_LAST, FALSE,
428
    NULL },
429
  { "context-gradient-select-previous", GIMP_STOCK_GRADIENT,
430
    "Previous Gradient", NULL, NULL,
431
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
432
    NULL },
433
  { "context-gradient-select-next", GIMP_STOCK_GRADIENT,
434
    "Next Gradient", NULL, NULL,
435
    GIMP_ACTION_SELECT_NEXT, FALSE,
436 437 438 439 440
    NULL }
};

static GimpEnumActionEntry context_font_select_actions[] =
{
441 442 443 444
  { "context-font-select-set", GIMP_STOCK_FONT,
    "Select Font by Index", NULL, NULL,
    GIMP_ACTION_SELECT_SET, TRUE,
    NULL },
445
  { "context-font-select-first", GIMP_STOCK_FONT,
446
    "First Font", NULL, NULL,
447
    GIMP_ACTION_SELECT_FIRST, FALSE,
448
    NULL },
449
  { "context-font-select-last", GIMP_STOCK_FONT,
450
    "Last Font", NULL, NULL,
451
    GIMP_ACTION_SELECT_LAST, FALSE,
452
    NULL },
453
  { "context-font-select-previous", GIMP_STOCK_FONT,
454
    "Previous Font", NULL, NULL,
455
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
456
    NULL },
457
  { "context-font-select-next", GIMP_STOCK_FONT,
458
    "Next Font", NULL, NULL,
459
    GIMP_ACTION_SELECT_NEXT, FALSE,
460 461 462
    NULL }
};

463 464
static GimpEnumActionEntry context_brush_shape_actions[] =
{
465 466
  { "context-brush-shape-circle", GIMP_STOCK_BRUSH,
    "Circular Brush", NULL, NULL,
467
    GIMP_BRUSH_GENERATED_CIRCLE, FALSE,
468
    NULL },
469 470
  { "context-brush-shape-square", GIMP_STOCK_BRUSH,
    "Square Brush", NULL, NULL,
471
    GIMP_BRUSH_GENERATED_SQUARE, FALSE,
472
    NULL },
473 474
  { "context-brush-shape-diamond", GIMP_STOCK_BRUSH,
    "Diamond Brush", NULL, NULL,
475
    GIMP_BRUSH_GENERATED_DIAMOND, FALSE,
476 477 478
    NULL }
};

479 480
static GimpEnumActionEntry context_brush_radius_actions[] =
{
481
  { "context-brush-radius-set", GIMP_STOCK_BRUSH,
482
    "Set Brush Radius", NULL, NULL,
483
    GIMP_ACTION_SELECT_SET, TRUE,
484
    NULL },
485
  { "context-brush-radius-minimum", GIMP_STOCK_BRUSH,
486
    "Minumum Radius", NULL, NULL,
487
    GIMP_ACTION_SELECT_FIRST, FALSE,
488
    NULL },
489
  { "context-brush-radius-maximum", GIMP_STOCK_BRUSH,
490
    "Maximum Radius", NULL, NULL,
491
    GIMP_ACTION_SELECT_LAST, FALSE,
492
    NULL },
493
  { "context-brush-radius-decrease", GIMP_STOCK_BRUSH,
494
    "Decrease Radius", NULL, NULL,
495
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
496
    NULL },
497
  { "context-brush-radius-increase", GIMP_STOCK_BRUSH,
498
    "Increase Radius", NULL, NULL,
499
    GIMP_ACTION_SELECT_NEXT, FALSE,
500
    NULL },
501
  { "context-brush-radius-decrease-skip", GIMP_STOCK_BRUSH,
502
    "Decrease Radius More", NULL, NULL,
503
    GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
504
    NULL },
505
  { "context-brush-radius-increase-skip", GIMP_STOCK_BRUSH,
506
    "Increase Radius More", NULL, NULL,
507
    GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
508 509 510
    NULL },
};

511 512
static GimpEnumActionEntry context_brush_spikes_actions[] =
{
513
  { "context-brush-spikes-set", GIMP_STOCK_BRUSH,
514
    "Set Brush Spikes", NULL, NULL,
515
    GIMP_ACTION_SELECT_SET, TRUE,
516
    NULL },
517
  { "context-brush-spikes-minimum", GIMP_STOCK_BRUSH,
518
    "Minumum Spikes", NULL, NULL,
519
    GIMP_ACTION_SELECT_FIRST, FALSE,
520
    NULL },
521
  { "context-brush-spikes-maximum", GIMP_STOCK_BRUSH,
522
    "Maximum Spikes", NULL, NULL,
523
    GIMP_ACTION_SELECT_LAST, FALSE,
524
    NULL },
525
  { "context-brush-spikes-decrease", GIMP_STOCK_BRUSH,
526
    "Decrease Spikes", NULL, NULL,
527
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
528
    NULL },
529
  { "context-brush-spikes-increase", GIMP_STOCK_BRUSH,
530
    "Increase Spikes", NULL, NULL,
531
    GIMP_ACTION_SELECT_NEXT, FALSE,
532
    NULL },
533
  { "context-brush-spikes-decrease-skip", GIMP_STOCK_BRUSH,
534
    "Decrease Spikes More", NULL, NULL,
535
    GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
536
    NULL },
537
  { "context-brush-spikes-increase-skip", GIMP_STOCK_BRUSH,
538
    "Increase Spikes More", NULL, NULL,
539
    GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
540 541 542
    NULL },
};

543 544
static GimpEnumActionEntry context_brush_hardness_actions[] =
{
545
  { "context-brush-hardness-set", GIMP_STOCK_BRUSH,
546
    "Set Brush Hardness", NULL, NULL,
547
    GIMP_ACTION_SELECT_SET, TRUE,
548
    NULL },
549
  { "context-brush-hardness-minimum", GIMP_STOCK_BRUSH,
550
    "Minumum Hardness", NULL, NULL,
551
    GIMP_ACTION_SELECT_FIRST, FALSE,
552
    NULL },
553
  { "context-brush-hardness-maximum", GIMP_STOCK_BRUSH,
554
    "Maximum Hardness", NULL, NULL,
555
    GIMP_ACTION_SELECT_LAST, FALSE,
556
    NULL },
557
  { "context-brush-hardness-decrease", GIMP_STOCK_BRUSH,
558
    "Decrease Hardness", NULL, NULL,
559
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
560
    NULL },
561
  { "context-brush-hardness-increase", GIMP_STOCK_BRUSH,
562
    "Increase Hardness", NULL, NULL,
563
    GIMP_ACTION_SELECT_NEXT, FALSE,
564
    NULL },
565
  { "context-brush-hardness-decrease-skip", GIMP_STOCK_BRUSH,
566
    "Decrease Hardness More", NULL, NULL,
567
    GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
568
    NULL },
569
  { "context-brush-hardness-increase-skip", GIMP_STOCK_BRUSH,
570
    "Increase Hardness More", NULL, NULL,
571
    GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
572 573 574 575 576
    NULL },
};

static GimpEnumActionEntry context_brush_aspect_actions[] =
{
577
  { "context-brush-aspect-set", GIMP_STOCK_BRUSH,
578
    "Set Brush Aspect", NULL, NULL,
579
    GIMP_ACTION_SELECT_SET, TRUE,
580
    NULL },
581
  { "context-brush-aspect-minimum", GIMP_STOCK_BRUSH,
582
    "Minumum Aspect", NULL, NULL,
583
    GIMP_ACTION_SELECT_FIRST, FALSE,
584
    NULL },
585
  { "context-brush-aspect-maximum", GIMP_STOCK_BRUSH,
586
    "Maximum Aspect", NULL, NULL,
587
    GIMP_ACTION_SELECT_LAST, FALSE,
588
    NULL },
589
  { "context-brush-aspect-decrease", GIMP_STOCK_BRUSH,
590
    "Decrease Aspect", NULL, NULL,
591
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
592
    NULL },
593
  { "context-brush-aspect-increase", GIMP_STOCK_BRUSH,
594
    "Increase Aspect", NULL, NULL,
595
    GIMP_ACTION_SELECT_NEXT, FALSE,
596
    NULL },
597
  { "context-brush-aspect-decrease-skip", GIMP_STOCK_BRUSH,
598
    "Decrease Aspect More", NULL, NULL,
599
    GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
600
    NULL },
601
  { "context-brush-aspect-increase-skip", GIMP_STOCK_BRUSH,
602
    "Increase Aspect More", NULL, NULL,
603
    GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
604 605 606 607 608
    NULL },
};

static GimpEnumActionEntry context_brush_angle_actions[] =
{
609
  { "context-brush-angle-set", GIMP_STOCK_BRUSH,
610
    "Set Brush Angle", NULL, NULL,
611
    GIMP_ACTION_SELECT_SET, TRUE,
612
    NULL },
613
  { "context-brush-angle-minimum", GIMP_STOCK_BRUSH,
614
    "Horizontal", NULL, NULL,
615
    GIMP_ACTION_SELECT_FIRST, FALSE,
616
    NULL },
617
  { "context-brush-angle-maximum", GIMP_STOCK_BRUSH,
618
    "Vertical", NULL, NULL,
619
    GIMP_ACTION_SELECT_LAST, FALSE,
620
    NULL },
621
  { "context-brush-angle-decrease", GIMP_STOCK_BRUSH,
622
    "Rotate Right", NULL, NULL,
623
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
624
    NULL },
625
  { "context-brush-angle-increase", GIMP_STOCK_BRUSH,
626
    "Rotate Left", NULL, NULL,
627
    GIMP_ACTION_SELECT_NEXT, FALSE,
628
    NULL },
629
  { "context-brush-angle-decrease-skip", GIMP_STOCK_BRUSH,
630
    "Rotate Right 15 degrees", NULL, NULL,
631
    GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
632
    NULL },
633
  { "context-brush-angle-increase-skip", GIMP_STOCK_BRUSH,
634
    "Rotate Left 15 degrees", NULL, NULL,
635
    GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
636 637 638 639 640 641 642 643 644 645 646
    NULL },
};


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

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
  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));

673 674 675 676
  gimp_action_group_add_enum_actions (group,
                                      context_opacity_actions,
                                      G_N_ELEMENTS (context_opacity_actions),
                                      G_CALLBACK (context_opacity_cmd_callback));
677 678 679 680
  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));
681

682 683 684 685
  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));
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706
  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));

707 708 709 710
  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));
711 712 713 714
  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));
715 716 717 718
  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));
719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736
  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)
{
737
  GimpContext *context   = action_data_get_context (data);
738
  gboolean     generated = FALSE;
739 740 741 742 743
  gdouble      radius    = 0.0;
  gint         spikes    = 0;
  gdouble      hardness  = 0.0;
  gdouble      aspect    = 0.0;
  gdouble      angle     = 0.0;
744 745 746 747 748 749 750 751 752 753 754 755

  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);
756
          spikes   = gimp_brush_generated_get_spikes       (gen);
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
          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
}