1
/* The GIMP -- an image manipulation program
2
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
#include "libgimpwidgets/gimpwidgets.h"
25
#include "actions-types.h"
27
#include "core/gimpcontext.h"
28
#include "core/gimpimage.h"
30
#include "widgets/gimpactiongroup.h"
31
#include "widgets/gimphelp-ids.h"
34
#include "colormap-editor-actions.h"
35
#include "colormap-editor-commands.h"
37
#include "gimp-intl.h"
40
static GimpActionEntry colormap_editor_actions[] =
42
{ "colormap-editor-popup", GIMP_STOCK_INDEXED_PALETTE,
43
N_("Colormap Menu"), NULL, NULL, NULL,
44
GIMP_HELP_INDEXED_PALETTE_DIALOG },
46
{ "colormap-editor-edit-color", GIMP_STOCK_EDIT,
47
N_("_Edit Color..."), NULL,
49
G_CALLBACK (colormap_editor_edit_color_cmd_callback),
50
GIMP_HELP_INDEXED_PALETTE_EDIT }
53
static GimpEnumActionEntry colormap_editor_add_color_actions[] =
55
{ "colormap-editor-add-color-from-fg", GTK_STOCK_ADD,
56
N_("_Add Color from FG"), "",
57
N_("Add color from FG"),
59
GIMP_HELP_INDEXED_PALETTE_ADD },
61
{ "colormap-editor-add-color-from-bg", GTK_STOCK_ADD,
62
N_("_Add Color from BG"), "",
63
N_("Add color from BG"),
65
GIMP_HELP_INDEXED_PALETTE_ADD }
70
colormap_editor_actions_setup (GimpActionGroup *group)
72
gimp_action_group_add_actions (group,
73
colormap_editor_actions,
74
G_N_ELEMENTS (colormap_editor_actions));
76
gimp_action_group_add_enum_actions (group,
77
colormap_editor_add_color_actions,
78
G_N_ELEMENTS (colormap_editor_add_color_actions),
79
G_CALLBACK (colormap_editor_add_color_cmd_callback));
83
colormap_editor_actions_update (GimpActionGroup *group,
86
GimpImage *gimage = action_data_get_image (data);
87
GimpContext *context = action_data_get_context (data);
88
gboolean indexed = FALSE;
95
indexed = gimp_image_base_type (gimage) == GIMP_INDEXED;
96
num_colors = gimage->num_cols;
101
gimp_context_get_foreground (context, &fg);
102
gimp_context_get_background (context, &bg);
105
#define SET_SENSITIVE(action,condition) \
106
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
107
#define SET_COLOR(action,color) \
108
gimp_action_group_set_action_color (group, action, color, FALSE);
110
SET_SENSITIVE ("colormap-editor-edit-color",
112
SET_SENSITIVE ("colormap-editor-add-color-from-fg",
113
gimage && indexed && num_colors < 256);
114
SET_SENSITIVE ("colormap-editor-add-color-from-bg",
115
gimage && indexed && num_colors < 256);
117
SET_COLOR ("colormap-editor-add-color-from-fg", context ? &fg : NULL);
118
SET_COLOR ("colormap-editor-add-color-from-bg", context ? &bg : NULL);