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

« back to all changes in this revision

Viewing changes to app/core/gimpunit.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
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * gimpunit.c
49
49
 
50
50
/*  these are the built-in units
51
51
 */
52
 
static GimpUnitDef gimp_unit_defs[GIMP_UNIT_END] =
 
52
static const GimpUnitDef gimp_unit_defs[GIMP_UNIT_END] =
53
53
{
54
54
  /* pseudo unit */
55
55
  { FALSE,  0.0, 0, "pixels",      "px", "px", N_("pixel"),      N_("pixels") },
65
65
 
66
66
/*  not a unit at all but kept here to have the strings in one place
67
67
 */
68
 
static GimpUnitDef gimp_unit_percent =
 
68
static const GimpUnitDef gimp_unit_percent =
69
69
{
70
 
  FALSE,    0.0, 0, "percent",     "%",  "%",  N_("percent"),    N_("percent")
 
70
  FALSE,    0.0, 0, "percent",     "%",  "%",  N_("percent"),    N_("plural|percent")
71
71
};
72
72
 
73
73
 
75
75
 
76
76
static GimpUnitDef *
77
77
_gimp_unit_get_user_unit (Gimp     *gimp,
78
 
                          GimpUnit  unit)
 
78
                          GimpUnit  unit)
79
79
{
80
80
  return g_list_nth_data (gimp->user_units, unit - GIMP_UNIT_END);
81
81
}
96
96
}
97
97
 
98
98
GimpUnit
99
 
_gimp_unit_new (Gimp    *gimp,
100
 
                gchar   *identifier,
101
 
                gdouble  factor,
102
 
                gint     digits,
103
 
                gchar   *symbol,
104
 
                gchar   *abbreviation,
105
 
                gchar   *singular,
106
 
                gchar   *plural)
 
99
_gimp_unit_new (Gimp        *gimp,
 
100
                const gchar *identifier,
 
101
                gdouble      factor,
 
102
                gint         digits,
 
103
                const gchar *symbol,
 
104
                const gchar *abbreviation,
 
105
                const gchar *singular,
 
106
                const gchar *plural)
107
107
{
108
108
  GimpUnitDef *user_unit;
109
109
 
126
126
 
127
127
gboolean
128
128
_gimp_unit_get_deletion_flag (Gimp     *gimp,
129
 
                              GimpUnit  unit)
 
129
                              GimpUnit  unit)
130
130
{
131
131
  g_return_val_if_fail (unit < (GIMP_UNIT_END + gimp->n_user_units), FALSE);
132
132
 
138
138
 
139
139
void
140
140
_gimp_unit_set_deletion_flag (Gimp     *gimp,
141
 
                              GimpUnit  unit,
142
 
                              gboolean  deletion_flag)
 
141
                              GimpUnit  unit,
 
142
                              gboolean  deletion_flag)
143
143
{
144
144
  g_return_if_fail ((unit >= GIMP_UNIT_END) &&
145
 
                    (unit < (GIMP_UNIT_END + gimp->n_user_units)));
 
145
                    (unit < (GIMP_UNIT_END + gimp->n_user_units)));
146
146
 
147
147
  _gimp_unit_get_user_unit (gimp, unit)->delete_on_exit =
148
148
    deletion_flag ? TRUE : FALSE;
150
150
 
151
151
gdouble
152
152
_gimp_unit_get_factor (Gimp     *gimp,
153
 
                       GimpUnit  unit)
 
153
                       GimpUnit  unit)
154
154
{
155
155
  g_return_val_if_fail (unit < (GIMP_UNIT_END + gimp->n_user_units),
156
 
                        gimp_unit_defs[GIMP_UNIT_INCH].factor);
 
156
                        gimp_unit_defs[GIMP_UNIT_INCH].factor);
157
157
 
158
158
  if (unit < GIMP_UNIT_END)
159
159
    return gimp_unit_defs[unit].factor;
163
163
 
164
164
gint
165
165
_gimp_unit_get_digits (Gimp     *gimp,
166
 
                       GimpUnit  unit)
 
166
                       GimpUnit  unit)
167
167
{
168
168
  g_return_val_if_fail (unit < (GIMP_UNIT_END + gimp->n_user_units),
169
 
                        gimp_unit_defs[GIMP_UNIT_INCH].digits);
 
169
                        gimp_unit_defs[GIMP_UNIT_INCH].digits);
170
170
 
171
171
  if (unit < GIMP_UNIT_END)
172
172
    return gimp_unit_defs[unit].digits;
176
176
 
177
177
const gchar *
178
178
_gimp_unit_get_identifier (Gimp     *gimp,
179
 
                           GimpUnit  unit)
 
179
                           GimpUnit  unit)
180
180
{
181
181
  g_return_val_if_fail ((unit < (GIMP_UNIT_END + gimp->n_user_units)) ||
182
 
                        (unit == GIMP_UNIT_PERCENT),
183
 
                        gimp_unit_defs[GIMP_UNIT_INCH].identifier);
 
182
                        (unit == GIMP_UNIT_PERCENT),
 
183
                        gimp_unit_defs[GIMP_UNIT_INCH].identifier);
184
184
 
185
185
  if (unit < GIMP_UNIT_END)
186
186
    return gimp_unit_defs[unit].identifier;
193
193
 
194
194
const gchar *
195
195
_gimp_unit_get_symbol (Gimp     *gimp,
196
 
                       GimpUnit  unit)
 
196
                       GimpUnit  unit)
197
197
{
198
198
  g_return_val_if_fail ((unit < (GIMP_UNIT_END + gimp->n_user_units)) ||
199
 
                        (unit == GIMP_UNIT_PERCENT),
200
 
                        gimp_unit_defs[GIMP_UNIT_INCH].symbol);
 
199
                        (unit == GIMP_UNIT_PERCENT),
 
200
                        gimp_unit_defs[GIMP_UNIT_INCH].symbol);
201
201
 
202
202
  if (unit < GIMP_UNIT_END)
203
203
    return gimp_unit_defs[unit].symbol;
210
210
 
211
211
const gchar *
212
212
_gimp_unit_get_abbreviation (Gimp     *gimp,
213
 
                             GimpUnit  unit)
 
213
                             GimpUnit  unit)
214
214
{
215
215
  g_return_val_if_fail ((unit < (GIMP_UNIT_END + gimp->n_user_units)) ||
216
 
                        (unit == GIMP_UNIT_PERCENT),
217
 
                        gimp_unit_defs[GIMP_UNIT_INCH].abbreviation);
 
216
                        (unit == GIMP_UNIT_PERCENT),
 
217
                        gimp_unit_defs[GIMP_UNIT_INCH].abbreviation);
218
218
 
219
219
  if (unit < GIMP_UNIT_END)
220
220
    return gimp_unit_defs[unit].abbreviation;
227
227
 
228
228
const gchar *
229
229
_gimp_unit_get_singular (Gimp     *gimp,
230
 
                         GimpUnit  unit)
 
230
                         GimpUnit  unit)
231
231
{
232
232
  g_return_val_if_fail ((unit < (GIMP_UNIT_END + gimp->n_user_units)) ||
233
 
                        (unit == GIMP_UNIT_PERCENT),
234
 
                        gettext (gimp_unit_defs[GIMP_UNIT_INCH].singular));
 
233
                        (unit == GIMP_UNIT_PERCENT),
 
234
                        gimp_unit_defs[GIMP_UNIT_INCH].singular);
235
235
 
236
236
  if (unit < GIMP_UNIT_END)
237
 
    return gettext (gimp_unit_defs[unit].singular);
 
237
    return g_strip_context (gimp_unit_defs[unit].singular,
 
238
                            gettext (gimp_unit_defs[unit].singular));
238
239
 
239
240
  if (unit == GIMP_UNIT_PERCENT)
240
 
    return gettext (gimp_unit_percent.singular);
 
241
    return g_strip_context (gimp_unit_percent.singular,
 
242
                            gettext (gimp_unit_percent.singular));
241
243
 
242
 
  return gettext (_gimp_unit_get_user_unit (gimp, unit)->singular);
 
244
  return _gimp_unit_get_user_unit (gimp, unit)->singular;
243
245
}
244
246
 
245
247
const gchar *
246
248
_gimp_unit_get_plural (Gimp     *gimp,
247
 
                       GimpUnit  unit)
 
249
                       GimpUnit  unit)
248
250
{
249
251
  g_return_val_if_fail ((unit < (GIMP_UNIT_END + gimp->n_user_units)) ||
250
 
                        (unit == GIMP_UNIT_PERCENT),
251
 
                        gettext (gimp_unit_defs[GIMP_UNIT_INCH].plural));
 
252
                        (unit == GIMP_UNIT_PERCENT),
 
253
                        gimp_unit_defs[GIMP_UNIT_INCH].plural);
252
254
 
253
255
  if (unit < GIMP_UNIT_END)
254
 
    return gettext (gimp_unit_defs[unit].plural);
 
256
    return g_strip_context (gimp_unit_defs[unit].plural,
 
257
                            gettext (gimp_unit_defs[unit].plural));
255
258
 
256
259
  if (unit == GIMP_UNIT_PERCENT)
257
 
    return gettext (gimp_unit_percent.plural);
258
 
 
259
 
  return gettext (_gimp_unit_get_user_unit (gimp, unit)->plural);
 
260
    return g_strip_context (gimp_unit_percent.plural,
 
261
                            gettext (gimp_unit_percent.plural));
 
262
 
 
263
  return _gimp_unit_get_user_unit (gimp, unit)->plural;
 
264
}
 
265
 
 
266
 
 
267
/* The sole purpose of this function is to release the allocated
 
268
 * memory. It must only be used from gimp_units_exit().
 
269
 */
 
270
void
 
271
gimp_user_units_free (Gimp *gimp)
 
272
{
 
273
  GList *list;
 
274
 
 
275
  for (list = gimp->user_units; list; list = g_list_next (list))
 
276
    {
 
277
      GimpUnitDef *user_unit = list->data;
 
278
 
 
279
      g_free (user_unit->identifier);
 
280
      g_free (user_unit->symbol);
 
281
      g_free (user_unit->abbreviation);
 
282
      g_free (user_unit->singular);
 
283
      g_free (user_unit->plural);
 
284
 
 
285
      g_free (user_unit);
 
286
    }
 
287
 
 
288
  g_list_free (gimp->user_units);
 
289
  gimp->user_units   = NULL;
 
290
  gimp->n_user_units = 0;
260
291
}