51
52
UPDATE_NOTEBOOK = 1 << 0,
52
53
UPDATE_SCALES = 1 << 1,
53
UPDATE_NEW_COLOR = 1 << 2
54
UPDATE_ENTRY = 1 << 2,
58
#define UPDATE_ALL (UPDATE_NOTEBOOK | \
63
static void gimp_color_selection_class_init (GimpColorSelectionClass *klass);
64
static void gimp_color_selection_init (GimpColorSelection *selection);
76
static void gimp_color_selection_set_property (GObject *object,
66
81
static void gimp_color_selection_switch_page (GtkWidget *widget,
67
82
GtkNotebookPage *page,
75
90
const GimpRGB *rgb,
76
91
const GimpHSV *hsv,
77
92
GimpColorSelection *selection);
93
static void gimp_color_selection_color_picked (GtkWidget *widget,
95
GimpColorSelection *selection);
96
static void gimp_color_selection_entry_changed (GimpColorHexEntry *entry,
97
GimpColorSelection *selection);
78
98
static void gimp_color_selection_channel_changed (GimpColorSelector *selector,
79
99
GimpColorSelectorChannel channel,
80
100
GimpColorSelection *selection);
85
105
UpdateType update);
88
static GtkVBoxClass *parent_class = NULL;
90
static guint selection_signals[LAST_SIGNAL] = { 0 };
94
gimp_color_selection_get_type (void)
96
static GType selection_type = 0;
100
static const GTypeInfo selection_info =
102
sizeof (GimpColorSelectionClass),
103
(GBaseInitFunc) NULL,
104
(GBaseFinalizeFunc) NULL,
105
(GClassInitFunc) gimp_color_selection_class_init,
106
NULL, /* class_finalize */
107
NULL, /* class_data */
108
sizeof (GimpColorSelection),
110
(GInstanceInitFunc) gimp_color_selection_init,
113
selection_type = g_type_register_static (GTK_TYPE_VBOX,
114
"GimpColorSelection",
118
return selection_type;
108
G_DEFINE_TYPE (GimpColorSelection, gimp_color_selection, GTK_TYPE_VBOX)
110
#define parent_class gimp_color_selection_parent_class
112
static guint selection_signals[LAST_SIGNAL] = { 0 };
122
116
gimp_color_selection_class_init (GimpColorSelectionClass *klass)
124
parent_class = g_type_class_peek_parent (klass);
118
GObjectClass *object_class = G_OBJECT_CLASS (klass);
120
object_class->set_property = gimp_color_selection_set_property;
122
klass->color_changed = NULL;
124
g_object_class_install_property (object_class, PROP_CONFIG,
125
g_param_spec_object ("config",
127
GIMP_TYPE_COLOR_CONFIG,
126
130
selection_signals[COLOR_CHANGED] =
127
g_signal_new ("color_changed",
131
g_signal_new ("color-changed",
128
132
G_TYPE_FROM_CLASS (klass),
129
133
G_SIGNAL_RUN_FIRST,
130
134
G_STRUCT_OFFSET (GimpColorSelectionClass, color_changed),
180
187
gtk_widget_show (selection->notebook);
182
g_signal_connect (selection->notebook, "color_changed",
189
g_signal_connect (selection->notebook, "color-changed",
183
190
G_CALLBACK (gimp_color_selection_notebook_changed),
185
192
g_signal_connect (GIMP_COLOR_NOTEBOOK (selection->notebook)->notebook,
187
194
G_CALLBACK (gimp_color_selection_switch_page),
212
219
gtk_container_add (GTK_CONTAINER (frame), selection->new_color);
213
220
gtk_widget_show (selection->new_color);
215
g_signal_connect (selection->new_color, "color_changed",
216
G_CALLBACK (gimp_color_selection_new_color_changed),
222
g_signal_connect (selection->new_color, "color-changed",
223
G_CALLBACK (gimp_color_selection_new_color_changed),
219
226
/* The old color area */
220
227
frame = gtk_frame_new (NULL);
254
261
gtk_widget_show (selection->scales);
256
g_signal_connect (selection->scales, "channel_changed",
263
g_signal_connect (selection->scales, "channel-changed",
257
264
G_CALLBACK (gimp_color_selection_channel_changed),
259
g_signal_connect (selection->scales, "color_changed",
266
g_signal_connect (selection->scales, "color-changed",
260
267
G_CALLBACK (gimp_color_selection_scales_changed),
270
hbox = gtk_hbox_new (FALSE, 6);
271
gtk_box_pack_start (GTK_BOX (selection->right_vbox), hbox, FALSE, FALSE, 0);
272
gtk_widget_show (hbox);
274
/* The color picker */
275
button = gimp_pick_button_new ();
276
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
277
gtk_widget_show (button);
279
g_signal_connect (button, "color-picked",
280
G_CALLBACK (gimp_color_selection_color_picked),
283
/* The hex triplet entry */
284
entry = gimp_color_hex_entry_new ();
285
gimp_help_set_help_data (entry,
286
_("Hexadecimal color notation as used in HTML and "
287
"CSS. This entry also accepts CSS color names."),
289
gtk_box_pack_end (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
290
gtk_widget_show (entry);
292
label = gtk_label_new_with_mnemonic (_("HTML _notation:"));
293
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
294
gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
295
gtk_widget_show (label);
297
g_object_set_data (G_OBJECT (selection), "color-hex-entry", entry);
299
g_signal_connect (entry, "color-changed",
300
G_CALLBACK (gimp_color_selection_entry_changed),
305
gimp_color_selection_set_property (GObject *object,
310
GimpColorSelection *selection = GIMP_COLOR_SELECTION (object);
315
gimp_color_selection_set_config (selection, g_value_get_object (value));
319
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
265
326
* gimp_color_selection_new:
430
488
g_signal_emit (selection, selection_signals[COLOR_CHANGED], 0);
492
* gimp_color_selection_set_config:
496
* Sets the color management configuration to use with this color selection.
501
gimp_color_selection_set_config (GimpColorSelection *selection,
502
GimpColorConfig *config)
504
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
505
g_return_if_fail (config == NULL || GIMP_IS_COLOR_CONFIG (config));
507
gimp_color_selector_set_config (GIMP_COLOR_SELECTOR (selection->notebook),
509
gimp_color_selector_set_config (GIMP_COLOR_SELECTOR (selection->scales),
434
513
/* private functions */
471
551
selection->rgb = *rgb;
472
552
selection->hsv = *hsv;
474
gimp_color_selection_update (selection, UPDATE_NOTEBOOK | UPDATE_NEW_COLOR);
554
gimp_color_selection_update (selection,
555
UPDATE_ENTRY | UPDATE_NOTEBOOK | UPDATE_COLOR);
556
gimp_color_selection_color_changed (selection);
560
gimp_color_selection_color_picked (GtkWidget *widget,
562
GimpColorSelection *selection)
564
gimp_color_selection_set_color (selection, rgb);
568
gimp_color_selection_entry_changed (GimpColorHexEntry *entry,
569
GimpColorSelection *selection)
571
gimp_color_hex_entry_get_color (entry, &selection->rgb);
573
gimp_rgb_to_hsv (&selection->rgb, &selection->hsv);
575
gimp_color_selection_update (selection,
576
UPDATE_NOTEBOOK | UPDATE_SCALES | UPDATE_COLOR);
475
577
gimp_color_selection_color_changed (selection);
493
595
gimp_color_area_get_color (GIMP_COLOR_AREA (widget), &selection->rgb);
494
596
gimp_rgb_to_hsv (&selection->rgb, &selection->hsv);
496
gimp_color_selection_update (selection, UPDATE_NOTEBOOK | UPDATE_SCALES);
598
gimp_color_selection_update (selection,
599
UPDATE_NOTEBOOK | UPDATE_SCALES | UPDATE_ENTRY);
497
600
gimp_color_selection_color_changed (selection);
534
if (update & UPDATE_NEW_COLOR)
637
if (update & UPDATE_ENTRY)
639
GimpColorHexEntry *entry;
641
entry = g_object_get_data (G_OBJECT (selection), "color-hex-entry");
643
g_signal_handlers_block_by_func (entry,
644
gimp_color_selection_entry_changed,
647
gimp_color_hex_entry_set_color (entry, &selection->rgb);
649
g_signal_handlers_unblock_by_func (entry,
650
gimp_color_selection_entry_changed,
654
if (update & UPDATE_COLOR)
536
656
g_signal_handlers_block_by_func (selection->new_color,
537
657
gimp_color_selection_new_color_changed,
540
660
gimp_color_area_set_color (GIMP_COLOR_AREA (selection->new_color),
543
663
g_signal_handlers_unblock_by_func (selection->new_color,
544
gimp_color_selection_new_color_changed,
664
gimp_color_selection_new_color_changed,