1
1
mirror of https://gitlab.gnome.org/GNOME/gimp.git synced 2025-10-06 01:12:40 +02:00

Compare commits

...

1 Commits

Author SHA1 Message Date
Alx Sa
2f57e9defb app/actions, menus: Add 'Select Layers' option
This patch adds an option to create a selection covering
just the area of the highlighted layers. This differs from
the Select All option, as it will not expand if you switch
layers.
2025-08-01 11:13:30 -04:00
6 changed files with 50 additions and 0 deletions

View File

@@ -46,6 +46,12 @@ static const GimpActionEntry select_actions[] =
select_all_cmd_callback,
GIMP_HELP_SELECTION_ALL },
{ "select-layers", NULL,
NC_("select-action", "_Layers"), NULL, { "<shift>A", NULL },
NC_("select-action", "Select all highlighted layers"),
select_layer_cmd_callback,
GIMP_HELP_SELECTION_LAYERS },
{ "select-none", GIMP_ICON_SELECTION_NONE,
NC_("select-action", "_None"), NULL, { "<primary><shift>A", NULL },
NC_("select-action", "Dismiss the selection"),
@@ -186,6 +192,7 @@ select_actions_update (GimpActionGroup *group,
gimp_action_group_set_action_sensitive (group, action, (condition) != 0, NULL)
SET_SENSITIVE ("select-all", image && ! sel_all);
SET_SENSITIVE ("select-layers", image && ! sel_all);
SET_SENSITIVE ("select-none", image && sel);
SET_SENSITIVE ("select-invert", image);

View File

@@ -30,6 +30,7 @@
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpchannel-combine.h"
#include "core/gimpimage.h"
#include "core/gimpselection.h"
@@ -88,6 +89,42 @@ select_all_cmd_callback (GimpAction *action,
gimp_image_flush (image);
}
void
select_layer_cmd_callback (GimpAction *action,
GVariant *value,
gpointer data)
{
GimpChannelOps ops;
GimpImage *image;
GimpItem *item;
GList *iter;
GList *layers;
return_if_no_image (image, data);
ops = GIMP_CHANNEL_OP_REPLACE;
layers = gimp_image_get_selected_layers (image);
if (g_list_length (layers) > 0)
gimp_channel_push_undo (gimp_image_get_mask (image),
C_("undo-type", "Select Layers"));
for (iter = layers; iter; iter = iter->next)
{
item = GIMP_ITEM (iter->data);
gimp_channel_combine_rect (gimp_image_get_mask (image),
ops,
gimp_item_get_offset_x (item),
gimp_item_get_offset_y (item),
gimp_item_get_width (item),
gimp_item_get_height (item));
ops = GIMP_CHANNEL_OP_ADD;
}
gimp_image_flush (image);
}
void
select_none_cmd_callback (GimpAction *action,
GVariant *value,

View File

@@ -21,6 +21,9 @@
void select_all_cmd_callback (GimpAction *action,
GVariant *value,
gpointer data);
void select_layer_cmd_callback (GimpAction *action,
GVariant *value,
gpointer data);
void select_none_cmd_callback (GimpAction *action,
GVariant *value,
gpointer data);

View File

@@ -69,6 +69,7 @@
#define GIMP_HELP_SELECTION_DIALOG "gimp-selection-dialog"
#define GIMP_HELP_SELECTION_ALL "gimp-selection-all"
#define GIMP_HELP_SELECTION_LAYERS "gimp-selection-layers"
#define GIMP_HELP_SELECTION_NONE "gimp-selection-none"
#define GIMP_HELP_SELECTION_INVERT "gimp-selection-invert"
#define GIMP_HELP_SELECTION_FLOAT "gimp-selection-float"

View File

@@ -149,6 +149,7 @@
<attribute name="label" translatable="yes" context="select-action">_Select</attribute>
<section>
<item><attribute name="action">app.select-all</attribute></item>
<item><attribute name="action">app.select-layers</attribute></item>
<item><attribute name="action">app.select-none</attribute></item>
<item><attribute name="action">app.select-invert</attribute></item>
<submenu>

View File

@@ -7,6 +7,7 @@
<attribute name="icon">gimp-selection</attribute>
<item><attribute name="action">app.select-all</attribute></item>
<item><attribute name="action">app.select-layers</attribute></item>
<item><attribute name="action">app.select-none</attribute></item>
<item><attribute name="action">app.select-invert</attribute></item>
<item><attribute name="action">app.paths-selection-from-paths</attribute></item>