tools-actions.c 22.8 KB
Newer Older
1
/* GIMP - The GNU Image Manipulation Program
Michael Natterer's avatar
Michael Natterer committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 * 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"

21 22
#include <string.h>

Michael Natterer's avatar
Michael Natterer committed
23 24 25 26 27 28 29
#include <gtk/gtk.h>

#include "libgimpwidgets/gimpwidgets.h"

#include "actions-types.h"

#include "core/gimp.h"
30
#include "core/gimpcontext.h"
Michael Natterer's avatar
Michael Natterer committed
31 32 33 34 35 36
#include "core/gimplist.h"
#include "core/gimptoolinfo.h"

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

37
#include "actions.h"
38 39
#include "tools-actions.h"
#include "tools-commands.h"
Michael Natterer's avatar
Michael Natterer committed
40 41 42 43

#include "gimp-intl.h"


44
static const GimpActionEntry tools_actions[] =
Michael Natterer's avatar
Michael Natterer committed
45
{
46 47
  { "tools-popup", GIMP_STOCK_TOOLS,
    N_("Tools Menu"), NULL, NULL, NULL,
48 49
    GIMP_HELP_TOOLS_DIALOG },

50 51 52 53 54
  { "tools-menu",           NULL, N_("_Tools")           },
  { "tools-select-menu",    NULL, N_("_Selection Tools") },
  { "tools-paint-menu",     NULL, N_("_Paint Tools")     },
  { "tools-transform-menu", NULL, N_("_Transform Tools") },
  { "tools-color-menu",     NULL, N_("_Color Tools")     },
Michael Natterer's avatar
Michael Natterer committed
55

56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
  { "tools-raise", GTK_STOCK_GO_UP,
    N_("R_aise Tool"), NULL,
    N_("Raise tool"),
    G_CALLBACK (tools_raise_cmd_callback),
    NULL },

  { "tools-raise-to-top", GTK_STOCK_GOTO_TOP,
    N_("Ra_ise to Top"), NULL,
    N_("Raise tool to top"),
    G_CALLBACK (tools_raise_to_top_cmd_callback),
    NULL },

  { "tools-lower", GTK_STOCK_GO_DOWN,
    N_("L_ower Tool"), NULL,
    N_("Lower tool"),
    G_CALLBACK (tools_lower_cmd_callback),
    NULL },

  { "tools-lower-to-bottom", GTK_STOCK_GOTO_BOTTOM,
    N_("Lo_wer to Bottom"), NULL,
    N_("Lower tool to bottom"),
    G_CALLBACK (tools_lower_to_bottom_cmd_callback),
    NULL },

80
  { "tools-reset", GIMP_STOCK_RESET,
81 82
    N_("_Reset Order & Visibility"), NULL,
    N_("Reset tool order and visibility"),
83 84 85 86
    G_CALLBACK (tools_reset_cmd_callback),
    NULL }
};

87
static const GimpToggleActionEntry tools_toggle_actions[] =
88
{
89
  { "tools-visibility", GIMP_STOCK_VISIBLE,
90
    N_("_Show in Toolbox"), NULL, NULL,
91 92 93
    G_CALLBACK (tools_toggle_visibility_cmd_callback),
    TRUE,
    NULL /* FIXME */ }
Michael Natterer's avatar
Michael Natterer committed
94 95
};

96
static const GimpStringActionEntry tools_alternative_actions[] =
97 98
{
  { "tools-by-color-select-short", GIMP_STOCK_TOOL_BY_COLOR_SELECT,
99 100
    N_("_By Color"), NULL,
    N_("Select regions with similar colors"),
101 102 103 104
    "gimp-by-color-select-tool",
    GIMP_HELP_TOOL_BY_COLOR_SELECT },

  { "tools-rotate-arbitrary", GIMP_STOCK_TOOL_ROTATE,
105 106
    N_("_Arbitrary Rotation..."), "",
    N_("Rotate by an arbitrary angle"),
107
    "gimp-rotate-layer",
108 109 110
    GIMP_HELP_TOOL_ROTATE }
};

111
static const GimpEnumActionEntry tools_color_average_radius_actions[] =
112 113 114 115 116 117
{
  { "tools-color-average-radius-set", GIMP_STOCK_TOOL_COLOR_PICKER,
    "Set Color Picker Radius", NULL, NULL,
    GIMP_ACTION_SELECT_SET, TRUE,
    NULL },
  { "tools-color-average-radius-minimum", GIMP_STOCK_TOOL_COLOR_PICKER,
118
    "M Color Picker Radius", NULL, NULL,
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
    GIMP_ACTION_SELECT_FIRST, FALSE,
    NULL },
  { "tools-color-average-radius-maximum", GIMP_STOCK_TOOL_COLOR_PICKER,
    "Maximum Color Picker Radius", NULL, NULL,
    GIMP_ACTION_SELECT_LAST, FALSE,
    NULL },
  { "tools-color-average-radius-decrease", GIMP_STOCK_TOOL_COLOR_PICKER,
    "Decrease Color Picker Radius", NULL, NULL,
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
    NULL },
  { "tools-color-average-radius-increase", GIMP_STOCK_TOOL_COLOR_PICKER,
    "Increase Color Picker Radius", NULL, NULL,
    GIMP_ACTION_SELECT_NEXT, FALSE,
    NULL },
  { "tools-color-average-radius-decrease-skip",
    GIMP_STOCK_TOOL_COLOR_PICKER,
    "Decrease Color Picker Radius More", NULL, NULL,
    GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
    NULL },
  { "tools-color-average-radius-increase-skip",
    GIMP_STOCK_TOOL_COLOR_PICKER,
    "Increase Color Picker Radius More", NULL, NULL,
    GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
    NULL },
};

145 146 147 148 149 150 151
static const GimpEnumActionEntry tools_paint_brush_scale_actions[] =
{
  { "tools-paint-brush-scale-set", GIMP_STOCK_TOOL_PAINTBRUSH,
    "Set Brush Scale", NULL, NULL,
    GIMP_ACTION_SELECT_SET, TRUE,
    NULL },
  { "tools-paint-brush-scale-minimum", GIMP_STOCK_TOOL_PAINTBRUSH,
152
    "M Brush Scale", NULL, NULL,
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
    GIMP_ACTION_SELECT_FIRST, FALSE,
    NULL },
  { "tools-paint-brush-scale-maximum", GIMP_STOCK_TOOL_PAINTBRUSH,
    "Maximum Brush Scale", NULL, NULL,
    GIMP_ACTION_SELECT_LAST, FALSE,
    NULL },
  { "tools-paint-brush-scale-decrease", GIMP_STOCK_TOOL_PAINTBRUSH,
    "Decrease Brush Scale", NULL, NULL,
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
    NULL },
  { "tools-paint-brush-scale-increase", GIMP_STOCK_TOOL_PAINTBRUSH,
    "Increase Brush Scale", NULL, NULL,
    GIMP_ACTION_SELECT_NEXT, FALSE,
    NULL },
  { "tools-paint-brush-scale-decrease-skip", GIMP_STOCK_TOOL_PAINTBRUSH,
    "Decrease Brush Scale More", NULL, NULL,
    GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
    NULL },
  { "tools-paint-brush-scale-increase-skip", GIMP_STOCK_TOOL_PAINTBRUSH,
    "Increase Brush Scale More", NULL, NULL,
    GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
    NULL },
};

177
static const GimpEnumActionEntry tools_ink_blob_size_actions[] =
Michael Natterer's avatar
Michael Natterer committed
178 179 180 181 182 183
{
  { "tools-ink-blob-size-set", GIMP_STOCK_TOOL_INK,
    "Set Ink Blob Size", NULL, NULL,
    GIMP_ACTION_SELECT_SET, TRUE,
    NULL },
  { "tools-ink-blob-size-minimum", GIMP_STOCK_TOOL_INK,
184
    "M Ink Blob Size", NULL, NULL,
Michael Natterer's avatar
Michael Natterer committed
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
    GIMP_ACTION_SELECT_FIRST, FALSE,
    NULL },
  { "tools-ink-blob-size-maximum", GIMP_STOCK_TOOL_INK,
    "Maximum Ink Blob Size", NULL, NULL,
    GIMP_ACTION_SELECT_LAST, FALSE,
    NULL },
  { "tools-ink-blob-size-decrease", GIMP_STOCK_TOOL_INK,
    "Decrease Ink Blob Size", NULL, NULL,
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
    NULL },
  { "tools-ink-blob-size-increase", GIMP_STOCK_TOOL_INK,
    "Increase Ink Blob Size", NULL, NULL,
    GIMP_ACTION_SELECT_NEXT, FALSE,
    NULL },
  { "tools-ink-blob-size-decrease-skip", GIMP_STOCK_TOOL_INK,
    "Decrease Ink Blob Size More", NULL, NULL,
    GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
    NULL },
  { "tools-ink-blob-size-increase-skip", GIMP_STOCK_TOOL_INK,
    "Increase Ink Blob Size More", NULL, NULL,
    GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
    NULL },
};

209
static const GimpEnumActionEntry tools_ink_blob_aspect_actions[] =
Michael Natterer's avatar
Michael Natterer committed
210 211 212 213 214 215
{
  { "tools-ink-blob-aspect-set", GIMP_STOCK_TOOL_INK,
    "Set Ink Blob Aspect", NULL, NULL,
    GIMP_ACTION_SELECT_SET, TRUE,
    NULL },
  { "tools-ink-blob-aspect-minimum", GIMP_STOCK_TOOL_INK,
216
    "M Ink Blob Aspect", NULL, NULL,
Michael Natterer's avatar
Michael Natterer committed
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
    GIMP_ACTION_SELECT_FIRST, FALSE,
    NULL },
  { "tools-ink-blob-aspect-maximum", GIMP_STOCK_TOOL_INK,
    "Maximum Ink Blob Aspect", NULL, NULL,
    GIMP_ACTION_SELECT_LAST, FALSE,
    NULL },
  { "tools-ink-blob-aspect-decrease", GIMP_STOCK_TOOL_INK,
    "Decrease Ink Blob Aspect", NULL, NULL,
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
    NULL },
  { "tools-ink-blob-aspect-increase", GIMP_STOCK_TOOL_INK,
    "Increase Ink Blob Aspect", NULL, NULL,
    GIMP_ACTION_SELECT_NEXT, FALSE,
    NULL },
  { "tools-ink-blob-aspect-decrease-skip", GIMP_STOCK_TOOL_INK,
    "Decrease Ink Blob Aspect More", NULL, NULL,
    GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
    NULL },
  { "tools-ink-blob-aspect-increase-skip", GIMP_STOCK_TOOL_INK,
    "Increase Ink Blob Aspect More", NULL, NULL,
    GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
    NULL },
};

241
static const GimpEnumActionEntry tools_ink_blob_angle_actions[] =
Michael Natterer's avatar
Michael Natterer committed
242 243 244 245 246 247
{
  { "tools-ink-blob-angle-set", GIMP_STOCK_TOOL_INK,
    "Set Ink Blob Angle", NULL, NULL,
    GIMP_ACTION_SELECT_SET, TRUE,
    NULL },
  { "tools-ink-blob-angle-minimum", GIMP_STOCK_TOOL_INK,
248
    "M Ink Blob Angle", NULL, NULL,
Michael Natterer's avatar
Michael Natterer committed
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
    GIMP_ACTION_SELECT_FIRST, FALSE,
    NULL },
  { "tools-ink-blob-angle-maximum", GIMP_STOCK_TOOL_INK,
    "Maximum Ink Blob Angle", NULL, NULL,
    GIMP_ACTION_SELECT_LAST, FALSE,
    NULL },
  { "tools-ink-blob-angle-decrease", GIMP_STOCK_TOOL_INK,
    "Decrease Ink Blob Angle", NULL, NULL,
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
    NULL },
  { "tools-ink-blob-angle-increase", GIMP_STOCK_TOOL_INK,
    "Increase Ink Blob Angle", NULL, NULL,
    GIMP_ACTION_SELECT_NEXT, FALSE,
    NULL },
  { "tools-ink-blob-angle-decrease-skip", GIMP_STOCK_TOOL_INK,
    "Decrease Ink Blob Angle More", NULL, NULL,
    GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
    NULL },
  { "tools-ink-blob-angle-increase-skip", GIMP_STOCK_TOOL_INK,
    "Increase Ink Blob Angle More", NULL, NULL,
    GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
    NULL },
};

273 274 275 276 277 278 279 280 281
static const GimpEnumActionEntry tools_foreground_select_brush_size_actions[] =
{
  { "tools-foreground-select-brush-size-set",
    GIMP_STOCK_TOOL_FOREGROUND_SELECT,
    "Set Foreground Select Brush Size", NULL, NULL,
    GIMP_ACTION_SELECT_SET, TRUE,
    NULL },
  { "tools-foreground-select-brush-size-minimum",
    GIMP_STOCK_TOOL_FOREGROUND_SELECT,
282
    "M Foreground Select Brush Size", NULL, NULL,
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
    GIMP_ACTION_SELECT_FIRST, FALSE,
    NULL },
  { "tools-foreground-select-brush-size-maximum",
    GIMP_STOCK_TOOL_FOREGROUND_SELECT,
    "Maximum Foreground Select Brush Size", NULL, NULL,
    GIMP_ACTION_SELECT_LAST, FALSE,
    NULL },
  { "tools-foreground-select-brush-size-decrease",
    GIMP_STOCK_TOOL_FOREGROUND_SELECT,
    "Decrease Foreground Select Brush Size", NULL, NULL,
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
    NULL },
  { "tools-foreground-select-brush-size-increase",
    GIMP_STOCK_TOOL_FOREGROUND_SELECT,
    "Increase Foreground Select Brush Size", NULL, NULL,
    GIMP_ACTION_SELECT_NEXT, FALSE,
    NULL },
  { "tools-foreground-select-brush-size-decrease-skip",
    GIMP_STOCK_TOOL_FOREGROUND_SELECT,
    "Decrease Foreground Select Brush Size More", NULL, NULL,
    GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
    NULL },
  { "tools-foreground-select-brush-size-increase-skip",
    GIMP_STOCK_TOOL_FOREGROUND_SELECT,
    "Increase Foreground Select Brush Size More", NULL, NULL,
    GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
    NULL },
};

312
static const GimpEnumActionEntry tools_value_1_actions[] =
Michael Natterer's avatar
Michael Natterer committed
313 314 315 316 317 318 319 320 321 322 323 324 325 326
{
  { "tools-value-1-set", GIMP_STOCK_TOOL_OPTIONS,
    "Set Value 1", NULL, NULL,
    GIMP_ACTION_SELECT_SET, TRUE,
    NULL },
  { "tools-value-1-minimum", GIMP_STOCK_TOOL_OPTIONS,
    "Minimize Value 1", NULL, NULL,
    GIMP_ACTION_SELECT_FIRST, FALSE,
    NULL },
  { "tools-value-1-maximum", GIMP_STOCK_TOOL_OPTIONS,
    "Maximize Value 1", NULL, NULL,
    GIMP_ACTION_SELECT_LAST, FALSE,
    NULL },
  { "tools-value-1-decrease", GIMP_STOCK_TOOL_OPTIONS,
327
    "Decrease Value 1", "less", NULL,
Michael Natterer's avatar
Michael Natterer committed
328 329 330
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
    NULL },
  { "tools-value-1-increase", GIMP_STOCK_TOOL_OPTIONS,
331
    "Increase Value 1", "greater", NULL,
Michael Natterer's avatar
Michael Natterer committed
332 333 334
    GIMP_ACTION_SELECT_NEXT, FALSE,
    NULL },
  { "tools-value-1-decrease-skip", GIMP_STOCK_TOOL_OPTIONS,
335
    "Decrease Value 1 More", "<control>less", NULL,
Michael Natterer's avatar
Michael Natterer committed
336 337 338
    GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
    NULL },
  { "tools-value-1-increase-skip", GIMP_STOCK_TOOL_OPTIONS,
339
    "Increase Value 1 More", "<control>greater", NULL,
Michael Natterer's avatar
Michael Natterer committed
340 341 342 343
    GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
    NULL },
};

344
static const GimpEnumActionEntry tools_value_2_actions[] =
Michael Natterer's avatar
Michael Natterer committed
345 346 347 348 349 350 351 352 353 354 355 356 357 358
{
  { "tools-value-2-set", GIMP_STOCK_TOOL_OPTIONS,
    "Set Value 2", NULL, NULL,
    GIMP_ACTION_SELECT_SET, TRUE,
    NULL },
  { "tools-value-2-minimum", GIMP_STOCK_TOOL_OPTIONS,
    "Minimize Value 2", NULL, NULL,
    GIMP_ACTION_SELECT_FIRST, FALSE,
    NULL },
  { "tools-value-2-maximum", GIMP_STOCK_TOOL_OPTIONS,
    "Maximize Value 2", NULL, NULL,
    GIMP_ACTION_SELECT_LAST, FALSE,
    NULL },
  { "tools-value-2-decrease", GIMP_STOCK_TOOL_OPTIONS,
359
    "Decrease Value 2", "bracketleft", NULL,
Michael Natterer's avatar
Michael Natterer committed
360 361 362
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
    NULL },
  { "tools-value-2-increase", GIMP_STOCK_TOOL_OPTIONS,
363
    "Increase Value 2", "bracketright", NULL,
Michael Natterer's avatar
Michael Natterer committed
364 365 366
    GIMP_ACTION_SELECT_NEXT, FALSE,
    NULL },
  { "tools-value-2-decrease-skip", GIMP_STOCK_TOOL_OPTIONS,
367
    "Decrease Value 2 More", "<shift>bracketleft", NULL,
Michael Natterer's avatar
Michael Natterer committed
368 369 370
    GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
    NULL },
  { "tools-value-2-increase-skip", GIMP_STOCK_TOOL_OPTIONS,
371
    "Increase Value 2 More", "<shift>bracketright", NULL,
Michael Natterer's avatar
Michael Natterer committed
372 373 374 375
    GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
    NULL },
};

376
static const GimpEnumActionEntry tools_value_3_actions[] =
Michael Natterer's avatar
Michael Natterer committed
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407
{
  { "tools-value-3-set", GIMP_STOCK_TOOL_OPTIONS,
    "Set Value 3", NULL, NULL,
    GIMP_ACTION_SELECT_SET, TRUE,
    NULL },
  { "tools-value-3-minimum", GIMP_STOCK_TOOL_OPTIONS,
    "Minimize Value 3", NULL, NULL,
    GIMP_ACTION_SELECT_FIRST, FALSE,
    NULL },
  { "tools-value-3-maximum", GIMP_STOCK_TOOL_OPTIONS,
    "Maximize Value 3", NULL, NULL,
    GIMP_ACTION_SELECT_LAST, FALSE,
    NULL },
  { "tools-value-3-decrease", GIMP_STOCK_TOOL_OPTIONS,
    "Decrease Value 3", NULL, NULL,
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
    NULL },
  { "tools-value-3-increase", GIMP_STOCK_TOOL_OPTIONS,
    "Increase Value 3", NULL, NULL,
    GIMP_ACTION_SELECT_NEXT, FALSE,
    NULL },
  { "tools-value-3-decrease-skip", GIMP_STOCK_TOOL_OPTIONS,
    "Decrease Value 3 More", NULL, NULL,
    GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
    NULL },
  { "tools-value-3-increase-skip", GIMP_STOCK_TOOL_OPTIONS,
    "Increase Value 3 More", NULL, NULL,
    GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
    NULL },
};

408
static const GimpEnumActionEntry tools_value_4_actions[] =
Michael Natterer's avatar
Michael Natterer committed
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
{
  { "tools-value-4-set", GIMP_STOCK_TOOL_OPTIONS,
    "Set Value 4", NULL, NULL,
    GIMP_ACTION_SELECT_SET, TRUE,
    NULL },
  { "tools-value-4-minimum", GIMP_STOCK_TOOL_OPTIONS,
    "Minimize Value 4", NULL, NULL,
    GIMP_ACTION_SELECT_FIRST, FALSE,
    NULL },
  { "tools-value-4-maximum", GIMP_STOCK_TOOL_OPTIONS,
    "Maximize Value 4", NULL, NULL,
    GIMP_ACTION_SELECT_LAST, FALSE,
    NULL },
  { "tools-value-4-decrease", GIMP_STOCK_TOOL_OPTIONS,
    "Decrease Value 4", NULL, NULL,
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
    NULL },
  { "tools-value-4-increase", GIMP_STOCK_TOOL_OPTIONS,
    "Increase Value 4", NULL, NULL,
    GIMP_ACTION_SELECT_NEXT, FALSE,
    NULL },
  { "tools-value-4-decrease-skip", GIMP_STOCK_TOOL_OPTIONS,
    "Decrease Value 4 More", NULL, NULL,
    GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
    NULL },
  { "tools-value-4-increase-skip", GIMP_STOCK_TOOL_OPTIONS,
    "Increase Value 4 More", NULL, NULL,
    GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
    NULL },
};

440
static const GimpEnumActionEntry tools_object_1_actions[] =
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463
{
  { "tools-object-1-set", GIMP_STOCK_TOOL_OPTIONS,
    "Select Object 1 by Index", NULL, NULL,
    GIMP_ACTION_SELECT_SET, TRUE,
    NULL },
  { "tools-object-1-first", GIMP_STOCK_TOOL_OPTIONS,
    "First Object 1", NULL, NULL,
    GIMP_ACTION_SELECT_FIRST, FALSE,
    NULL },
  { "tools-object-1-last", GIMP_STOCK_TOOL_OPTIONS,
    "Last Object 1", NULL, NULL,
    GIMP_ACTION_SELECT_LAST, FALSE,
    NULL },
  { "tools-object-1-previous", GIMP_STOCK_TOOL_OPTIONS,
    "Previous Object 1", NULL, NULL,
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
    NULL },
  { "tools-object-1-next", GIMP_STOCK_TOOL_OPTIONS,
    "Next Object 1", NULL, NULL,
    GIMP_ACTION_SELECT_NEXT, FALSE,
    NULL }
};

464
static const GimpEnumActionEntry tools_object_2_actions[] =
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487
{
  { "tools-object-2-set", GIMP_STOCK_TOOL_OPTIONS,
    "Select Object 2 by Index", NULL, NULL,
    GIMP_ACTION_SELECT_SET, TRUE,
    NULL },
  { "tools-object-2-first", GIMP_STOCK_TOOL_OPTIONS,
    "First Object 2", NULL, NULL,
    GIMP_ACTION_SELECT_FIRST, FALSE,
    NULL },
  { "tools-object-2-last", GIMP_STOCK_TOOL_OPTIONS,
    "Last Object 2", NULL, NULL,
    GIMP_ACTION_SELECT_LAST, FALSE,
    NULL },
  { "tools-object-2-previous", GIMP_STOCK_TOOL_OPTIONS,
    "Previous Object 2", NULL, NULL,
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
    NULL },
  { "tools-object-2-next", GIMP_STOCK_TOOL_OPTIONS,
    "Next Object 2", NULL, NULL,
    GIMP_ACTION_SELECT_NEXT, FALSE,
    NULL }
};

Michael Natterer's avatar
Michael Natterer committed
488 489

void
490
tools_actions_setup (GimpActionGroup *group)
Michael Natterer's avatar
Michael Natterer committed
491
{
492 493
  GtkAction *action;
  GList     *list;
Michael Natterer's avatar
Michael Natterer committed
494 495 496

  gimp_action_group_add_actions (group,
                                 tools_actions,
497
                                 G_N_ELEMENTS (tools_actions));
Michael Natterer's avatar
Michael Natterer committed
498

499 500 501 502
  gimp_action_group_add_toggle_actions (group,
                                        tools_toggle_actions,
                                        G_N_ELEMENTS (tools_toggle_actions));

503 504 505 506 507 508 509 510 511
  gimp_action_group_add_string_actions (group,
                                        tools_alternative_actions,
                                        G_N_ELEMENTS (tools_alternative_actions),
                                        G_CALLBACK (tools_select_cmd_callback));

  action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
                                        "tools-by-color-select-short");
  gtk_action_set_accel_path (action, "<Actions>/tools/tools-by-color-select");

512 513 514 515 516
  gimp_action_group_add_enum_actions (group,
                                      tools_color_average_radius_actions,
                                      G_N_ELEMENTS (tools_color_average_radius_actions),
                                      G_CALLBACK (tools_color_average_radius_cmd_callback));

517 518 519 520 521
  gimp_action_group_add_enum_actions (group,
                                      tools_paint_brush_scale_actions,
                                      G_N_ELEMENTS (tools_paint_brush_scale_actions),
                                      G_CALLBACK (tools_paint_brush_scale_cmd_callback));

Michael Natterer's avatar
Michael Natterer committed
522 523 524 525 526 527 528 529 530 531 532 533 534
  gimp_action_group_add_enum_actions (group,
                                      tools_ink_blob_size_actions,
                                      G_N_ELEMENTS (tools_ink_blob_size_actions),
                                      G_CALLBACK (tools_ink_blob_size_cmd_callback));
  gimp_action_group_add_enum_actions (group,
                                      tools_ink_blob_aspect_actions,
                                      G_N_ELEMENTS (tools_ink_blob_aspect_actions),
                                      G_CALLBACK (tools_ink_blob_aspect_cmd_callback));
  gimp_action_group_add_enum_actions (group,
                                      tools_ink_blob_angle_actions,
                                      G_N_ELEMENTS (tools_ink_blob_angle_actions),
                                      G_CALLBACK (tools_ink_blob_angle_cmd_callback));

535 536 537 538 539
  gimp_action_group_add_enum_actions (group,
                                      tools_foreground_select_brush_size_actions,
                                      G_N_ELEMENTS (tools_foreground_select_brush_size_actions),
                                      G_CALLBACK (tools_fg_select_brush_size_cmd_callback));

Michael Natterer's avatar
Michael Natterer committed
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556
  gimp_action_group_add_enum_actions (group,
                                      tools_value_1_actions,
                                      G_N_ELEMENTS (tools_value_1_actions),
                                      G_CALLBACK (tools_value_1_cmd_callback));
  gimp_action_group_add_enum_actions (group,
                                      tools_value_2_actions,
                                      G_N_ELEMENTS (tools_value_2_actions),
                                      G_CALLBACK (tools_value_2_cmd_callback));
  gimp_action_group_add_enum_actions (group,
                                      tools_value_3_actions,
                                      G_N_ELEMENTS (tools_value_3_actions),
                                      G_CALLBACK (tools_value_3_cmd_callback));
  gimp_action_group_add_enum_actions (group,
                                      tools_value_4_actions,
                                      G_N_ELEMENTS (tools_value_4_actions),
                                      G_CALLBACK (tools_value_4_cmd_callback));

557 558 559 560 561 562 563 564 565
  gimp_action_group_add_enum_actions (group,
                                      tools_object_1_actions,
                                      G_N_ELEMENTS (tools_object_1_actions),
                                      G_CALLBACK (tools_object_1_cmd_callback));
  gimp_action_group_add_enum_actions (group,
                                      tools_object_2_actions,
                                      G_N_ELEMENTS (tools_object_2_actions),
                                      G_CALLBACK (tools_object_2_cmd_callback));

Michael Natterer's avatar
Michael Natterer committed
566 567 568 569 570 571 572 573 574 575 576
  for (list = GIMP_LIST (group->gimp->tool_info_list)->list;
       list;
       list = g_list_next (list))
    {
      GimpToolInfo *tool_info = list->data;

      if (tool_info->menu_path)
        {
          GimpStringActionEntry  entry;
          const gchar           *stock_id;
          const gchar           *identifier;
577 578
          gchar                 *tmp;
          gchar                 *name;
Michael Natterer's avatar
Michael Natterer committed
579 580 581 582

          stock_id   = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool_info));
          identifier = gimp_object_get_name (GIMP_OBJECT (tool_info));

583 584 585 586 587 588
          tmp = g_strndup (identifier + strlen ("gimp-"),
                           strlen (identifier) - strlen ("gimp--tool"));
          name = g_strdup_printf ("tools-%s", tmp);
          g_free (tmp);

          entry.name        = name;
Michael Natterer's avatar
Michael Natterer committed
589 590 591
          entry.stock_id    = stock_id;
          entry.label       = tool_info->menu_path;
          entry.accelerator = tool_info->menu_accel;
592
          entry.tooltip     = tool_info->help;
593
          entry.help_id     = tool_info->help_id;
Michael Natterer's avatar
Michael Natterer committed
594 595 596 597
          entry.value       = identifier;

          gimp_action_group_add_string_actions (group,
                                                &entry, 1,
598
                                                G_CALLBACK (tools_select_cmd_callback));
599 600

          g_free (name);
Michael Natterer's avatar
Michael Natterer committed
601 602 603 604 605 606 607 608
        }
    }
}

void
tools_actions_update (GimpActionGroup *group,
                      gpointer         data)
{
609 610 611 612 613
  GimpContext   *context   = gimp_get_user_context (group->gimp);
  GimpToolInfo  *tool_info = gimp_context_get_tool (context);
  GimpContainer *container = context->gimp->tool_info_list;
  gboolean       raise     = FALSE;
  gboolean       lower     = FALSE;
614

615 616
#define SET_SENSITIVE(action,condition) \
        gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
617 618 619
#define SET_ACTIVE(action,condition) \
        gimp_action_group_set_action_active (group, action, (condition) != 0)

620
  SET_SENSITIVE ("tools-visibility", tool_info);
621 622

  if (tool_info)
623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640
    {
      gint last_index;
      gint index;

      SET_ACTIVE ("tools-visibility", tool_info->visible);

      last_index = gimp_container_num_children (container) -1;
      index      = gimp_container_get_child_index   (container,
                                                     GIMP_OBJECT (tool_info));

      raise = index != 0;
      lower = index != last_index;
    }

  SET_SENSITIVE ("tools-raise",           raise);
  SET_SENSITIVE ("tools-raise-to-top",    raise);
  SET_SENSITIVE ("tools-lower",           lower);
  SET_SENSITIVE ("tools-lower-to-bottom", lower);
641

642
#undef SET_SENSITIVE
643
#undef SET_ACTIVE
Michael Natterer's avatar
Michael Natterer committed
644
}