GtkCellRendererAccel: Try harder to capture bound keys

Add a grab on the editable widget, so that we can capture
also shortcuts which are bound in the application itself.

https://bugzilla.gnome.org/736203
This commit is contained in:
Matthias Clasen 2014-09-06 20:56:03 -04:00
parent bbf9b95354
commit 794230e708

View File

@ -519,7 +519,7 @@ gtk_cell_renderer_accel_start_editing (GtkCellRenderer *cell,
gtk_container_add (GTK_CONTAINER (eventbox), label);
gtk_widget_show_all (eventbox);
gtk_widget_grab_focus (eventbox);
gtk_grab_add (eventbox);
return GTK_CELL_EDITABLE (eventbox);
}
@ -659,6 +659,7 @@ gtk_cell_editable_event_box_key_press_event (GtkWidget *widget,
edited = TRUE;
out:
gtk_grab_remove (box);
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));
@ -677,24 +678,12 @@ gtk_cell_editable_event_box_unrealize (GtkWidget *widget)
{
GtkCellEditableEventBox *box = (GtkCellEditableEventBox*)widget;
gtk_grab_remove (box);
gtk_cell_renderer_accel_ungrab (GTK_CELL_RENDERER_ACCEL (box->cell));
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,
@ -767,7 +756,6 @@ 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,