[gtk: 1/4] combobox: Make combo box activatable
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 1/4] combobox: Make combo box activatable
- Date: Thu, 4 Nov 2021 01:19:44 +0000 (UTC)
commit c4df987eef4d86199e7ea1024b02b9fa1399fe7b
Author: Maximiliano Sandoval R <msandova gnome org>
Date: Fri Sep 10 15:42:15 2021 +0200
combobox: Make combo box activatable
The activation is simply forwarded to the button
within.
gtk/gtkcombobox.c | 32 ++++++++++++++++++++++++++++++++
gtk/gtkcombobox.h | 3 ++-
2 files changed, 34 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index 70d0f637a3..f007d841f9 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -172,6 +172,7 @@ typedef struct
*/
enum {
+ ACTIVATE,
CHANGED,
MOVE_ACTIVE,
POPUP,
@@ -346,6 +347,14 @@ gtk_combo_box_measure (GtkWidget *widget,
minimum_baseline, natural_baseline);
}
+static void
+gtk_combo_box_activate (GtkComboBox *combo_box)
+{
+ GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
+
+ gtk_widget_activate (priv->button);
+}
+
static void
gtk_combo_box_size_allocate (GtkWidget *widget,
int width,
@@ -419,9 +428,32 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
object_class->set_property = gtk_combo_box_set_property;
object_class->get_property = gtk_combo_box_get_property;
+ klass->activate = gtk_combo_box_activate;
klass->format_entry_text = gtk_combo_box_format_entry_text;
/* signals */
+ /**
+ * GtkComboBox::activate:
+ * @widget: the object which received the signal.
+ *
+ * Emitted to when the combo box is activated.
+ *
+ * The `::activate` signal on `GtkComboBox` is an action signal and
+ * emitting it causes the combo box to pop up its dropdown.
+ *
+ * Since: 4.6
+ */
+ combo_box_signals[ACTIVATE] =
+ g_signal_new (I_ ("activate"),
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (GtkComboBoxClass, activate),
+ NULL, NULL,
+ NULL,
+ G_TYPE_NONE, 0);
+
+ gtk_widget_class_set_activate_signal (widget_class, combo_box_signals[ACTIVATE]);
+
/**
* GtkComboBox::changed:
* @widget: the object which received the signal
diff --git a/gtk/gtkcombobox.h b/gtk/gtkcombobox.h
index 9631e2043e..fde7e89653 100644
--- a/gtk/gtkcombobox.h
+++ b/gtk/gtkcombobox.h
@@ -60,10 +60,11 @@ struct _GtkComboBoxClass
void (* changed) (GtkComboBox *combo_box);
char *(* format_entry_text) (GtkComboBox *combo_box,
const char *path);
+ void (* activate) (GtkComboBox *combo_box);
/*< private >*/
- gpointer padding[8];
+ gpointer padding[7];
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]