colorbutton: Make color buttons activatable again

The activation is simply forwarded to the toggle button
within.
This commit is contained in:
Matthias Clasen 2021-07-05 10:10:19 -04:00
parent 271afb7eab
commit fc65d6393a

View File

@ -91,6 +91,7 @@ struct _GtkColorButtonClass {
GtkWidgetClass parent_class;
void (* color_set) (GtkColorButton *cp);
void (* activate) (GtkColorButton *self);
};
/* Properties */
@ -108,6 +109,7 @@ enum
enum
{
COLOR_SET,
ACTIVATE,
LAST_SIGNAL
};
@ -137,6 +139,12 @@ G_DEFINE_TYPE_WITH_CODE (GtkColorButton, gtk_color_button, GTK_TYPE_WIDGET,
G_IMPLEMENT_INTERFACE (GTK_TYPE_COLOR_CHOOSER,
gtk_color_button_iface_init))
static void
gtk_color_button_activate (GtkColorButton *self)
{
gtk_widget_activate (self->button);
}
static void
gtk_color_button_class_init (GtkColorButtonClass *klass)
{
@ -155,6 +163,7 @@ gtk_color_button_class_init (GtkColorButtonClass *klass)
widget_class->root = gtk_color_button_root;
klass->color_set = NULL;
klass->activate = gtk_color_button_activate;
g_object_class_override_property (gobject_class, PROP_RGBA, "rgba");
g_object_class_override_property (gobject_class, PROP_USE_ALPHA, "use-alpha");
@ -194,6 +203,28 @@ gtk_color_button_class_init (GtkColorButtonClass *klass)
NULL,
G_TYPE_NONE, 0);
/**
* GtkColorButton::activate:
* @widget: the object which received the signal.
*
* Emitted to when the color button is activated.
*
* The `::activate` signal on `GtkMenuButton` is an action signal and
* emitting it causes the button to pop up its dialog.
*
* Since: 4.4
*/
color_button_signals[ACTIVATE] =
g_signal_new (I_ ("activate"),
G_OBJECT_CLASS_TYPE (gobject_class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkColorButtonClass, activate),
NULL, NULL,
NULL,
G_TYPE_NONE, 0);
gtk_widget_class_set_activate_signal (widget_class, color_button_signals[ACTIVATE]);
/**
* GtkColorButton:show-editor:
*