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

« back to all changes in this revision

Viewing changes to app/dialogs/info-window.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
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 "libgimpbase/gimpbase.h"
24
 
#include "libgimpcolor/gimpcolor.h"
25
 
#include "libgimpwidgets/gimpwidgets.h"
26
 
 
27
 
#include "dialogs-types.h"
28
 
 
29
 
#include "core/gimp.h"
30
 
#include "core/gimpcontainer.h"
31
 
#include "core/gimpcontext.h"
32
 
#include "core/gimpimage.h"
33
 
#include "core/gimppickable.h"
34
 
#include "core/gimptemplate.h"
35
 
#include "core/gimpunit.h"
36
 
 
37
 
#include "display/gimpdisplay.h"
38
 
#include "display/gimpdisplayshell.h"
39
 
 
40
 
#include "widgets/gimpcolorframe.h"
41
 
#include "widgets/gimphelp-ids.h"
42
 
#include "widgets/gimpviewabledialog.h"
43
 
 
44
 
#include "info-dialog.h"
45
 
#include "info-window.h"
46
 
 
47
 
#include "gimp-intl.h"
48
 
 
49
 
 
50
 
#define MAX_BUF 256
51
 
 
52
 
typedef struct _InfoWinData InfoWinData;
53
 
 
54
 
struct _InfoWinData
55
 
{
56
 
  GimpDisplay *gdisp;
57
 
 
58
 
  gchar        dimensions_str[MAX_BUF];
59
 
  gchar        real_dimensions_str[MAX_BUF];
60
 
  gchar        scale_str[MAX_BUF];
61
 
  gchar        num_layers_str[MAX_BUF];
62
 
  gchar        memsize_str[MAX_BUF];
63
 
  gchar        color_type_str[MAX_BUF];
64
 
  gchar        visual_class_str[MAX_BUF];
65
 
  gchar        visual_depth_str[MAX_BUF];
66
 
  gchar        resolution_str[MAX_BUF];
67
 
  gchar        comment_str[MAX_BUF];
68
 
 
69
 
  GtkWidget   *pixel_labels[2];
70
 
  GtkWidget   *unit_labels[2];
71
 
  GtkWidget   *comment_label;
72
 
 
73
 
  GtkWidget   *frame1;
74
 
  GtkWidget   *frame2;
75
 
 
76
 
  gboolean     show_cursor;
77
 
};
78
 
 
79
 
 
80
 
/*  The different classes of visuals  */
81
 
static const gchar *visual_classes[] =
82
 
{
83
 
  N_("Static Gray"),
84
 
  N_("Grayscale"),
85
 
  N_("Static Color"),
86
 
  N_("Pseudo Color"),
87
 
  N_("True Color"),
88
 
  N_("Direct Color"),
89
 
};
90
 
 
91
 
 
92
 
static void
93
 
info_window_response (GtkWidget  *widget,
94
 
                      gint        response_id,
95
 
                      InfoDialog *info_win)
96
 
{
97
 
  info_dialog_hide (info_win);
98
 
}
99
 
 
100
 
static void
101
 
info_window_page_switch (GtkWidget       *widget,
102
 
                         GtkNotebookPage *page,
103
 
                         gint             page_num,
104
 
                         InfoDialog      *info_win)
105
 
{
106
 
  InfoWinData *iwd = info_win->user_data;
107
 
 
108
 
  iwd->show_cursor = (page_num == 1);
109
 
}
110
 
 
111
 
 
112
 
/*  displays information:
113
 
 *    cursor pos
114
 
 *    cursor pos in real units
115
 
 *    color under cursor
116
 
 */
117
 
 
118
 
static void
119
 
info_window_create_cursor (InfoDialog *info_win,
120
 
                           Gimp       *gimp)
121
 
{
122
 
  InfoWinData *iwd = info_win->user_data;
123
 
  GtkWidget   *frame;
124
 
  GtkWidget   *table;
125
 
  GtkWidget   *hbox;
126
 
  GtkWidget   *vbox;
127
 
 
128
 
  vbox = gtk_vbox_new (FALSE, 12);
129
 
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
130
 
  gtk_notebook_append_page (GTK_NOTEBOOK (info_win->info_notebook),
131
 
                            vbox, gtk_label_new (_("Cursor")));
132
 
  gtk_widget_show (vbox);
133
 
 
134
 
 
135
 
  /* cursor information */
136
 
 
137
 
  hbox = gtk_hbox_new (TRUE, 6);
138
 
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
139
 
  gtk_widget_show (hbox);
140
 
 
141
 
  frame = gimp_frame_new (_("Pixels"));
142
 
  gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
143
 
  gtk_widget_show (frame);
144
 
 
145
 
  table = gtk_table_new (2, 2, FALSE);
146
 
  gtk_table_set_col_spacings (GTK_TABLE (table), 4);
147
 
  gtk_table_set_row_spacings (GTK_TABLE (table), 2);
148
 
  gtk_container_add (GTK_CONTAINER (frame), table);
149
 
  gtk_widget_show (table);
150
 
 
151
 
  iwd->pixel_labels[0] = gtk_label_new (_("n/a"));
152
 
  gtk_misc_set_alignment (GTK_MISC (iwd->pixel_labels[0]), 1.0, 0.5);
153
 
  gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
154
 
                             _("X"), 0.5, 0.5,
155
 
                             iwd->pixel_labels[0], 1, FALSE);
156
 
 
157
 
  iwd->pixel_labels[1] = gtk_label_new (_("n/a"));
158
 
  gtk_misc_set_alignment (GTK_MISC (iwd->pixel_labels[1]), 1.0, 0.5);
159
 
  gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
160
 
                             _("Y"), 0.5, 0.5,
161
 
                             iwd->pixel_labels[1], 1, FALSE);
162
 
 
163
 
  frame = gimp_frame_new (_("Units"));
164
 
  gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
165
 
  gtk_widget_show (frame);
166
 
 
167
 
  table = gtk_table_new (2, 2, FALSE);
168
 
  gtk_table_set_col_spacings (GTK_TABLE (table), 4);
169
 
  gtk_table_set_row_spacings (GTK_TABLE (table), 2);
170
 
  gtk_container_add (GTK_CONTAINER (frame), table);
171
 
  gtk_widget_show (table);
172
 
 
173
 
  iwd->unit_labels[0] = gtk_label_new (_("n/a"));
174
 
  gtk_misc_set_alignment (GTK_MISC (iwd->unit_labels[0]), 1.0, 0.5);
175
 
  gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
176
 
                             _("X"), 0.5, 0.5,
177
 
                             iwd->unit_labels[0], 1, FALSE);
178
 
 
179
 
  iwd->unit_labels[1] = gtk_label_new (_("n/a"));
180
 
  gtk_misc_set_alignment (GTK_MISC (iwd->unit_labels[1]), 1.0, 0.5);
181
 
  gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
182
 
                             _("Y"), 0.5, 0.5,
183
 
                             iwd->unit_labels[1], 1, FALSE);
184
 
 
185
 
 
186
 
  /* color information */
187
 
 
188
 
  hbox = gtk_hbox_new (TRUE, 6);
189
 
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
190
 
  gtk_widget_show (hbox);
191
 
 
192
 
  iwd->frame1 = gimp_color_frame_new ();
193
 
  gimp_color_frame_set_mode (GIMP_COLOR_FRAME (iwd->frame1),
194
 
                             GIMP_COLOR_FRAME_MODE_PIXEL);
195
 
  gtk_box_pack_start (GTK_BOX (hbox), iwd->frame1, TRUE, TRUE, 0);
196
 
  gtk_widget_show (iwd->frame1);
197
 
 
198
 
  iwd->frame2 = gimp_color_frame_new ();
199
 
  gimp_color_frame_set_mode (GIMP_COLOR_FRAME (iwd->frame2),
200
 
                             GIMP_COLOR_FRAME_MODE_RGB);
201
 
  gtk_box_pack_start (GTK_BOX (hbox), iwd->frame2, TRUE, TRUE, 0);
202
 
  gtk_widget_show (iwd->frame2);
203
 
 
204
 
 
205
 
  g_signal_connect (info_win->info_notebook, "switch_page",
206
 
                    G_CALLBACK (info_window_page_switch),
207
 
                    info_win);
208
 
}
209
 
 
210
 
 
211
 
/*  displays gimp-comment parasite
212
 
 */
213
 
 
214
 
static void
215
 
info_window_create_comment (InfoDialog  *info_win,
216
 
                            GimpDisplay *gdisp)
217
 
{
218
 
  InfoWinData  *iwd = info_win->user_data;
219
 
  GtkWidget    *label;
220
 
  GtkWidget    *vbox;
221
 
  GtkWidget    *vbox2;
222
 
  GimpParasite *comment;
223
 
  gchar        *utf8;
224
 
 
225
 
  vbox = gtk_vbox_new (FALSE, 12);
226
 
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
227
 
  gtk_notebook_append_page (GTK_NOTEBOOK (info_win->info_notebook),
228
 
                            vbox, gtk_label_new (_("Comment")));
229
 
  gtk_widget_show (vbox);
230
 
 
231
 
  /*  add the information field  */
232
 
  vbox2 = gtk_vbox_new (FALSE, 6);
233
 
  gtk_box_pack_start (GTK_BOX (vbox), vbox2, TRUE, TRUE, 0);
234
 
  gtk_widget_show (vbox2);
235
 
 
236
 
  /*  image comment  */
237
 
  comment = gimp_image_parasite_find (gdisp->gimage, "gimp-comment");
238
 
 
239
 
  if (comment)
240
 
    {
241
 
      gchar *str = g_strndup (gimp_parasite_data (comment),
242
 
                              gimp_parasite_data_size (comment));
243
 
 
244
 
      utf8 = gimp_any_to_utf8 (str, -1, NULL);
245
 
    }
246
 
  else
247
 
    {
248
 
      utf8 = g_strdup (_("(none)"));
249
 
    }
250
 
 
251
 
  g_snprintf (iwd->comment_str, MAX_BUF, "%s", utf8);
252
 
 
253
 
  g_free (utf8);
254
 
 
255
 
  label = gtk_label_new (iwd->comment_str);
256
 
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
257
 
  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
258
 
  gtk_label_set_selectable (GTK_LABEL (label), TRUE);
259
 
  gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, FALSE, 0);
260
 
  gtk_widget_show (label);
261
 
  iwd->comment_label = label;
262
 
}
263
 
 
264
 
 
265
 
InfoDialog *
266
 
info_window_create (GimpDisplay *gdisp)
267
 
{
268
 
  InfoDialog  *info_win;
269
 
  InfoWinData *iwd;
270
 
  gint         type;
271
 
 
272
 
  type = gimp_image_base_type (gdisp->gimage);
273
 
 
274
 
  info_win = info_dialog_notebook_new (GIMP_VIEWABLE (gdisp->gimage),
275
 
                                       _("Info Window"), "gimp-info-window",
276
 
                                       GIMP_STOCK_INFO,
277
 
                                       _("Image Information"),
278
 
                                       gdisp->shell,
279
 
                                       gimp_standard_help_func,
280
 
                                       GIMP_HELP_INFO_DIALOG);
281
 
 
282
 
  gtk_dialog_add_button (GTK_DIALOG (info_win->shell),
283
 
                         GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
284
 
 
285
 
  g_signal_connect (info_win->shell, "response",
286
 
                    G_CALLBACK (info_window_response),
287
 
                    info_win);
288
 
 
289
 
  iwd = g_new0 (InfoWinData, 1);
290
 
  iwd->gdisp = gdisp;
291
 
  info_win->user_data = iwd;
292
 
 
293
 
  /*  add the information fields  */
294
 
  info_dialog_add_label (info_win, _("Pixel dimensions:"),
295
 
                         iwd->dimensions_str);
296
 
  info_dialog_add_label (info_win, _("Print size:"),
297
 
                         iwd->real_dimensions_str);
298
 
  info_dialog_add_label (info_win, _("Resolution:"),
299
 
                        iwd->resolution_str);
300
 
  info_dialog_add_label (info_win, _("Scale ratio:"),
301
 
                         iwd->scale_str);
302
 
  info_dialog_add_label (info_win, _("Number of layers:"),
303
 
                         iwd->num_layers_str);
304
 
  info_dialog_add_label (info_win, _("Size in memory:"),
305
 
                         iwd->memsize_str);
306
 
  info_dialog_add_label (info_win, _("Display type:"),
307
 
                         iwd->color_type_str);
308
 
  info_dialog_add_label (info_win, _("Visual class:"),
309
 
                         iwd->visual_class_str);
310
 
  info_dialog_add_label (info_win, _("Visual depth:"),
311
 
                         iwd->visual_depth_str);
312
 
 
313
 
  /*  Add extra tabs  */
314
 
  info_window_create_cursor (info_win, gdisp->gimage->gimp);
315
 
  info_window_create_comment (info_win, gdisp);
316
 
 
317
 
  /* Set back to first page */
318
 
  gtk_notebook_set_current_page (GTK_NOTEBOOK (info_win->info_notebook), 0);
319
 
 
320
 
  return info_win;
321
 
}
322
 
 
323
 
static InfoDialog *info_window_auto = NULL;
324
 
 
325
 
static void
326
 
info_window_change_display (GimpContext *context,
327
 
                            GimpDisplay *newdisp,
328
 
                            gpointer     data)
329
 
{
330
 
  GimpDisplay *gdisp = newdisp;
331
 
  GimpDisplay *old_gdisp;
332
 
  GimpImage   *gimage;
333
 
  InfoWinData *iwd;
334
 
 
335
 
  iwd = info_window_auto->user_data;
336
 
 
337
 
  old_gdisp = (GimpDisplay *) iwd->gdisp;
338
 
 
339
 
  if (!info_window_auto || gdisp == old_gdisp || !gdisp)
340
 
    return;
341
 
 
342
 
  gimage = gdisp->gimage;
343
 
 
344
 
  if (gimage && gimp_container_have (context->gimp->images,
345
 
                                     GIMP_OBJECT (gimage)))
346
 
    {
347
 
      iwd->gdisp = gdisp;
348
 
      info_window_update (gdisp);
349
 
    }
350
 
}
351
 
 
352
 
void
353
 
info_window_follow_auto (Gimp *gimp)
354
 
{
355
 
  GimpContext *context;
356
 
  GimpDisplay *gdisp;
357
 
 
358
 
  g_return_if_fail (GIMP_IS_GIMP (gimp));
359
 
 
360
 
  context = gimp_get_user_context (gimp);
361
 
 
362
 
  gdisp = gimp_context_get_display (context);
363
 
 
364
 
  if (! gdisp)
365
 
    return;
366
 
 
367
 
  if (! info_window_auto)
368
 
    {
369
 
      info_window_auto = info_window_create (gdisp);
370
 
 
371
 
      g_signal_connect (context, "display_changed",
372
 
                        G_CALLBACK (info_window_change_display),
373
 
                        NULL);
374
 
 
375
 
      info_window_update (gdisp);
376
 
    }
377
 
 
378
 
  info_dialog_present (info_window_auto);
379
 
}
380
 
 
381
 
 
382
 
/* Updates all cursor information. */
383
 
 
384
 
void
385
 
info_window_update_cursor (GimpDisplay *gdisp,
386
 
                           gdouble      tx,
387
 
                           gdouble      ty)
388
 
{
389
 
  InfoDialog  *info_win;
390
 
  InfoWinData *iwd;
391
 
  guchar      *color;
392
 
 
393
 
  info_win = GIMP_DISPLAY_SHELL (gdisp->shell)->info_dialog;
394
 
 
395
 
  if (! info_win && info_window_auto != NULL)
396
 
    info_win = info_window_auto;
397
 
 
398
 
  if (! info_win)
399
 
    return;
400
 
 
401
 
  iwd = info_win->user_data;
402
 
 
403
 
  if (info_window_auto)
404
 
    {
405
 
      gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (info_window_auto->shell),
406
 
                                         GIMP_VIEWABLE (gdisp->gimage));
407
 
    }
408
 
 
409
 
  if (iwd->gdisp != gdisp)
410
 
    {
411
 
      iwd->gdisp = gdisp;
412
 
 
413
 
      info_window_update (gdisp);
414
 
    }
415
 
 
416
 
  gtk_label_set_text (GTK_LABEL (iwd->comment_label), iwd->comment_str);
417
 
 
418
 
  if (! iwd || ! iwd->show_cursor)
419
 
    return;
420
 
 
421
 
  /* fill in position information */
422
 
 
423
 
  if (tx < 0.0 && ty < 0.0)
424
 
    {
425
 
      gtk_label_set_text (GTK_LABEL (iwd->pixel_labels[0]), _("n/a"));
426
 
      gtk_label_set_text (GTK_LABEL (iwd->pixel_labels[1]), _("n/a"));
427
 
      gtk_label_set_text (GTK_LABEL (iwd->unit_labels[0]),  _("n/a"));
428
 
      gtk_label_set_text (GTK_LABEL (iwd->unit_labels[1]),  _("n/a"));
429
 
    }
430
 
  else
431
 
    {
432
 
      GimpImage   *image = gdisp->gimage;
433
 
      GimpUnit     unit  = GIMP_DISPLAY_SHELL (gdisp->shell)->unit;
434
 
      gdouble      unit_factor;
435
 
      gint         unit_digits;
436
 
      const gchar *unit_str;
437
 
      gchar        format_buf[32];
438
 
      gchar        buf[32];
439
 
 
440
 
      if (unit == GIMP_UNIT_PIXEL)
441
 
        unit = gimp_image_get_unit (image);
442
 
 
443
 
      unit_factor = _gimp_unit_get_factor (image->gimp, unit);
444
 
      unit_digits = _gimp_unit_get_digits (image->gimp, unit);
445
 
      unit_str    = _gimp_unit_get_abbreviation (image->gimp, unit);
446
 
 
447
 
      g_snprintf (buf, sizeof (buf), "%d", (gint) tx);
448
 
      gtk_label_set_text (GTK_LABEL (iwd->pixel_labels[0]), buf);
449
 
 
450
 
      g_snprintf (buf, sizeof (buf), "%d", (gint) ty);
451
 
      gtk_label_set_text (GTK_LABEL (iwd->pixel_labels[1]), buf);
452
 
 
453
 
      g_snprintf (format_buf, sizeof (format_buf),
454
 
                  "%%.%df %s", unit_digits, unit_str);
455
 
 
456
 
      g_snprintf (buf, sizeof (buf), format_buf,
457
 
                  tx * unit_factor / image->xresolution);
458
 
      gtk_label_set_text (GTK_LABEL (iwd->unit_labels[0]), buf);
459
 
 
460
 
      g_snprintf (buf, sizeof (buf), format_buf,
461
 
                  ty * unit_factor / image->yresolution);
462
 
      gtk_label_set_text (GTK_LABEL (iwd->unit_labels[1]), buf);
463
 
 
464
 
    }
465
 
 
466
 
  /* fill in color information */
467
 
  color = gimp_pickable_get_color_at (GIMP_PICKABLE (gdisp->gimage->projection),
468
 
                                      tx, ty);
469
 
 
470
 
  if (! color || (tx < 0.0 && ty < 0.0))
471
 
    {
472
 
      gimp_color_frame_set_invalid (GIMP_COLOR_FRAME (iwd->frame1));
473
 
      gimp_color_frame_set_invalid (GIMP_COLOR_FRAME (iwd->frame2));
474
 
    }
475
 
  else
476
 
    {
477
 
      GimpImageType sample_type;
478
 
      GimpRGB       rgb;
479
 
 
480
 
      sample_type = gimp_pickable_get_image_type (GIMP_PICKABLE (gdisp->gimage->projection));
481
 
 
482
 
      gimp_rgba_set_uchar (&rgb,
483
 
                           color[RED_PIX],
484
 
                           color[GREEN_PIX],
485
 
                           color[BLUE_PIX],
486
 
                           color[ALPHA_PIX]);
487
 
 
488
 
      gimp_color_frame_set_color (GIMP_COLOR_FRAME (iwd->frame1),
489
 
                                  sample_type, &rgb, -1);
490
 
      gimp_color_frame_set_color (GIMP_COLOR_FRAME (iwd->frame2),
491
 
                                  sample_type, &rgb, -1);
492
 
 
493
 
      g_free (color);
494
 
    }
495
 
}
496
 
 
497
 
void
498
 
info_window_free (InfoDialog *info_win)
499
 
{
500
 
  InfoWinData *iwd;
501
 
 
502
 
  if (! info_win && info_window_auto)
503
 
    {
504
 
      gtk_widget_set_sensitive (info_window_auto->vbox, FALSE);
505
 
      return;
506
 
    }
507
 
 
508
 
  if (! info_win)
509
 
    return;
510
 
 
511
 
  iwd = info_win->user_data;
512
 
 
513
 
  g_free (iwd);
514
 
  info_dialog_free (info_win);
515
 
}
516
 
 
517
 
void
518
 
info_window_update (GimpDisplay *gdisp)
519
 
{
520
 
  GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (gdisp->shell);
521
 
  GimpImage        *image;
522
 
  InfoWinData      *iwd;
523
 
  gint              type;
524
 
  GimpUnit          unit;
525
 
  gdouble           unit_factor;
526
 
  gint              unit_digits;
527
 
  gchar             format_buf[32];
528
 
  InfoDialog       *info_win;
529
 
 
530
 
  info_win = shell->info_dialog;
531
 
 
532
 
  if (! info_win && info_window_auto != NULL)
533
 
    info_win = info_window_auto;
534
 
 
535
 
  if (! info_win)
536
 
    return;
537
 
 
538
 
  iwd = info_win->user_data;
539
 
 
540
 
  if (info_window_auto)
541
 
    gtk_widget_set_sensitive (info_window_auto->vbox, TRUE);
542
 
 
543
 
  /* If doing info_window_auto then return if this display
544
 
   * is not the one we are showing.
545
 
   */
546
 
  if (info_window_auto && iwd->gdisp != gdisp)
547
 
    return;
548
 
 
549
 
  image = gdisp->gimage;
550
 
 
551
 
  /*  pixel size  */
552
 
  g_snprintf (iwd->dimensions_str, MAX_BUF, _("%d x %d pixels"),
553
 
              image->width, image->height);
554
 
 
555
 
  /*  print size  */
556
 
  unit = GIMP_DISPLAY_SHELL (gdisp->shell)->unit;
557
 
 
558
 
  if (unit == GIMP_UNIT_PIXEL)
559
 
    unit = gimp_image_get_unit (image);
560
 
 
561
 
  unit_factor = _gimp_unit_get_factor (image->gimp, unit);
562
 
  unit_digits = _gimp_unit_get_digits (image->gimp, unit);
563
 
 
564
 
  g_snprintf (format_buf, sizeof (format_buf), "%%.%df x %%.%df %s",
565
 
              unit_digits + 1, unit_digits + 1,
566
 
              _gimp_unit_get_plural (image->gimp, unit));
567
 
  g_snprintf (iwd->real_dimensions_str, MAX_BUF, format_buf,
568
 
              image->width  * unit_factor / image->xresolution,
569
 
              image->height * unit_factor / image->yresolution);
570
 
 
571
 
  /*  resolution  */
572
 
  unit = gimp_image_get_unit (image);
573
 
  unit_factor = _gimp_unit_get_factor (image->gimp, unit);
574
 
 
575
 
  g_snprintf (format_buf, sizeof (format_buf), _("pixels/%s"),
576
 
              _gimp_unit_get_abbreviation (image->gimp, unit));
577
 
  g_snprintf (iwd->resolution_str, MAX_BUF, _("%g x %g %s"),
578
 
              image->xresolution / unit_factor,
579
 
              image->yresolution / unit_factor,
580
 
              unit == GIMP_UNIT_INCH ? _("dpi") : format_buf);
581
 
 
582
 
  /*  user zoom ratio  */
583
 
  g_snprintf (iwd->scale_str, MAX_BUF, "%.2f", shell->scale * 100);
584
 
 
585
 
  /*  number of layers  */
586
 
  g_snprintf (iwd->num_layers_str, MAX_BUF, "%d",
587
 
              gimp_container_num_children (image->layers));
588
 
 
589
 
  /*  size in memory  */
590
 
  {
591
 
    GimpObject *object = GIMP_OBJECT (image);
592
 
    gchar      *str;
593
 
 
594
 
    str = gimp_memsize_to_string (gimp_object_get_memsize (object, NULL));
595
 
 
596
 
    g_snprintf (iwd->memsize_str, MAX_BUF, "%s", str);
597
 
 
598
 
    g_free (str);
599
 
  }
600
 
 
601
 
  type = gimp_image_base_type (image);
602
 
 
603
 
  /*  color type  */
604
 
  switch (type)
605
 
    {
606
 
    case GIMP_RGB:
607
 
      g_snprintf (iwd->color_type_str, MAX_BUF, "%s", _("RGB Color"));
608
 
      break;
609
 
    case GIMP_GRAY:
610
 
      g_snprintf (iwd->color_type_str, MAX_BUF, "%s", _("Grayscale"));
611
 
      break;
612
 
    case GIMP_INDEXED:
613
 
      g_snprintf (iwd->color_type_str, MAX_BUF, "%s (%d %s)",
614
 
                  _("Indexed Color"), image->num_cols, _("colors"));
615
 
      break;
616
 
    }
617
 
 
618
 
  /*  image comment  */
619
 
  {
620
 
    GimpParasite *comment;
621
 
    gchar        *utf8;
622
 
 
623
 
    comment = gimp_image_parasite_find (gdisp->gimage, "gimp-comment");
624
 
 
625
 
    if (comment)
626
 
      {
627
 
        gchar *str = g_strndup (gimp_parasite_data (comment),
628
 
                                gimp_parasite_data_size (comment));
629
 
 
630
 
        utf8 = gimp_any_to_utf8 (str, -1, NULL);
631
 
      }
632
 
    else
633
 
      {
634
 
        utf8 = g_strdup (_("(none)"));
635
 
      }
636
 
 
637
 
    g_snprintf (iwd->comment_str, MAX_BUF, "%s", utf8);
638
 
 
639
 
    g_free (utf8);
640
 
  }
641
 
 
642
 
  {
643
 
    GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (shell));
644
 
    GdkVisual *visual = gdk_screen_get_rgb_visual (screen);
645
 
 
646
 
    /*  visual class  */
647
 
    g_snprintf (iwd->visual_class_str, MAX_BUF, "%s",
648
 
                gettext (visual_classes[visual->type]));
649
 
 
650
 
    /*  visual depth  */
651
 
    g_snprintf (iwd->visual_depth_str, MAX_BUF, "%d", visual->depth);
652
 
  }
653
 
 
654
 
  info_dialog_update (info_win);
655
 
}