2004-04-19 22:54:24 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (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
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "actions-types.h"
|
|
|
|
|
|
|
|
#include "core/gimpimage.h"
|
|
|
|
#include "core/gimplist.h"
|
|
|
|
|
|
|
|
#include "widgets/gimpactiongroup.h"
|
|
|
|
#include "widgets/gimpcomponenteditor.h"
|
|
|
|
#include "widgets/gimphelp-ids.h"
|
2004-05-03 03:37:17 +08:00
|
|
|
|
2004-05-03 22:03:51 +08:00
|
|
|
#include "actions.h"
|
2004-04-19 22:54:24 +08:00
|
|
|
#include "channels-actions.h"
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "channels-commands.h"
|
2004-04-19 22:54:24 +08:00
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
|
|
|
static GimpActionEntry channels_actions[] =
|
|
|
|
{
|
2004-10-18 19:29:58 +08:00
|
|
|
{ "channels-popup", GIMP_STOCK_CHANNELS,
|
|
|
|
N_("Channels Menu"), NULL, NULL, NULL,
|
2004-05-02 16:56:07 +08:00
|
|
|
GIMP_HELP_CHANNEL_DIALOG },
|
2004-04-22 00:10:00 +08:00
|
|
|
|
2004-04-19 22:54:24 +08:00
|
|
|
{ "channels-edit-attributes", GIMP_STOCK_EDIT,
|
2004-10-16 23:48:23 +08:00
|
|
|
N_("_Edit Channel Attributes..."), NULL,
|
|
|
|
N_("Edit channel attributes"),
|
2004-04-19 22:54:24 +08:00
|
|
|
G_CALLBACK (channels_edit_attributes_cmd_callback),
|
|
|
|
GIMP_HELP_CHANNEL_EDIT },
|
|
|
|
|
|
|
|
{ "channels-new", GTK_STOCK_NEW,
|
2004-10-16 23:48:23 +08:00
|
|
|
N_("_New Channel..."), "",
|
2004-10-23 08:53:48 +08:00
|
|
|
N_("New channel..."),
|
2004-04-19 22:54:24 +08:00
|
|
|
G_CALLBACK (channels_new_cmd_callback),
|
|
|
|
GIMP_HELP_CHANNEL_NEW },
|
|
|
|
|
2004-10-23 08:53:48 +08:00
|
|
|
{ "channels-new-last-values", GTK_STOCK_NEW,
|
2004-10-16 23:48:23 +08:00
|
|
|
N_("_New Channel"), "",
|
2004-10-23 08:53:48 +08:00
|
|
|
N_("New channel with last values"),
|
|
|
|
G_CALLBACK (channels_new_last_vals_cmd_callback),
|
2004-10-16 23:48:23 +08:00
|
|
|
GIMP_HELP_CHANNEL_NEW },
|
|
|
|
|
2004-04-19 22:54:24 +08:00
|
|
|
{ "channels-duplicate", GIMP_STOCK_DUPLICATE,
|
2004-10-16 23:48:23 +08:00
|
|
|
N_("D_uplicate Channel"), NULL,
|
|
|
|
N_("Duplicate channel"),
|
2004-04-19 22:54:24 +08:00
|
|
|
G_CALLBACK (channels_duplicate_cmd_callback),
|
|
|
|
GIMP_HELP_CHANNEL_DUPLICATE },
|
|
|
|
|
|
|
|
{ "channels-delete", GTK_STOCK_DELETE,
|
2004-10-16 23:48:23 +08:00
|
|
|
N_("_Delete Channel"), "",
|
|
|
|
N_("Delete channel"),
|
2004-04-19 22:54:24 +08:00
|
|
|
G_CALLBACK (channels_delete_cmd_callback),
|
|
|
|
GIMP_HELP_CHANNEL_DELETE },
|
|
|
|
|
|
|
|
{ "channels-raise", GTK_STOCK_GO_UP,
|
2004-10-16 23:48:23 +08:00
|
|
|
N_("_Raise Channel"), "",
|
|
|
|
N_("Raise channel"),
|
2004-04-19 22:54:24 +08:00
|
|
|
G_CALLBACK (channels_raise_cmd_callback),
|
|
|
|
GIMP_HELP_CHANNEL_RAISE },
|
|
|
|
|
|
|
|
{ "channels-raise-to-top", GTK_STOCK_GOTO_TOP,
|
2004-10-16 23:48:23 +08:00
|
|
|
N_("Raise Channel to _Top"), "",
|
|
|
|
N_("Raise channel to top"),
|
2004-04-19 22:54:24 +08:00
|
|
|
G_CALLBACK (channels_raise_to_top_cmd_callback),
|
|
|
|
GIMP_HELP_CHANNEL_RAISE_TO_TOP },
|
|
|
|
|
|
|
|
{ "channels-lower", GTK_STOCK_GO_DOWN,
|
2004-10-16 23:48:23 +08:00
|
|
|
N_("_Lower Channel"), "",
|
|
|
|
N_("Lower channel"),
|
2004-04-19 22:54:24 +08:00
|
|
|
G_CALLBACK (channels_lower_cmd_callback),
|
|
|
|
GIMP_HELP_CHANNEL_LOWER },
|
|
|
|
|
|
|
|
{ "channels-lower-to-bottom", GTK_STOCK_GOTO_BOTTOM,
|
2004-10-16 23:48:23 +08:00
|
|
|
N_("Lower Channel to _Bottom"), "",
|
|
|
|
N_("Lower channel to bottom"),
|
2004-04-19 22:54:24 +08:00
|
|
|
G_CALLBACK (channels_lower_to_bottom_cmd_callback),
|
|
|
|
GIMP_HELP_CHANNEL_LOWER_TO_BOTTOM }
|
|
|
|
};
|
|
|
|
|
|
|
|
static GimpEnumActionEntry channels_to_selection_actions[] =
|
|
|
|
{
|
|
|
|
{ "channels-selection-replace", GIMP_STOCK_SELECTION_REPLACE,
|
2004-10-17 01:10:04 +08:00
|
|
|
N_("Channel to Sele_ction"), NULL,
|
|
|
|
N_("Channel to selection"),
|
2004-11-19 00:04:41 +08:00
|
|
|
GIMP_CHANNEL_OP_REPLACE, FALSE,
|
2004-04-19 22:54:24 +08:00
|
|
|
GIMP_HELP_CHANNEL_SELECTION_REPLACE },
|
|
|
|
|
|
|
|
{ "channels-selection-add", GIMP_STOCK_SELECTION_ADD,
|
2004-10-17 01:10:04 +08:00
|
|
|
N_("_Add to Selection"), NULL,
|
|
|
|
N_("Add"),
|
2004-11-19 00:04:41 +08:00
|
|
|
GIMP_CHANNEL_OP_ADD, FALSE,
|
2004-04-19 22:54:24 +08:00
|
|
|
GIMP_HELP_CHANNEL_SELECTION_ADD },
|
|
|
|
|
|
|
|
{ "channels-selection-subtract", GIMP_STOCK_SELECTION_SUBTRACT,
|
2004-10-17 01:10:04 +08:00
|
|
|
N_("_Subtract from Selection"), NULL,
|
|
|
|
N_("Subtract"),
|
2004-11-19 00:04:41 +08:00
|
|
|
GIMP_CHANNEL_OP_SUBTRACT, FALSE,
|
2004-04-19 22:54:24 +08:00
|
|
|
GIMP_HELP_CHANNEL_SELECTION_SUBTRACT },
|
|
|
|
|
|
|
|
{ "channels-selection-intersect", GIMP_STOCK_SELECTION_INTERSECT,
|
2004-10-17 01:10:04 +08:00
|
|
|
N_("_Intersect with Selection"), NULL,
|
|
|
|
N_("Intersect"),
|
2004-11-19 00:04:41 +08:00
|
|
|
GIMP_CHANNEL_OP_INTERSECT, FALSE,
|
2004-04-19 22:54:24 +08:00
|
|
|
GIMP_HELP_CHANNEL_SELECTION_INTERSECT }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2004-04-27 21:55:26 +08:00
|
|
|
channels_actions_setup (GimpActionGroup *group)
|
2004-04-19 22:54:24 +08:00
|
|
|
{
|
|
|
|
gimp_action_group_add_actions (group,
|
|
|
|
channels_actions,
|
2004-04-27 21:55:26 +08:00
|
|
|
G_N_ELEMENTS (channels_actions));
|
2004-04-19 22:54:24 +08:00
|
|
|
|
|
|
|
gimp_action_group_add_enum_actions (group,
|
|
|
|
channels_to_selection_actions,
|
|
|
|
G_N_ELEMENTS (channels_to_selection_actions),
|
2004-04-27 21:55:26 +08:00
|
|
|
G_CALLBACK (channels_to_selection_cmd_callback));
|
2004-04-19 22:54:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
channels_actions_update (GimpActionGroup *group,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2004-10-18 19:29:58 +08:00
|
|
|
GimpImage *gimage = action_data_get_image (data);
|
2004-04-19 22:54:24 +08:00
|
|
|
GimpChannel *channel = NULL;
|
|
|
|
gboolean fs = FALSE;
|
|
|
|
gboolean component = FALSE;
|
|
|
|
GList *next = NULL;
|
|
|
|
GList *prev = NULL;
|
|
|
|
|
2004-05-23 18:04:41 +08:00
|
|
|
if (gimage)
|
2004-04-19 22:54:24 +08:00
|
|
|
{
|
2004-05-23 18:04:41 +08:00
|
|
|
fs = (gimp_image_floating_sel (gimage) != NULL);
|
2004-04-19 22:54:24 +08:00
|
|
|
|
2004-05-23 18:04:41 +08:00
|
|
|
if (GIMP_IS_COMPONENT_EDITOR (data))
|
2004-04-19 22:54:24 +08:00
|
|
|
{
|
|
|
|
if (GIMP_COMPONENT_EDITOR (data)->clicked_component != -1)
|
|
|
|
component = TRUE;
|
|
|
|
}
|
2004-05-23 18:04:41 +08:00
|
|
|
else
|
2004-04-19 22:54:24 +08:00
|
|
|
{
|
|
|
|
channel = gimp_image_get_active_channel (gimage);
|
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
if (channel)
|
2004-04-19 22:54:24 +08:00
|
|
|
{
|
2004-10-18 19:29:58 +08:00
|
|
|
GList *list;
|
|
|
|
|
|
|
|
list = g_list_find (GIMP_LIST (gimage->channels)->list, channel);
|
|
|
|
|
|
|
|
if (list)
|
2004-04-19 22:54:24 +08:00
|
|
|
{
|
|
|
|
prev = g_list_previous (list);
|
|
|
|
next = g_list_next (list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SET_SENSITIVE(action,condition) \
|
|
|
|
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
|
|
|
|
|
|
|
|
SET_SENSITIVE ("channels-edit-attributes", !fs && channel);
|
|
|
|
|
|
|
|
SET_SENSITIVE ("channels-new", !fs && gimage);
|
2004-10-23 08:53:48 +08:00
|
|
|
SET_SENSITIVE ("channels-new-last-values", !fs && gimage);
|
2004-04-19 22:54:24 +08:00
|
|
|
SET_SENSITIVE ("channels-duplicate", !fs && (channel || component));
|
|
|
|
SET_SENSITIVE ("channels-delete", !fs && channel);
|
|
|
|
|
|
|
|
SET_SENSITIVE ("channels-raise", !fs && channel && prev);
|
|
|
|
SET_SENSITIVE ("channels-raise-to-top", !fs && channel && prev);
|
|
|
|
SET_SENSITIVE ("channels-lower", !fs && channel && next);
|
|
|
|
SET_SENSITIVE ("channels-lower-to-bottom", !fs && channel && next);
|
|
|
|
|
|
|
|
SET_SENSITIVE ("channels-selection-replace", !fs && (channel || component));
|
|
|
|
SET_SENSITIVE ("channels-selection-add", !fs && (channel || component));
|
|
|
|
SET_SENSITIVE ("channels-selection-subtract", !fs && (channel || component));
|
|
|
|
SET_SENSITIVE ("channels-selection-intersect", !fs && (channel || component));
|
|
|
|
|
|
|
|
#undef SET_SENSITIVE
|
|
|
|
}
|