app: layers-select-* multi-selection aware.

Allows to move multiple selection up and down, within each selected
layer's own depth.
This commit is contained in:
Jehan 2020-05-05 11:53:07 +02:00
parent 8f22f12ee7
commit 22a86c44ca
2 changed files with 37 additions and 31 deletions

View file

@ -558,26 +558,26 @@ static const GimpEnumActionEntry layers_alpha_to_selection_actions[] =
static const GimpEnumActionEntry layers_select_actions[] =
{
{ "layers-select-top", NULL,
NC_("layers-action", "Select _Top Layer"), "Home",
NC_("layers-action", "Select the topmost layer"),
NC_("layers-action", "Select _Top Layers"), "Home",
NC_("layers-action", "Select the topmost layers"),
GIMP_ACTION_SELECT_FIRST, FALSE,
GIMP_HELP_LAYER_TOP },
{ "layers-select-bottom", NULL,
NC_("layers-action", "Select _Bottom Layer"), "End",
NC_("layers-action", "Select the bottommost layer"),
NC_("layers-action", "Select _Bottom Layers"), "End",
NC_("layers-action", "Select the bottommost layers"),
GIMP_ACTION_SELECT_LAST, FALSE,
GIMP_HELP_LAYER_BOTTOM },
{ "layers-select-previous", NULL,
NC_("layers-action", "Select _Previous Layer"), "Prior",
NC_("layers-action", "Select the layer above the current layer"),
NC_("layers-action", "Select _Previous Layers"), "Prior",
NC_("layers-action", "Select the layers above the current layers"),
GIMP_ACTION_SELECT_PREVIOUS, FALSE,
GIMP_HELP_LAYER_PREVIOUS },
{ "layers-select-next", NULL,
NC_("layers-action", "Select _Next Layer"), "Next",
NC_("layers-action", "Select the layer below the current layer"),
NC_("layers-action", "Select _Next Layers"), "Next",
NC_("layers-action", "Select the layers below the current layers"),
GIMP_ACTION_SELECT_NEXT, FALSE,
GIMP_HELP_LAYER_NEXT }
};
@ -781,9 +781,7 @@ layers_actions_update (GimpActionGroup *group,
gboolean bs_mutable = FALSE;
gboolean cs_mutable = FALSE;
gboolean cm_mutable = FALSE;
GList *next = NULL;
GList *next_visible = NULL;
GList *prev = NULL;
gboolean next_mode = TRUE;
gboolean prev_mode = TRUE;
gboolean last_mode = FALSE;
@ -966,10 +964,7 @@ layers_actions_update (GimpActionGroup *group,
if (list)
{
prev = g_list_previous (list);
next = g_list_next (list);
for (next_visible = next;
for (next_visible = g_list_next (list);
next_visible;
next_visible = g_list_next (next_visible))
{
@ -1028,10 +1023,10 @@ layers_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("layers-mode-previous", n_layers > 0 && !ac && prev_mode);
SET_SENSITIVE ("layers-mode-next", n_layers > 0 && !ac && next_mode);
SET_SENSITIVE ("layers-select-top", layer && !fs && !ac && prev);
SET_SENSITIVE ("layers-select-bottom", layer && !fs && !ac && next);
SET_SENSITIVE ("layers-select-previous", layer && !fs && !ac && prev);
SET_SENSITIVE ("layers-select-next", layer && !fs && !ac && next);
SET_SENSITIVE ("layers-select-top", n_layers > 0 && !fs && !ac && have_prev);
SET_SENSITIVE ("layers-select-bottom", n_layers > 0 && !fs && !ac && have_next);
SET_SENSITIVE ("layers-select-previous", n_layers > 0 && !fs && !ac && have_prev);
SET_SENSITIVE ("layers-select-next", n_layers > 0 && !fs && !ac && have_next);
SET_SENSITIVE ("layers-raise", n_layers > 0 && !fs && !ac && have_prev);
SET_SENSITIVE ("layers-raise-to-top", n_layers > 0 && !fs && !ac && have_prev);

View file

@ -577,30 +577,41 @@ layers_select_cmd_callback (GimpAction *action,
gpointer data)
{
GimpImage *image;
GimpLayer *layer;
GList *new_layers = NULL;
GList *layers;
GList *iter;
GimpContainer *container;
GimpLayer *new_layer;
GimpActionSelectType select_type;
gboolean run_once;
return_if_no_image (image, data);
select_type = (GimpActionSelectType) g_variant_get_int32 (value);
layer = gimp_image_get_active_layer (image);
layers = gimp_image_get_selected_layers (image);
run_once = (g_list_length (layers) == 0);
if (layer)
container = gimp_item_get_container (GIMP_ITEM (layer));
else
container = gimp_image_get_layers (image);
new_layer = (GimpLayer *) action_select_object (select_type,
container,
(GimpObject *) layer);
if (new_layer && new_layer != layer)
for (iter = layers; iter || run_once; iter = iter ? iter->next : NULL)
{
gimp_image_set_active_layer (image, new_layer);
if (iter)
container = gimp_item_get_container (GIMP_ITEM (iter->data));
else /* run_once */
container = gimp_image_get_layers (image);
new_layer = (GimpLayer *) action_select_object (select_type,
container,
(GimpObject *) iter->data);
if (new_layer)
new_layers = g_list_prepend (new_layers, new_layer);
}
if (new_layers)
{
gimp_image_set_selected_layers (image, new_layers);
gimp_image_flush (image);
}
g_list_free (new_layers);
}
void