diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2018-06-26 15:44:13 +0200 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2018-07-30 13:14:12 +0200 |
commit | ca8008e2c9c172feed7879f36ca846445ccda749 (patch) | |
tree | ab1c6db72ce3384a1db62cbebbfbbab3e44e3efa | |
parent | 0d7b4ecb14685680b84d39fbd6e3075e79e2546d (diff) | |
download | gtk+-ca8008e2c9c172feed7879f36ca846445ccda749.tar.gz |
gtkcombobox: Use keycontroller on GtkCellEditable implementation
-rw-r--r-- | gtk/gtkcombobox.c | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c index caf4042640..792d2ebb28 100644 --- a/gtk/gtkcombobox.c +++ b/gtk/gtkcombobox.c @@ -2734,19 +2734,12 @@ gtk_combo_box_dispose (GObject* object) } static gboolean -gtk_cell_editable_event (GtkWidget *widget, - GdkEvent *event, - gpointer data) +gtk_cell_editable_key_pressed (GtkEventControllerKey *key, + guint keyval, + guint keycode, + GdkModifierType modifiers, + GtkComboBox *combo_box) { - GtkComboBox *combo_box = GTK_COMBO_BOX (data); - guint keyval; - - if (gdk_event_get_event_type (event) != GDK_KEY_PRESS) - return GDK_EVENT_PROPAGATE; - - if (!gdk_event_get_keyval (event, &keyval)) - return GDK_EVENT_PROPAGATE; - if (keyval == GDK_KEY_Escape) { g_object_set (combo_box, @@ -2776,25 +2769,25 @@ gtk_combo_box_start_editing (GtkCellEditable *cell_editable, { GtkComboBox *combo_box = GTK_COMBO_BOX (cell_editable); GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box); + GtkEventController *controller; GtkWidget *child; priv->is_cell_renderer = TRUE; + controller = gtk_event_controller_key_new (); + g_signal_connect_object (controller, "key-pressed", + G_CALLBACK (gtk_cell_editable_key_pressed), + cell_editable, 0); + if (priv->cell_view) { - g_signal_connect_object (priv->button, "event", - G_CALLBACK (gtk_cell_editable_event), - cell_editable, 0); - + gtk_widget_add_controller (priv->button, controller); gtk_widget_grab_focus (priv->button); } else { child = gtk_bin_get_child (GTK_BIN (combo_box)); - - g_signal_connect_object (child, "event", - G_CALLBACK (gtk_cell_editable_event), - cell_editable, 0); + gtk_widget_add_controller (child, controller); gtk_widget_grab_focus (child); gtk_widget_set_can_focus (priv->button, FALSE); |