78
71
static void gimp_selection_options_reset (GimpToolOptions *tool_options);
80
static void selection_options_fixed_mode_notify (GimpSelectionOptions *options,
82
GtkWidget *fixed_box);
85
static GimpToolOptionsClass *parent_class = NULL;
89
gimp_selection_options_get_type (void)
91
static GType type = 0;
95
static const GTypeInfo info =
97
sizeof (GimpSelectionOptionsClass),
99
(GBaseFinalizeFunc) NULL,
100
(GClassInitFunc) gimp_selection_options_class_init,
101
NULL, /* class_finalize */
102
NULL, /* class_data */
103
sizeof (GimpSelectionOptions),
105
(GInstanceInitFunc) NULL
108
type = g_type_register_static (GIMP_TYPE_TOOL_OPTIONS,
109
"GimpSelectionOptions",
74
G_DEFINE_TYPE (GimpSelectionOptions, gimp_selection_options,
75
GIMP_TYPE_TOOL_OPTIONS)
77
#define parent_class gimp_selection_options_parent_class
117
81
gimp_selection_options_class_init (GimpSelectionOptionsClass *klass)
130
92
"operation", NULL,
131
93
GIMP_TYPE_CHANNEL_OPS,
132
94
GIMP_CHANNEL_OP_REPLACE,
95
GIMP_PARAM_STATIC_STRINGS);
134
96
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_ANTIALIAS,
136
98
N_("Smooth edges"),
100
GIMP_PARAM_STATIC_STRINGS);
139
101
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_FEATHER,
104
GIMP_PARAM_STATIC_STRINGS);
143
105
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_FEATHER_RADIUS,
144
106
"feather-radius", NULL,
145
107
0.0, 100.0, 10.0,
108
GIMP_PARAM_STATIC_STRINGS);
148
110
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SELECT_TRANSPARENT,
149
111
"select-transparent",
150
112
N_("Allow completely transparent regions "
151
113
"to be selected"),
115
GIMP_PARAM_STATIC_STRINGS);
154
116
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAMPLE_MERGED,
156
118
N_("Base selection on all visible layers"),
120
GIMP_PARAM_STATIC_STRINGS);
159
121
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_THRESHOLD,
161
123
N_("Maximum color difference"),
162
124
0.0, 255.0, 15.0,
165
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_AUTO_SHRINK,
169
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHRINK_MERGED,
171
N_("Use all visible layers when shrinking "
176
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_FIXED_MODE,
178
GIMP_TYPE_RECT_SELECT_MODE,
179
GIMP_RECT_SELECT_MODE_FREE,
181
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_FIXED_WIDTH,
183
0.0, GIMP_MAX_IMAGE_SIZE, 1.0,
185
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_FIXED_HEIGHT,
186
"fixed-height", NULL,
187
0.0, GIMP_MAX_IMAGE_SIZE, 1.0,
189
GIMP_CONFIG_INSTALL_PROP_UNIT (object_class, PROP_FIXED_UNIT,
191
TRUE, TRUE, GIMP_UNIT_PIXEL,
125
GIMP_PARAM_STATIC_STRINGS);
126
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_SELECT_CRITERION,
127
"select-criterion", NULL,
128
GIMP_TYPE_SELECT_CRITERION,
129
GIMP_SELECT_CRITERION_COMPOSITE,
130
GIMP_PARAM_STATIC_STRINGS);
194
132
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_INTERACTIVE,
195
133
"interactive", NULL,
135
GIMP_PARAM_STATIC_STRINGS);
139
gimp_selection_options_init (GimpSelectionOptions *options)
345
254
GIMP_TOOL_OPTIONS_CLASS (parent_class)->reset (tool_options);
258
gimp_selection_options_get_modifier (GimpChannelOps operation)
260
GdkModifierType mod = 0;
264
case GIMP_CHANNEL_OP_ADD:
265
mod = GDK_SHIFT_MASK;
268
case GIMP_CHANNEL_OP_SUBTRACT:
269
mod = GDK_CONTROL_MASK;
272
case GIMP_CHANNEL_OP_REPLACE:
276
case GIMP_CHANNEL_OP_INTERSECT:
277
mod = GDK_CONTROL_MASK | GDK_SHIFT_MASK;
281
return gimp_get_mod_string (mod);
349
285
gimp_selection_options_gui (GimpToolOptions *tool_options)
351
287
GObject *config = G_OBJECT (tool_options);
352
288
GimpSelectionOptions *options = GIMP_SELECTION_OPTIONS (tool_options);
289
GtkWidget *vbox = gimp_tool_options_gui (tool_options);
354
290
GtkWidget *button;
356
vbox = gimp_tool_options_gui (tool_options);
358
292
/* the selection operation radio buttons */
361
295
GtkWidget *label;
364
300
hbox = gimp_prop_enum_stock_box_new (config, "operation",
365
301
"gimp-selection", 0, 0);
366
302
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
367
303
gtk_widget_show (hbox);
369
list = gtk_container_get_children (GTK_CONTAINER (hbox));
370
gtk_box_reorder_child (GTK_BOX (hbox), GTK_WIDGET (list->next->next->data),
305
children = gtk_container_get_children (GTK_CONTAINER (hbox));
307
/* add modifier keys to the tooltips */
308
for (list = children, i = 0; list; list = list->next, i++)
310
GtkWidget *button = list->data;
311
GtkTooltipsData *data = gtk_tooltips_data_get (button);
312
const gchar *modifier = gimp_selection_options_get_modifier (i);
317
if (data && data->tip_text)
319
gchar *tip = g_strdup_printf ("%s (%s)", data->tip_text, modifier);
321
gimp_help_set_help_data (button, tip, NULL);
326
gimp_help_set_help_data (button, modifier, NULL);
330
/* move GIMP_CHANNEL_OP_REPLACE to the front */
331
gtk_box_reorder_child (GTK_BOX (hbox),
332
GTK_WIDGET (children->next->next->data), 0);
334
g_list_free (children);
374
336
label = gtk_label_new (_("Mode:"));
375
337
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
383
345
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
384
346
gtk_widget_show (button);
386
if (tool_options->tool_info->tool_type == GIMP_TYPE_RECT_SELECT_TOOL)
348
if (tool_options->tool_info->tool_type == GIMP_TYPE_FOREGROUND_SELECT_TOOL)
387
349
gtk_widget_set_sensitive (button, FALSE);
351
options->antialias_toggle = button;
389
353
/* the feather frame */
391
355
GtkWidget *frame;
392
356
GtkWidget *table;
394
frame = gimp_frame_new (NULL);
358
table = gtk_table_new (1, 3, FALSE);
359
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
361
frame = gimp_prop_expanding_frame_new (config, "feather",
395
364
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
396
365
gtk_widget_show (frame);
398
button = gimp_prop_check_button_new (config, "feather",
400
gtk_frame_set_label_widget (GTK_FRAME (frame), button);
401
gtk_widget_show (button);
403
table = gtk_table_new (1, 3, FALSE);
404
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
405
gtk_container_add (GTK_CONTAINER (frame), table);
406
if (options->feather)
407
gtk_widget_show (table);
409
g_signal_connect_object (button, "toggled",
410
G_CALLBACK (gimp_toggle_button_set_visible),
413
367
/* the feather radius scale */
414
368
gimp_prop_scale_entry_new (config, "feather-radius",
415
369
GTK_TABLE (table), 0, 0,
468
423
FALSE, 0.0, 0.0);
471
/* widgets for fixed size select */
472
if (tool_options->tool_info->tool_type == GIMP_TYPE_RECT_SELECT_TOOL ||
473
tool_options->tool_info->tool_type == GIMP_TYPE_ELLIPSE_SELECT_TOOL)
480
GtkWidget *width_spinbutton;
481
GtkWidget *height_spinbutton;
483
frame = gimp_frame_new (NULL);
484
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
485
gtk_widget_show (frame);
487
button = gimp_prop_check_button_new (config, "auto-shrink",
488
_("Auto shrink selection"));
489
gtk_frame_set_label_widget (GTK_FRAME (frame), button);
490
gtk_widget_show (button);
492
vbox2 = gtk_vbox_new (FALSE, 0);
493
gtk_container_add (GTK_CONTAINER (frame), vbox2);
494
if (options->auto_shrink)
495
gtk_widget_show (vbox2);
497
g_signal_connect_object (button, "toggled",
498
G_CALLBACK (gimp_toggle_button_set_visible),
501
button = gimp_prop_check_button_new (config, "shrink-merged",
503
gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
504
gtk_widget_show (button);
506
frame = gimp_frame_new (NULL);
507
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
508
gtk_widget_show (frame);
510
combo = gimp_prop_enum_combo_box_new (config, "fixed-mode", 0, 0);
511
gtk_frame_set_label_widget (GTK_FRAME (frame), combo);
512
gtk_widget_show (combo);
514
table = gtk_table_new (2, 3, FALSE);
515
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
516
gtk_container_add (GTK_CONTAINER (frame), table);
518
gtk_widget_set_sensitive (table,
519
options->fixed_mode != GIMP_RECT_SELECT_MODE_FREE);
520
g_signal_connect (config, "notify::fixed-mode",
521
G_CALLBACK (selection_options_fixed_mode_notify),
524
width_spinbutton = gimp_prop_spin_button_new (config, "fixed-width",
526
gtk_entry_set_width_chars (GTK_ENTRY (width_spinbutton), 6);
528
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
529
_("Width:"), 0.0, 0.5,
530
width_spinbutton, 1, FALSE);
532
height_spinbutton = gimp_prop_spin_button_new (config, "fixed-height",
534
gtk_entry_set_width_chars (GTK_ENTRY (height_spinbutton), 6);
425
/* the select criterion combo */
426
combo = gimp_prop_enum_combo_box_new (config, "select-criterion", 0, 0);
536
427
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
537
_("Height:"), 0.0, 0.5,
538
height_spinbutton, 1, FALSE);
540
menu = gimp_prop_unit_menu_new (config, "fixed-unit", "%a");
541
gtk_table_attach (GTK_TABLE (table), menu, 2, 3, 1, 2,
542
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
543
gtk_widget_show (menu);
545
g_object_set_data (G_OBJECT (menu), "set_digits", width_spinbutton);
546
g_object_set_data (G_OBJECT (width_spinbutton), "set_digits",
548
gimp_unit_menu_set_pixel_digits (GIMP_UNIT_MENU (menu), 0);
550
gtk_widget_show (table);
428
_("Select by:"), 0.0, 0.5,
557
/* private functions */
560
selection_options_fixed_mode_notify (GimpSelectionOptions *options,
562
GtkWidget *fixed_box)
564
gtk_widget_set_sensitive (fixed_box,
565
options->fixed_mode != GIMP_RECT_SELECT_MODE_FREE);