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

« back to all changes in this revision

Viewing changes to app/display/gimpdisplayshell-title.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 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
22
22
 
23
23
#include <gtk/gtk.h>
24
24
 
 
25
#include "libgimpwidgets/gimpwidgets.h"
 
26
 
25
27
#include "libgimpbase/gimpbase.h"
26
28
 
27
29
#include "display-types.h"
36
38
 
37
39
#include "file/file-utils.h"
38
40
 
39
 
#ifdef __GNUC__
40
 
#warning FIXME #include "dialogs/dialogs-types.h"
41
 
#endif
42
 
#include "dialogs/dialogs-types.h"
43
 
#include "dialogs/info-window.h"
44
 
 
45
41
#include "gimpdisplay.h"
46
42
#include "gimpdisplayshell.h"
47
 
#include "gimpdisplayshell-scale.h"
48
43
#include "gimpdisplayshell-title.h"
49
44
#include "gimpstatusbar.h"
50
45
 
55
50
 
56
51
 
57
52
static gboolean gimp_display_shell_update_title_idle (gpointer          data);
58
 
static void     gimp_display_shell_format_title      (GimpDisplayShell *gdisp,
 
53
static void     gimp_display_shell_format_title      (GimpDisplayShell *display,
59
54
                                                      gchar            *title,
60
55
                                                      gint              title_len,
61
56
                                                      const gchar      *format);
71
66
 
72
67
  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
73
68
 
74
 
  config = GIMP_DISPLAY_CONFIG (shell->gdisp->gimage->gimp->config);
 
69
  config = GIMP_DISPLAY_CONFIG (shell->display->image->gimp->config);
75
70
 
76
71
  gimp_display_shell_format_title (shell, title, sizeof (title),
77
72
                                   config->image_status_format);
78
73
 
79
 
  gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar), "title", title);
 
74
  gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar), "title",
 
75
                       "%s", title);
80
76
}
81
77
 
82
78
void
102
98
  gchar              title[MAX_TITLE_BUF];
103
99
 
104
100
  shell  = GIMP_DISPLAY_SHELL (data);
105
 
  config = GIMP_DISPLAY_CONFIG (shell->gdisp->gimage->gimp->config);
 
101
  config = GIMP_DISPLAY_CONFIG (shell->display->image->gimp->config);
106
102
 
107
103
  shell->title_idle_id = 0;
108
104
 
118
114
                                       config->image_status_format);
119
115
    }
120
116
 
121
 
  gimp_statusbar_replace (GIMP_STATUSBAR (shell->statusbar), "title", title);
122
 
 
123
 
#ifdef __GNUC__
124
 
#warning FIXME: dont call info_window_update() here.
125
 
#endif
126
 
  info_window_update (shell->gdisp);
 
117
  gimp_statusbar_replace (GIMP_STATUSBAR (shell->statusbar), "title",
 
118
                          "%s", title);
127
119
 
128
120
  return FALSE;
129
121
}
169
161
 
170
162
  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
171
163
 
172
 
  image = shell->gdisp->gimage;
 
164
  image = shell->display->image;
173
165
  gimp  = image->gimp;
174
166
 
175
 
  gimp_display_shell_scale_get_fraction (shell->scale, &num, &denom);
 
167
  gimp_zoom_model_get_fraction (shell->zoom, &num, &denom);
176
168
 
177
169
  while (i < title_len && *format)
178
170
    {
179
171
      switch (*format)
180
 
        {
181
 
        case '%':
182
 
          format++;
183
 
          switch (*format)
184
 
            {
185
 
            case 0:
186
 
              /* format string ends within %-sequence, print literal '%' */
187
 
 
188
 
            case '%':
189
 
              title[i++] = '%';
190
 
              break;
191
 
 
192
 
            case 'f': /* pruned filename */
193
 
              {
194
 
                const gchar *uri = gimp_image_get_uri (image);
195
 
                gchar       *basename;
196
 
 
197
 
                basename = file_utils_uri_to_utf8_basename (uri);
198
 
 
199
 
                i += print (title, title_len, i, "%s", basename);
200
 
 
201
 
                g_free (basename);
202
 
              }
203
 
              break;
204
 
 
205
 
            case 'F': /* full filename */
206
 
              {
207
 
                gchar *filename;
208
 
                const gchar *uri = gimp_image_get_uri (image);
209
 
 
210
 
                filename = file_utils_uri_to_utf8_filename (uri);
 
172
        {
 
173
        case '%':
 
174
          format++;
 
175
          switch (*format)
 
176
            {
 
177
            case 0:
 
178
              /* format string ends within %-sequence, print literal '%' */
 
179
 
 
180
            case '%':
 
181
              title[i++] = '%';
 
182
              break;
 
183
 
 
184
            case 'f': /* pruned filename */
 
185
              {
 
186
                const gchar *uri = gimp_image_get_uri (image);
 
187
                gchar       *basename;
 
188
 
 
189
                basename = file_utils_uri_display_basename (uri);
 
190
 
 
191
                i += print (title, title_len, i, "%s", basename);
 
192
 
 
193
                g_free (basename);
 
194
              }
 
195
              break;
 
196
 
 
197
            case 'F': /* full filename */
 
198
              {
 
199
                gchar *filename;
 
200
                const gchar *uri = gimp_image_get_uri (image);
 
201
 
 
202
                filename = file_utils_uri_display_name (uri);
211
203
 
212
204
                i += print (title, title_len, i, "%s", filename);
213
205
 
214
206
                g_free (filename);
215
207
              }
216
 
              break;
217
 
 
218
 
            case 'p': /* PDB id */
219
 
              i += print (title, title_len, i, "%d", gimp_image_get_ID (image));
220
 
              break;
221
 
 
222
 
            case 'i': /* instance */
223
 
              i += print (title, title_len, i, "%d", shell->gdisp->instance);
224
 
              break;
225
 
 
226
 
            case 't': /* type */
 
208
              break;
 
209
 
 
210
            case 'p': /* PDB id */
 
211
              i += print (title, title_len, i, "%d", gimp_image_get_ID (image));
 
212
              break;
 
213
 
 
214
            case 'i': /* instance */
 
215
              i += print (title, title_len, i, "%d", shell->display->instance);
 
216
              break;
 
217
 
 
218
            case 't': /* type */
227
219
              {
228
220
                const gchar *image_type_str = NULL;
229
221
                gboolean     empty          = gimp_image_is_empty (image);
246
238
 
247
239
                i += print (title, title_len, i, "%s", image_type_str);
248
240
              }
249
 
              break;
250
 
 
251
 
            case 's': /* user source zoom factor */
252
 
              i += print (title, title_len, i, "%d", denom);
253
 
              break;
254
 
 
255
 
            case 'd': /* user destination zoom factor */
256
 
              i += print (title, title_len, i, "%d", num);
257
 
              break;
258
 
 
259
 
            case 'z': /* user zoom factor (percentage) */
260
 
              i += print (title, title_len, i,
261
 
                          shell->scale >= 0.15 ? "%.0f" : "%.2f",
262
 
                          100 * shell->scale);
263
 
              break;
264
 
 
265
 
            case 'D': /* dirty flag */
266
 
              if (format[1] == 0)
267
 
                {
268
 
                  /* format string ends within %D-sequence, print literal '%D' */
 
241
              break;
 
242
 
 
243
            case 's': /* user source zoom factor */
 
244
              i += print (title, title_len, i, "%d", denom);
 
245
              break;
 
246
 
 
247
            case 'd': /* user destination zoom factor */
 
248
              i += print (title, title_len, i, "%d", num);
 
249
              break;
 
250
 
 
251
            case 'z': /* user zoom factor (percentage) */
 
252
              {
 
253
                gdouble  scale = gimp_zoom_model_get_factor (shell->zoom);
 
254
 
 
255
                i += print (title, title_len, i,
 
256
                            scale >= 0.15 ? "%.0f" : "%.2f", 100.0 * scale);
 
257
              }
 
258
              break;
 
259
 
 
260
            case 'D': /* dirty flag */
 
261
              if (format[1] == 0)
 
262
                {
 
263
                  /* format string ends within %D-sequence, print literal '%D' */
269
264
                  i += print (title, title_len, i, "%%D");
270
 
                  break;
271
 
                }
272
 
              if (image->dirty)
273
 
                title[i++] = format[1];
274
 
              format++;
275
 
              break;
 
265
                  break;
 
266
                }
 
267
              if (image->dirty)
 
268
                title[i++] = format[1];
 
269
              format++;
 
270
              break;
276
271
 
277
 
            case 'C': /* clean flag */
278
 
              if (format[1] == 0)
279
 
                {
280
 
                  /* format string ends within %C-sequence, print literal '%C' */
 
272
            case 'C': /* clean flag */
 
273
              if (format[1] == 0)
 
274
                {
 
275
                  /* format string ends within %C-sequence, print literal '%C' */
281
276
                  i += print (title, title_len, i, "%%C");
282
 
                  break;
283
 
                }
284
 
              if (! image->dirty)
285
 
                title[i++] = format[1];
286
 
              format++;
287
 
              break;
288
 
 
289
 
            case 'B': /* dirty flag (long) */
290
 
              if (image->dirty)
291
 
                i += print (title, title_len, i, "%s",
292
 
                            _("(modified)"));
293
 
              break;
294
 
 
295
 
            case 'A': /* clean flag (long) */
296
 
              if (! image->dirty)
297
 
                i += print (title, title_len, i, "%s",
298
 
                            _("(clean)"));
299
 
              break;
 
277
                  break;
 
278
                }
 
279
              if (! image->dirty)
 
280
                title[i++] = format[1];
 
281
              format++;
 
282
              break;
 
283
 
 
284
            case 'B': /* dirty flag (long) */
 
285
              if (image->dirty)
 
286
                i += print (title, title_len, i, "%s", _("(modified)"));
 
287
              break;
 
288
 
 
289
            case 'A': /* clean flag (long) */
 
290
              if (! image->dirty)
 
291
                i += print (title, title_len, i, "%s", _("(clean)"));
 
292
              break;
300
293
 
301
294
            case 'm': /* memory used by image */
302
295
              {
322
315
                gint num = gimp_container_num_children (image->layers);
323
316
 
324
317
                i += print (title, title_len, i,
325
 
                            num == 1 ? _("1 layer") : _("%d layers"), num);
 
318
                            ngettext ("%d layer", "%d layers", num), num);
326
319
              }
327
320
              break;
328
321
 
350
343
              }
351
344
              break;
352
345
 
353
 
            case 'W': /* width in real-world units */
 
346
            case 'W': /* width in real-world units */
354
347
              if (shell->unit != GIMP_UNIT_PIXEL)
355
348
                {
356
349
                  gchar unit_format[8];
364
357
                  break;
365
358
                }
366
359
              /* else fallthru */
367
 
            case 'w': /* width in pixels */
368
 
              i += print (title, title_len, i, "%d", image->width);
369
 
              break;
 
360
            case 'w': /* width in pixels */
 
361
              i += print (title, title_len, i, "%d", image->width);
 
362
              break;
370
363
 
371
 
            case 'H': /* height in real-world units */
 
364
            case 'H': /* height in real-world units */
372
365
              if (shell->unit != GIMP_UNIT_PIXEL)
373
366
                {
374
367
                  gchar unit_format[8];
382
375
                  break;
383
376
                }
384
377
              /* else fallthru */
385
 
            case 'h': /* height in pixels */
386
 
              i += print (title, title_len, i, "%d", image->height);
387
 
              break;
388
 
 
389
 
            case 'u': /* unit symbol */
390
 
              i += print (title, title_len, i, "%s",
391
 
                          _gimp_unit_get_symbol (gimp, shell->unit));
392
 
              break;
393
 
 
394
 
            case 'U': /* unit abbreviation */
395
 
              i += print (title, title_len, i, "%s",
396
 
                          _gimp_unit_get_abbreviation (gimp, shell->unit));
397
 
              break;
398
 
 
399
 
              /* Other cool things to be added:
400
 
               * %r = xresolution
 
378
            case 'h': /* height in pixels */
 
379
              i += print (title, title_len, i, "%d", image->height);
 
380
              break;
 
381
 
 
382
            case 'u': /* unit symbol */
 
383
              i += print (title, title_len, i, "%s",
 
384
                          _gimp_unit_get_symbol (gimp, shell->unit));
 
385
              break;
 
386
 
 
387
            case 'U': /* unit abbreviation */
 
388
              i += print (title, title_len, i, "%s",
 
389
                          _gimp_unit_get_abbreviation (gimp, shell->unit));
 
390
              break;
 
391
 
 
392
              /* Other cool things to be added:
 
393
               * %r = xresolution
401
394
               * %R = yresolution
402
395
               * %� = image's fractal dimension
403
396
               * %� = the answer to everything
404
 
               */
 
397
               */
405
398
 
406
 
            default:
 
399
            default:
407
400
              /* format string contains unknown %-sequence, print it literally */
408
401
              i += print (title, title_len, i, "%%%c", *format);
409
402
              break;
410
 
            }
411
 
          break;
 
403
            }
 
404
          break;
412
405
 
413
 
        default:
414
 
          title[i++] = *format;
415
 
          break;
416
 
        }
 
406
        default:
 
407
          title[i++] = *format;
 
408
          break;
 
409
        }
417
410
 
418
411
      format++;
419
412
    }