65
74
static void gimp_color_button_class_init (GimpColorButtonClass *klass);
66
75
static void gimp_color_button_init (GimpColorButton *button,
67
76
GimpColorButtonClass *klass);
78
static void gimp_color_button_get_property (GObject *object,
82
static void gimp_color_button_set_property (GObject *object,
86
static void gimp_color_button_finalize (GObject *object);
69
88
static void gimp_color_button_destroy (GtkObject *object);
71
90
static gboolean gimp_color_button_button_press (GtkWidget *widget,
88
107
gpointer help_data);
91
static GtkActionEntry actions[] =
110
static const GtkActionEntry actions[] =
93
112
{ "color-button-popup", NULL,
94
113
"Color Button Menu", NULL, NULL,
124
143
static GType button_type = 0;
128
static const GTypeInfo button_info =
147
const GTypeInfo button_info =
130
149
sizeof (GimpColorButtonClass),
131
150
(GBaseInitFunc) NULL,
150
169
gimp_color_button_class_init (GimpColorButtonClass *klass)
152
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
153
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
154
GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass);
171
GObjectClass *object_class = G_OBJECT_CLASS (klass);
172
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
173
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
174
GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass);
156
177
parent_class = g_type_class_peek_parent (klass);
158
179
gimp_color_button_signals[COLOR_CHANGED] =
159
g_signal_new ("color_changed",
180
g_signal_new ("color-changed",
160
181
G_TYPE_FROM_CLASS (klass),
161
182
G_SIGNAL_RUN_FIRST,
162
183
G_STRUCT_OFFSET (GimpColorButtonClass, color_changed),
164
185
g_cclosure_marshal_VOID__VOID,
167
object_class->destroy = gimp_color_button_destroy;
188
object_class->get_property = gimp_color_button_get_property;
189
object_class->set_property = gimp_color_button_set_property;
190
object_class->finalize = gimp_color_button_finalize;
192
gtk_object_class->destroy = gimp_color_button_destroy;
169
194
widget_class->button_press_event = gimp_color_button_button_press;
170
195
widget_class->state_changed = gimp_color_button_state_changed;
174
199
klass->color_changed = NULL;
175
200
klass->get_action_type = gimp_color_button_get_action_type;
202
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
205
* GimpColorButton:title:
207
* The title to be used for the color selection dialog.
211
g_object_class_install_property (object_class, PROP_TITLE,
212
g_param_spec_string ("title", NULL, NULL,
214
GIMP_PARAM_READWRITE |
215
G_PARAM_CONSTRUCT_ONLY));
217
* GimpColorButton:color:
219
* The color displayed in the button's color area.
223
g_object_class_install_property (object_class, PROP_COLOR,
224
gimp_param_spec_rgb ("color", NULL, NULL,
226
GIMP_PARAM_READWRITE |
229
* GimpColorButton:type:
231
* The type of the button's color area.
235
g_object_class_install_property (object_class, PROP_TYPE,
236
g_param_spec_enum ("type", NULL, NULL,
237
GIMP_TYPE_COLOR_AREA_TYPE,
238
GIMP_COLOR_AREA_FLAT,
239
GIMP_PARAM_READWRITE |
242
* GimpColorButton:continuous-update:
244
* The update policy of the color button.
248
g_object_class_install_property (object_class, PROP_UPDATE,
249
g_param_spec_boolean ("continuous-update",
182
260
GtkActionGroup *group;
183
261
GtkUIManager *ui_manager;
187
button->continuous_update = FALSE;
188
button->title = NULL;
189
button->dialog = NULL;
191
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
192
button->color_area = gimp_color_area_new (&color, FALSE, GDK_BUTTON2_MASK);
193
g_signal_connect (button->color_area, "color_changed",
264
button->title = NULL;
265
button->dialog = NULL;
267
button->color_area = g_object_new (GIMP_TYPE_COLOR_AREA,
268
"drag-mask", GDK_BUTTON1_MASK,
271
g_signal_connect (button->color_area, "color-changed",
194
272
G_CALLBACK (gimp_color_button_area_changed),
254
332
button->title = NULL;
335
G_OBJECT_CLASS (parent_class)->finalize (object);
339
gimp_color_button_get_property (GObject *object,
344
GimpColorButton *button = GIMP_COLOR_BUTTON (object);
349
g_value_set_string (value, button->title);
353
g_object_get_property (G_OBJECT (button->color_area), "color", value);
357
g_object_get_property (G_OBJECT (button->color_area), "type", value);
361
g_value_set_boolean (value, button->continuous_update);
365
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
371
gimp_color_button_set_property (GObject *object,
376
GimpColorButton *button = GIMP_COLOR_BUTTON (object);
381
g_free (button->title);
382
button->title = g_value_dup_string (value);
386
g_object_set_property (G_OBJECT (button->color_area), "color", value);
390
g_object_set_property (G_OBJECT (button->color_area), "type", value);
394
gimp_color_button_set_update (button, g_value_get_boolean (value));
398
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
404
gimp_color_button_destroy (GtkObject *object)
406
GimpColorButton *button = GIMP_COLOR_BUTTON (object);
257
408
if (button->dialog)
259
410
gtk_widget_destroy (button->dialog);
328
479
dialog = color_button->dialog =
329
480
gimp_dialog_new (color_button->title, COLOR_SELECTION_KEY,
330
GTK_WIDGET (button), 0,
481
gtk_widget_get_toplevel (GTK_WIDGET (button)), 0,
331
482
gimp_color_button_help_func, NULL,
333
484
GIMP_STOCK_RESET, RESPONSE_RESET,
490
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
339
496
g_signal_connect (dialog, "response",
340
497
G_CALLBACK (gimp_color_button_dialog_response),
353
510
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), selection);
354
511
gtk_widget_show (selection);
356
g_signal_connect (selection, "color_changed",
513
g_signal_connect (selection, "color-changed",
357
514
G_CALLBACK (gimp_color_button_selection_changed),
386
543
* This returns a button with a preview showing the color.
387
544
* When the button is clicked a GtkColorSelectionDialog is opened.
388
545
* If the user changes the color the new color is written into the
389
* array that was used to pass the initial color and the "color_changed"
546
* array that was used to pass the initial color and the "color-changed"
390
547
* signal is emitted.
392
549
* Returns: Pointer to the new #GimpColorButton widget.
403
560
g_return_val_if_fail (color != NULL, NULL);
405
button = g_object_new (GIMP_TYPE_COLOR_BUTTON, NULL);
407
button->title = g_strdup (title);
562
button = g_object_new (GIMP_TYPE_COLOR_BUTTON,
409
568
gtk_widget_set_size_request (GTK_WIDGET (button->color_area), width, height);
411
gimp_color_area_set_type (GIMP_COLOR_AREA (button->color_area), type);
412
gimp_color_area_set_color (GIMP_COLOR_AREA (button->color_area), color);
414
570
return GTK_WIDGET (button);
502
662
* @button: A #GimpColorButton widget.
503
663
* @continuous: The new setting of the @continuous_update property.
505
* When set to #TRUE, the @button will emit the "color_changed"
665
* When set to #TRUE, the @button will emit the "color-changed"
506
666
* continuously while the color is changed in the color selection