2006-12-09 13:33:38 -08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2004-04-19 07:54:24 -07:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
2009-01-17 14:28:01 -08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2004-04-19 07:54:24 -07:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 14:28:01 -08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2004-04-19 07:54:24 -07:00
|
|
|
* (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
|
2018-07-11 14:47:19 -07:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2004-04-19 07:54:24 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2008-10-09 13:24:04 -07:00
|
|
|
#include <gegl.h>
|
2004-04-19 07:54:24 -07:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
|
|
#include "actions-types.h"
|
|
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
|
|
|
|
#include "core/gimpchannel.h"
|
|
|
|
|
#include "core/gimpimage.h"
|
|
|
|
|
|
|
|
|
|
#include "widgets/gimpactiongroup.h"
|
|
|
|
|
#include "widgets/gimphelp-ids.h"
|
|
|
|
|
|
2004-05-03 07:03:51 -07:00
|
|
|
#include "actions.h"
|
2004-04-19 07:54:24 -07:00
|
|
|
#include "select-actions.h"
|
2004-04-20 06:25:55 -07:00
|
|
|
#include "select-commands.h"
|
2004-04-19 07:54:24 -07:00
|
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
|
|
2006-04-10 01:06:18 -07:00
|
|
|
static const GimpActionEntry select_actions[] =
|
2004-04-19 07:54:24 -07:00
|
|
|
{
|
2017-03-05 07:01:59 -08:00
|
|
|
{ "selection-popup", GIMP_ICON_SELECTION,
|
2008-12-03 07:27:42 -08:00
|
|
|
NC_("select-action", "Selection Editor Menu"), NULL, NULL, NULL,
|
2004-05-12 11:36:33 -07:00
|
|
|
GIMP_HELP_SELECTION_DIALOG },
|
|
|
|
|
|
2008-12-03 07:27:42 -08:00
|
|
|
{ "select-menu", NULL, NC_("select-action", "_Select") },
|
2004-04-19 07:54:24 -07:00
|
|
|
|
2017-03-05 07:01:59 -08:00
|
|
|
{ "select-all", GIMP_ICON_SELECTION_ALL,
|
2011-09-16 13:56:08 -07:00
|
|
|
NC_("select-action", "_All"), "<primary>A",
|
2008-12-04 02:32:20 -08:00
|
|
|
NC_("select-action", "Select everything"),
|
2004-04-19 07:54:24 -07:00
|
|
|
G_CALLBACK (select_all_cmd_callback),
|
|
|
|
|
GIMP_HELP_SELECTION_ALL },
|
|
|
|
|
|
2017-03-05 07:01:59 -08:00
|
|
|
{ "select-none", GIMP_ICON_SELECTION_NONE,
|
2011-09-16 13:56:08 -07:00
|
|
|
NC_("select-action", "_None"), "<primary><shift>A",
|
2008-12-04 02:32:20 -08:00
|
|
|
NC_("select-action", "Dismiss the selection"),
|
2004-04-19 07:54:24 -07:00
|
|
|
G_CALLBACK (select_none_cmd_callback),
|
|
|
|
|
GIMP_HELP_SELECTION_NONE },
|
|
|
|
|
|
2017-03-05 07:01:59 -08:00
|
|
|
{ "select-invert", GIMP_ICON_INVERT,
|
2011-09-16 13:56:08 -07:00
|
|
|
NC_("select-action", "_Invert"), "<primary>I",
|
2008-12-04 02:32:20 -08:00
|
|
|
NC_("select-action", "Invert the selection"),
|
2004-04-19 07:54:24 -07:00
|
|
|
G_CALLBACK (select_invert_cmd_callback),
|
|
|
|
|
GIMP_HELP_SELECTION_INVERT },
|
|
|
|
|
|
2017-03-05 07:01:59 -08:00
|
|
|
{ "select-float", GIMP_ICON_LAYER_FLOATING_SELECTION,
|
2011-09-16 13:56:08 -07:00
|
|
|
NC_("select-action", "_Float"), "<primary><shift>L",
|
2008-12-04 02:32:20 -08:00
|
|
|
NC_("select-action", "Create a floating selection"),
|
2004-04-19 07:54:24 -07:00
|
|
|
G_CALLBACK (select_float_cmd_callback),
|
|
|
|
|
GIMP_HELP_SELECTION_FLOAT },
|
|
|
|
|
|
|
|
|
|
{ "select-feather", NULL,
|
2008-12-03 07:27:42 -08:00
|
|
|
NC_("select-action", "Fea_ther..."), NULL,
|
2008-12-04 02:32:20 -08:00
|
|
|
NC_("select-action",
|
|
|
|
|
"Blur the selection border so that it fades out smoothly"),
|
2004-04-19 07:54:24 -07:00
|
|
|
G_CALLBACK (select_feather_cmd_callback),
|
|
|
|
|
GIMP_HELP_SELECTION_FEATHER },
|
|
|
|
|
|
|
|
|
|
{ "select-sharpen", NULL,
|
2008-12-03 07:27:42 -08:00
|
|
|
NC_("select-action", "_Sharpen"), NULL,
|
2011-08-27 05:49:19 -07:00
|
|
|
NC_("select-action", "Remove fuzziness from the selection"),
|
2004-04-19 07:54:24 -07:00
|
|
|
G_CALLBACK (select_sharpen_cmd_callback),
|
|
|
|
|
GIMP_HELP_SELECTION_SHARPEN },
|
|
|
|
|
|
2017-03-05 07:01:59 -08:00
|
|
|
{ "select-shrink", GIMP_ICON_SELECTION_SHRINK,
|
2008-12-03 07:27:42 -08:00
|
|
|
NC_("select-action", "S_hrink..."), NULL,
|
2008-12-04 02:32:20 -08:00
|
|
|
NC_("select-action", "Contract the selection"),
|
2004-04-19 07:54:24 -07:00
|
|
|
G_CALLBACK (select_shrink_cmd_callback),
|
|
|
|
|
GIMP_HELP_SELECTION_SHRINK },
|
|
|
|
|
|
2017-03-05 07:01:59 -08:00
|
|
|
{ "select-grow", GIMP_ICON_SELECTION_GROW,
|
2008-12-03 07:27:42 -08:00
|
|
|
NC_("select-action", "_Grow..."), NULL,
|
2008-12-04 02:32:20 -08:00
|
|
|
NC_("select-action", "Enlarge the selection"),
|
2004-04-19 07:54:24 -07:00
|
|
|
G_CALLBACK (select_grow_cmd_callback),
|
|
|
|
|
GIMP_HELP_SELECTION_GROW },
|
|
|
|
|
|
2017-03-05 07:01:59 -08:00
|
|
|
{ "select-border", GIMP_ICON_SELECTION_BORDER,
|
2008-12-03 07:27:42 -08:00
|
|
|
NC_("select-action", "Bo_rder..."), NULL,
|
2008-12-04 02:32:20 -08:00
|
|
|
NC_("select-action", "Replace the selection by its border"),
|
2004-04-19 07:54:24 -07:00
|
|
|
G_CALLBACK (select_border_cmd_callback),
|
|
|
|
|
GIMP_HELP_SELECTION_BORDER },
|
|
|
|
|
|
2016-01-24 09:43:35 -08:00
|
|
|
{ "select-flood", NULL,
|
2016-04-10 07:34:14 -07:00
|
|
|
NC_("select-action", "Re_move Holes"), NULL,
|
2016-02-03 11:25:02 -08:00
|
|
|
NC_("select-action", "Remove holes from the selection"),
|
2016-01-24 09:43:35 -08:00
|
|
|
G_CALLBACK (select_flood_cmd_callback),
|
|
|
|
|
GIMP_HELP_SELECTION_FLOOD },
|
|
|
|
|
|
2017-03-05 07:01:59 -08:00
|
|
|
{ "select-save", GIMP_ICON_SELECTION_TO_CHANNEL,
|
2008-12-03 07:27:42 -08:00
|
|
|
NC_("select-action", "Save to _Channel"), NULL,
|
2008-12-04 02:32:20 -08:00
|
|
|
NC_("select-action", "Save the selection to a channel"),
|
2004-04-19 07:54:24 -07:00
|
|
|
G_CALLBACK (select_save_cmd_callback),
|
|
|
|
|
GIMP_HELP_SELECTION_TO_CHANNEL },
|
|
|
|
|
|
2017-03-05 07:01:59 -08:00
|
|
|
{ "select-fill", GIMP_ICON_TOOL_BUCKET_FILL,
|
2016-03-15 12:52:22 -07:00
|
|
|
NC_("select-action", "_Fill Selection Outline..."), NULL,
|
|
|
|
|
NC_("select-action", "Fill the selection outline"),
|
|
|
|
|
G_CALLBACK (select_fill_cmd_callback),
|
|
|
|
|
GIMP_HELP_SELECTION_FILL },
|
|
|
|
|
|
2017-03-05 07:01:59 -08:00
|
|
|
{ "select-fill-last-values", GIMP_ICON_TOOL_BUCKET_FILL,
|
2016-03-15 12:52:22 -07:00
|
|
|
NC_("select-action", "_Fill Selection Outline"), NULL,
|
|
|
|
|
NC_("select-action", "Fill the selection outline with last used values"),
|
|
|
|
|
G_CALLBACK (select_fill_last_vals_cmd_callback),
|
|
|
|
|
GIMP_HELP_SELECTION_FILL },
|
|
|
|
|
|
2017-03-05 07:01:59 -08:00
|
|
|
{ "select-stroke", GIMP_ICON_SELECTION_STROKE,
|
2008-12-03 07:27:42 -08:00
|
|
|
NC_("select-action", "_Stroke Selection..."), NULL,
|
2008-12-04 02:32:20 -08:00
|
|
|
NC_("select-action", "Paint along the selection outline"),
|
2004-05-12 11:36:33 -07:00
|
|
|
G_CALLBACK (select_stroke_cmd_callback),
|
2004-10-20 16:14:24 -07:00
|
|
|
GIMP_HELP_SELECTION_STROKE },
|
|
|
|
|
|
2017-03-05 07:01:59 -08:00
|
|
|
{ "select-stroke-last-values", GIMP_ICON_SELECTION_STROKE,
|
2008-12-03 07:27:42 -08:00
|
|
|
NC_("select-action", "_Stroke Selection"), NULL,
|
2008-12-04 02:32:20 -08:00
|
|
|
NC_("select-action", "Stroke the selection with last used values"),
|
2004-10-20 16:14:24 -07:00
|
|
|
G_CALLBACK (select_stroke_last_vals_cmd_callback),
|
2004-06-03 02:47:05 -07:00
|
|
|
GIMP_HELP_SELECTION_STROKE }
|
2004-04-19 07:54:24 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2004-04-27 06:55:26 -07:00
|
|
|
select_actions_setup (GimpActionGroup *group)
|
2004-04-19 07:54:24 -07:00
|
|
|
{
|
2008-12-03 07:27:42 -08:00
|
|
|
gimp_action_group_add_actions (group, "select-action",
|
2004-04-19 07:54:24 -07:00
|
|
|
select_actions,
|
2016-12-20 19:05:32 -08:00
|
|
|
G_N_ELEMENTS (select_actions));
|
2004-04-19 07:54:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
select_actions_update (GimpActionGroup *group,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
2009-08-29 03:51:58 -07:00
|
|
|
GimpImage *image = action_data_get_image (data);
|
2004-05-12 11:36:33 -07:00
|
|
|
GimpDrawable *drawable = NULL;
|
|
|
|
|
gboolean fs = FALSE;
|
|
|
|
|
gboolean sel = FALSE;
|
2009-08-20 08:11:31 -07:00
|
|
|
gboolean writable = FALSE;
|
2009-08-29 03:51:58 -07:00
|
|
|
gboolean children = FALSE;
|
2004-04-19 07:54:24 -07:00
|
|
|
|
2006-03-28 09:08:36 -08:00
|
|
|
if (image)
|
2004-05-03 07:03:51 -07:00
|
|
|
{
|
2007-07-19 07:59:51 -07:00
|
|
|
drawable = gimp_image_get_active_drawable (image);
|
2004-05-12 11:36:33 -07:00
|
|
|
|
2009-08-20 08:11:31 -07:00
|
|
|
if (drawable)
|
|
|
|
|
{
|
2009-08-29 06:27:04 -07:00
|
|
|
writable = ! gimp_item_is_content_locked (GIMP_ITEM (drawable));
|
2009-08-29 03:51:58 -07:00
|
|
|
|
|
|
|
|
if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)))
|
|
|
|
|
children = TRUE;
|
2009-08-20 08:11:31 -07:00
|
|
|
}
|
|
|
|
|
|
2008-11-14 07:01:44 -08:00
|
|
|
fs = (gimp_image_get_floating_selection (image) != NULL);
|
2006-03-28 09:08:36 -08:00
|
|
|
sel = ! gimp_channel_is_empty (gimp_image_get_mask (image));
|
2004-04-19 07:54:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define SET_SENSITIVE(action,condition) \
|
|
|
|
|
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
|
|
|
|
|
|
2004-10-20 16:14:24 -07:00
|
|
|
SET_SENSITIVE ("select-all", drawable);
|
|
|
|
|
SET_SENSITIVE ("select-none", drawable && sel);
|
|
|
|
|
SET_SENSITIVE ("select-invert", drawable);
|
2009-08-29 03:51:58 -07:00
|
|
|
SET_SENSITIVE ("select-float", writable && !children && sel);
|
2004-06-03 02:47:05 -07:00
|
|
|
|
|
|
|
|
SET_SENSITIVE ("select-feather", drawable && sel);
|
|
|
|
|
SET_SENSITIVE ("select-sharpen", drawable && sel);
|
|
|
|
|
SET_SENSITIVE ("select-shrink", drawable && sel);
|
|
|
|
|
SET_SENSITIVE ("select-grow", drawable && sel);
|
|
|
|
|
SET_SENSITIVE ("select-border", drawable && sel);
|
2016-01-24 09:43:35 -08:00
|
|
|
SET_SENSITIVE ("select-flood", drawable && sel);
|
2004-06-03 02:47:05 -07:00
|
|
|
|
2004-10-22 17:53:48 -07:00
|
|
|
SET_SENSITIVE ("select-save", drawable && !fs);
|
2016-03-15 12:52:22 -07:00
|
|
|
SET_SENSITIVE ("select-fill", writable && !children && sel);
|
|
|
|
|
SET_SENSITIVE ("select-fill-last-values", writable && !children && sel);
|
2009-08-29 11:20:25 -07:00
|
|
|
SET_SENSITIVE ("select-stroke", writable && !children && sel);
|
|
|
|
|
SET_SENSITIVE ("select-stroke-last-values", writable && !children && sel);
|
2004-04-19 07:54:24 -07:00
|
|
|
|
|
|
|
|
#undef SET_SENSITIVE
|
|
|
|
|
}
|