~ubuntu-branches/ubuntu/vivid/gimp/vivid

« back to all changes in this revision

Viewing changes to app/actions/drawable-actions.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach
  • Date: 2012-05-08 18:50:03 UTC
  • mto: (1.1.26) (0.5.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 71.
  • Revision ID: package-import@ubuntu.com-20120508185003-tltkvbaysf8d2426
Import upstream version 2.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
 
 * This program is free software; you can redistribute it and/or modify
 
4
 * This program is free software: you can redistribute it and/or modify
5
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
 
6
 * the Free Software Foundation; either version 3 of the License, or
7
7
 * (at your option) any later version.
8
8
 *
9
9
 * This program is distributed in the hope that it will be useful,
12
12
 * GNU General Public License for more details.
13
13
 *
14
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.
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
16
 */
18
17
 
19
18
#include "config.h"
20
19
 
 
20
#include <gegl.h>
21
21
#include <gtk/gtk.h>
22
22
 
23
23
#include "libgimpwidgets/gimpwidgets.h"
42
42
static const GimpActionEntry drawable_actions[] =
43
43
{
44
44
  { "drawable-equalize", NULL,
45
 
    N_("_Equalize"), NULL,
46
 
    N_("Automatic contrast enhancement"),
 
45
    NC_("drawable-action", "_Equalize"), NULL,
 
46
    NC_("drawable-action", "Automatic contrast enhancement"),
47
47
    G_CALLBACK (drawable_equalize_cmd_callback),
48
48
    GIMP_HELP_LAYER_EQUALIZE },
49
49
 
50
50
  { "drawable-invert", GIMP_STOCK_INVERT,
51
 
    N_("In_vert"), NULL,
52
 
    N_("Invert the colors"),
 
51
    NC_("drawable-action", "In_vert"), NULL,
 
52
    NC_("drawable-action", "Invert the colors"),
53
53
    G_CALLBACK (drawable_invert_cmd_callback),
54
54
    GIMP_HELP_LAYER_INVERT },
55
55
 
56
56
  { "drawable-levels-stretch", NULL,
57
 
    N_("_White Balance"), NULL,
58
 
    N_("Automatic white balance correction"),
 
57
    NC_("drawable-action", "_White Balance"), NULL,
 
58
    NC_("drawable-action", "Automatic white balance correction"),
59
59
    G_CALLBACK (drawable_levels_stretch_cmd_callback),
60
60
    GIMP_HELP_LAYER_WHITE_BALANCE},
61
61
 
62
62
  { "drawable-offset", NULL,
63
 
    N_("_Offset..."), "<control><shift>O",
64
 
    N_("Shift the pixels, optionally wrapping them at the borders"),
 
63
    NC_("drawable-action", "_Offset..."), "<primary><shift>O",
 
64
    NC_("drawable-action",
 
65
        "Shift the pixels, optionally wrapping them at the borders"),
65
66
    G_CALLBACK (drawable_offset_cmd_callback),
66
67
    GIMP_HELP_LAYER_OFFSET }
67
68
};
68
69
 
69
70
static const GimpToggleActionEntry drawable_toggle_actions[] =
70
71
{
 
72
  { "drawable-visible", GIMP_STOCK_VISIBLE,
 
73
    NC_("drawable-action", "_Visible"), NULL,
 
74
    NC_("drawable-action", "Toggle visibility"),
 
75
    G_CALLBACK (drawable_visible_cmd_callback),
 
76
    FALSE,
 
77
    GIMP_HELP_LAYER_VISIBLE },
 
78
 
71
79
  { "drawable-linked", GIMP_STOCK_LINKED,
72
 
    N_("_Linked"), NULL,
73
 
    N_("Toggle the linked state"),
 
80
    NC_("drawable-action", "_Linked"), NULL,
 
81
    NC_("drawable-action", "Toggle the linked state"),
74
82
    G_CALLBACK (drawable_linked_cmd_callback),
75
83
    FALSE,
76
84
    GIMP_HELP_LAYER_LINKED },
77
85
 
78
 
  { "drawable-visible", GIMP_STOCK_VISIBLE,
79
 
    N_("_Visible"), NULL,
80
 
    N_("Toggle visibility"),
81
 
    G_CALLBACK (drawable_visible_cmd_callback),
 
86
  { "drawable-lock-content", NULL /* GIMP_STOCK_LOCK */,
 
87
    NC_("drawable-action", "L_ock pixels"), NULL,
 
88
    NC_("drawable-action",
 
89
        "Keep the pixels on this drawable from being modified"),
 
90
    G_CALLBACK (drawable_lock_content_cmd_callback),
82
91
    FALSE,
83
 
    GIMP_HELP_LAYER_VISIBLE }
 
92
    NULL, /* GIMP_HELP_LAYER_LOCK_PIXELS */ }
84
93
};
85
94
 
86
95
static const GimpEnumActionEntry drawable_flip_actions[] =
87
96
{
88
97
  { "drawable-flip-horizontal", GIMP_STOCK_FLIP_HORIZONTAL,
89
 
    N_("Flip _Horizontally"), NULL,
90
 
    N_("Flip horizontally"),
 
98
    NC_("drawable-action", "Flip _Horizontally"), NULL,
 
99
    NC_("drawable-action", "Flip horizontally"),
91
100
    GIMP_ORIENTATION_HORIZONTAL, FALSE,
92
101
    GIMP_HELP_LAYER_FLIP_HORIZONTAL },
93
102
 
94
103
  { "drawable-flip-vertical", GIMP_STOCK_FLIP_VERTICAL,
95
 
    N_("Flip _Vertically"), NULL,
96
 
    N_("Flip vertically"),
 
104
    NC_("drawable-action", "Flip _Vertically"), NULL,
 
105
    NC_("drawable-action", "Flip vertically"),
97
106
    GIMP_ORIENTATION_VERTICAL, FALSE,
98
107
    GIMP_HELP_LAYER_FLIP_VERTICAL }
99
108
};
101
110
static const GimpEnumActionEntry drawable_rotate_actions[] =
102
111
{
103
112
  { "drawable-rotate-90", GIMP_STOCK_ROTATE_90,
104
 
    N_("Rotate 90° _clockwise"), NULL,
105
 
    N_("Rotate 90 degrees to the right"),
 
113
    NC_("drawable-action", "Rotate 90° _clockwise"), NULL,
 
114
    NC_("drawable-action", "Rotate 90 degrees to the right"),
106
115
    GIMP_ROTATE_90, FALSE,
107
116
    GIMP_HELP_LAYER_ROTATE_90 },
108
117
 
109
118
  { "drawable-rotate-180", GIMP_STOCK_ROTATE_180,
110
 
    N_("Rotate _180°"), NULL,
111
 
    N_("Turn upside-down"),
 
119
    NC_("drawable-action", "Rotate _180°"), NULL,
 
120
    NC_("drawable-action", "Turn upside-down"),
112
121
    GIMP_ROTATE_180, FALSE,
113
122
    GIMP_HELP_LAYER_ROTATE_180 },
114
123
 
115
124
  { "drawable-rotate-270", GIMP_STOCK_ROTATE_270,
116
 
    N_("Rotate 90° counter-clock_wise"), NULL,
117
 
    N_("Rotate 90 degrees to the left"),
 
125
    NC_("drawable-action", "Rotate 90° counter-clock_wise"), NULL,
 
126
    NC_("drawable-action", "Rotate 90 degrees to the left"),
118
127
    GIMP_ROTATE_270, FALSE,
119
128
    GIMP_HELP_LAYER_ROTATE_270 }
120
129
};
123
132
void
124
133
drawable_actions_setup (GimpActionGroup *group)
125
134
{
126
 
  gimp_action_group_add_actions (group,
 
135
  gimp_action_group_add_actions (group, "drawable-action",
127
136
                                 drawable_actions,
128
137
                                 G_N_ELEMENTS (drawable_actions));
129
138
 
130
 
  gimp_action_group_add_toggle_actions (group,
 
139
  gimp_action_group_add_toggle_actions (group, "drawable-action",
131
140
                                        drawable_toggle_actions,
132
141
                                        G_N_ELEMENTS (drawable_toggle_actions));
133
142
 
134
 
  gimp_action_group_add_enum_actions (group,
 
143
  gimp_action_group_add_enum_actions (group, "drawable-action",
135
144
                                      drawable_flip_actions,
136
145
                                      G_N_ELEMENTS (drawable_flip_actions),
137
146
                                      G_CALLBACK (drawable_flip_cmd_callback));
138
147
 
139
 
  gimp_action_group_add_enum_actions (group,
 
148
  gimp_action_group_add_enum_actions (group, "drawable-action",
140
149
                                      drawable_rotate_actions,
141
150
                                      G_N_ELEMENTS (drawable_rotate_actions),
142
151
                                      G_CALLBACK (drawable_rotate_cmd_callback));
 
152
 
 
153
#define SET_ALWAYS_SHOW_IMAGE(action,show) \
 
154
        gimp_action_group_set_action_always_show_image (group, action, show)
 
155
 
 
156
  SET_ALWAYS_SHOW_IMAGE ("drawable-rotate-90",  TRUE);
 
157
  SET_ALWAYS_SHOW_IMAGE ("drawable-rotate-180", TRUE);
 
158
  SET_ALWAYS_SHOW_IMAGE ("drawable-rotate-270", TRUE);
 
159
 
 
160
#undef SET_ALWAYS_SHOW_IMAGE
143
161
}
144
162
 
145
163
void
149
167
  GimpImage    *image;
150
168
  GimpDrawable *drawable   = NULL;
151
169
  gboolean      is_rgb     = FALSE;
152
 
  gboolean      is_gray    = FALSE;
153
170
  gboolean      is_indexed = FALSE;
154
171
  gboolean      visible    = FALSE;
155
172
  gboolean      linked     = FALSE;
 
173
  gboolean      locked     = FALSE;
 
174
  gboolean      can_lock   = FALSE;
 
175
  gboolean      writable   = FALSE;
 
176
  gboolean      children   = FALSE;
156
177
 
157
178
  image = action_data_get_image (data);
158
179
 
166
187
          GimpItem      *item;
167
188
 
168
189
          is_rgb     = GIMP_IMAGE_TYPE_IS_RGB     (drawable_type);
169
 
          is_gray    = GIMP_IMAGE_TYPE_IS_GRAY    (drawable_type);
170
190
          is_indexed = GIMP_IMAGE_TYPE_IS_INDEXED (drawable_type);
171
191
 
172
192
          if (GIMP_IS_LAYER_MASK (drawable))
174
194
          else
175
195
            item = GIMP_ITEM (drawable);
176
196
 
177
 
          visible = gimp_item_get_visible (item);
178
 
          linked  = gimp_item_get_linked  (item);
 
197
          visible  = gimp_item_get_visible (item);
 
198
          linked   = gimp_item_get_linked (item);
 
199
          locked   = gimp_item_get_lock_content (item);
 
200
          can_lock = gimp_item_can_lock_content (item);
 
201
          writable = ! gimp_item_is_content_locked (item);
 
202
 
 
203
          if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)))
 
204
            children = TRUE;
179
205
        }
180
206
    }
181
207
 
184
210
#define SET_ACTIVE(action,condition) \
185
211
        gimp_action_group_set_action_active (group, action, (condition) != 0)
186
212
 
187
 
  SET_SENSITIVE ("drawable-equalize",       drawable && ! is_indexed);
188
 
  SET_SENSITIVE ("drawable-invert",         drawable && ! is_indexed);
189
 
  SET_SENSITIVE ("drawable-levels-stretch", drawable &&   is_rgb);
190
 
  SET_SENSITIVE ("drawable-offset",         drawable);
191
 
 
192
 
  SET_SENSITIVE ("drawable-visible", drawable);
193
 
  SET_SENSITIVE ("drawable-linked",  drawable);
194
 
 
195
 
  SET_ACTIVE ("drawable-visible", visible);
196
 
  SET_ACTIVE ("drawable-linked",  linked);
197
 
 
198
 
  SET_SENSITIVE ("drawable-flip-horizontal", drawable);
199
 
  SET_SENSITIVE ("drawable-flip-vertical",   drawable);
200
 
 
201
 
  SET_SENSITIVE ("drawable-rotate-90",  drawable);
202
 
  SET_SENSITIVE ("drawable-rotate-180", drawable);
203
 
  SET_SENSITIVE ("drawable-rotate-270", drawable);
 
213
  SET_SENSITIVE ("drawable-equalize",       writable && !children && !is_indexed);
 
214
  SET_SENSITIVE ("drawable-invert",         writable && !children && !is_indexed);
 
215
  SET_SENSITIVE ("drawable-levels-stretch", writable && !children &&  is_rgb);
 
216
  SET_SENSITIVE ("drawable-offset",         writable && !children);
 
217
 
 
218
  SET_SENSITIVE ("drawable-visible",      drawable);
 
219
  SET_SENSITIVE ("drawable-linked",       drawable);
 
220
  SET_SENSITIVE ("drawable-lock-content", can_lock);
 
221
 
 
222
  SET_ACTIVE ("drawable-visible",      visible);
 
223
  SET_ACTIVE ("drawable-linked",       linked);
 
224
  SET_ACTIVE ("drawable-lock-content", locked);
 
225
 
 
226
  SET_SENSITIVE ("drawable-flip-horizontal", writable);
 
227
  SET_SENSITIVE ("drawable-flip-vertical",   writable);
 
228
 
 
229
  SET_SENSITIVE ("drawable-rotate-90",  writable);
 
230
  SET_SENSITIVE ("drawable-rotate-180", writable);
 
231
  SET_SENSITIVE ("drawable-rotate-270", writable);
204
232
 
205
233
#undef SET_SENSITIVE
206
234
#undef SET_ACTIVE