layers-actions.c 18.1 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
/* 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/gimpimage.h"
#include "core/gimplayer.h"
29
#include "core/gimplayermask.h"
30 31 32 33 34 35 36
#include "core/gimplist.h"

#include "text/gimptextlayer.h"

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

37
#include "actions.h"
38
#include "image-commands.h"
39
#include "layers-actions.h"
Michael Natterer's avatar
Michael Natterer committed
40
#include "layers-commands.h"
41 42 43 44 45 46

#include "gimp-intl.h"


static GimpActionEntry layers_actions[] =
{
47 48
  { "layers-popup", GIMP_STOCK_LAYERS,
    N_("Layers Menu"), NULL, NULL, NULL,
49
    GIMP_HELP_LAYER_DIALOG },
50

51 52 53 54 55 56 57
  { "layers-menu",              NULL,                    N_("_Layer")        },
  { "layers-stack-menu",        NULL,                    N_("Stac_k")        },
  { "layers-colors-menu",       NULL,                    N_("_Colors")       },
  { "layers-colors-auto-menu",  NULL,                    N_("_Auto")         },
  { "layers-mask-menu",         NULL,                    N_("_Mask")         },
  { "layers-transparency-menu", NULL,                    N_("Tr_ansparency") },
  { "layers-transform-menu",    NULL,                    N_("_Transform")    },
58
  { "layers-properties-menu",   GTK_STOCK_PROPERTIES,    N_("_Properties")   },
59 60
  { "layers-opacity-menu",      GIMP_STOCK_TRANSPARENCY, N_("_Opacity")      },
  { "layers-mode-menu",         GIMP_STOCK_TOOL_PENCIL,  N_("Layer _Mode")   },
61 62 63 64 65 66 67

  { "layers-text-tool", GIMP_STOCK_TOOL_TEXT,
    N_("Te_xt Tool"), NULL, NULL,
    G_CALLBACK (layers_text_tool_cmd_callback),
    GIMP_HELP_TOOL_TEXT },

  { "layers-edit-attributes", GIMP_STOCK_EDIT,
68 69
    N_("_Edit Layer Attributes..."), NULL,
    N_("Edit layer attributes"),
70 71 72 73
    G_CALLBACK (layers_edit_attributes_cmd_callback),
    GIMP_HELP_LAYER_EDIT },

  { "layers-new", GTK_STOCK_NEW,
74
    N_("_New Layer..."), "<control><shift>N",
75
    N_("New layer..."),
76 77 78
    G_CALLBACK (layers_new_cmd_callback),
    GIMP_HELP_LAYER_NEW },

79
  { "layers-new-last-values", GTK_STOCK_NEW,
80
    N_("_New Layer"), "",
81 82
    N_("New layer with last values"),
    G_CALLBACK (layers_new_last_vals_cmd_callback),
83 84
    GIMP_HELP_LAYER_NEW },

85
  { "layers-duplicate", GIMP_STOCK_DUPLICATE,
86
    N_("D_uplicate Layer"), "<control><shift>D",
87
    N_("Duplicate layer"),
88 89 90 91
    G_CALLBACK (layers_duplicate_cmd_callback),
    GIMP_HELP_LAYER_DUPLICATE },

  { "layers-delete", GTK_STOCK_DELETE,
92 93
    N_("_Delete Layer"), "",
    N_("Delete layer"),
94 95 96 97
    G_CALLBACK (layers_delete_cmd_callback),
    GIMP_HELP_LAYER_DELETE },

  { "layers-raise", GTK_STOCK_GO_UP,
98 99
    N_("_Raise Layer"), "",
    N_("Raise layer"),
100 101 102 103
    G_CALLBACK (layers_raise_cmd_callback),
    GIMP_HELP_LAYER_RAISE },

  { "layers-raise-to-top", GTK_STOCK_GOTO_TOP,
104 105
    N_("Layer to _Top"), "",
    N_("Raise layer to top"),
106 107 108 109
    G_CALLBACK (layers_raise_to_top_cmd_callback),
    GIMP_HELP_LAYER_RAISE_TO_TOP },

  { "layers-lower", GTK_STOCK_GO_DOWN,
110 111
    N_("_Lower Layer"), "",
    N_("Lower layer"),
112 113 114 115
    G_CALLBACK (layers_lower_cmd_callback),
    GIMP_HELP_LAYER_LOWER },

  { "layers-lower-to-bottom", GTK_STOCK_GOTO_BOTTOM,
116 117
    N_("Layer to _Bottom"), "",
    N_("Lower layer to bottom"),
118 119 120 121
    G_CALLBACK (layers_lower_to_bottom_cmd_callback),
    GIMP_HELP_LAYER_LOWER_TO_BOTTOM },

  { "layers-anchor", GIMP_STOCK_ANCHOR,
122
    N_("_Anchor Layer"), "<control>H",
123
    N_("Anchor floating layer"),
124 125 126 127 128 129 130 131 132 133
    G_CALLBACK (layers_anchor_cmd_callback),
    GIMP_HELP_LAYER_ANCHOR },

  { "layers-merge-down", GIMP_STOCK_MERGE_DOWN,
    N_("Merge Do_wn"), NULL, NULL,
    G_CALLBACK (layers_merge_down_cmd_callback),
    GIMP_HELP_LAYER_MERGE_DOWN },

  { "layers-merge-layers", NULL,
    N_("Merge _Visible Layers..."), NULL, NULL,
134
    G_CALLBACK (image_merge_layers_cmd_callback),
135 136 137 138
    GIMP_HELP_IMAGE_MERGE_LAYERS },

  { "layers-flatten-image", NULL,
    N_("_Flatten Image"), NULL, NULL,
139
    G_CALLBACK (image_flatten_image_cmd_callback),
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
    GIMP_HELP_IMAGE_FLATTEN },

  { "layers-text-discard", GIMP_STOCK_TOOL_TEXT,
    N_("_Discard Text Information"), NULL, NULL,
    G_CALLBACK (layers_text_discard_cmd_callback),
    GIMP_HELP_LAYER_TEXT_DISCARD },

  { "layers-resize", GIMP_STOCK_RESIZE,
    N_("Layer B_oundary Size..."), NULL, NULL,
    G_CALLBACK (layers_resize_cmd_callback),
    GIMP_HELP_LAYER_RESIZE },

  { "layers-resize-to-image", GIMP_STOCK_LAYER_TO_IMAGESIZE,
    N_("Layer to _Image Size"), NULL, NULL,
    G_CALLBACK (layers_resize_to_image_cmd_callback),
    GIMP_HELP_LAYER_RESIZE_TO_IMAGE },

  { "layers-scale", GIMP_STOCK_SCALE,
    N_("_Scale Layer..."), NULL, NULL,
    G_CALLBACK (layers_scale_cmd_callback),
    GIMP_HELP_LAYER_SCALE },

162 163 164 165 166
  { "layers-crop", GIMP_STOCK_TOOL_CROP,
    N_("Cr_op Layer"), NULL, NULL,
    G_CALLBACK (layers_crop_cmd_callback),
    GIMP_HELP_LAYER_CROP },

167 168 169 170 171
  { "layers-mask-add", GIMP_STOCK_LAYER_MASK,
    N_("Add La_yer Mask..."), NULL, NULL,
    G_CALLBACK (layers_mask_add_cmd_callback),
    GIMP_HELP_LAYER_MASK_ADD },

172 173 174
  { "layers-alpha-add", GIMP_STOCK_TRANSPARENCY,
    N_("Add Alpha C_hannel"), NULL, NULL,
    G_CALLBACK (layers_alpha_add_cmd_callback),
Michael Natterer's avatar
Michael Natterer committed
175 176 177 178 179 180
    GIMP_HELP_LAYER_ALPHA_ADD },

  { "layers-alpha-remove", NULL,
    N_("_Remove Alpha Channel"), NULL, NULL,
    G_CALLBACK (layers_alpha_remove_cmd_callback),
    GIMP_HELP_LAYER_ALPHA_REMOVE }
181 182
};

183
static GimpToggleActionEntry layers_toggle_actions[] =
184
{
185 186 187
  { "layers-lock-alpha", GIMP_STOCK_TRANSPARENCY,
    N_("Lock Alph_a Channel"), NULL, NULL,
    G_CALLBACK (layers_lock_alpha_cmd_callback),
188
    FALSE,
189
    GIMP_HELP_LAYER_LOCK_ALPHA },
190 191

  { "layers-mask-edit", GIMP_STOCK_EDIT,
192
    N_("_Edit Layer Mask"), NULL, NULL,
193 194
    G_CALLBACK (layers_mask_edit_cmd_callback),
    FALSE,
195
    GIMP_HELP_LAYER_MASK_EDIT },
196

197
  { "layers-mask-show", GIMP_STOCK_VISIBLE,
198
    N_("S_how Layer Mask"), NULL, NULL,
199 200
    G_CALLBACK (layers_mask_show_cmd_callback),
    FALSE,
201
    GIMP_HELP_LAYER_MASK_SHOW },
202 203

  { "layers-mask-disable", NULL,
204
    N_("_Disable Layer Mask"), NULL, NULL,
205 206
    G_CALLBACK (layers_mask_disable_cmd_callback),
    FALSE,
207
    GIMP_HELP_LAYER_MASK_DISABLE }
208 209
};

210 211
static GimpEnumActionEntry layers_mask_apply_actions[] =
{
212 213
  { "layers-mask-apply", NULL,
    N_("Apply Layer _Mask"), NULL, NULL,
214
    GIMP_MASK_APPLY, FALSE,
215 216 217 218
    GIMP_HELP_LAYER_MASK_APPLY },

  { "layers-mask-delete", GTK_STOCK_DELETE,
    N_("Delete Layer Mas_k"), "", NULL,
219
    GIMP_MASK_DISCARD, FALSE,
220
    GIMP_HELP_LAYER_MASK_DELETE }
221 222 223 224 225 226
};

static GimpEnumActionEntry layers_mask_to_selection_actions[] =
{
  { "layers-mask-selection-replace", GIMP_STOCK_SELECTION_REPLACE,
    N_("_Mask to Selection"), NULL, NULL,
227
    GIMP_CHANNEL_OP_REPLACE, FALSE,
228 229
    GIMP_HELP_LAYER_MASK_SELECTION_REPLACE },

230
  { "layers-mask-selection-add", GIMP_STOCK_SELECTION_ADD,
231
    N_("_Add to Selection"), NULL, NULL,
232
    GIMP_CHANNEL_OP_ADD, FALSE,
233 234 235 236
    GIMP_HELP_LAYER_MASK_SELECTION_ADD },

  { "layers-mask-selection-subtract", GIMP_STOCK_SELECTION_SUBTRACT,
    N_("_Subtract from Selection"), NULL, NULL,
237
    GIMP_CHANNEL_OP_SUBTRACT, FALSE,
238 239 240 241
    GIMP_HELP_LAYER_MASK_SELECTION_SUBTRACT },

  { "layers-mask-selection-intersect", GIMP_STOCK_SELECTION_INTERSECT,
    N_("_Intersect with Selection"), NULL, NULL,
242
    GIMP_CHANNEL_OP_INTERSECT, FALSE,
243 244 245 246 247 248 249
    GIMP_HELP_LAYER_MASK_SELECTION_INTERSECT }
};

static GimpEnumActionEntry layers_alpha_to_selection_actions[] =
{
  { "layers-alpha-selection-replace", GIMP_STOCK_SELECTION_REPLACE,
    N_("Al_pha to Selection"), NULL, NULL,
250
    GIMP_CHANNEL_OP_REPLACE, FALSE,
251 252 253 254
    GIMP_HELP_LAYER_ALPHA_SELECTION_REPLACE },

  { "layers-alpha-selection-add", GIMP_STOCK_SELECTION_ADD,
    N_("A_dd to Selection"), NULL, NULL,
255
    GIMP_CHANNEL_OP_ADD, FALSE,
256 257 258 259
    GIMP_HELP_LAYER_ALPHA_SELECTION_ADD },

  { "layers-alpha-selection-subtract", GIMP_STOCK_SELECTION_SUBTRACT,
    N_("_Subtract from Selection"), NULL, NULL,
260
    GIMP_CHANNEL_OP_SUBTRACT, FALSE,
261 262
    GIMP_HELP_LAYER_ALPHA_SELECTION_SUBTRACT },

263
  { "layers-alpha-selection-intersect", GIMP_STOCK_SELECTION_INTERSECT,
264
    N_("_Intersect with Selection"), NULL, NULL,
265
    GIMP_CHANNEL_OP_INTERSECT, FALSE,
266 267 268
    GIMP_HELP_LAYER_ALPHA_SELECTION_INTERSECT }
};

269 270 271 272
static GimpEnumActionEntry layers_select_actions[] =
{
  { "layers-select-top", NULL,
    N_("Select _Top Layer"), "Home", NULL,
273
    GIMP_ACTION_SELECT_FIRST, FALSE,
274 275 276 277
    GIMP_HELP_LAYER_TOP },

  { "layers-select-bottom", NULL,
    N_("Select _Bottom Layer"), "End", NULL,
278
    GIMP_ACTION_SELECT_LAST, FALSE,
279 280 281 282
    GIMP_HELP_LAYER_BOTTOM },

  { "layers-select-previous", NULL,
    N_("Select _Previous Layer"), "Prior", NULL,
283
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
284 285 286 287
    GIMP_HELP_LAYER_PREVIOUS },

  { "layers-select-next", NULL,
    N_("Select _Next Layer"), "Next", NULL,
288
    GIMP_ACTION_SELECT_NEXT, FALSE,
289 290 291 292 293 294 295
    GIMP_HELP_LAYER_NEXT }
};

static GimpEnumActionEntry layers_opacity_actions[] =
{
  { "layers-opacity-set", GIMP_STOCK_TRANSPARENCY,
    N_("Set Opacity"), NULL, NULL,
296
    GIMP_ACTION_SELECT_SET, TRUE,
297 298
    GIMP_HELP_LAYER_OPACITY },
  { "layers-opacity-transparent", GIMP_STOCK_TRANSPARENCY,
299
    "Completely Transparent", NULL, NULL,
300
    GIMP_ACTION_SELECT_FIRST, FALSE,
301 302
    GIMP_HELP_LAYER_OPACITY },
  { "layers-opacity-opaque", GIMP_STOCK_TRANSPARENCY,
303
    "Completely Opaque", NULL, NULL,
304
    GIMP_ACTION_SELECT_LAST, FALSE,
305 306
    GIMP_HELP_LAYER_OPACITY },
  { "layers-opacity-decrease", GIMP_STOCK_TRANSPARENCY,
307
    "More Transparent", NULL, NULL,
308
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
309 310
    GIMP_HELP_LAYER_OPACITY },
  { "layers-opacity-increase", GIMP_STOCK_TRANSPARENCY,
311
    "More Opaque", NULL, NULL,
312
    GIMP_ACTION_SELECT_NEXT, FALSE,
313 314
    GIMP_HELP_LAYER_OPACITY },
  { "layers-opacity-decrease-skip", GIMP_STOCK_TRANSPARENCY,
315
    "10% More Transparent", NULL, NULL,
316
    GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
317 318
    GIMP_HELP_LAYER_OPACITY },
  { "layers-opacity-increase-skip", GIMP_STOCK_TRANSPARENCY,
319
    "10% More Opaque", NULL, NULL,
320
    GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
321
    GIMP_HELP_LAYER_OPACITY }
322 323
};

324
static GimpEnumActionEntry layers_mode_actions[] =
325
{
326 327
  { "layers-mode-first", GIMP_STOCK_TOOL_PENCIL,
    "First Layer Mode", NULL, NULL,
328
    GIMP_ACTION_SELECT_FIRST, FALSE,
329 330 331
    GIMP_HELP_LAYER_MODE },
  { "layers-mode-last", GIMP_STOCK_TOOL_PENCIL,
    "Last Layer Mode", NULL, NULL,
332
    GIMP_ACTION_SELECT_LAST, FALSE,
333 334 335
    GIMP_HELP_LAYER_MODE },
  { "layers-mode-previous", GIMP_STOCK_TOOL_PENCIL,
    "Previous Layer Mode", NULL, NULL,
336
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
337 338 339
    GIMP_HELP_LAYER_MODE },
  { "layers-mode-next", GIMP_STOCK_TOOL_PENCIL,
    "Next Layer Mode", NULL, NULL,
340
    GIMP_ACTION_SELECT_NEXT, FALSE,
341
    GIMP_HELP_LAYER_MODE }
342 343
};

344

345
void
346
layers_actions_setup (GimpActionGroup *group)
347 348 349
{
  gimp_action_group_add_actions (group,
                                 layers_actions,
350
                                 G_N_ELEMENTS (layers_actions));
351

352 353 354 355
  gimp_action_group_add_toggle_actions (group,
                                        layers_toggle_actions,
                                        G_N_ELEMENTS (layers_toggle_actions));

356 357 358 359 360
  gimp_action_group_add_enum_actions (group,
                                      layers_mask_apply_actions,
                                      G_N_ELEMENTS (layers_mask_apply_actions),
                                      G_CALLBACK (layers_mask_apply_cmd_callback));

361 362 363
  gimp_action_group_add_enum_actions (group,
                                      layers_mask_to_selection_actions,
                                      G_N_ELEMENTS (layers_mask_to_selection_actions),
364
                                      G_CALLBACK (layers_mask_to_selection_cmd_callback));
365 366 367 368

  gimp_action_group_add_enum_actions (group,
                                      layers_alpha_to_selection_actions,
                                      G_N_ELEMENTS (layers_alpha_to_selection_actions),
369
                                      G_CALLBACK (layers_alpha_to_selection_cmd_callback));
370 371 372 373 374

  gimp_action_group_add_enum_actions (group,
                                      layers_select_actions,
                                      G_N_ELEMENTS (layers_select_actions),
                                      G_CALLBACK (layers_select_cmd_callback));
375

376 377 378 379
  gimp_action_group_add_enum_actions (group,
                                      layers_opacity_actions,
                                      G_N_ELEMENTS (layers_opacity_actions),
                                      G_CALLBACK (layers_opacity_cmd_callback));
380 381

  gimp_action_group_add_enum_actions (group,
382 383 384
                                      layers_mode_actions,
                                      G_N_ELEMENTS (layers_mode_actions),
                                      G_CALLBACK (layers_mode_cmd_callback));
385 386 387 388 389 390
}

void
layers_actions_update (GimpActionGroup *group,
                       gpointer         data)
{
391
  GimpImage     *gimage     = action_data_get_image (data);
392
  GimpLayer     *layer      = NULL;
393
  GimpLayerMask *mask       = NULL;     /*  layer mask             */
394 395
  gboolean       fs         = FALSE;    /*  floating sel           */
  gboolean       ac         = FALSE;    /*  active channel         */
396
  gboolean       sel        = FALSE;
397 398
  gboolean       alpha      = FALSE;    /*  alpha channel present  */
  gboolean       indexed    = FALSE;    /*  is indexed             */
399
  gboolean       lock_alpha = FALSE;
400 401 402
  gboolean       text_layer = FALSE;
  GList         *next       = NULL;
  GList         *prev       = NULL;
403 404 405

  if (gimage)
    {
406 407 408 409
      fs      = (gimp_image_floating_sel (gimage) != NULL);
      ac      = (gimp_image_get_active_channel (gimage) != NULL);
      sel     = ! gimp_channel_is_empty (gimp_image_get_mask (gimage));
      indexed = (gimp_image_base_type (gimage) == GIMP_INDEXED);
410 411 412 413

      layer = gimp_image_get_active_layer (gimage);

      if (layer)
414
        {
415
          GList *list;
416

417 418 419
          mask       = gimp_layer_get_mask (layer);
          lock_alpha = gimp_layer_get_lock_alpha (layer);
          alpha      = gimp_drawable_has_alpha (GIMP_DRAWABLE (layer));
420

421
          list = g_list_find (GIMP_LIST (gimage->layers)->list, layer);
422

423
          if (list)
424 425 426 427 428
            {
              prev = g_list_previous (list);
              next = g_list_next (list);
            }

429 430 431
          if (layer)
            text_layer = gimp_drawable_is_text_layer (GIMP_DRAWABLE (layer));
        }
432 433 434 435 436 437
    }

#define SET_VISIBLE(action,condition) \
        gimp_action_group_set_action_visible (group, action, (condition) != 0)
#define SET_SENSITIVE(action,condition) \
        gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
438 439
#define SET_ACTIVE(action,condition) \
        gimp_action_group_set_action_active (group, action, (condition) != 0)
440 441 442 443

  SET_VISIBLE   ("layers-text-tool",       text_layer && !ac);
  SET_SENSITIVE ("layers-edit-attributes", layer && !fs && !ac);

444 445 446 447
  SET_SENSITIVE ("layers-new",             gimage);
  SET_SENSITIVE ("layers-new-last-values", gimage);
  SET_SENSITIVE ("layers-duplicate",       layer && !fs && !ac);
  SET_SENSITIVE ("layers-delete",          layer && !ac);
448 449 450

  SET_SENSITIVE ("layers-select-top",      layer && !fs && !ac && prev);
  SET_SENSITIVE ("layers-select-bottom",   layer && !fs && !ac && next);
451 452
  SET_SENSITIVE ("layers-select-previous", layer && !fs && !ac && prev);
  SET_SENSITIVE ("layers-select-next",     layer && !fs && !ac && next);
453

454 455 456 457
  SET_SENSITIVE ("layers-raise",           layer && !fs && !ac && prev);
  SET_SENSITIVE ("layers-raise-to-top",    layer && !fs && !ac && prev);
  SET_SENSITIVE ("layers-lower",           layer && !fs && !ac && next);
  SET_SENSITIVE ("layers-lower-to-bottom", layer && !fs && !ac && next);
458 459 460 461 462 463 464 465 466 467 468

  SET_SENSITIVE ("layers-anchor",        layer &&  fs && !ac);
  SET_SENSITIVE ("layers-merge-down",    layer && !fs && !ac && next);
  SET_SENSITIVE ("layers-merge-layers",  layer && !fs && !ac);
  SET_SENSITIVE ("layers-flatten-image", layer && !fs && !ac);
  SET_VISIBLE   ("layers-text-discard",  text_layer && !ac);

  SET_SENSITIVE ("layers-resize",          layer && !ac);
  SET_SENSITIVE ("layers-resize-to-image", layer && !ac);
  SET_SENSITIVE ("layers-scale",           layer && !ac);

469 470
  SET_SENSITIVE ("layers-crop",            layer && sel);

471
  SET_SENSITIVE ("layers-alpha-add",       layer && !fs && !alpha);
Michael Natterer's avatar
Michael Natterer committed
472
  SET_SENSITIVE ("layers-alpha-remove",    layer && !fs &&  alpha);
473

474 475
  SET_SENSITIVE ("layers-lock-alpha", layer);
  SET_ACTIVE    ("layers-lock-alpha", lock_alpha);
476

477
  SET_SENSITIVE ("layers-mask-add",    layer && !fs && !ac && !mask);
478 479 480 481 482 483 484 485 486 487
  SET_SENSITIVE ("layers-mask-apply",  layer && !fs && !ac &&  mask);
  SET_SENSITIVE ("layers-mask-delete", layer && !fs && !ac &&  mask);

  SET_SENSITIVE ("layers-mask-edit",    layer && !fs && !ac &&  mask);
  SET_SENSITIVE ("layers-mask-show",    layer && !fs && !ac &&  mask);
  SET_SENSITIVE ("layers-mask-disable", layer && !fs && !ac &&  mask);

  SET_ACTIVE ("layers-mask-edit",    mask && gimp_layer_mask_get_edit (mask));
  SET_ACTIVE ("layers-mask-show",    mask && gimp_layer_mask_get_show (mask));
  SET_ACTIVE ("layers-mask-disable", mask && !gimp_layer_mask_get_apply (mask));
488

489 490 491 492
  SET_SENSITIVE ("layers-mask-selection-replace",   layer && !fs && !ac && mask);
  SET_SENSITIVE ("layers-mask-selection-add",       layer && !fs && !ac && mask);
  SET_SENSITIVE ("layers-mask-selection-subtract",  layer && !fs && !ac && mask);
  SET_SENSITIVE ("layers-mask-selection-intersect", layer && !fs && !ac && mask);
493 494 495 496 497 498 499 500

  SET_SENSITIVE ("layers-alpha-selection-replace",   layer && !fs && !ac);
  SET_SENSITIVE ("layers-alpha-selection-add",       layer && !fs && !ac);
  SET_SENSITIVE ("layers-alpha-selection-subtract",  layer && !fs && !ac);
  SET_SENSITIVE ("layers-alpha-selection-intersect", layer && !fs && !ac);

#undef SET_VISIBLE
#undef SET_SENSITIVE
501
#undef SET_ACTIVE
502
}