~ubuntu-branches/ubuntu/hoary/gimp/hoary

« back to all changes in this revision

Viewing changes to app/actions/colormap-editor-actions.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2005-04-04 14:51:23 UTC
  • Revision ID: james.westby@ubuntu.com-20050404145123-9py049eeelfymur8
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* The GIMP -- an image manipulation program
 
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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.
 
17
 */
 
18
 
 
19
#include "config.h"
 
20
 
 
21
#include <gtk/gtk.h>
 
22
 
 
23
#include "libgimpwidgets/gimpwidgets.h"
 
24
 
 
25
#include "actions-types.h"
 
26
 
 
27
#include "core/gimpcontext.h"
 
28
#include "core/gimpimage.h"
 
29
 
 
30
#include "widgets/gimpactiongroup.h"
 
31
#include "widgets/gimphelp-ids.h"
 
32
 
 
33
#include "actions.h"
 
34
#include "colormap-editor-actions.h"
 
35
#include "colormap-editor-commands.h"
 
36
 
 
37
#include "gimp-intl.h"
 
38
 
 
39
 
 
40
static GimpActionEntry colormap_editor_actions[] =
 
41
{
 
42
  { "colormap-editor-popup", GIMP_STOCK_INDEXED_PALETTE,
 
43
    N_("Colormap Menu"), NULL, NULL, NULL,
 
44
    GIMP_HELP_INDEXED_PALETTE_DIALOG },
 
45
 
 
46
  { "colormap-editor-edit-color", GIMP_STOCK_EDIT,
 
47
    N_("_Edit Color..."), NULL,
 
48
    N_("Edit color"),
 
49
    G_CALLBACK (colormap_editor_edit_color_cmd_callback),
 
50
    GIMP_HELP_INDEXED_PALETTE_EDIT }
 
51
};
 
52
 
 
53
static GimpEnumActionEntry colormap_editor_add_color_actions[] =
 
54
{
 
55
  { "colormap-editor-add-color-from-fg", GTK_STOCK_ADD,
 
56
    N_("_Add Color from FG"), "",
 
57
    N_("Add color from FG"),
 
58
    FALSE, FALSE,
 
59
    GIMP_HELP_INDEXED_PALETTE_ADD },
 
60
 
 
61
  { "colormap-editor-add-color-from-bg", GTK_STOCK_ADD,
 
62
    N_("_Add Color from BG"), "",
 
63
    N_("Add color from BG"),
 
64
    TRUE, FALSE,
 
65
    GIMP_HELP_INDEXED_PALETTE_ADD }
 
66
};
 
67
 
 
68
 
 
69
void
 
70
colormap_editor_actions_setup (GimpActionGroup *group)
 
71
{
 
72
  gimp_action_group_add_actions (group,
 
73
                                 colormap_editor_actions,
 
74
                                 G_N_ELEMENTS (colormap_editor_actions));
 
75
 
 
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));
 
80
}
 
81
 
 
82
void
 
83
colormap_editor_actions_update (GimpActionGroup *group,
 
84
                                gpointer         data)
 
85
{
 
86
  GimpImage   *gimage     = action_data_get_image (data);
 
87
  GimpContext *context    = action_data_get_context (data);
 
88
  gboolean     indexed    = FALSE;
 
89
  gint         num_colors = 0;
 
90
  GimpRGB      fg;
 
91
  GimpRGB      bg;
 
92
 
 
93
  if (gimage)
 
94
    {
 
95
      indexed    = gimp_image_base_type (gimage) == GIMP_INDEXED;
 
96
      num_colors = gimage->num_cols;
 
97
    }
 
98
 
 
99
  if (context)
 
100
    {
 
101
      gimp_context_get_foreground (context, &fg);
 
102
      gimp_context_get_background (context, &bg);
 
103
    }
 
104
 
 
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);
 
109
 
 
110
  SET_SENSITIVE ("colormap-editor-edit-color",
 
111
                 gimage && indexed);
 
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);
 
116
 
 
117
  SET_COLOR ("colormap-editor-add-color-from-fg", context ? &fg : NULL);
 
118
  SET_COLOR ("colormap-editor-add-color-from-bg", context ? &bg : NULL);
 
119
 
 
120
#undef SET_SENSITIVE
 
121
#undef SET_COLOR
 
122
}