~ubuntu-branches/ubuntu/saucy/gimp/saucy

« back to all changes in this revision

Viewing changes to app/widgets/gimpcurveview.c

  • Committer: Package Import Robot
  • Author(s): Micah Gersten
  • Date: 2012-05-20 19:21:01 UTC
  • mfrom: (1.1.26) (0.4.16 sid)
  • Revision ID: package-import@ubuntu.com-20120520192101-bs7zetx8ffoq2nfv
Tags: 2.8.0-2ubuntu1
* Merge from Debian unstable (LP: #908472). Remaining Changes:
  - debian/patches/02_help-message.patch,
    debian/patches/03_gimp.desktop.in.in.patch:
    + Update some strings for Ubuntu
  - debian/control:
    + Update description
  - debian/rules:
    + Set gettext domain and update translation templates
* Drop the following patches that were applied upstream:
  - debian/patches/ghost-cursor.patch: fix Wacom tablet cursor events
  - debian/patches/embed-page-setup-dialog.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
 
 * This program is free software; you can redistribute it and/or modify
 
4
 * This program is free software: you can redistribute it and/or modify
5
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
 
6
 * the Free Software Foundation; either version 3 of the License, or
7
7
 * (at your option) any later version.
8
8
 *
9
9
 * This program is distributed in the hope that it will be useful,
12
12
 * GNU General Public License for more details.
13
13
 *
14
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.
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
16
 */
18
17
 
19
18
#include "config.h"
24
23
#include <gdk/gdkkeysyms.h>
25
24
 
26
25
#include "libgimpmath/gimpmath.h"
 
26
#include "libgimpcolor/gimpcolor.h"
 
27
#include "libgimpconfig/gimpconfig.h"
 
28
#include "libgimpwidgets/gimpwidgets.h"
27
29
 
28
30
#include "widgets-types.h"
29
31
 
 
32
#include "core/gimp.h"
30
33
#include "core/gimpcurve.h"
31
34
#include "core/gimpcurve-map.h"
32
35
#include "core/gimpmarshal.h"
33
36
 
 
37
#include "gimpclipboard.h"
34
38
#include "gimpcurveview.h"
35
39
 
36
40
 
37
41
enum
38
42
{
39
43
  PROP_0,
 
44
  PROP_GIMP,
40
45
  PROP_BASE_LINE,
41
46
  PROP_GRID_ROWS,
42
 
  PROP_GRID_COLUMNS
43
 
};
44
 
 
45
 
 
46
 
static void       gimp_curve_view_finalize       (GObject          *object);
47
 
static void       gimp_curve_view_dispose        (GObject          *object);
48
 
static void       gimp_curve_view_set_property   (GObject          *object,
49
 
                                                  guint             property_id,
50
 
                                                  const GValue     *value,
51
 
                                                  GParamSpec       *pspec);
52
 
static void       gimp_curve_view_get_property   (GObject          *object,
53
 
                                                  guint             property_id,
54
 
                                                  GValue           *value,
55
 
                                                  GParamSpec       *pspec);
56
 
 
57
 
static void       gimp_curve_view_style_set      (GtkWidget        *widget,
58
 
                                                  GtkStyle         *prev_style);
59
 
static gboolean   gimp_curve_view_expose         (GtkWidget        *widget,
60
 
                                                  GdkEventExpose   *event);
61
 
static gboolean   gimp_curve_view_button_press   (GtkWidget        *widget,
62
 
                                                  GdkEventButton   *bevent);
63
 
static gboolean   gimp_curve_view_button_release (GtkWidget        *widget,
64
 
                                                  GdkEventButton   *bevent);
65
 
static gboolean   gimp_curve_view_motion_notify  (GtkWidget        *widget,
66
 
                                                  GdkEventMotion   *bevent);
67
 
static gboolean   gimp_curve_view_leave_notify   (GtkWidget        *widget,
68
 
                                                  GdkEventCrossing *cevent);
69
 
static gboolean   gimp_curve_view_key_press      (GtkWidget        *widget,
70
 
                                                  GdkEventKey      *kevent);
71
 
 
72
 
static void       gimp_curve_view_set_cursor     (GimpCurveView    *view,
73
 
                                                  gdouble           x,
74
 
                                                  gdouble           y);
75
 
static void       gimp_curve_view_unset_cursor   (GimpCurveView *view);
 
47
  PROP_GRID_COLUMNS,
 
48
  PROP_X_AXIS_LABEL,
 
49
  PROP_Y_AXIS_LABEL
 
50
};
 
51
 
 
52
enum
 
53
{
 
54
  CUT_CLIPBOARD,
 
55
  COPY_CLIPBOARD,
 
56
  PASTE_CLIPBOARD,
 
57
  LAST_SIGNAL
 
58
};
 
59
 
 
60
 
 
61
typedef struct
 
62
{
 
63
  GimpCurve *curve;
 
64
  GimpRGB    color;
 
65
} BGCurve;
 
66
 
 
67
 
 
68
static void       gimp_curve_view_finalize        (GObject          *object);
 
69
static void       gimp_curve_view_dispose         (GObject          *object);
 
70
static void       gimp_curve_view_set_property    (GObject          *object,
 
71
                                                   guint             property_id,
 
72
                                                   const GValue     *value,
 
73
                                                   GParamSpec       *pspec);
 
74
static void       gimp_curve_view_get_property    (GObject          *object,
 
75
                                                   guint             property_id,
 
76
                                                   GValue           *value,
 
77
                                                   GParamSpec       *pspec);
 
78
 
 
79
static void       gimp_curve_view_style_set       (GtkWidget        *widget,
 
80
                                                   GtkStyle         *prev_style);
 
81
static gboolean   gimp_curve_view_expose          (GtkWidget        *widget,
 
82
                                                   GdkEventExpose   *event);
 
83
static gboolean   gimp_curve_view_button_press    (GtkWidget        *widget,
 
84
                                                   GdkEventButton   *bevent);
 
85
static gboolean   gimp_curve_view_button_release  (GtkWidget        *widget,
 
86
                                                   GdkEventButton   *bevent);
 
87
static gboolean   gimp_curve_view_motion_notify   (GtkWidget        *widget,
 
88
                                                   GdkEventMotion   *bevent);
 
89
static gboolean   gimp_curve_view_leave_notify    (GtkWidget        *widget,
 
90
                                                   GdkEventCrossing *cevent);
 
91
static gboolean   gimp_curve_view_key_press       (GtkWidget        *widget,
 
92
                                                   GdkEventKey      *kevent);
 
93
 
 
94
static void       gimp_curve_view_cut_clipboard   (GimpCurveView    *view);
 
95
static void       gimp_curve_view_copy_clipboard  (GimpCurveView    *view);
 
96
static void       gimp_curve_view_paste_clipboard (GimpCurveView    *view);
 
97
 
 
98
static void       gimp_curve_view_set_cursor      (GimpCurveView    *view,
 
99
                                                   gdouble           x,
 
100
                                                   gdouble           y);
 
101
static void       gimp_curve_view_unset_cursor    (GimpCurveView *view);
76
102
 
77
103
 
78
104
G_DEFINE_TYPE (GimpCurveView, gimp_curve_view,
80
106
 
81
107
#define parent_class gimp_curve_view_parent_class
82
108
 
 
109
static guint curve_view_signals[LAST_SIGNAL] = { 0 };
 
110
 
83
111
 
84
112
static void
85
113
gimp_curve_view_class_init (GimpCurveViewClass *klass)
86
114
{
87
115
  GObjectClass   *object_class = G_OBJECT_CLASS (klass);
88
116
  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
117
  GtkBindingSet  *binding_set;
89
118
 
90
119
  object_class->finalize             = gimp_curve_view_finalize;
91
120
  object_class->dispose              = gimp_curve_view_dispose;
100
129
  widget_class->leave_notify_event   = gimp_curve_view_leave_notify;
101
130
  widget_class->key_press_event      = gimp_curve_view_key_press;
102
131
 
 
132
  klass->cut_clipboard               = gimp_curve_view_cut_clipboard;
 
133
  klass->copy_clipboard              = gimp_curve_view_copy_clipboard;
 
134
  klass->paste_clipboard             = gimp_curve_view_paste_clipboard;
 
135
 
 
136
  g_object_class_install_property (object_class, PROP_GIMP,
 
137
                                   g_param_spec_object ("gimp",
 
138
                                                        NULL, NULL,
 
139
                                                        GIMP_TYPE_GIMP,
 
140
                                                        GIMP_PARAM_READWRITE));
 
141
 
103
142
  g_object_class_install_property (object_class, PROP_BASE_LINE,
104
143
                                   g_param_spec_boolean ("base-line",
105
144
                                                         NULL, NULL,
106
145
                                                         TRUE,
107
146
                                                         GIMP_PARAM_READWRITE |
108
147
                                                         G_PARAM_CONSTRUCT_ONLY));
 
148
 
109
149
  g_object_class_install_property (object_class, PROP_GRID_ROWS,
110
150
                                   g_param_spec_int ("grid-rows", NULL, NULL,
111
151
                                                     0, 100, 8,
112
152
                                                     GIMP_PARAM_READWRITE |
113
153
                                                     G_PARAM_CONSTRUCT_ONLY));
 
154
 
114
155
  g_object_class_install_property (object_class, PROP_GRID_COLUMNS,
115
156
                                   g_param_spec_int ("grid-columns", NULL, NULL,
116
157
                                                     0, 100, 8,
117
158
                                                     GIMP_PARAM_READWRITE |
118
159
                                                     G_PARAM_CONSTRUCT_ONLY));
 
160
 
 
161
  g_object_class_install_property (object_class, PROP_X_AXIS_LABEL,
 
162
                                   g_param_spec_string ("x-axis-label", NULL, NULL,
 
163
                                                        NULL,
 
164
                                                        GIMP_PARAM_READWRITE));
 
165
 
 
166
  g_object_class_install_property (object_class, PROP_Y_AXIS_LABEL,
 
167
                                   g_param_spec_string ("y-axis-label", NULL, NULL,
 
168
                                                        NULL,
 
169
                                                        GIMP_PARAM_READWRITE));
 
170
 
 
171
  curve_view_signals[CUT_CLIPBOARD] =
 
172
    g_signal_new ("cut-clipboard",
 
173
                  G_TYPE_FROM_CLASS (klass),
 
174
                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
 
175
                  G_STRUCT_OFFSET (GimpCurveViewClass, cut_clipboard),
 
176
                  NULL, NULL,
 
177
                  gimp_marshal_VOID__VOID,
 
178
                  G_TYPE_NONE, 0);
 
179
 
 
180
  curve_view_signals[COPY_CLIPBOARD] =
 
181
    g_signal_new ("copy-clipboard",
 
182
                  G_TYPE_FROM_CLASS (klass),
 
183
                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
 
184
                  G_STRUCT_OFFSET (GimpCurveViewClass, copy_clipboard),
 
185
                  NULL, NULL,
 
186
                  gimp_marshal_VOID__VOID,
 
187
                  G_TYPE_NONE, 0);
 
188
 
 
189
  curve_view_signals[PASTE_CLIPBOARD] =
 
190
    g_signal_new ("paste-clipboard",
 
191
                  G_TYPE_FROM_CLASS (klass),
 
192
                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
 
193
                  G_STRUCT_OFFSET (GimpCurveViewClass, paste_clipboard),
 
194
                  NULL, NULL,
 
195
                  gimp_marshal_VOID__VOID,
 
196
                  G_TYPE_NONE, 0);
 
197
 
 
198
  binding_set = gtk_binding_set_by_class (klass);
 
199
 
 
200
  gtk_binding_entry_add_signal (binding_set, GDK_KEY_x, GDK_CONTROL_MASK,
 
201
                                "cut-clipboard", 0);
 
202
  gtk_binding_entry_add_signal (binding_set, GDK_KEY_c, GDK_CONTROL_MASK,
 
203
                                "copy-clipboard", 0);
 
204
  gtk_binding_entry_add_signal (binding_set, GDK_KEY_v, GDK_CONTROL_MASK,
 
205
                                "paste-clipboard", 0);
119
206
}
120
207
 
121
208
static void
129
216
  view->xpos        = -1.0;
130
217
  view->cursor_x    = -1.0;
131
218
  view->cursor_y    = -1.0;
132
 
 
133
 
  GTK_WIDGET_SET_FLAGS (view, GTK_CAN_FOCUS);
134
 
 
 
219
  view->range_x_min = 0.0;
 
220
  view->range_x_max = 1.0;
 
221
  view->range_y_min = 0.0;
 
222
  view->range_y_max = 1.0;
 
223
 
 
224
  view->x_axis_label = NULL;
 
225
  view->y_axis_label = NULL;
 
226
 
 
227
  gtk_widget_set_can_focus (GTK_WIDGET (view), TRUE);
135
228
  gtk_widget_add_events (GTK_WIDGET (view),
136
229
                         GDK_BUTTON_PRESS_MASK   |
137
230
                         GDK_BUTTON_RELEASE_MASK |
146
239
{
147
240
  GimpCurveView *view = GIMP_CURVE_VIEW (object);
148
241
 
149
 
  if (view->xpos_layout)
 
242
  if (view->layout)
150
243
    {
151
 
      g_object_unref (view->xpos_layout);
152
 
      view->xpos_layout = NULL;
 
244
      g_object_unref (view->layout);
 
245
      view->layout = NULL;
153
246
    }
154
247
 
155
248
  if (view->cursor_layout)
158
251
      view->cursor_layout = NULL;
159
252
    }
160
253
 
 
254
  if (view->x_axis_label)
 
255
    {
 
256
      g_free (view->x_axis_label);
 
257
      view->x_axis_label = NULL;
 
258
    }
 
259
 
 
260
  if (view->y_axis_label)
 
261
    {
 
262
      g_free (view->y_axis_label);
 
263
      view->y_axis_label = NULL;
 
264
    }
 
265
 
161
266
  G_OBJECT_CLASS (parent_class)->finalize (object);
162
267
}
163
268
 
166
271
{
167
272
  GimpCurveView *view = GIMP_CURVE_VIEW (object);
168
273
 
169
 
  gimp_curve_view_set_curve (view, NULL);
 
274
  gimp_curve_view_set_curve (view, NULL, NULL);
 
275
 
 
276
  if (view->bg_curves)
 
277
    gimp_curve_view_remove_all_backgrounds (view);
170
278
 
171
279
  G_OBJECT_CLASS (parent_class)->dispose (object);
172
280
}
181
289
 
182
290
  switch (property_id)
183
291
    {
 
292
    case PROP_GIMP:
 
293
      view->gimp = g_value_get_object (value); /* don't ref */
 
294
      break;
184
295
    case PROP_GRID_ROWS:
185
296
      view->grid_rows = g_value_get_int (value);
186
297
      break;
190
301
    case PROP_BASE_LINE:
191
302
      view->draw_base_line = g_value_get_boolean (value);
192
303
      break;
 
304
    case PROP_X_AXIS_LABEL:
 
305
      gimp_curve_view_set_x_axis_label (view, g_value_get_string (value));
 
306
      break;
 
307
    case PROP_Y_AXIS_LABEL:
 
308
      gimp_curve_view_set_y_axis_label (view, g_value_get_string (value));
 
309
      break;
193
310
    default:
194
311
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
195
312
      break;
206
323
 
207
324
  switch (property_id)
208
325
    {
 
326
    case PROP_GIMP:
 
327
      g_value_set_object (value, view->gimp);
 
328
      break;
209
329
    case PROP_GRID_ROWS:
210
330
      g_value_set_int (value, view->grid_rows);
211
331
      break;
215
335
    case PROP_BASE_LINE:
216
336
      g_value_set_boolean (value, view->draw_base_line);
217
337
      break;
 
338
    case PROP_X_AXIS_LABEL:
 
339
      g_value_set_string (value, view->x_axis_label);
 
340
      break;
 
341
    case PROP_Y_AXIS_LABEL:
 
342
      g_value_set_string (value, view->y_axis_label);
 
343
      break;
218
344
    default:
219
345
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
220
346
      break;
229
355
 
230
356
  GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
231
357
 
232
 
  if (view->xpos_layout)
 
358
  if (view->layout)
233
359
    {
234
 
      g_object_unref (view->xpos_layout);
235
 
      view->xpos_layout = NULL;
 
360
      g_object_unref (view->layout);
 
361
      view->layout = NULL;
236
362
    }
237
363
 
238
364
  if (view->cursor_layout)
244
370
 
245
371
static void
246
372
gimp_curve_view_draw_grid (GimpCurveView *view,
247
 
                           GtkStyle      *style,
248
373
                           cairo_t       *cr,
249
374
                           gint           width,
250
375
                           gint           height,
252
377
{
253
378
  gint i;
254
379
 
255
 
  gdk_cairo_set_source_color (cr, &style->dark[GTK_STATE_NORMAL]);
256
 
 
257
380
  for (i = 1; i < view->grid_rows; i++)
258
381
    {
259
 
      gint y = i * height / view->grid_rows;
 
382
      gint y = i * (height - 1) / view->grid_rows;
260
383
 
261
384
      if ((view->grid_rows % 2) == 0 && (i == view->grid_rows / 2))
262
385
        continue;
267
390
 
268
391
  for (i = 1; i < view->grid_columns; i++)
269
392
    {
270
 
      gint x = i * width / view->grid_columns;
 
393
      gint x = i * (width - 1) / view->grid_columns;
271
394
 
272
395
      if ((view->grid_columns % 2) == 0 && (i == view->grid_columns / 2))
273
396
        continue;
287
410
 
288
411
  if ((view->grid_rows % 2) == 0)
289
412
    {
290
 
      gint y = height / 2;
 
413
      gint y = (height - 1) / 2;
291
414
 
292
415
      cairo_move_to (cr, border,             border + y);
293
416
      cairo_line_to (cr, border + width - 1, border + y);
295
418
 
296
419
  if ((view->grid_columns % 2) == 0)
297
420
    {
298
 
      gint x = width / 2;
 
421
      gint x = (width - 1) / 2;
299
422
 
300
423
      cairo_move_to (cr, border + x, border);
301
424
      cairo_line_to (cr, border + x, border + height - 1);
325
448
#define RADIUS 3
326
449
 
327
450
  cairo_move_to (cr,
328
 
                 border + (gdouble) width  * x + RADIUS,
329
 
                 border + (gdouble) height * y);
 
451
                 border + (gdouble) (width  - 1) * x + RADIUS,
 
452
                 border + (gdouble) (height - 1) * y);
330
453
  cairo_arc (cr,
331
 
             border + (gdouble) width  * x,
332
 
             border + (gdouble) height * y,
 
454
             border + (gdouble) (width  - 1) * x,
 
455
             border + (gdouble) (height - 1) * y,
333
456
             RADIUS,
334
457
             0, 2 * G_PI);
335
458
}
336
459
 
 
460
static void
 
461
gimp_curve_view_draw_curve (GimpCurveView *view,
 
462
                            cairo_t       *cr,
 
463
                            GimpCurve     *curve,
 
464
                            gint           width,
 
465
                            gint           height,
 
466
                            gint           border)
 
467
{
 
468
  gdouble x, y;
 
469
  gint    i;
 
470
 
 
471
  x = 0.0;
 
472
  y = 1.0 - gimp_curve_map_value (curve, 0.0);
 
473
 
 
474
  cairo_move_to (cr,
 
475
                 border + (gdouble) (width  - 1) * x,
 
476
                 border + (gdouble) (height - 1)* y);
 
477
 
 
478
  for (i = 1; i < 256; i++)
 
479
    {
 
480
      x = (gdouble) i / 255.0;
 
481
      y = 1.0 - gimp_curve_map_value (curve, x);
 
482
 
 
483
      cairo_line_to (cr,
 
484
                     border + (gdouble) (width  - 1) * x,
 
485
                     border + (gdouble) (height - 1) * y);
 
486
    }
 
487
 
 
488
  cairo_stroke (cr);
 
489
}
 
490
 
337
491
static gboolean
338
492
gimp_curve_view_expose (GtkWidget      *widget,
339
493
                        GdkEventExpose *event)
340
494
{
341
 
  GimpCurveView *view  = GIMP_CURVE_VIEW (widget);
342
 
  GtkStyle      *style = gtk_widget_get_style (widget);
 
495
  GimpCurveView *view   = GIMP_CURVE_VIEW (widget);
 
496
  GdkWindow     *window = gtk_widget_get_window (widget);
 
497
  GtkStyle      *style  = gtk_widget_get_style (widget);
 
498
  GtkAllocation  allocation;
343
499
  cairo_t       *cr;
 
500
  GList         *list;
344
501
  gint           border;
345
502
  gint           width;
346
503
  gint           height;
 
504
  gint           layout_x;
 
505
  gint           layout_y;
347
506
  gdouble        x, y;
348
507
  gint           i;
349
508
 
352
511
  if (! view->curve)
353
512
    return FALSE;
354
513
 
 
514
  gtk_widget_get_allocation (widget, &allocation);
 
515
 
355
516
  border = GIMP_HISTOGRAM_VIEW (view)->border_width;
356
 
 
357
 
  width  = widget->allocation.width  - 2 * border - 1;
358
 
  height = widget->allocation.height - 2 * border - 1;
359
 
 
360
 
  cr = gdk_cairo_create (widget->window);
 
517
  width  = allocation.width  - 2 * border;
 
518
  height = allocation.height - 2 * border;
 
519
 
 
520
  cr = gdk_cairo_create (gtk_widget_get_window (widget));
361
521
 
362
522
  gdk_cairo_region (cr, event->region);
363
523
  cairo_clip (cr);
364
524
 
 
525
  if (gtk_widget_has_focus (widget))
 
526
    {
 
527
      gtk_paint_focus (style, window,
 
528
                       gtk_widget_get_state (widget),
 
529
                       &event->area, widget, NULL,
 
530
                       border - 2, border - 2,
 
531
                       width + 4, height + 4);
 
532
    }
 
533
 
 
534
  cairo_set_line_width (cr, 1.0);
 
535
  cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
365
536
  cairo_translate (cr, 0.5, 0.5);
366
537
 
367
538
  /*  Draw the grid lines  */
368
 
  gimp_curve_view_draw_grid (view, style, cr, width, height, border);
 
539
  gdk_cairo_set_source_color (cr, &style->dark[GTK_STATE_NORMAL]);
 
540
 
 
541
  gimp_curve_view_draw_grid (view, cr, width, height, border);
 
542
 
 
543
  /*  Draw the axis labels  */
 
544
 
 
545
  if (view->x_axis_label)
 
546
    {
 
547
      if (! view->layout)
 
548
        view->layout = gtk_widget_create_pango_layout (widget, NULL);
 
549
 
 
550
      pango_layout_set_text (view->layout, view->x_axis_label, -1);
 
551
      pango_layout_get_pixel_size (view->layout, &layout_x, &layout_y);
 
552
 
 
553
      cairo_move_to (cr,
 
554
                     width - border - layout_x,
 
555
                     height - border - layout_y);
 
556
 
 
557
      gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_NORMAL]);
 
558
      pango_cairo_show_layout (cr, view->layout);
 
559
    }
 
560
 
 
561
  if (view->y_axis_label)
 
562
    {
 
563
      if (! view->layout)
 
564
        view->layout = gtk_widget_create_pango_layout (widget, NULL);
 
565
 
 
566
      pango_layout_set_text (view->layout, view->y_axis_label, -1);
 
567
      pango_layout_get_pixel_size (view->layout, &layout_x, &layout_y);
 
568
 
 
569
      cairo_save (cr);
 
570
 
 
571
      cairo_move_to (cr,
 
572
                     2 * border,
 
573
                     2 * border + layout_x);
 
574
      cairo_rotate (cr, - G_PI / 2);
 
575
 
 
576
      gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_NORMAL]);
 
577
      pango_cairo_show_layout (cr, view->layout);
 
578
 
 
579
      cairo_restore (cr);
 
580
    }
 
581
 
 
582
 
 
583
  /*  Draw the background curves  */
 
584
  for (list = view->bg_curves; list; list = g_list_next (list))
 
585
    {
 
586
      BGCurve *bg = list->data;
 
587
 
 
588
      cairo_set_source_rgba (cr,
 
589
                             bg->color.r,
 
590
                             bg->color.g,
 
591
                             bg->color.b,
 
592
                             0.5);
 
593
 
 
594
      gimp_curve_view_draw_curve (view, cr, bg->curve,
 
595
                                  width, height, border);
 
596
    }
369
597
 
370
598
  /*  Draw the curve  */
371
 
  gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_NORMAL]);
372
 
 
373
 
  x = 0.0;
374
 
  y = 1.0 - gimp_curve_map_value (view->curve, 0.0);
375
 
 
376
 
  cairo_move_to (cr,
377
 
                 border + (gdouble) width  * x,
378
 
                 border + (gdouble) height * y);
379
 
 
380
 
  for (i = 1; i < 256; i++)
381
 
    {
382
 
      x = (gdouble) i / 255.0;
383
 
      y = 1.0 - gimp_curve_map_value (view->curve, x);
384
 
 
385
 
      cairo_line_to (cr,
386
 
                     border + (gdouble) width  * x,
387
 
                     border + (gdouble) height * y);
388
 
    }
389
 
 
390
 
  cairo_stroke (cr);
391
 
 
 
599
  if (view->curve_color)
 
600
    gimp_cairo_set_source_rgb (cr, view->curve_color);
 
601
  else
 
602
    gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_NORMAL]);
 
603
 
 
604
  gimp_curve_view_draw_curve (view, cr, view->curve,
 
605
                              width, height, border);
 
606
 
 
607
  /*  Draw the points  */
392
608
  if (gimp_curve_get_curve_type (view->curve) == GIMP_CURVE_SMOOTH)
393
609
    {
394
610
      gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_NORMAL]);
415
631
 
416
632
  if (view->xpos >= 0.0)
417
633
    {
418
 
      gint  layout_x;
419
 
      gint  layout_y;
420
634
      gchar buf[32];
421
635
 
422
636
      gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_NORMAL]);
423
637
 
424
638
      /* draw the color line */
425
639
      cairo_move_to (cr,
426
 
                     border + ROUND ((gdouble) width * view->xpos),
427
 
                     border);
 
640
                     border + ROUND ((gdouble) (width - 1) * view->xpos),
 
641
                     border + 1);
428
642
      cairo_line_to (cr,
429
 
                     border + ROUND ((gdouble) width * view->xpos),
 
643
                     border + ROUND ((gdouble) (width - 1) * view->xpos),
430
644
                     border + height - 1);
431
645
      cairo_stroke (cr);
432
646
 
433
647
      /* and xpos indicator */
434
648
      g_snprintf (buf, sizeof (buf), "x:%d", (gint) (view->xpos * 255.999));
435
649
 
436
 
      if (! view->xpos_layout)
437
 
        view->xpos_layout = gtk_widget_create_pango_layout (widget, NULL);
 
650
      if (! view->layout)
 
651
        view->layout = gtk_widget_create_pango_layout (widget, NULL);
438
652
 
439
 
      pango_layout_set_text (view->xpos_layout, buf, -1);
440
 
      pango_layout_get_pixel_size (view->xpos_layout, &layout_x, &layout_y);
 
653
      pango_layout_set_text (view->layout, buf, -1);
 
654
      pango_layout_get_pixel_size (view->layout, &layout_x, &layout_y);
441
655
 
442
656
      if (view->xpos < 0.5)
443
657
        layout_x = border;
447
661
      cairo_move_to (cr,
448
662
                     border + (gdouble) width * view->xpos + layout_x,
449
663
                     border + height - border - layout_y);
450
 
      pango_cairo_show_layout (cr, view->xpos_layout);
451
 
      cairo_fill (cr);
 
664
      pango_cairo_show_layout (cr, view->layout);
452
665
    }
453
666
 
454
667
  if (view->cursor_x >= 0.0 && view->cursor_x <= 1.0 &&
459
672
 
460
673
      if (! view->cursor_layout)
461
674
        {
462
 
          view->cursor_layout = gtk_widget_create_pango_layout (widget,
463
 
                                                                "x:888 y:888");
 
675
          /*  stupid heuristic: special-case for 0..255  */
 
676
          if (view->range_x_max == 255.0 &&
 
677
              view->range_y_max == 255.0)
 
678
            {
 
679
              view->cursor_layout =
 
680
                gtk_widget_create_pango_layout (widget, "x:888 y:888");
 
681
            }
 
682
          else
 
683
            {
 
684
              view->cursor_layout =
 
685
                gtk_widget_create_pango_layout (widget, "x:0.888 y:0.888");
 
686
            }
 
687
 
464
688
          pango_layout_get_pixel_extents (view->cursor_layout,
465
689
                                          NULL, &view->cursor_rect);
466
690
        }
470
694
      w = view->cursor_rect.width;
471
695
      h = view->cursor_rect.height;
472
696
 
 
697
      if (view->x_axis_label)
 
698
        x += border + view->cursor_rect.height; /* coincidentially the right value */
 
699
 
473
700
      cairo_push_group (cr);
474
701
 
475
702
      gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_NORMAL]);
480
707
      cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
481
708
      cairo_stroke (cr);
482
709
 
483
 
      g_snprintf (buf, sizeof (buf), "x:%3d y:%3d",
484
 
                  (gint) (view->cursor_x         * 255.999),
485
 
                  (gint) ((1.0 - view->cursor_y) * 255.999));
 
710
      /*  stupid heuristic: special-case for 0..255  */
 
711
      if (view->range_x_max == 255.0 &&
 
712
          view->range_y_max == 255.0)
 
713
        {
 
714
          g_snprintf (buf, sizeof (buf), "x:%3d y:%3d",
 
715
                      (gint) (view->cursor_x *
 
716
                              (view->range_x_max - view->range_x_min) +
 
717
                              view->range_x_min),
 
718
                      (gint) ((1.0 - view->cursor_y) *
 
719
                              (view->range_y_max - view->range_y_min) +
 
720
                              view->range_y_min));
 
721
        }
 
722
      else
 
723
        {
 
724
          g_snprintf (buf, sizeof (buf), "x:%0.3f y:%0.3f",
 
725
                      view->cursor_x *
 
726
                      (view->range_x_max - view->range_x_min) +
 
727
                      view->range_x_min,
 
728
                      (1.0 - view->cursor_y) *
 
729
                      (view->range_y_max - view->range_y_min) +
 
730
                      view->range_y_min);
 
731
        }
 
732
 
486
733
      pango_layout_set_text (view->cursor_layout, buf, -1);
487
734
 
488
735
      gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_NORMAL]);
489
736
 
490
737
      cairo_move_to (cr, x, y);
491
738
      pango_cairo_show_layout (cr, view->cursor_layout);
492
 
      cairo_fill (cr);
493
739
 
494
740
      cairo_pop_group_to_source (cr);
495
741
      cairo_paint_with_alpha (cr, 0.6);
509
755
      GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (view));
510
756
      GdkCursor  *cursor  = gdk_cursor_new_for_display (display, new_cursor);
511
757
 
512
 
      gdk_window_set_cursor (GTK_WIDGET (view)->window, cursor);
 
758
      gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (view)), cursor);
513
759
      gdk_cursor_unref (cursor);
514
760
 
515
761
      view->cursor_type = new_cursor;
522
768
{
523
769
  GimpCurveView *view  = GIMP_CURVE_VIEW (widget);
524
770
  GimpCurve     *curve = view->curve;
 
771
  GtkAllocation  allocation;
525
772
  gint           border;
526
773
  gint           width, height;
527
774
  gdouble        x;
532
779
  if (! curve || bevent->button != 1)
533
780
    return TRUE;
534
781
 
 
782
  gtk_widget_get_allocation (widget, &allocation);
 
783
 
535
784
  border = GIMP_HISTOGRAM_VIEW (view)->border_width;
536
 
  width  = widget->allocation.width  - 2 * border;
537
 
  height = widget->allocation.height - 2 * border;
 
785
  width  = allocation.width  - 2 * border;
 
786
  height = allocation.height - 2 * border;
538
787
 
539
788
  x = (gdouble) (bevent->x - border) / (gdouble) width;
540
789
  y = (gdouble) (bevent->y - border) / (gdouble) height;
593
842
      break;
594
843
    }
595
844
 
596
 
  if (! GTK_WIDGET_HAS_FOCUS (widget))
 
845
  if (! gtk_widget_has_focus (widget))
597
846
    gtk_widget_grab_focus (widget);
598
847
 
599
848
  return TRUE;
621
870
{
622
871
  GimpCurveView  *view       = GIMP_CURVE_VIEW (widget);
623
872
  GimpCurve      *curve      = view->curve;
 
873
  GtkAllocation   allocation;
624
874
  GimpCursorType  new_cursor = GDK_X_CURSOR;
625
875
  gint            border;
626
876
  gint            width, height;
632
882
  if (! curve)
633
883
    return TRUE;
634
884
 
 
885
  gtk_widget_get_allocation (widget, &allocation);
 
886
 
635
887
  border = GIMP_HISTOGRAM_VIEW (view)->border_width;
636
 
  width  = widget->allocation.width  - 2 * border;
637
 
  height = widget->allocation.height - 2 * border;
 
888
  width  = allocation.width  - 2 * border;
 
889
  height = allocation.height - 2 * border;
638
890
 
639
891
  x = (gdouble) (mevent->x - border) / (gdouble) width;
640
892
  y = (gdouble) (mevent->y - border) / (gdouble) height;
717
969
                  gdouble xpos = (gdouble) i / (gdouble) (n_samples - 1);
718
970
                  gdouble ypos = (y1 + ((y2 - y1) * (xpos - x1)) / (x2 - x1));
719
971
 
 
972
                  xpos = CLAMP (xpos, 0.0, 1.0);
 
973
                  ypos = CLAMP (ypos, 0.0, 1.0);
 
974
 
720
975
                  gimp_curve_set_curve (curve, xpos, 1.0 - ypos);
721
976
                }
722
977
 
761
1016
gimp_curve_view_key_press (GtkWidget   *widget,
762
1017
                           GdkEventKey *kevent)
763
1018
{
764
 
  GimpCurveView *view   = GIMP_CURVE_VIEW (widget);
765
 
  GimpCurve     *curve  = view->curve;
766
 
  gint           i      = view->selected;
767
 
  gdouble        x, y;
768
 
  gboolean       retval = FALSE;
769
 
 
770
 
  if (view->grabbed || ! curve ||
771
 
      gimp_curve_get_curve_type (curve) == GIMP_CURVE_FREE)
772
 
    return FALSE;
773
 
 
774
 
  gimp_curve_get_point (curve, i, NULL, &y);
775
 
 
776
 
  switch (kevent->keyval)
777
 
    {
778
 
    case GDK_Left:
779
 
      for (i = i - 1; i >= 0 && ! retval; i--)
780
 
        {
781
 
          gimp_curve_get_point (curve, i, &x, NULL);
782
 
 
783
 
          if (x >= 0.0)
784
 
            {
785
 
              gimp_curve_view_set_selected (view, i);
786
 
 
787
 
              retval = TRUE;
788
 
            }
789
 
        }
790
 
      break;
791
 
 
792
 
    case GDK_Right:
793
 
      for (i = i + 1; i < curve->n_points && ! retval; i++)
794
 
        {
795
 
          gimp_curve_get_point (curve, i, &x, NULL);
796
 
 
797
 
          if (x >= 0.0)
798
 
            {
799
 
              gimp_curve_view_set_selected (view, i);
800
 
 
801
 
              retval = TRUE;
802
 
            }
803
 
        }
804
 
      break;
805
 
 
806
 
    case GDK_Up:
807
 
      if (y < 1.0)
808
 
        {
809
 
          y = y + (kevent->state & GDK_SHIFT_MASK ?
810
 
                   (16.0 / 255.0) : (1.0 / 255.0));
811
 
 
812
 
          gimp_curve_move_point (curve, i, CLAMP (y, 0.0, 1.0));
813
 
 
814
 
          retval = TRUE;
815
 
        }
816
 
      break;
817
 
 
818
 
    case GDK_Down:
819
 
      if (y > 0)
820
 
        {
821
 
          y = y - (kevent->state & GDK_SHIFT_MASK ?
822
 
                   (16.0 / 255.0) : (1.0 / 255.0));
823
 
 
824
 
          gimp_curve_move_point (curve, i, CLAMP (y, 0.0, 1.0));
825
 
 
826
 
          retval = TRUE;
827
 
        }
828
 
      break;
829
 
 
830
 
    default:
831
 
      break;
832
 
    }
833
 
 
834
 
  if (retval)
835
 
    set_cursor (view, GDK_TCROSS);
836
 
 
837
 
  return retval;
838
 
}
 
1019
  GimpCurveView *view    = GIMP_CURVE_VIEW (widget);
 
1020
  GimpCurve     *curve   = view->curve;
 
1021
  gboolean       handled = FALSE;
 
1022
 
 
1023
  if (! view->grabbed && curve &&
 
1024
      gimp_curve_get_curve_type (curve) == GIMP_CURVE_SMOOTH)
 
1025
    {
 
1026
      gint    i = view->selected;
 
1027
      gdouble x, y;
 
1028
 
 
1029
      gimp_curve_get_point (curve, i, NULL, &y);
 
1030
 
 
1031
      switch (kevent->keyval)
 
1032
        {
 
1033
        case GDK_KEY_Left:
 
1034
          for (i = i - 1; i >= 0 && ! handled; i--)
 
1035
            {
 
1036
              gimp_curve_get_point (curve, i, &x, NULL);
 
1037
 
 
1038
              if (x >= 0.0)
 
1039
                {
 
1040
                  gimp_curve_view_set_selected (view, i);
 
1041
 
 
1042
                  handled = TRUE;
 
1043
                }
 
1044
            }
 
1045
          break;
 
1046
 
 
1047
        case GDK_KEY_Right:
 
1048
          for (i = i + 1; i < curve->n_points && ! handled; i++)
 
1049
            {
 
1050
              gimp_curve_get_point (curve, i, &x, NULL);
 
1051
 
 
1052
              if (x >= 0.0)
 
1053
                {
 
1054
                  gimp_curve_view_set_selected (view, i);
 
1055
 
 
1056
                  handled = TRUE;
 
1057
                }
 
1058
            }
 
1059
          break;
 
1060
 
 
1061
        case GDK_KEY_Up:
 
1062
          if (y < 1.0)
 
1063
            {
 
1064
              y = y + (kevent->state & GDK_SHIFT_MASK ?
 
1065
                       (16.0 / 255.0) : (1.0 / 255.0));
 
1066
 
 
1067
              gimp_curve_move_point (curve, i, CLAMP (y, 0.0, 1.0));
 
1068
 
 
1069
              handled = TRUE;
 
1070
            }
 
1071
          break;
 
1072
 
 
1073
        case GDK_KEY_Down:
 
1074
          if (y > 0)
 
1075
            {
 
1076
              y = y - (kevent->state & GDK_SHIFT_MASK ?
 
1077
                       (16.0 / 255.0) : (1.0 / 255.0));
 
1078
 
 
1079
              gimp_curve_move_point (curve, i, CLAMP (y, 0.0, 1.0));
 
1080
 
 
1081
              handled = TRUE;
 
1082
            }
 
1083
          break;
 
1084
 
 
1085
        case GDK_KEY_Delete:
 
1086
          gimp_curve_delete_point (curve, i);
 
1087
          break;
 
1088
 
 
1089
        default:
 
1090
          break;
 
1091
        }
 
1092
    }
 
1093
 
 
1094
  if (handled)
 
1095
    {
 
1096
      set_cursor (view, GDK_TCROSS);
 
1097
 
 
1098
      return TRUE;
 
1099
    }
 
1100
 
 
1101
  return GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, kevent);
 
1102
}
 
1103
 
 
1104
static void
 
1105
gimp_curve_view_cut_clipboard (GimpCurveView *view)
 
1106
{
 
1107
  g_printerr ("%s\n", G_STRFUNC);
 
1108
 
 
1109
  if (! view->curve || ! view->gimp)
 
1110
    {
 
1111
      gtk_widget_error_bell (GTK_WIDGET (view));
 
1112
      return;
 
1113
    }
 
1114
 
 
1115
  gimp_curve_view_copy_clipboard (view);
 
1116
 
 
1117
  gimp_curve_reset (view->curve, FALSE);
 
1118
}
 
1119
 
 
1120
static void
 
1121
gimp_curve_view_copy_clipboard (GimpCurveView *view)
 
1122
{
 
1123
  GimpCurve *copy;
 
1124
 
 
1125
  g_printerr ("%s\n", G_STRFUNC);
 
1126
 
 
1127
  if (! view->curve || ! view->gimp)
 
1128
    {
 
1129
      gtk_widget_error_bell (GTK_WIDGET (view));
 
1130
      return;
 
1131
    }
 
1132
 
 
1133
  copy = GIMP_CURVE (gimp_data_duplicate (GIMP_DATA (view->curve)));
 
1134
  gimp_clipboard_set_curve (view->gimp, copy);
 
1135
  g_object_unref (copy);
 
1136
}
 
1137
 
 
1138
static void
 
1139
gimp_curve_view_paste_clipboard (GimpCurveView *view)
 
1140
{
 
1141
  GimpCurve *copy;
 
1142
 
 
1143
  g_printerr ("%s\n", G_STRFUNC);
 
1144
 
 
1145
  if (! view->curve || ! view->gimp)
 
1146
    {
 
1147
      gtk_widget_error_bell (GTK_WIDGET (view));
 
1148
      return;
 
1149
    }
 
1150
 
 
1151
  copy = gimp_clipboard_get_curve (view->gimp);
 
1152
 
 
1153
  if (copy)
 
1154
    {
 
1155
      gimp_config_copy (GIMP_CONFIG (copy),
 
1156
                        GIMP_CONFIG (view->curve), 0);
 
1157
      g_object_unref (copy);
 
1158
    }
 
1159
}
 
1160
 
 
1161
 
 
1162
/*  public functions  */
839
1163
 
840
1164
GtkWidget *
841
1165
gimp_curve_view_new (void)
852
1176
 
853
1177
void
854
1178
gimp_curve_view_set_curve (GimpCurveView *view,
855
 
                           GimpCurve     *curve)
 
1179
                           GimpCurve     *curve,
 
1180
                           const GimpRGB *color)
856
1181
{
857
1182
  g_return_if_fail (GIMP_IS_CURVE_VIEW (view));
858
1183
  g_return_if_fail (curve == NULL || GIMP_IS_CURVE (curve));
877
1202
                        G_CALLBACK (gimp_curve_view_curve_dirty),
878
1203
                        view);
879
1204
    }
 
1205
 
 
1206
  if (view->curve_color)
 
1207
    g_free (view->curve_color);
 
1208
 
 
1209
  if (color)
 
1210
    view->curve_color = g_memdup (color, sizeof (GimpRGB));
 
1211
  else
 
1212
    view->curve_color = NULL;
 
1213
 
 
1214
  gtk_widget_queue_draw (GTK_WIDGET (view));
880
1215
}
881
1216
 
882
1217
GimpCurve *
888
1223
}
889
1224
 
890
1225
void
 
1226
gimp_curve_view_add_background (GimpCurveView *view,
 
1227
                                GimpCurve     *curve,
 
1228
                                const GimpRGB *color)
 
1229
{
 
1230
  GList   *list;
 
1231
  BGCurve *bg;
 
1232
 
 
1233
  g_return_if_fail (GIMP_IS_CURVE_VIEW (view));
 
1234
  g_return_if_fail (GIMP_IS_CURVE (curve));
 
1235
  g_return_if_fail (color != NULL);
 
1236
 
 
1237
  for (list = view->bg_curves; list; list = g_list_next (list))
 
1238
    {
 
1239
      bg = list->data;
 
1240
 
 
1241
      g_return_if_fail (curve != bg->curve);
 
1242
    }
 
1243
 
 
1244
  bg = g_slice_new0 (BGCurve);
 
1245
 
 
1246
  bg->curve = g_object_ref (curve);
 
1247
  bg->color = *color;
 
1248
 
 
1249
  g_signal_connect (bg->curve, "dirty",
 
1250
                    G_CALLBACK (gimp_curve_view_curve_dirty),
 
1251
                    view);
 
1252
 
 
1253
  view->bg_curves = g_list_append (view->bg_curves, bg);
 
1254
 
 
1255
  gtk_widget_queue_draw (GTK_WIDGET (view));
 
1256
}
 
1257
 
 
1258
void
 
1259
gimp_curve_view_remove_background (GimpCurveView *view,
 
1260
                                   GimpCurve     *curve)
 
1261
{
 
1262
  GList *list;
 
1263
 
 
1264
  g_return_if_fail (GIMP_IS_CURVE_VIEW (view));
 
1265
  g_return_if_fail (GIMP_IS_CURVE (curve));
 
1266
 
 
1267
  for (list = view->bg_curves; list; list = g_list_next (list))
 
1268
    {
 
1269
      BGCurve *bg = list->data;
 
1270
 
 
1271
      if (bg->curve == curve)
 
1272
        {
 
1273
          g_signal_handlers_disconnect_by_func (bg->curve,
 
1274
                                                gimp_curve_view_curve_dirty,
 
1275
                                                view);
 
1276
          g_object_unref (bg->curve);
 
1277
 
 
1278
          view->bg_curves = g_list_remove (view->bg_curves, bg);
 
1279
 
 
1280
          g_slice_free (BGCurve, bg);
 
1281
 
 
1282
          gtk_widget_queue_draw (GTK_WIDGET (view));
 
1283
 
 
1284
          break;
 
1285
        }
 
1286
    }
 
1287
 
 
1288
  if (! list)
 
1289
    g_return_if_reached ();
 
1290
}
 
1291
 
 
1292
void
 
1293
gimp_curve_view_remove_all_backgrounds (GimpCurveView *view)
 
1294
{
 
1295
  g_return_if_fail (GIMP_IS_CURVE_VIEW (view));
 
1296
 
 
1297
  while (view->bg_curves)
 
1298
    {
 
1299
      BGCurve *bg = view->bg_curves->data;
 
1300
 
 
1301
      g_signal_handlers_disconnect_by_func (bg->curve,
 
1302
                                            gimp_curve_view_curve_dirty,
 
1303
                                            view);
 
1304
      g_object_unref (bg->curve);
 
1305
 
 
1306
      view->bg_curves = g_list_remove (view->bg_curves, bg);
 
1307
 
 
1308
      g_slice_free (BGCurve, bg);
 
1309
    }
 
1310
 
 
1311
  gtk_widget_queue_draw (GTK_WIDGET (view));
 
1312
}
 
1313
 
 
1314
void
891
1315
gimp_curve_view_set_selected (GimpCurveView *view,
892
1316
                              gint           selected)
893
1317
{
899
1323
}
900
1324
 
901
1325
void
 
1326
gimp_curve_view_set_range_x (GimpCurveView *view,
 
1327
                             gdouble        min,
 
1328
                             gdouble        max)
 
1329
{
 
1330
  g_return_if_fail (GIMP_IS_CURVE_VIEW (view));
 
1331
 
 
1332
  view->range_x_min = min;
 
1333
  view->range_x_max = max;
 
1334
}
 
1335
 
 
1336
void
 
1337
gimp_curve_view_set_range_y (GimpCurveView *view,
 
1338
                             gdouble        min,
 
1339
                             gdouble        max)
 
1340
{
 
1341
  g_return_if_fail (GIMP_IS_CURVE_VIEW (view));
 
1342
 
 
1343
  view->range_y_min = min;
 
1344
  view->range_y_max = max;
 
1345
}
 
1346
 
 
1347
void
902
1348
gimp_curve_view_set_xpos (GimpCurveView *view,
903
1349
                          gdouble        x)
904
1350
{
909
1355
  gtk_widget_queue_draw (GTK_WIDGET (view));
910
1356
}
911
1357
 
 
1358
void
 
1359
gimp_curve_view_set_x_axis_label (GimpCurveView *view,
 
1360
                                  const gchar   *label)
 
1361
{
 
1362
  g_return_if_fail (GIMP_IS_CURVE_VIEW (view));
 
1363
 
 
1364
  if (view->x_axis_label)
 
1365
    g_free (view->x_axis_label);
 
1366
 
 
1367
  view->x_axis_label = g_strdup (label);
 
1368
 
 
1369
  g_object_notify (G_OBJECT (view), "x-axis-label");
 
1370
 
 
1371
  gtk_widget_queue_draw (GTK_WIDGET (view));
 
1372
}
 
1373
 
 
1374
void
 
1375
gimp_curve_view_set_y_axis_label (GimpCurveView *view,
 
1376
                                  const gchar   *label)
 
1377
{
 
1378
  g_return_if_fail (GIMP_IS_CURVE_VIEW (view));
 
1379
 
 
1380
  if (view->y_axis_label)
 
1381
    g_free (view->y_axis_label);
 
1382
 
 
1383
  view->y_axis_label = g_strdup (label);
 
1384
 
 
1385
  g_object_notify (G_OBJECT (view), "y-axis-label");
 
1386
 
 
1387
  gtk_widget_queue_draw (GTK_WIDGET (view));
 
1388
}
 
1389
 
912
1390
 
913
1391
/*  private functions  */
914
1392