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

« back to all changes in this revision

Viewing changes to app/widgets/gimphistogrameditor.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
27
27
#include "base/gimphistogram.h"
28
28
#include "base/pixel-region.h"
29
29
 
30
 
#include "config/gimpbaseconfig.h"
31
 
 
32
30
#include "core/gimp.h"
33
31
#include "core/gimpdrawable.h"
34
32
#include "core/gimpdrawable-histogram.h"
35
33
#include "core/gimpimage.h"
36
34
 
37
35
#include "gimpdocked.h"
38
 
#include "gimpenumcombobox.h"
39
 
#include "gimpenumstore.h"
40
36
#include "gimphelp-ids.h"
41
37
#include "gimphistogrambox.h"
42
38
#include "gimphistogrameditor.h"
43
39
#include "gimphistogramview.h"
44
 
#include "gimppropwidgets.h"
45
40
#include "gimpsessioninfo.h"
46
41
#include "gimpwidgets-utils.h"
47
42
 
48
43
#include "gimp-intl.h"
49
44
 
50
45
 
51
 
static void  gimp_histogram_editor_class_init     (GimpHistogramEditorClass *klass);
52
 
static void  gimp_histogram_editor_init           (GimpHistogramEditor      *editor);
53
 
static void    gimp_histogram_editor_docked_iface_init (GimpDockedInterface *docked_iface);
 
46
static void    gimp_histogram_editor_docked_iface_init (GimpDockedInterface *iface);
 
47
 
54
48
static void    gimp_histogram_editor_set_aux_info (GimpDocked          *docked,
55
49
                                                   GList               *aux_info);
56
50
static GList * gimp_histogram_editor_get_aux_info (GimpDocked          *docked);
57
51
 
58
52
static void  gimp_histogram_editor_set_image      (GimpImageEditor     *editor,
59
 
                                                   GimpImage           *gimage);
60
 
static void  gimp_histogram_editor_layer_changed  (GimpImage           *gimage,
 
53
                                                   GimpImage           *image);
 
54
static void  gimp_histogram_editor_layer_changed  (GimpImage           *image,
61
55
                                                   GimpHistogramEditor *editor);
62
56
static void  gimp_histogram_editor_update         (GimpHistogramEditor *editor);
63
57
 
64
58
static gboolean gimp_histogram_editor_idle_update (GimpHistogramEditor *editor);
65
 
static gboolean gimp_histogram_editor_item_visible (GtkTreeModel       *model,
66
 
                                                    GtkTreeIter        *iter,
67
 
                                                    gpointer            data);
 
59
static gboolean gimp_histogram_menu_sensitivity   (gint                 value,
 
60
                                                   gpointer             data);
68
61
static void  gimp_histogram_editor_menu_update    (GimpHistogramEditor *editor);
 
62
static void  gimp_histogram_editor_name_update    (GimpHistogramEditor *editor);
69
63
static void  gimp_histogram_editor_info_update    (GimpHistogramEditor *editor);
70
64
 
71
 
 
72
 
static GimpImageEditorClass *parent_class        = NULL;
73
 
static GimpDockedInterface  *parent_docked_iface = NULL;
74
 
 
75
 
 
76
 
GType
77
 
gimp_histogram_editor_get_type (void)
78
 
{
79
 
  static GType editor_type = 0;
80
 
 
81
 
  if (! editor_type)
82
 
    {
83
 
      static const GTypeInfo editor_info =
84
 
      {
85
 
        sizeof (GimpHistogramEditorClass),
86
 
        (GBaseInitFunc) NULL,
87
 
        (GBaseFinalizeFunc) NULL,
88
 
        (GClassInitFunc) gimp_histogram_editor_class_init,
89
 
        NULL,           /* class_finalize */
90
 
        NULL,           /* class_data     */
91
 
        sizeof (GimpHistogramEditor),
92
 
        0,              /* n_preallocs    */
93
 
        (GInstanceInitFunc) gimp_histogram_editor_init,
94
 
      };
95
 
      static const GInterfaceInfo docked_iface_info =
96
 
      {
97
 
        (GInterfaceInitFunc) gimp_histogram_editor_docked_iface_init,
98
 
        NULL,           /* iface_finalize */
99
 
        NULL            /* iface_data     */
100
 
      };
101
 
 
102
 
      editor_type = g_type_register_static (GIMP_TYPE_IMAGE_EDITOR,
103
 
                                            "GimpHistogramEditor",
104
 
                                            &editor_info, 0);
105
 
      g_type_add_interface_static (editor_type, GIMP_TYPE_DOCKED,
106
 
                                   &docked_iface_info);
107
 
    }
108
 
 
109
 
  return editor_type;
110
 
}
 
65
static gboolean gimp_histogram_view_expose        (GimpHistogramEditor *editor);
 
66
 
 
67
 
 
68
G_DEFINE_TYPE_WITH_CODE (GimpHistogramEditor, gimp_histogram_editor,
 
69
                         GIMP_TYPE_IMAGE_EDITOR,
 
70
                         G_IMPLEMENT_INTERFACE (GIMP_TYPE_DOCKED,
 
71
                                                gimp_histogram_editor_docked_iface_init))
 
72
 
 
73
#define parent_class gimp_histogram_editor_parent_class
 
74
 
 
75
static GimpDockedInterface *parent_docked_iface = NULL;
 
76
 
111
77
 
112
78
static void
113
79
gimp_histogram_editor_class_init (GimpHistogramEditorClass* klass)
114
80
{
115
81
  GimpImageEditorClass *image_editor_class = GIMP_IMAGE_EDITOR_CLASS (klass);
116
82
 
117
 
  parent_class = g_type_class_peek_parent (klass);
118
 
 
119
83
  image_editor_class->set_image = gimp_histogram_editor_set_image;
120
84
}
121
85
 
132
96
  const gchar *gimp_histogram_editor_labels[] =
133
97
    {
134
98
      N_("Mean:"),
135
 
      N_("Std Dev:"),
 
99
      N_("Std dev:"),
136
100
      N_("Median:"),
137
101
      N_("Pixels:"),
138
102
      N_("Count:"),
141
105
 
142
106
  editor->drawable  = NULL;
143
107
  editor->histogram = NULL;
 
108
  editor->valid     = FALSE;
144
109
  editor->idle_id   = 0;
145
110
  editor->box       = gimp_histogram_box_new ();
146
111
 
147
 
  editor->name = label = gtk_label_new (_("(None)"));
148
 
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
149
 
  gimp_label_set_attributes (GTK_LABEL (editor->name),
150
 
                             PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
151
 
                             -1);
152
 
  gtk_box_pack_start (GTK_BOX (editor), label, FALSE, FALSE, 0);
153
 
  gtk_widget_show (label);
 
112
  gimp_editor_set_show_name (GIMP_EDITOR (editor), TRUE);
154
113
 
155
114
  view = GIMP_HISTOGRAM_BOX (editor->box)->view;
156
115
 
167
126
                                                      0, 0);
168
127
  gimp_enum_combo_box_set_stock_prefix (GIMP_ENUM_COMBO_BOX (menu),
169
128
                                        "gimp-channel");
170
 
  gimp_enum_combo_box_set_visible (GIMP_ENUM_COMBO_BOX (editor->menu),
171
 
                                   gimp_histogram_editor_item_visible,
172
 
                                   editor);
 
129
  gimp_int_combo_box_set_sensitivity (GIMP_INT_COMBO_BOX (editor->menu),
 
130
                                      gimp_histogram_menu_sensitivity,
 
131
                                      editor, NULL);
173
132
  gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (editor->menu),
174
133
                                 view->channel);
175
134
  gtk_box_pack_start (GTK_BOX (hbox), menu, FALSE, FALSE, 0);
184
143
  gtk_box_pack_start (GTK_BOX (editor), editor->box, TRUE, TRUE, 0);
185
144
  gtk_widget_show (GTK_WIDGET (editor->box));
186
145
 
187
 
  g_signal_connect_swapped (view, "range_changed",
 
146
  g_signal_connect_swapped (view, "range-changed",
188
147
                            G_CALLBACK (gimp_histogram_editor_info_update),
189
148
                            editor);
190
149
  g_signal_connect_swapped (view, "notify::histogram-channel",
191
150
                            G_CALLBACK (gimp_histogram_editor_info_update),
192
151
                            editor);
193
152
 
 
153
  g_signal_connect_swapped (view, "expose-event",
 
154
                            G_CALLBACK (gimp_histogram_view_expose),
 
155
                            editor);
 
156
 
194
157
  table = gtk_table_new (3, 4, FALSE);
195
 
  gtk_table_set_col_spacings (GTK_TABLE (table), 6);
 
158
  gtk_table_set_col_spacings (GTK_TABLE (table), 2);
 
159
  gtk_table_set_col_spacing (GTK_TABLE (table), 1, 6);
196
160
  gtk_box_pack_start (GTK_BOX (editor), table, FALSE, FALSE, 0);
197
161
  gtk_widget_show (table);
198
162
 
202
166
      gint y = (i % 3);
203
167
 
204
168
      label = gtk_label_new (gettext (gimp_histogram_editor_labels[i]));
205
 
      gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
 
169
      gimp_label_set_attributes (GTK_LABEL (label),
 
170
                                 PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD,
 
171
                                 PANGO_ATTR_SCALE,  PANGO_SCALE_SMALL,
 
172
                                 -1);
 
173
      gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
206
174
      gtk_table_attach (GTK_TABLE (table), label, x, x + 1, y, y + 1,
207
 
                        GTK_FILL, GTK_FILL, 2, 2);
 
175
                        GTK_FILL | GTK_EXPAND, GTK_FILL, 2, 2);
208
176
      gtk_widget_show (label);
209
177
 
210
 
      editor->labels[i] = label = gtk_label_new (NULL);
211
 
      gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
 
178
      editor->labels[i] =
 
179
        label = g_object_new (GTK_TYPE_LABEL,
 
180
                              "xalign",      0.0,
 
181
                              "yalign",      0.5,
 
182
                              "width-chars", i > 2 ? 9 : 5,
 
183
                              NULL);
 
184
      gimp_label_set_attributes (GTK_LABEL (editor->labels[i]),
 
185
                                 PANGO_ATTR_SCALE, PANGO_SCALE_SMALL,
 
186
                                 -1);
212
187
      gtk_table_attach (GTK_TABLE (table), label, x + 1, x + 2, y, y + 1,
213
188
                        GTK_FILL, GTK_FILL, 2, 2);
214
189
      gtk_widget_show (label);
220
195
{
221
196
  parent_docked_iface = g_type_interface_peek_parent (docked_iface);
222
197
 
 
198
  if (! parent_docked_iface)
 
199
    parent_docked_iface = g_type_default_interface_peek (GIMP_TYPE_DOCKED);
 
200
 
223
201
  docked_iface->set_aux_info = gimp_histogram_editor_set_aux_info;
224
202
  docked_iface->get_aux_info = gimp_histogram_editor_get_aux_info;
225
203
}
231
209
  GimpHistogramEditor *editor = GIMP_HISTOGRAM_EDITOR (docked);
232
210
  GimpHistogramView   *view   = GIMP_HISTOGRAM_BOX (editor->box)->view;
233
211
 
234
 
  if (parent_docked_iface->set_aux_info)
235
 
    parent_docked_iface->set_aux_info (docked, aux_info);
 
212
  parent_docked_iface->set_aux_info (docked, aux_info);
236
213
 
237
214
  gimp_session_info_aux_set_props (G_OBJECT (view), aux_info,
238
215
                                   "histogram-channel",
247
224
  GimpHistogramView   *view   = GIMP_HISTOGRAM_BOX (editor->box)->view;
248
225
  GList               *aux_info;
249
226
 
250
 
  aux_info = gimp_session_info_aux_new_from_props (G_OBJECT (view),
251
 
                                                   "histogram-channel",
252
 
                                                   "histogram-scale",
253
 
                                                   NULL);
 
227
  aux_info = parent_docked_iface->get_aux_info (docked);
254
228
 
255
 
  if (parent_docked_iface->get_aux_info)
256
 
    return g_list_concat (parent_docked_iface->get_aux_info (docked),
257
 
                          aux_info);
258
 
  else
259
 
    return aux_info;
 
229
  return g_list_concat (aux_info,
 
230
                        gimp_session_info_aux_new_from_props (G_OBJECT (view),
 
231
                                                              "histogram-channel",
 
232
                                                              "histogram-scale",
 
233
                                                              NULL));
260
234
}
261
235
 
262
236
static void
263
237
gimp_histogram_editor_set_image (GimpImageEditor *image_editor,
264
 
                                 GimpImage       *gimage)
 
238
                                 GimpImage       *image)
265
239
{
266
240
  GimpHistogramEditor *editor = GIMP_HISTOGRAM_EDITOR (image_editor);
267
241
  GimpHistogramView   *view   = GIMP_HISTOGRAM_BOX (editor->box)->view;
268
242
 
269
 
  if (image_editor->gimage)
 
243
  if (image_editor->image)
270
244
    {
271
245
      if (editor->idle_id)
272
246
        {
274
248
          editor->idle_id = 0;
275
249
        }
276
250
 
277
 
      g_signal_handlers_disconnect_by_func (image_editor->gimage,
 
251
      g_signal_handlers_disconnect_by_func (image_editor->image,
278
252
                                            gimp_histogram_editor_layer_changed,
279
253
                                            editor);
280
 
      g_signal_handlers_disconnect_by_func (image_editor->gimage,
 
254
      g_signal_handlers_disconnect_by_func (image_editor->image,
281
255
                                            gimp_histogram_editor_menu_update,
282
256
                                            editor);
283
257
 
290
264
      gimp_histogram_view_set_histogram (view, NULL);
291
265
    }
292
266
 
293
 
  GIMP_IMAGE_EDITOR_CLASS (parent_class)->set_image (image_editor, gimage);
 
267
  GIMP_IMAGE_EDITOR_CLASS (parent_class)->set_image (image_editor, image);
294
268
 
295
 
  if (gimage)
 
269
  if (image)
296
270
    {
297
 
      editor->histogram =
298
 
        gimp_histogram_new (GIMP_BASE_CONFIG (gimage->gimp->config));
 
271
      editor->histogram = gimp_histogram_new ();
299
272
 
300
273
      gimp_histogram_view_set_histogram (view, editor->histogram);
301
274
 
302
 
      g_signal_connect_object (gimage, "mode_changed",
 
275
      g_signal_connect_object (image, "mode-changed",
303
276
                               G_CALLBACK (gimp_histogram_editor_menu_update),
304
277
                               editor, G_CONNECT_SWAPPED);
305
 
      g_signal_connect_object (gimage, "active_layer_changed",
 
278
      g_signal_connect_object (image, "active-layer-changed",
306
279
                               G_CALLBACK (gimp_histogram_editor_layer_changed),
307
280
                               editor, 0);
308
 
      g_signal_connect_object (gimage, "mask_changed",
 
281
      g_signal_connect_object (image, "mask-changed",
309
282
                               G_CALLBACK (gimp_histogram_editor_update),
310
283
                               editor, G_CONNECT_SWAPPED);
311
284
    }
312
285
 
313
 
  gimp_histogram_editor_layer_changed (gimage, editor);
 
286
  gimp_histogram_editor_layer_changed (image, editor);
314
287
}
315
288
 
316
289
GtkWidget *
320
293
}
321
294
 
322
295
static void
323
 
gimp_histogram_editor_layer_changed (GimpImage           *gimage,
 
296
gimp_histogram_editor_layer_changed (GimpImage           *image,
324
297
                                     GimpHistogramEditor *editor)
325
298
{
326
 
  const gchar *name;
327
 
 
328
299
  if (editor->drawable)
329
300
    {
330
301
      g_signal_handlers_disconnect_by_func (editor->drawable,
 
302
                                            gimp_histogram_editor_name_update,
 
303
                                            editor);
 
304
      g_signal_handlers_disconnect_by_func (editor->drawable,
331
305
                                            gimp_histogram_editor_menu_update,
332
306
                                            editor);
333
307
      g_signal_handlers_disconnect_by_func (editor->drawable,
336
310
      editor->drawable = NULL;
337
311
    }
338
312
 
339
 
  if (gimage)
340
 
    editor->drawable = (GimpDrawable *) gimp_image_get_active_layer (gimage);
 
313
  if (image)
 
314
    editor->drawable = (GimpDrawable *) gimp_image_get_active_layer (image);
341
315
 
342
316
  gimp_histogram_editor_menu_update (editor);
343
317
 
344
318
  if (editor->drawable)
345
319
    {
346
 
      name = gimp_object_get_name (GIMP_OBJECT (editor->drawable));
347
 
 
348
 
      g_signal_connect_object (editor->drawable, "invalidate_preview",
 
320
      g_signal_connect_object (editor->drawable, "invalidate-preview",
349
321
                               G_CALLBACK (gimp_histogram_editor_update),
350
322
                               editor, G_CONNECT_SWAPPED);
351
 
      g_signal_connect_object (editor->drawable, "alpha_changed",
 
323
      g_signal_connect_object (editor->drawable, "alpha-changed",
352
324
                               G_CALLBACK (gimp_histogram_editor_menu_update),
353
325
                               editor, G_CONNECT_SWAPPED);
 
326
      g_signal_connect_object (editor->drawable, "name-changed",
 
327
                               G_CALLBACK (gimp_histogram_editor_name_update),
 
328
                               editor, G_CONNECT_SWAPPED);
354
329
 
355
330
      gimp_histogram_editor_update (editor);
356
331
    }
357
 
  else
 
332
  else if (editor->histogram)
358
333
    {
359
 
      name = _("(None)");
360
 
 
361
 
      if (editor->histogram)
362
 
        {
363
 
          gimp_histogram_calculate (editor->histogram, NULL, NULL);
364
 
          gtk_widget_queue_draw GTK_WIDGET (editor->box);
365
 
          gimp_histogram_editor_info_update (editor);
366
 
        }
 
334
      editor->valid = FALSE;
 
335
      gtk_widget_queue_draw (GTK_WIDGET (editor->box));
367
336
    }
368
337
 
369
 
  gtk_label_set_text (GTK_LABEL (editor->name), name);
 
338
  gimp_histogram_editor_info_update (editor);
 
339
  gimp_histogram_editor_name_update (editor);
370
340
}
371
341
 
372
342
static void
375
345
  if (editor->idle_id)
376
346
    g_source_remove (editor->idle_id);
377
347
 
378
 
  editor->idle_id = g_idle_add_full (G_PRIORITY_LOW,
379
 
                                     (GSourceFunc) gimp_histogram_editor_idle_update,
380
 
                                     editor,
381
 
                                     (GDestroyNotify) NULL);
 
348
  editor->idle_id =
 
349
    g_idle_add_full (G_PRIORITY_LOW,
 
350
                     (GSourceFunc) gimp_histogram_editor_idle_update,
 
351
                     editor,
 
352
                     NULL);
382
353
}
383
354
 
384
355
static gboolean
386
357
{
387
358
  editor->idle_id = 0;
388
359
 
389
 
  if (editor->drawable && editor->histogram)
390
 
    {
391
 
      gimp_drawable_calculate_histogram (editor->drawable, editor->histogram);
392
 
      gtk_widget_queue_draw GTK_WIDGET (editor->box);
393
 
      gimp_histogram_editor_info_update (editor);
394
 
    }
 
360
  /* Mark the histogram as invalid and queue a redraw.
 
361
   * We will then recalculate the histogram when the view is exposed.
 
362
   */
 
363
 
 
364
  editor->valid = FALSE;
 
365
  gtk_widget_queue_draw (GTK_WIDGET (editor->box));
395
366
 
396
367
  return FALSE;
397
368
}
422
393
}
423
394
 
424
395
static gboolean
425
 
gimp_histogram_editor_item_visible (GtkTreeModel *model,
426
 
                                    GtkTreeIter  *iter,
427
 
                                    gpointer      data)
 
396
gimp_histogram_menu_sensitivity (gint      value,
 
397
                                 gpointer  data)
428
398
{
429
 
  GimpHistogramEditor  *editor = GIMP_HISTOGRAM_EDITOR (data);
430
 
  GimpHistogramChannel  channel;
431
 
 
432
 
  gtk_tree_model_get (model, iter,
433
 
                      GIMP_INT_STORE_VALUE, &channel,
434
 
                      -1);
435
 
 
436
 
  return gimp_histogram_editor_channel_valid (editor, channel);
 
399
  GimpHistogramEditor  *editor  = GIMP_HISTOGRAM_EDITOR (data);
 
400
  GimpHistogramChannel  channel = value;
 
401
 
 
402
  if (editor->drawable)
 
403
    return gimp_histogram_editor_channel_valid (editor, channel);
 
404
 
 
405
  return FALSE;
437
406
}
438
407
 
439
408
static void
440
409
gimp_histogram_editor_menu_update (GimpHistogramEditor *editor)
441
410
{
442
411
  GimpHistogramView *view = GIMP_HISTOGRAM_BOX (editor->box)->view;
443
 
  GtkTreeModel      *model;
444
412
 
445
 
  model = gtk_combo_box_get_model (GTK_COMBO_BOX (editor->menu));
446
 
  gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (model));
 
413
  gtk_widget_queue_draw (editor->menu);
447
414
 
448
415
  if (! gimp_histogram_editor_channel_valid (editor, view->channel))
449
416
    {
452
419
}
453
420
 
454
421
static void
 
422
gimp_histogram_editor_name_update (GimpHistogramEditor *editor)
 
423
{
 
424
  const gchar *name = NULL;
 
425
 
 
426
  if (editor->drawable)
 
427
    name = gimp_object_get_name (GIMP_OBJECT (editor->drawable));
 
428
 
 
429
  gimp_editor_set_name (GIMP_EDITOR (editor), name);
 
430
}
 
431
 
 
432
static void
455
433
gimp_histogram_editor_info_update (GimpHistogramEditor *editor)
456
434
{
457
435
  GimpHistogramView *view = GIMP_HISTOGRAM_BOX (editor->box)->view;
467
445
      count  = gimp_histogram_get_count (hist, view->channel,
468
446
                                         view->start, view->end);
469
447
 
470
 
      g_snprintf (text, sizeof (text), "%3.1f",
 
448
      g_snprintf (text, sizeof (text), "%.1f",
471
449
                  gimp_histogram_get_mean (hist, view->channel,
472
450
                                           view->start, view->end));
473
451
      gtk_label_set_text (GTK_LABEL (editor->labels[0]), text);
474
452
 
475
 
      g_snprintf (text, sizeof (text), "%3.1f",
 
453
      g_snprintf (text, sizeof (text), "%.1f",
476
454
                  gimp_histogram_get_std_dev (hist, view->channel,
477
455
                                              view->start, view->end));
478
456
      gtk_label_set_text (GTK_LABEL (editor->labels[1]), text);
479
457
 
480
 
      g_snprintf (text, sizeof (text), "%3.1f",
 
458
      g_snprintf (text, sizeof (text), "%.1f",
481
459
                  (gdouble) gimp_histogram_get_median  (hist, view->channel,
482
460
                                                        view->start,
483
461
                                                        view->end));
484
462
      gtk_label_set_text (GTK_LABEL (editor->labels[2]), text);
485
463
 
486
 
      g_snprintf (text, sizeof (text), "%8d", (gint) pixels);
 
464
      g_snprintf (text, sizeof (text), "%d", (gint) pixels);
487
465
      gtk_label_set_text (GTK_LABEL (editor->labels[3]), text);
488
466
 
489
 
      g_snprintf (text, sizeof (text), "%8d", (gint) count);
 
467
      g_snprintf (text, sizeof (text), "%d", (gint) count);
490
468
      gtk_label_set_text (GTK_LABEL (editor->labels[4]), text);
491
469
 
492
 
      g_snprintf (text, sizeof (text), "%4.1f", (pixels > 0 ?
 
470
      g_snprintf (text, sizeof (text), "%.1f", (pixels > 0 ?
493
471
                                                 (100.0 * count / pixels) :
494
472
                                                 0.0));
495
473
      gtk_label_set_text (GTK_LABEL (editor->labels[5]), text);
502
480
        gtk_label_set_text (GTK_LABEL (editor->labels[i]), NULL);
503
481
    }
504
482
}
 
483
 
 
484
static gboolean
 
485
gimp_histogram_view_expose (GimpHistogramEditor *editor)
 
486
{
 
487
  if (! editor->valid && editor->histogram)
 
488
    {
 
489
      if (editor->drawable)
 
490
        gimp_drawable_calculate_histogram (editor->drawable, editor->histogram);
 
491
      else
 
492
        gimp_histogram_calculate (editor->histogram, NULL, NULL);
 
493
 
 
494
      editor->valid = TRUE;
 
495
 
 
496
      gimp_histogram_editor_info_update (editor);
 
497
    }
 
498
 
 
499
  return FALSE;
 
500
}