~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/widgets/gimpcontrollerwheel.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* LIBGIMP - The GIMP Library
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
3
3
 *
4
4
 * gimpcontrollerwheel.c
5
5
 * Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
6
6
 *
7
 
 * This library is free software; you can redistribute it and/or
8
 
 * modify it under the terms of the GNU Lesser General Public
9
 
 * License as published by the Free Software Foundation; either
10
 
 * version 2 of the License, or (at your option) any later version.
 
7
 * This program is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; either version 2 of the License, or
 
10
 * (at your option) any later version.
11
11
 *
12
 
 * This library is distributed in the hope that it will be useful,
 
12
 * This program is distributed in the hope that it will be useful,
13
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 
 * Lesser General Public License for more details.
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
16
16
 *
17
 
 * You should have received a copy of the GNU Lesser General Public
18
 
 * License along with this library; if not, write to the
19
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
 
 * Boston, MA 02111-1307, USA.
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program; if not, write to the Free Software
 
19
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
20
 */
22
21
 
23
22
#include "config.h"
30
29
 
31
30
#include "gimpcontrollerwheel.h"
32
31
#include "gimphelp-ids.h"
 
32
#include "gimpwidgets-utils.h"
33
33
 
34
34
#include "gimp-intl.h"
35
35
 
38
38
 
39
39
struct _WheelEvent
40
40
{
41
 
  GdkScrollDirection  direction;
42
 
  GdkModifierType     modifiers;
43
 
  const gchar        *name;
44
 
  const gchar        *blurb;
 
41
  const GdkScrollDirection  direction;
 
42
  const GdkModifierType     modifiers;
 
43
  const gchar              *name;
 
44
  gchar                    *blurb;
45
45
};
46
46
 
47
47
 
48
 
static void          gimp_controller_wheel_class_init      (GimpControllerWheelClass *klass);
49
 
static void          gimp_controller_wheel_init            (GimpControllerWheel      *wheel);
50
 
 
51
48
static GObject     * gimp_controller_wheel_constructor     (GType           type,
52
49
                                                            guint           n_params,
53
50
                                                            GObjectConstructParam *params);
59
56
                                                            gint            event_id);
60
57
 
61
58
 
62
 
static GimpControllerClass *parent_class = NULL;
63
 
 
64
 
static const WheelEvent wheel_events[] =
 
59
G_DEFINE_TYPE (GimpControllerWheel, gimp_controller_wheel,
 
60
               GIMP_TYPE_CONTROLLER)
 
61
 
 
62
#define parent_class gimp_controller_wheel_parent_class
 
63
 
 
64
 
 
65
static WheelEvent wheel_events[] =
65
66
{
66
67
  { GDK_SCROLL_UP, GDK_MOD1_MASK | GDK_CONTROL_MASK | GDK_SHIFT_MASK,
67
68
    "scroll-up-shift-control-alt",
68
 
    N_("Scroll Up (Shift + Control + Alt)") },
 
69
    N_("Scroll Up") },
69
70
  { GDK_SCROLL_UP, GDK_MOD1_MASK | GDK_CONTROL_MASK,
70
71
    "scroll-up-control-alt",
71
 
    N_("Scroll Up (Control + Alt)") },
 
72
    N_("Scroll Up") },
72
73
  { GDK_SCROLL_UP, GDK_MOD1_MASK | GDK_SHIFT_MASK,
73
74
    "scroll-up-shift-alt",
74
 
    N_("Scroll Up (Shift + Alt)") },
 
75
    N_("Scroll Up") },
75
76
  { GDK_SCROLL_UP, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
76
77
    "scroll-up-shift-control",
77
 
    N_("Scroll Up (Shift + Control)") },
 
78
    N_("Scroll Up") },
78
79
  { GDK_SCROLL_UP, GDK_MOD1_MASK,
79
80
    "scroll-up-alt",
80
 
    N_("Scroll Up (Alt)") },
 
81
    N_("Scroll Up") },
81
82
  { GDK_SCROLL_UP, GDK_CONTROL_MASK,
82
83
    "scroll-up-control",
83
 
    N_("Scroll Up (Control)") },
 
84
    N_("Scroll Up") },
84
85
  { GDK_SCROLL_UP, GDK_SHIFT_MASK,
85
86
    "scroll-up-shift",
86
 
    N_("Scroll Up (Shift)") },
 
87
    N_("Scroll Up") },
87
88
  { GDK_SCROLL_UP, 0,
88
89
    "scroll-up",
89
90
    N_("Scroll Up") },
90
91
 
91
92
  { GDK_SCROLL_DOWN, GDK_MOD1_MASK | GDK_CONTROL_MASK | GDK_SHIFT_MASK,
92
93
    "scroll-down-shift-control-alt",
93
 
    N_("Scroll Down (Shift + Control + Alt)") },
 
94
    N_("Scroll Down") },
94
95
  { GDK_SCROLL_DOWN, GDK_MOD1_MASK | GDK_CONTROL_MASK,
95
96
    "scroll-down-control-alt",
96
 
    N_("Scroll Down (Control + Alt)") },
 
97
    N_("Scroll Down") },
97
98
  { GDK_SCROLL_DOWN, GDK_MOD1_MASK | GDK_SHIFT_MASK,
98
99
    "scroll-down-shift-alt",
99
 
    N_("Scroll Down (Shift + Alt)") },
 
100
    N_("Scroll Down") },
100
101
  { GDK_SCROLL_DOWN, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
101
102
    "scroll-down-shift-control",
102
 
    N_("Scroll Down (Shift + Control)") },
 
103
    N_("Scroll Down") },
103
104
  { GDK_SCROLL_DOWN, GDK_MOD1_MASK,
104
105
    "scroll-down-alt",
105
 
    N_("Scroll Down (Alt)") },
 
106
    N_("Scroll Down") },
106
107
  { GDK_SCROLL_DOWN, GDK_CONTROL_MASK,
107
108
    "scroll-down-control",
108
 
    N_("Scroll Down (Control)") },
 
109
    N_("Scroll Down") },
109
110
  { GDK_SCROLL_DOWN, GDK_SHIFT_MASK,
110
111
    "scroll-down-shift",
111
 
    N_("Scroll Down (Shift)") },
 
112
    N_("Scroll Down") },
112
113
  { GDK_SCROLL_DOWN, 0,
113
114
    "scroll-down",
114
115
    N_("Scroll Down") },
115
116
 
116
117
  { GDK_SCROLL_LEFT, GDK_MOD1_MASK | GDK_CONTROL_MASK | GDK_SHIFT_MASK,
117
118
    "scroll-left-shift-control-alt",
118
 
    N_("Scroll Left (Shift + Control + Alt)") },
 
119
    N_("Scroll Left") },
119
120
  { GDK_SCROLL_LEFT, GDK_MOD1_MASK | GDK_CONTROL_MASK,
120
121
    "scroll-left-control-alt",
121
 
    N_("Scroll Left (Control + Alt)") },
 
122
    N_("Scroll Left") },
122
123
  { GDK_SCROLL_LEFT, GDK_MOD1_MASK | GDK_SHIFT_MASK,
123
124
    "scroll-left-shift-alt",
124
 
    N_("Scroll Left (Shift + Alt)") },
 
125
    N_("Scroll Left") },
125
126
  { GDK_SCROLL_LEFT, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
126
127
    "scroll-left-shift-control",
127
 
    N_("Scroll Left (Shift + Control)") },
 
128
    N_("Scroll Left") },
128
129
  { GDK_SCROLL_LEFT, GDK_MOD1_MASK,
129
130
    "scroll-left-alt",
130
 
    N_("Scroll Left (Alt)") },
 
131
    N_("Scroll Left") },
131
132
  { GDK_SCROLL_LEFT, GDK_CONTROL_MASK,
132
133
    "scroll-left-control",
133
 
    N_("Scroll Left (Control)") },
 
134
    N_("Scroll Left") },
134
135
  { GDK_SCROLL_LEFT, GDK_SHIFT_MASK,
135
136
    "scroll-left-shift",
136
 
    N_("Scroll Left (Shift)") },
 
137
    N_("Scroll Left") },
137
138
  { GDK_SCROLL_LEFT, 0,
138
139
    "scroll-left",
139
140
    N_("Scroll Left") },
140
141
 
141
142
  { GDK_SCROLL_RIGHT, GDK_MOD1_MASK | GDK_CONTROL_MASK | GDK_SHIFT_MASK,
142
143
    "scroll-right-shift-control-alt",
143
 
    N_("Scroll Right (Shift + Control + Alt)") },
 
144
    N_("Scroll Right") },
144
145
  { GDK_SCROLL_RIGHT, GDK_MOD1_MASK | GDK_CONTROL_MASK,
145
146
    "scroll-right-control-alt",
146
 
    N_("Scroll Right (Control + Alt)") },
 
147
    N_("Scroll Right") },
147
148
  { GDK_SCROLL_RIGHT, GDK_MOD1_MASK | GDK_SHIFT_MASK,
148
149
    "scroll-right-shift-alt",
149
 
    N_("Scroll Right (Shift + Alt)") },
 
150
    N_("Scroll Right") },
150
151
  { GDK_SCROLL_RIGHT, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
151
152
    "scroll-right-shift-control",
152
 
    N_("Scroll Right (Shift + Control)") },
 
153
    N_("Scroll Right") },
153
154
  { GDK_SCROLL_RIGHT, GDK_MOD1_MASK,
154
155
    "scroll-right-alt",
155
 
    N_("Scroll Right (Alt)") },
 
156
    N_("Scroll Right") },
156
157
  { GDK_SCROLL_RIGHT, GDK_CONTROL_MASK,
157
158
    "scroll-right-control",
158
 
    N_("Scroll Right (Control)") },
 
159
    N_("Scroll Right") },
159
160
  { GDK_SCROLL_RIGHT, GDK_SHIFT_MASK,
160
161
    "scroll-right-shift",
161
 
    N_("Scroll Right (Shift)") },
 
162
    N_("Scroll Right") },
162
163
  { GDK_SCROLL_RIGHT, 0,
163
164
    "scroll-right",
164
165
    N_("Scroll Right") }
165
166
};
166
167
 
167
168
 
168
 
GType
169
 
gimp_controller_wheel_get_type (void)
170
 
{
171
 
  static GType controller_type = 0;
172
 
 
173
 
  if (! controller_type)
174
 
    {
175
 
      static const GTypeInfo controller_info =
176
 
      {
177
 
        sizeof (GimpControllerWheelClass),
178
 
        (GBaseInitFunc) NULL,
179
 
        (GBaseFinalizeFunc) NULL,
180
 
        (GClassInitFunc) gimp_controller_wheel_class_init,
181
 
        NULL,           /* class_finalize */
182
 
        NULL,           /* class_data     */
183
 
        sizeof (GimpControllerWheel),
184
 
        0,              /* n_preallocs    */
185
 
        (GInstanceInitFunc) gimp_controller_wheel_init,
186
 
      };
187
 
 
188
 
      controller_type = g_type_register_static (GIMP_TYPE_CONTROLLER,
189
 
                                                "GimpControllerWheel",
190
 
                                                &controller_info, 0);
191
 
    }
192
 
 
193
 
  return controller_type;
194
 
}
195
 
 
196
169
static void
197
170
gimp_controller_wheel_class_init (GimpControllerWheelClass *klass)
198
171
{
199
172
  GObjectClass        *object_class     = G_OBJECT_CLASS (klass);
200
173
  GimpControllerClass *controller_class = GIMP_CONTROLLER_CLASS (klass);
201
174
 
202
 
  parent_class = g_type_class_peek_parent (klass);
203
 
 
204
175
  object_class->constructor         = gimp_controller_wheel_constructor;
205
176
 
206
177
  controller_class->name            = _("Mouse Wheel");
207
178
  controller_class->help_id         = GIMP_HELP_CONTROLLER_WHEEL;
 
179
  controller_class->stock_id        = GIMP_STOCK_CONTROLLER_WHEEL;
208
180
 
209
181
  controller_class->get_n_events    = gimp_controller_wheel_get_n_events;
210
182
  controller_class->get_event_name  = gimp_controller_wheel_get_event_name;
214
186
static void
215
187
gimp_controller_wheel_init (GimpControllerWheel *wheel)
216
188
{
 
189
  static gboolean event_names_initialized = FALSE;
 
190
 
 
191
  if (! event_names_initialized)
 
192
    {
 
193
      gint i;
 
194
 
 
195
      for (i = 0; i < G_N_ELEMENTS (wheel_events); i++)
 
196
        {
 
197
          WheelEvent *wevent = &wheel_events[i];
 
198
 
 
199
          if (wevent->modifiers != 0)
 
200
            {
 
201
              wevent->blurb =
 
202
                g_strdup_printf ("%s (%s)", gettext (wevent->blurb),
 
203
                                 gimp_get_mod_string (wevent->modifiers));
 
204
            }
 
205
        }
 
206
 
 
207
      event_names_initialized = TRUE;
 
208
    }
217
209
}
218
210
 
219
211
static GObject *
256
248
  if (event_id < 0 || event_id >= G_N_ELEMENTS (wheel_events))
257
249
    return NULL;
258
250
 
259
 
  return gettext (wheel_events[event_id].blurb);
 
251
  return wheel_events[event_id].blurb;
260
252
}
261
253
 
262
254
gboolean