2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2004-04-19 22:54:24 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2004-04-19 22:54:24 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2004-04-19 22:54:24 +08: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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2004-04-19 22:54:24 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2004-04-19 22:54:24 +08: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 22:03:51 +08:00
|
|
|
#include "actions.h"
|
2004-04-19 22:54:24 +08:00
|
|
|
#include "select-actions.h"
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "select-commands.h"
|
2004-04-19 22:54:24 +08:00
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
2006-04-10 16:06:18 +08:00
|
|
|
static const GimpActionEntry select_actions[] =
|
2004-04-19 22:54:24 +08:00
|
|
|
{
|
2007-07-08 20:23:44 +08:00
|
|
|
{ "selection-popup", GIMP_STOCK_TOOL_RECT_SELECT,
|
2008-12-03 23:27:42 +08:00
|
|
|
NC_("select-action", "Selection Editor Menu"), NULL, NULL, NULL,
|
2004-05-13 02:36:33 +08:00
|
|
|
GIMP_HELP_SELECTION_DIALOG },
|
|
|
|
|
2008-12-03 23:27:42 +08:00
|
|
|
{ "select-menu", NULL, NC_("select-action", "_Select") },
|
2004-04-19 22:54:24 +08:00
|
|
|
|
|
|
|
{ "select-all", GIMP_STOCK_SELECTION_ALL,
|
2008-12-03 23:27:42 +08:00
|
|
|
NC_("select-action", "_All"), "<control>A",
|
2008-12-04 18:32:20 +08:00
|
|
|
NC_("select-action", "Select everything"),
|
2004-04-19 22:54:24 +08:00
|
|
|
G_CALLBACK (select_all_cmd_callback),
|
|
|
|
GIMP_HELP_SELECTION_ALL },
|
|
|
|
|
|
|
|
{ "select-none", GIMP_STOCK_SELECTION_NONE,
|
2008-12-03 23:27:42 +08:00
|
|
|
NC_("select-action", "_None"), "<control><shift>A",
|
2008-12-04 18:32:20 +08:00
|
|
|
NC_("select-action", "Dismiss the selection"),
|
2004-04-19 22:54:24 +08:00
|
|
|
G_CALLBACK (select_none_cmd_callback),
|
|
|
|
GIMP_HELP_SELECTION_NONE },
|
|
|
|
|
|
|
|
{ "select-invert", GIMP_STOCK_INVERT,
|
2008-12-03 23:27:42 +08:00
|
|
|
NC_("select-action", "_Invert"), "<control>I",
|
2008-12-04 18:32:20 +08:00
|
|
|
NC_("select-action", "Invert the selection"),
|
2004-04-19 22:54:24 +08:00
|
|
|
G_CALLBACK (select_invert_cmd_callback),
|
|
|
|
GIMP_HELP_SELECTION_INVERT },
|
|
|
|
|
|
|
|
{ "select-float", GIMP_STOCK_FLOATING_SELECTION,
|
2008-12-03 23:27:42 +08:00
|
|
|
NC_("select-action", "_Float"), "<control><shift>L",
|
2008-12-04 18:32:20 +08:00
|
|
|
NC_("select-action", "Create a floating selection"),
|
2004-04-19 22:54:24 +08:00
|
|
|
G_CALLBACK (select_float_cmd_callback),
|
|
|
|
GIMP_HELP_SELECTION_FLOAT },
|
|
|
|
|
|
|
|
{ "select-feather", NULL,
|
2008-12-03 23:27:42 +08:00
|
|
|
NC_("select-action", "Fea_ther..."), NULL,
|
2008-12-04 18:32:20 +08:00
|
|
|
NC_("select-action",
|
|
|
|
"Blur the selection border so that it fades out smoothly"),
|
2004-04-19 22:54:24 +08:00
|
|
|
G_CALLBACK (select_feather_cmd_callback),
|
|
|
|
GIMP_HELP_SELECTION_FEATHER },
|
|
|
|
|
|
|
|
{ "select-sharpen", NULL,
|
2008-12-03 23:27:42 +08:00
|
|
|
NC_("select-action", "_Sharpen"), NULL,
|
2008-12-04 18:32:20 +08:00
|
|
|
NC_("select-action", "Remove fuzzyness from the selection"),
|
2004-04-19 22:54:24 +08:00
|
|
|
G_CALLBACK (select_sharpen_cmd_callback),
|
|
|
|
GIMP_HELP_SELECTION_SHARPEN },
|
|
|
|
|
|
|
|
{ "select-shrink", GIMP_STOCK_SELECTION_SHRINK,
|
2008-12-03 23:27:42 +08:00
|
|
|
NC_("select-action", "S_hrink..."), NULL,
|
2008-12-04 18:32:20 +08:00
|
|
|
NC_("select-action", "Contract the selection"),
|
2004-04-19 22:54:24 +08:00
|
|
|
G_CALLBACK (select_shrink_cmd_callback),
|
|
|
|
GIMP_HELP_SELECTION_SHRINK },
|
|
|
|
|
|
|
|
{ "select-grow", GIMP_STOCK_SELECTION_GROW,
|
2008-12-03 23:27:42 +08:00
|
|
|
NC_("select-action", "_Grow..."), NULL,
|
2008-12-04 18:32:20 +08:00
|
|
|
NC_("select-action", "Enlarge the selection"),
|
2004-04-19 22:54:24 +08:00
|
|
|
G_CALLBACK (select_grow_cmd_callback),
|
|
|
|
GIMP_HELP_SELECTION_GROW },
|
|
|
|
|
|
|
|
{ "select-border", GIMP_STOCK_SELECTION_BORDER,
|
2008-12-03 23:27:42 +08:00
|
|
|
NC_("select-action", "Bo_rder..."), NULL,
|
2008-12-04 18:32:20 +08:00
|
|
|
NC_("select-action", "Replace the selection by its border"),
|
2004-04-19 22:54:24 +08:00
|
|
|
G_CALLBACK (select_border_cmd_callback),
|
|
|
|
GIMP_HELP_SELECTION_BORDER },
|
|
|
|
|
|
|
|
{ "select-save", GIMP_STOCK_SELECTION_TO_CHANNEL,
|
2008-12-03 23:27:42 +08:00
|
|
|
NC_("select-action", "Save to _Channel"), NULL,
|
2008-12-04 18:32:20 +08:00
|
|
|
NC_("select-action", "Save the selection to a channel"),
|
2004-04-19 22:54:24 +08:00
|
|
|
G_CALLBACK (select_save_cmd_callback),
|
|
|
|
GIMP_HELP_SELECTION_TO_CHANNEL },
|
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
{ "select-stroke", GIMP_STOCK_SELECTION_STROKE,
|
2008-12-03 23:27:42 +08:00
|
|
|
NC_("select-action", "_Stroke Selection..."), NULL,
|
2008-12-04 18:32:20 +08:00
|
|
|
NC_("select-action", "Paint along the selection outline"),
|
2004-05-13 02:36:33 +08:00
|
|
|
G_CALLBACK (select_stroke_cmd_callback),
|
2004-10-21 07:14:24 +08:00
|
|
|
GIMP_HELP_SELECTION_STROKE },
|
|
|
|
|
2004-10-23 08:53:48 +08:00
|
|
|
{ "select-stroke-last-values", GIMP_STOCK_SELECTION_STROKE,
|
2008-12-03 23:27:42 +08:00
|
|
|
NC_("select-action", "_Stroke Selection"), NULL,
|
2008-12-04 18:32:20 +08:00
|
|
|
NC_("select-action", "Stroke the selection with last used values"),
|
2004-10-21 07:14:24 +08:00
|
|
|
G_CALLBACK (select_stroke_last_vals_cmd_callback),
|
2004-06-03 17:47:05 +08:00
|
|
|
GIMP_HELP_SELECTION_STROKE }
|
2004-04-19 22:54:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2004-04-27 21:55:26 +08:00
|
|
|
select_actions_setup (GimpActionGroup *group)
|
2004-04-19 22:54:24 +08:00
|
|
|
{
|
2008-12-03 23:27:42 +08:00
|
|
|
gimp_action_group_add_actions (group, "select-action",
|
2004-04-19 22:54:24 +08:00
|
|
|
select_actions,
|
2008-12-03 23:27:42 +08:00
|
|
|
G_N_ELEMENTS (select_actions));
|
2004-04-19 22:54:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
select_actions_update (GimpActionGroup *group,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2009-08-29 18:51:58 +08:00
|
|
|
GimpImage *image = action_data_get_image (data);
|
2004-05-13 02:36:33 +08:00
|
|
|
GimpDrawable *drawable = NULL;
|
|
|
|
gboolean fs = FALSE;
|
|
|
|
gboolean sel = FALSE;
|
2009-08-20 23:11:31 +08:00
|
|
|
gboolean writable = FALSE;
|
2009-08-29 18:51:58 +08:00
|
|
|
gboolean children = FALSE;
|
2004-04-19 22:54:24 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (image)
|
2004-05-03 22:03:51 +08:00
|
|
|
{
|
2007-07-19 22:59:51 +08:00
|
|
|
drawable = gimp_image_get_active_drawable (image);
|
2004-05-13 02:36:33 +08:00
|
|
|
|
2009-08-20 23:11:31 +08:00
|
|
|
if (drawable)
|
|
|
|
{
|
2009-08-29 21:27:04 +08:00
|
|
|
writable = ! gimp_item_is_content_locked (GIMP_ITEM (drawable));
|
2009-08-29 18:51:58 +08:00
|
|
|
|
|
|
|
if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)))
|
|
|
|
children = TRUE;
|
2009-08-20 23:11:31 +08:00
|
|
|
}
|
|
|
|
|
2008-11-14 23:01:44 +08:00
|
|
|
fs = (gimp_image_get_floating_selection (image) != NULL);
|
2006-03-29 01:08:36 +08:00
|
|
|
sel = ! gimp_channel_is_empty (gimp_image_get_mask (image));
|
2004-04-19 22:54:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define SET_SENSITIVE(action,condition) \
|
|
|
|
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
|
|
|
|
|
2004-10-21 07:14:24 +08:00
|
|
|
SET_SENSITIVE ("select-all", drawable);
|
|
|
|
SET_SENSITIVE ("select-none", drawable && sel);
|
|
|
|
SET_SENSITIVE ("select-invert", drawable);
|
2009-08-29 18:51:58 +08:00
|
|
|
SET_SENSITIVE ("select-float", writable && !children && sel);
|
2004-06-03 17:47:05 +08: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);
|
|
|
|
|
2004-10-23 08:53:48 +08:00
|
|
|
SET_SENSITIVE ("select-save", drawable && !fs);
|
2009-08-20 23:11:31 +08:00
|
|
|
SET_SENSITIVE ("select-stroke", writable && sel);
|
|
|
|
SET_SENSITIVE ("select-stroke-last-values", writable && sel);
|
2004-04-19 22:54:24 +08:00
|
|
|
|
|
|
|
#undef SET_SENSITIVE
|
|
|
|
}
|