From fa0e43471c14cc02843af4438fde39b7fdabdec4 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 6 Sep 2014 19:01:14 -0400 Subject: [PATCH] GtkCellRendererAccel: Stop editing on focus out This is not automatic, and with grabs in place, it is awkward to have focus moved elsewhere, so stop editing whenever the cell editable loses focus. --- gtk/gtkcellrendereraccel.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gtk/gtkcellrendereraccel.c b/gtk/gtkcellrendereraccel.c index fbbd78c973..eb660f5664 100644 --- a/gtk/gtkcellrendereraccel.c +++ b/gtk/gtkcellrendereraccel.c @@ -660,7 +660,6 @@ gtk_cell_editable_event_box_key_press_event (GtkWidget *widget, out: gtk_cell_renderer_accel_ungrab (GTK_CELL_RENDERER_ACCEL (box->cell)); - gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (widget)); gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (widget)); @@ -683,6 +682,19 @@ gtk_cell_editable_event_box_unrealize (GtkWidget *widget) GTK_WIDGET_CLASS (gtk_cell_editable_event_box_parent_class)->unrealize (widget); } +static gboolean +gtk_cell_editable_event_box_focus_out (GtkWidget *widget, + GdkEventFocus *event) +{ + GtkCellEditableEventBox *box = (GtkCellEditableEventBox*)widget; + + gtk_cell_renderer_accel_ungrab (GTK_CELL_RENDERER_ACCEL (box->cell)); + gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (widget)); + gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (widget)); + + return FALSE; +} + static void gtk_cell_editable_event_box_set_property (GObject *object, guint prop_id, @@ -755,6 +767,7 @@ gtk_cell_editable_event_box_class_init (GtkCellEditableEventBoxClass *class) widget_class->key_press_event = gtk_cell_editable_event_box_key_press_event; widget_class->unrealize = gtk_cell_editable_event_box_unrealize; + widget_class->focus_out_event = gtk_cell_editable_event_box_focus_out; g_object_class_override_property (object_class, PROP_EDITING_CANCELED,