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

« back to all changes in this revision

Viewing changes to plug-ins/rcm/rcm_dialog.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2008-10-06 13:30:41 UTC
  • mto: This revision was merged to the branch mainline in revision 35.
  • Revision ID: james.westby@ubuntu.com-20081006133041-3panbkcanaymfsmp
Tags: upstream-2.6.0
ImportĀ upstreamĀ versionĀ 2.6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
 
 *
4
 
 * This is a plug-in for GIMP.
5
 
 *
6
 
 * Colormap-Rotation plug-in. Exchanges two color ranges.
7
 
 *
8
 
 * Copyright (C) 1999 Sven Anders (anderss@fmi.uni-passau.de)
9
 
 *                    Based on code from Pavel Grinfeld (pavel@ml.com)
10
 
 *
11
 
 *
12
 
 * This program is free software; you can redistribute it and/or modify
13
 
 * it under the terms of the GNU General Public License as published by
14
 
 * the Free Software Foundation; either version 2 of the License, or
15
 
 * (at your option) any later version.
16
 
 *
17
 
 * This program is distributed in the hope that it will be useful,
18
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 
 * GNU General Public License for more details.
21
 
 *
22
 
 * You should have received a copy of the GNU General Public License
23
 
 * along with this program; if not, write to the Free Software
24
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
 
 */
26
 
 
27
 
/*---------------------------------------------------------------------------
28
 
 * Change log:
29
 
 *
30
 
 * Version 2.0, 04 April 1999.
31
 
 *  Nearly complete rewrite, made plug-in stable.
32
 
 *  (Works with GIMP 1.1 and GTK+ 1.2)
33
 
 *
34
 
 * Version 1.0, 27 March 1997.
35
 
 *  Initial (unstable) release by Pavel Grinfeld
36
 
 *
37
 
 *---------------------------------------------------------------------------*/
38
 
 
39
 
#include "config.h"
40
 
 
41
 
#include <libgimp/gimp.h>
42
 
#include <libgimp/gimpui.h>
43
 
 
44
 
#include "rcm.h"
45
 
#include "rcm_misc.h"
46
 
#include "rcm_gdk.h"
47
 
#include "rcm_callback.h"
48
 
#include "rcm_dialog.h"
49
 
#include "rcm_stock.h"
50
 
 
51
 
#include "images/rcm-stock-pixbufs.h"
52
 
 
53
 
#include "libgimp/stdplugins-intl.h"
54
 
 
55
 
 
56
 
/* Defines */
57
 
 
58
 
#define INITIAL_ALPHA      0
59
 
#define INITIAL_BETA       G_PI_2
60
 
#define INITIAL_GRAY_SAT   0.0
61
 
#define INITIAL_GRAY_RSAT  0.0
62
 
#define INITIAL_GRAY_HUE   0.0
63
 
 
64
 
#define RANGE_ADJUST_MASK GDK_EXPOSURE_MASK | \
65
 
                          GDK_ENTER_NOTIFY_MASK | \
66
 
                          GDK_BUTTON_PRESS_MASK | \
67
 
                          GDK_BUTTON_RELEASE_MASK | \
68
 
                          GDK_BUTTON1_MOTION_MASK | \
69
 
                          GDK_POINTER_MOTION_HINT_MASK
70
 
 
71
 
 
72
 
/* Previews: create one preview */
73
 
 
74
 
static GtkWidget *
75
 
rcm_create_one_preview (GtkWidget **preview,
76
 
                        gint        mode,
77
 
                        gint        width,
78
 
                        gint        height)
79
 
{
80
 
  GtkWidget *align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
81
 
  GtkWidget *frame;
82
 
 
83
 
  frame = gtk_frame_new (NULL);
84
 
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
85
 
  gtk_container_add (GTK_CONTAINER (align), frame);
86
 
  gtk_widget_show (frame);
87
 
 
88
 
  *preview = gimp_preview_area_new ();
89
 
 
90
 
  gtk_widget_set_size_request (*preview, width, height);
91
 
  gtk_container_add (GTK_CONTAINER (frame), *preview);
92
 
  gtk_widget_show (*preview);
93
 
 
94
 
  g_object_set_data (G_OBJECT (*preview), "mode", GINT_TO_POINTER (mode));
95
 
 
96
 
  return align;
97
 
}
98
 
 
99
 
 
100
 
/* Previews */
101
 
 
102
 
static GtkWidget *
103
 
rcm_create_previews (void)
104
 
{
105
 
  GtkWidget *top_vbox;
106
 
  GtkWidget *vbox;
107
 
  GtkWidget *frame;
108
 
  GtkWidget *hbox;
109
 
  GtkWidget *label;
110
 
  GtkWidget *button;
111
 
  GtkWidget *combo;
112
 
 
113
 
  top_vbox = gtk_vbox_new (FALSE, 12);
114
 
 
115
 
  vbox = gtk_vbox_new (FALSE, 6);
116
 
  gtk_box_pack_start (GTK_BOX (top_vbox), vbox, TRUE, TRUE, 0);
117
 
  gtk_widget_show (vbox);
118
 
 
119
 
  label = gtk_label_new (_("Original"));
120
 
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
121
 
  gtk_widget_show (label);
122
 
 
123
 
  frame = rcm_create_one_preview (&Current.Bna->before, ORIGINAL,
124
 
                                  Current.reduced->width,
125
 
                                  Current.reduced->height);
126
 
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
127
 
  gtk_widget_show (frame);
128
 
 
129
 
  g_signal_connect_after (Current.Bna->before, "size-allocate",
130
 
                          G_CALLBACK (rcm_render_preview),
131
 
                          NULL);
132
 
 
133
 
  vbox = gtk_vbox_new (FALSE, 6);
134
 
  gtk_box_pack_start (GTK_BOX (top_vbox), vbox, TRUE, TRUE, 0);
135
 
  gtk_widget_show (vbox);
136
 
 
137
 
  label = gtk_label_new (_("Rotated"));
138
 
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
139
 
  gtk_widget_show (label);
140
 
 
141
 
  frame = rcm_create_one_preview (&Current.Bna->after, CURRENT,
142
 
                                  Current.reduced->width,
143
 
                                  Current.reduced->height);
144
 
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
145
 
  gtk_widget_show (frame);
146
 
 
147
 
  g_signal_connect_after (Current.Bna->after, "size-allocate",
148
 
                          G_CALLBACK (rcm_render_preview),
149
 
                          NULL);
150
 
 
151
 
  vbox = gtk_vbox_new (FALSE, 6);
152
 
  gtk_box_pack_start (GTK_BOX (top_vbox), vbox, FALSE, FALSE, 0);
153
 
  gtk_widget_show (vbox);
154
 
 
155
 
  button = gtk_check_button_new_with_label (_("Continuous update"));
156
 
  gtk_box_pack_start(GTK_BOX (vbox), button, FALSE, FALSE, 0);
157
 
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), Current.RealTime);
158
 
  gtk_widget_show (button);
159
 
 
160
 
  g_signal_connect (button, "clicked",
161
 
                    G_CALLBACK (rcm_preview_as_you_drag),
162
 
                    &(Current.RealTime));
163
 
 
164
 
  hbox = gtk_hbox_new (FALSE, 6);
165
 
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
166
 
  gtk_widget_show (hbox);
167
 
 
168
 
  label = gtk_label_new (_("Area:"));
169
 
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
170
 
  gtk_widget_show (label);
171
 
 
172
 
  combo = gimp_int_combo_box_new (_("Entire Layer"), ENTIRE_IMAGE,
173
 
                                  _("Selection"),    SELECTION,
174
 
                                  _("Context"),      SELECTION_IN_CONTEXT,
175
 
                                  NULL);
176
 
  gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), Current.Slctn);
177
 
 
178
 
  gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
179
 
  gtk_widget_show (combo);
180
 
 
181
 
  g_signal_connect (combo, "changed",
182
 
                    G_CALLBACK (rcm_combo_callback),
183
 
                    NULL);
184
 
 
185
 
  gtk_widget_show (top_vbox);
186
 
 
187
 
  return top_vbox;
188
 
}
189
 
 
190
 
 
191
 
/* Main: One circles with values and buttons */
192
 
 
193
 
static RcmCircle*
194
 
rcm_create_one_circle (gint   height,
195
 
                       gchar *label_content)
196
 
{
197
 
  GtkWidget     *frame, *button_table, *legend_table;
198
 
  GtkWidget     *label, *button, *entry;
199
 
  GtkAdjustment *adj;
200
 
  RcmCircle     *st;
201
 
 
202
 
  st = g_new (RcmCircle, 1);
203
 
 
204
 
  st->action_flag   = VIRGIN;
205
 
  st->angle         = g_new (RcmAngle, 1);
206
 
  st->angle->alpha  = INITIAL_ALPHA;
207
 
  st->angle->beta   = INITIAL_BETA;
208
 
  st->angle->cw_ccw = 1;
209
 
 
210
 
  /** Main: Circle: create (main) frame **/
211
 
  st->frame = gimp_frame_new (label_content);
212
 
  gtk_widget_show (st->frame);
213
 
 
214
 
  /** Main: Circle: create frame & preview **/
215
 
 
216
 
  /* create frame */
217
 
  frame = gtk_frame_new (NULL);
218
 
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
219
 
  gtk_widget_show (frame);
220
 
 
221
 
  /* create preview */
222
 
  st->preview = gimp_preview_area_new ();
223
 
  gtk_widget_set_size_request (st->preview, height, height);
224
 
  gtk_container_add (GTK_CONTAINER (frame), st->preview);
225
 
  gtk_widget_show (st->preview);
226
 
 
227
 
  /* set signals */
228
 
  gtk_widget_set_events (st->preview, RANGE_ADJUST_MASK);
229
 
 
230
 
  g_signal_connect_after (st->preview, "expose-event",
231
 
                          G_CALLBACK (rcm_expose_event),
232
 
                          st);
233
 
 
234
 
  g_signal_connect (st->preview, "button-press-event",
235
 
                    G_CALLBACK (rcm_button_press_event),
236
 
                    st);
237
 
 
238
 
  g_signal_connect (st->preview, "button-release-event",
239
 
                    G_CALLBACK (rcm_release_event),
240
 
                    st);
241
 
 
242
 
  g_signal_connect (st->preview, "motion-notify-event",
243
 
                    G_CALLBACK (rcm_motion_notify_event),
244
 
                    st);
245
 
 
246
 
  /** Main: Circle: create table for buttons **/
247
 
  button_table = gtk_table_new (3, 1, FALSE);
248
 
  gtk_widget_show (button_table);
249
 
 
250
 
  /** Main: Circle: Buttons **/
251
 
 
252
 
  button = gtk_button_new_from_stock (st->angle->cw_ccw > 0 ?
253
 
                                      STOCK_COLORMAP_SWITCH_CLOCKWISE :
254
 
                                      STOCK_COLORMAP_SWITCH_COUNTERCLOCKWISE);
255
 
  g_signal_connect (button, "clicked",
256
 
                    G_CALLBACK (rcm_cw_ccw),
257
 
                    st);
258
 
  gtk_widget_show (button);
259
 
  gtk_table_attach (GTK_TABLE (button_table), button,
260
 
                    0, 1, 0, 1,
261
 
                    GTK_EXPAND | GTK_FILL, GTK_FILL, 4, 2);
262
 
 
263
 
  st->cw_ccw_pixmap = NULL;
264
 
  st->cw_ccw_button = button;
265
 
  st->cw_ccw_box    = NULL;
266
 
  st->cw_ccw_label  = NULL;
267
 
 
268
 
  button = gtk_button_new_from_stock (STOCK_COLORMAP_CHANGE_ORDER);
269
 
  g_signal_connect (button, "clicked",
270
 
                    G_CALLBACK (rcm_a_to_b),
271
 
                    st);
272
 
  gtk_widget_show (button);
273
 
  gtk_table_attach (GTK_TABLE (button_table), button,
274
 
                    0, 1, 1, 2,
275
 
                    GTK_EXPAND | GTK_FILL, GTK_FILL, 4, 2);
276
 
 
277
 
  st->a_b_pixmap = NULL;
278
 
  st->a_b_box    = NULL;
279
 
  st->a_b_button = button;
280
 
 
281
 
  button = gtk_button_new_from_stock (STOCK_COLORMAP_SELECT_ALL);
282
 
  g_signal_connect (button, "clicked",
283
 
                    G_CALLBACK (rcm_360_degrees),
284
 
                    st);
285
 
  gtk_widget_show (button);
286
 
  gtk_table_attach (GTK_TABLE (button_table), button,
287
 
                    0, 1, 2, 3,
288
 
                    GTK_EXPAND | GTK_FILL, GTK_FILL, 4, 2);
289
 
 
290
 
  st->f360_pixmap = NULL;
291
 
  st->f360_box    = NULL;
292
 
  st->f360_button = button;
293
 
 
294
 
  /** Main: Circle: Legend **/
295
 
  legend_table = gtk_table_new (1, 6, FALSE);
296
 
  gtk_widget_show (legend_table);
297
 
 
298
 
  /* spinbutton 1 */
299
 
  label = gtk_label_new (_("From:"));
300
 
  gtk_widget_show (label);
301
 
  gtk_table_attach (GTK_TABLE (legend_table), label, 0, 1, 0, 1,
302
 
                    0, GTK_EXPAND, 5, 5);
303
 
 
304
 
  st->angle->alpha = INITIAL_ALPHA;
305
 
  adj = (GtkAdjustment *) gtk_adjustment_new(st->angle->alpha, 0.0, 2.0, 0.0001, 0.001, 0.0);
306
 
  st->alpha_entry = entry = gtk_spin_button_new(adj, 0.01, 4);
307
 
  gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(entry), TRUE);
308
 
  gtk_table_attach(GTK_TABLE(legend_table), entry, 1,2, 0,1,
309
 
                   GTK_EXPAND|GTK_FILL, GTK_EXPAND, 2, 4);
310
 
  gtk_widget_show(entry);
311
 
 
312
 
  g_signal_connect (entry, "changed",
313
 
                    G_CALLBACK (rcm_set_alpha),
314
 
                    st);
315
 
 
316
 
  /* label */
317
 
  st->alpha_units_label = gtk_label_new (rcm_units_string (Current.Units));
318
 
  gtk_widget_show (st->alpha_units_label);
319
 
 
320
 
  gtk_table_attach (GTK_TABLE (legend_table),
321
 
                    st->alpha_units_label, 2, 3, 0, 1,
322
 
                    0, GTK_EXPAND, 4, 4);
323
 
 
324
 
  /* spinbutton 2 */
325
 
  label = gtk_label_new (_("To:"));
326
 
  gtk_widget_show (label);
327
 
  gtk_table_attach (GTK_TABLE (legend_table), label, 3,4, 0,1,
328
 
                    0, GTK_EXPAND, 4, 4);
329
 
 
330
 
  st->angle->beta = INITIAL_BETA;
331
 
  adj = (GtkAdjustment *) gtk_adjustment_new (st->angle->beta,
332
 
                                              0.0, 2.0, 0.0001, 0.001, 0.0);
333
 
  st->beta_entry = entry = gtk_spin_button_new (adj, 0.01, 4);
334
 
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (entry), TRUE);
335
 
  gtk_table_attach (GTK_TABLE (legend_table), entry, 4,5, 0,1,
336
 
                    GTK_EXPAND|GTK_FILL, GTK_EXPAND, 2, 4);
337
 
  gtk_widget_show (entry);
338
 
 
339
 
  g_signal_connect (entry, "changed",
340
 
                    G_CALLBACK (rcm_set_beta),
341
 
                    st);
342
 
 
343
 
  /* label */
344
 
  st->beta_units_label = gtk_label_new (rcm_units_string (Current.Units));
345
 
  gtk_widget_show (st->beta_units_label);
346
 
 
347
 
  gtk_table_attach (GTK_TABLE (legend_table), st->beta_units_label, 5,6, 0,1,
348
 
                    0, GTK_EXPAND, 4, 4);
349
 
 
350
 
  /* Main: Circle: create table for Preview / Buttons / Legend */
351
 
  st->table= gtk_table_new (2, 2, FALSE);
352
 
  gtk_widget_show (st->table);
353
 
 
354
 
  gtk_table_attach (GTK_TABLE (st->table), frame, 0, 1, 0, 1,
355
 
                    0, GTK_EXPAND, 4, 0);
356
 
 
357
 
  gtk_table_attach (GTK_TABLE (st->table), button_table, 1, 2, 0, 1,
358
 
                    0, GTK_EXPAND, 2, 0);
359
 
 
360
 
  gtk_table_attach (GTK_TABLE (st->table), legend_table, 0, 2, 1, 2,
361
 
                    GTK_EXPAND | GTK_FILL, GTK_EXPAND, 0, 2);
362
 
 
363
 
  /* add table to (main) frame */
364
 
  gtk_container_add (GTK_CONTAINER (st->frame), st->table);
365
 
 
366
 
  return st;
367
 
}
368
 
 
369
 
 
370
 
/* Main */
371
 
 
372
 
static GtkWidget *
373
 
rcm_create_main (void)
374
 
{
375
 
  GtkWidget *vbox;
376
 
 
377
 
  Current.From = rcm_create_one_circle (SUM, _("From:"));
378
 
  Current.To   = rcm_create_one_circle (SUM, _("To:"));
379
 
 
380
 
  vbox = gtk_vbox_new (FALSE, 12);
381
 
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
382
 
  gtk_widget_show (vbox);
383
 
 
384
 
  gtk_box_pack_start (GTK_BOX (vbox), Current.From->frame,
385
 
                      FALSE, FALSE, 0);
386
 
  gtk_box_pack_start (GTK_BOX (vbox), Current.To->frame,
387
 
                      FALSE, FALSE, 0);
388
 
 
389
 
  return vbox;
390
 
}
391
 
 
392
 
 
393
 
/* Misc: Gray */
394
 
 
395
 
static GtkWidget *
396
 
rcm_create_gray (void)
397
 
{
398
 
  GtkWidget *top_vbox, *vbox;
399
 
  GtkWidget *frame, *preview;
400
 
  GtkWidget *table;
401
 
  GtkWidget *entry;
402
 
  GtkWidget *radio_box;
403
 
  GtkWidget *hbox;
404
 
  GtkWidget *label;
405
 
  GtkWidget *button;
406
 
  GSList    *group = NULL;
407
 
  RcmGray   *st;
408
 
  GtkAdjustment *adj;
409
 
 
410
 
  Current.Gray = st = g_new (RcmGray, 1);
411
 
  st->hue         = 0;
412
 
  st->satur       = 0;
413
 
  st->action_flag = VIRGIN;
414
 
 
415
 
  top_vbox = gtk_vbox_new (FALSE, 12);
416
 
  gtk_container_set_border_width (GTK_CONTAINER (top_vbox), 12);
417
 
  gtk_widget_show (top_vbox);
418
 
 
419
 
  frame = gimp_frame_new (_("Gray"));
420
 
  gtk_box_pack_start (GTK_BOX (top_vbox), frame, FALSE, FALSE, 0);
421
 
  gtk_widget_show (frame);
422
 
 
423
 
  vbox = gtk_vbox_new (FALSE, 6);
424
 
  gtk_container_add (GTK_CONTAINER (frame), vbox);
425
 
  gtk_widget_show (vbox);
426
 
 
427
 
  hbox = gtk_hbox_new (FALSE, 0);
428
 
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
429
 
  gtk_widget_show (hbox);
430
 
 
431
 
  frame = gtk_frame_new (NULL);
432
 
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
433
 
  gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
434
 
  gtk_widget_show (frame);
435
 
 
436
 
  st->preview = preview = gimp_preview_area_new ();
437
 
  gtk_widget_set_size_request (preview, GRAY_SUM, GRAY_SUM);
438
 
  gtk_container_add (GTK_CONTAINER (frame), preview);
439
 
  gtk_widget_show (preview);
440
 
 
441
 
  gtk_widget_add_events (preview, RANGE_ADJUST_MASK);
442
 
 
443
 
  g_signal_connect_after (preview, "expose-event",
444
 
                          G_CALLBACK (rcm_gray_expose_event),
445
 
                          st);
446
 
 
447
 
  g_signal_connect (preview, "button-press-event",
448
 
                    G_CALLBACK (rcm_gray_button_press_event),
449
 
                    st);
450
 
 
451
 
  g_signal_connect (preview, "button-release-event",
452
 
                    G_CALLBACK (rcm_gray_release_event),
453
 
                    st);
454
 
 
455
 
  g_signal_connect (preview, "motion-notify-event",
456
 
                    G_CALLBACK (rcm_gray_motion_notify_event),
457
 
                    st);
458
 
 
459
 
  /* Gray: Circle: Legend */
460
 
  table = gtk_table_new (2, 3, FALSE);
461
 
  gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
462
 
  gtk_table_set_col_spacings (GTK_TABLE (table), 6);
463
 
  gtk_table_set_row_spacings (GTK_TABLE (table), 6);
464
 
  gtk_widget_show (table);
465
 
 
466
 
  /* Gray: Circle: Spinbutton 1 */
467
 
  label = gtk_label_new(_("Hue:"));
468
 
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
469
 
  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
470
 
                    GTK_FILL, GTK_FILL, 0, 0);
471
 
  gtk_widget_show (label);
472
 
 
473
 
  st->hue = INITIAL_GRAY_HUE;
474
 
  adj = (GtkAdjustment *) gtk_adjustment_new (st->hue,
475
 
                                              0.0, 2.0, 0.0001, 0.001, 0.0);
476
 
  st->hue_entry = entry = gtk_spin_button_new (adj, 0.01, 4);
477
 
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON(entry), TRUE);
478
 
  gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 0, 1,
479
 
                    GTK_FILL, GTK_FILL, 0, 0);
480
 
  gtk_widget_show (entry);
481
 
 
482
 
  g_signal_connect (entry, "changed",
483
 
                    G_CALLBACK (rcm_set_hue),
484
 
                    st);
485
 
 
486
 
  /* Gray: Circle: units label */
487
 
  st->hue_units_label = gtk_label_new (rcm_units_string (Current.Units));
488
 
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
489
 
  gtk_table_attach (GTK_TABLE (table), st->hue_units_label, 2, 3, 0, 1,
490
 
                    GTK_FILL, GTK_FILL, 0, 0);
491
 
  gtk_widget_show (st->hue_units_label);
492
 
 
493
 
  /* Gray: Circle: Spinbutton 2 */
494
 
  label = gtk_label_new (_("Saturation:"));
495
 
  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
496
 
  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
497
 
                    GTK_FILL, GTK_FILL, 0, 0);
498
 
  gtk_widget_show (label);
499
 
 
500
 
  st->satur = INITIAL_GRAY_SAT;
501
 
  adj = (GtkAdjustment *) gtk_adjustment_new (st->satur,
502
 
                                              0.0, 1.0, 0.0001, 0.001, 0.0);
503
 
  st->satur_entry = entry = gtk_spin_button_new (adj, 0.01, 4);
504
 
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (entry), TRUE);
505
 
  gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2,
506
 
                    GTK_FILL, GTK_FILL, 0, 2);
507
 
  gtk_widget_show (entry);
508
 
 
509
 
  g_signal_connect (entry, "changed",
510
 
                    G_CALLBACK (rcm_set_satur),
511
 
                    st);
512
 
 
513
 
  /** Gray: Operation-Mode **/
514
 
  frame = gimp_frame_new (_("Gray Mode"));
515
 
  gtk_box_pack_start (GTK_BOX (top_vbox), frame, FALSE, FALSE, 0);
516
 
  gtk_widget_show (frame);
517
 
 
518
 
  radio_box = gtk_vbox_new (FALSE, 6);
519
 
  gtk_container_add (GTK_CONTAINER (frame), radio_box);
520
 
  gtk_widget_show (radio_box);
521
 
 
522
 
  /* Gray: Operation-Mode: two radio buttons */
523
 
  button = gtk_radio_button_new_with_label(group, _("Treat as this"));
524
 
  group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
525
 
  gtk_box_pack_start (GTK_BOX (radio_box), button, FALSE, FALSE, 0);
526
 
  gtk_widget_show (button);
527
 
 
528
 
  if (Current.Gray_to_from == GRAY_FROM)
529
 
    gtk_button_clicked (GTK_BUTTON (button));
530
 
 
531
 
  g_signal_connect (button, "clicked",
532
 
                    G_CALLBACK (rcm_switch_to_gray_from),
533
 
                    &(Current.Gray_to_from));
534
 
 
535
 
  button = gtk_radio_button_new_with_label (group, _("Change to this"));
536
 
  group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
537
 
  gtk_box_pack_start (GTK_BOX (radio_box), button, FALSE, FALSE, 0);
538
 
  gtk_widget_show (button);
539
 
 
540
 
  if (Current.Gray_to_from == GRAY_TO)
541
 
    gtk_button_clicked (GTK_BUTTON (button));
542
 
 
543
 
  g_signal_connect (button, "clicked",
544
 
                    G_CALLBACK (rcm_switch_to_gray_to),
545
 
                    &(Current.Gray_to_from));
546
 
 
547
 
  /** Gray: What is gray? **/
548
 
  frame = gimp_frame_new (_("Gray Threshold"));
549
 
  gtk_box_pack_start (GTK_BOX (top_vbox), frame, FALSE, FALSE, 0);
550
 
  gtk_widget_show (frame);
551
 
 
552
 
  hbox = gtk_hbox_new (FALSE, 6);
553
 
  gtk_container_add (GTK_CONTAINER (frame), hbox);
554
 
  gtk_widget_show (hbox);
555
 
 
556
 
  label = gtk_label_new (_("Saturation:"));
557
 
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
558
 
  gtk_widget_show (label);
559
 
 
560
 
  st->gray_sat = INITIAL_GRAY_RSAT;
561
 
  adj = (GtkAdjustment *) gtk_adjustment_new (st->gray_sat,
562
 
                                              0.0, 1.0, 0.0001, 0.001, 0.0);
563
 
 
564
 
  entry = gtk_spin_button_new (adj, 0.01, 4);
565
 
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (entry), TRUE);
566
 
  gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
567
 
  gtk_widget_show (entry);
568
 
 
569
 
  g_signal_connect (entry, "changed",
570
 
                    G_CALLBACK (rcm_set_gray_sat),
571
 
                    st);
572
 
 
573
 
  return top_vbox;
574
 
}
575
 
 
576
 
 
577
 
/* Misc */
578
 
 
579
 
static GtkWidget *
580
 
rcm_create_units (void)
581
 
{
582
 
  GtkWidget *frame;
583
 
  GtkWidget *vbox;
584
 
  GtkWidget *button;
585
 
  GSList    *group = NULL;
586
 
 
587
 
  /** Misc: Used unit selection **/
588
 
  frame = gimp_frame_new (_("Units"));
589
 
  gtk_container_set_border_width (GTK_CONTAINER (frame), 12);
590
 
  gtk_widget_show (frame);
591
 
 
592
 
  vbox = gtk_vbox_new (FALSE, 6);
593
 
  gtk_container_add (GTK_CONTAINER (frame), vbox);
594
 
  gtk_widget_show (vbox);
595
 
 
596
 
  /* Misc: Used unit selection: 3 radio buttons */
597
 
  button = gtk_radio_button_new_with_label (group, _("Radians"));
598
 
  group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
599
 
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
600
 
  gtk_widget_show (button);
601
 
 
602
 
  if (Current.Units == RADIANS)
603
 
    gtk_button_clicked (GTK_BUTTON (button));
604
 
 
605
 
  g_signal_connect (button, "clicked",
606
 
                    G_CALLBACK (rcm_switch_to_radians),
607
 
                    NULL);
608
 
 
609
 
  button = gtk_radio_button_new_with_label (group, _("Radians/Pi"));
610
 
  group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
611
 
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
612
 
  gtk_widget_show (button);
613
 
 
614
 
  if (Current.Units == RADIANS_OVER_PI)
615
 
    gtk_button_clicked (GTK_BUTTON (button));
616
 
 
617
 
  g_signal_connect (button, "clicked",
618
 
                    G_CALLBACK (rcm_switch_to_radians_over_PI),
619
 
                    NULL);
620
 
 
621
 
  button = gtk_radio_button_new_with_label (group, _("Degrees"));
622
 
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
623
 
  gtk_widget_show (button);
624
 
 
625
 
  if (Current.Units == DEGREES)
626
 
    gtk_button_clicked (GTK_BUTTON (button));
627
 
 
628
 
  g_signal_connect (button, "clicked",
629
 
                    G_CALLBACK (rcm_switch_to_degrees),
630
 
                    NULL);
631
 
 
632
 
  return frame;
633
 
}
634
 
 
635
 
 
636
 
/* create and call main dialog */
637
 
 
638
 
gboolean
639
 
rcm_dialog (void)
640
 
{
641
 
  GtkWidget *dialog;
642
 
  GtkWidget *hbox;
643
 
  GtkWidget *notebook;
644
 
  GtkWidget *previews;
645
 
  gboolean   run;
646
 
 
647
 
  Current.Bna = g_new (RcmBna, 1);
648
 
 
649
 
  gimp_ui_init (PLUG_IN_BINARY, TRUE);
650
 
  rcm_stock_init ();
651
 
 
652
 
  dialog = gimp_dialog_new (_("Rotate Colors"), PLUG_IN_BINARY,
653
 
                            NULL, 0,
654
 
                            gimp_standard_help_func, PLUG_IN_PROC,
655
 
 
656
 
                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
657
 
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,
658
 
 
659
 
                            NULL);
660
 
 
661
 
  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
662
 
                                           GTK_RESPONSE_OK,
663
 
                                           GTK_RESPONSE_CANCEL,
664
 
                                           -1);
665
 
 
666
 
  gimp_window_set_transient (GTK_WINDOW (dialog));
667
 
 
668
 
  Current.Bna->dlg = dialog;
669
 
 
670
 
  /* Create sub-dialogs */
671
 
  Current.reduced = rcm_reduce_image (Current.drawable, Current.mask,
672
 
                                      MAX_PREVIEW_SIZE, Current.Slctn);
673
 
 
674
 
  Current.Bna->bna_frame = previews = rcm_create_previews ();
675
 
 
676
 
  /* H-Box */
677
 
  hbox = gtk_hbox_new (FALSE, 12);
678
 
  gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);
679
 
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox,
680
 
                      TRUE, TRUE, 0);
681
 
  gtk_widget_show (hbox);
682
 
 
683
 
  gtk_box_pack_start (GTK_BOX (hbox), previews, TRUE, TRUE, 0);
684
 
 
685
 
  /* Notebook */
686
 
  notebook = gtk_notebook_new ();
687
 
  gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
688
 
  gtk_box_pack_start (GTK_BOX (hbox), notebook, TRUE, TRUE, 0);
689
 
  gtk_widget_show (notebook);
690
 
 
691
 
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), rcm_create_main (),
692
 
                            gtk_label_new (_("Main Options")));
693
 
 
694
 
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), rcm_create_gray (),
695
 
                            gtk_label_new (_("Gray Options")));
696
 
 
697
 
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), rcm_create_units (),
698
 
                            gtk_label_new (_("Units")));
699
 
 
700
 
  gtk_widget_show (dialog);
701
 
 
702
 
  rcm_render_circle (Current.From->preview, SUM, MARGIN);
703
 
  rcm_render_circle (Current.To->preview, SUM, MARGIN);
704
 
  rcm_render_circle (Current.Gray->preview, GRAY_SUM, GRAY_MARGIN);
705
 
 
706
 
  run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
707
 
 
708
 
  gtk_widget_destroy (dialog);
709
 
 
710
 
  return run;
711
 
}