gtkcombobox: Use keycontroller on GtkCellEditable implementation

This commit is contained in:
Carlos Garnacho 2018-06-26 15:44:13 +02:00
parent 0d7b4ecb14
commit ca8008e2c9

View File

@ -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);