dropdown: Make DropDown activatable

The activation is simply forwarded to the button
within.
This commit is contained in:
Maximiliano Sandoval R 2021-09-10 15:42:47 +02:00
parent c4df987eef
commit 3918cdd989
No known key found for this signature in database
GPG Key ID: D64A8D747F6FE706

View File

@ -126,9 +126,16 @@ enum
N_PROPS
};
enum
{
ACTIVATE,
LAST_SIGNAL
};
G_DEFINE_TYPE (GtkDropDown, gtk_drop_down, GTK_TYPE_WIDGET)
static GParamSpec *properties[N_PROPS] = { NULL, };
static guint signals[LAST_SIGNAL] = { 0 };
static void
button_toggled (GtkWidget *widget,
@ -203,6 +210,12 @@ selection_changed (GtkSingleSelection *selection,
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SELECTED_ITEM]);
}
static void
gtk_drop_down_activate (GtkDropDown *self)
{
gtk_widget_activate (self->button);
}
static void
update_filter (GtkDropDown *self)
{
@ -547,6 +560,28 @@ gtk_drop_down_class_init (GtkDropDownClass *klass)
g_object_class_install_properties (gobject_class, N_PROPS, properties);
/**
* GtkDropDown::activate:
* @widget: the object which received the signal.
*
* Emitted to when the drop down is activated.
*
* The `::activate` signal on `GtkDropDown` is an action signal and
* emitting it causes the drop down to pop up its dropdown.
*
* Since: 4.6
*/
signals[ACTIVATE] =
g_signal_new_class_handler (I_ ("activate"),
G_OBJECT_CLASS_TYPE (gobject_class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
G_CALLBACK (gtk_drop_down_activate),
NULL, NULL,
NULL,
G_TYPE_NONE, 0);
gtk_widget_class_set_activate_signal (widget_class, signals[ACTIVATE]);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/ui/gtkdropdown.ui");
gtk_widget_class_bind_template_child (widget_class, GtkDropDown, arrow);
gtk_widget_class_bind_template_child (widget_class, GtkDropDown, button);