Bug 785061 - Add channels-select-(prev|next|top|bottom) actions.

This commit is contained in:
Jehan
2017-11-16 01:26:19 +01:00
parent 4003bc79db
commit 1e87642ef0
4 changed files with 67 additions and 0 deletions

View File

@ -218,6 +218,33 @@ static const GimpEnumActionEntry channels_to_selection_actions[] =
GIMP_HELP_CHANNEL_SELECTION_INTERSECT }
};
static const GimpEnumActionEntry channels_select_actions[] =
{
{ "channels-select-top", NULL,
NC_("channels-action", "Select _Top Channel"), NULL,
NC_("channels-action", "Select the topmost channel"),
GIMP_ACTION_SELECT_FIRST, FALSE,
GIMP_HELP_CHANNEL_TOP },
{ "channels-select-bottom", NULL,
NC_("channels-action", "Select _Bottom Channel"), NULL,
NC_("channels-action", "Select the bottommost channel"),
GIMP_ACTION_SELECT_LAST, FALSE,
GIMP_HELP_CHANNEL_BOTTOM },
{ "channels-select-previous", NULL,
NC_("channels-action", "Select _Previous Channel"), NULL,
NC_("channels-action", "Select the channel above the current channel"),
GIMP_ACTION_SELECT_PREVIOUS, FALSE,
GIMP_HELP_CHANNEL_PREVIOUS },
{ "channels-select-next", NULL,
NC_("channels-action", "Select _Next Channel"), NULL,
NC_("channels-action", "Select the channel below the current channel"),
GIMP_ACTION_SELECT_NEXT, FALSE,
GIMP_HELP_CHANNEL_NEXT }
};
void
channels_actions_setup (GimpActionGroup *group)
@ -240,6 +267,11 @@ channels_actions_setup (GimpActionGroup *group)
G_N_ELEMENTS (channels_to_selection_actions),
G_CALLBACK (channels_to_selection_cmd_callback));
gimp_action_group_add_enum_actions (group, "channels-action",
channels_select_actions,
G_N_ELEMENTS (channels_select_actions),
G_CALLBACK (channels_select_cmd_callback));
items_actions_setup (group, "channels");
}
@ -305,6 +337,11 @@ channels_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("channels-selection-subtract", !fs && (channel || component));
SET_SENSITIVE ("channels-selection-intersect", !fs && (channel || component));
SET_SENSITIVE ("channels-select-top", !fs && channel && prev);
SET_SENSITIVE ("channels-select-bottom", !fs && channel && next);
SET_SENSITIVE ("channels-select-previous", !fs && channel && prev);
SET_SENSITIVE ("channels-select-next", !fs && channel && next);
#undef SET_SENSITIVE
items_actions_update (group, "channels", GIMP_ITEM (channel));

View File

@ -424,6 +424,28 @@ channels_color_tag_cmd_callback (GtkAction *action,
(GimpColorTag) value);
}
void
channels_select_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpImage *image;
GimpChannel *channel;
GimpChannel *channel2;
GimpContainer *container;
return_if_no_channel (image, channel, data);
container = gimp_image_get_channels (image);
channel2 = (GimpChannel *) action_select_object ((GimpActionSelectType) value,
container,
(GimpObject *) channel);
if (channel2 && channel2 != channel)
{
gimp_image_set_active_channel (image, channel2);
gimp_image_flush (image);
}
}
/* private functions */

View File

@ -56,5 +56,9 @@ void channels_color_tag_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void channels_select_cmd_callback (GtkAction *action,
gint value,
gpointer data);
#endif /* __CHANNELS_COMMANDS_H__ */

View File

@ -233,6 +233,10 @@
#define GIMP_HELP_CHANNEL_LOWER_TO_BOTTOM "gimp-channel-lower-to-bottom"
#define GIMP_HELP_CHANNEL_DUPLICATE "gimp-channel-duplicate"
#define GIMP_HELP_CHANNEL_DELETE "gimp-channel-delete"
#define GIMP_HELP_CHANNEL_PREVIOUS "gimp-channel-previous"
#define GIMP_HELP_CHANNEL_NEXT "gimp-channel-next"
#define GIMP_HELP_CHANNEL_TOP "gimp-channel-top"
#define GIMP_HELP_CHANNEL_BOTTOM "gimp-channel-bottom"
#define GIMP_HELP_CHANNEL_VISIBLE "gimp-channel-visible"
#define GIMP_HELP_CHANNEL_LINKED "gimp-channel-linked"
#define GIMP_HELP_CHANNEL_COLOR_TAG "gimp-channel-color-tag"