a11y: Stop using ::event

We can just as well use notify::has-focus for the purpose of
focus tracking, and we can at the same time avoid emitting the
deprecated AtkObject::focus-event signal.
This commit is contained in:
Matthias Clasen 2018-05-25 18:25:29 -04:00
parent e610c02a9e
commit d561e52cde

View File

@ -43,25 +43,6 @@ G_DEFINE_TYPE_WITH_CODE (GtkWidgetAccessible, gtk_widget_accessible, GTK_TYPE_AC
G_ADD_PRIVATE (GtkWidgetAccessible)
G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init))
/* Translate GtkWidget::focus-in/out-event to AtkObject::focus-event */
static gboolean
focus_cb (GtkWidget *widget,
GdkEvent *event)
{
if (gdk_event_get_event_type (event) == GDK_FOCUS_CHANGE)
{
AtkObject *obj;
gboolean in;
obj = gtk_widget_get_accessible (widget);
gdk_event_get_focus_in (event, &in);
g_signal_emit_by_name (obj, "focus-event", in);
}
return GDK_EVENT_PROPAGATE;
}
/* Translate GtkWidget property change notification to the notify_gtk vfunc */
static void
notify_cb (GObject *obj,
@ -107,18 +88,6 @@ map_cb (GtkWidget *widget)
return 1;
}
static void
gtk_widget_accessible_focus_event (AtkObject *obj,
gboolean focus_in)
{
AtkObject *focus_obj;
focus_obj = g_object_get_data (G_OBJECT (obj), "gail-focus-object");
if (focus_obj == NULL)
focus_obj = obj;
atk_object_notify_state_change (focus_obj, ATK_STATE_FOCUSED, focus_in);
}
static void
gtk_widget_accessible_update_tooltip (GtkWidgetAccessible *accessible,
GtkWidget *widget)
@ -137,7 +106,6 @@ gtk_widget_accessible_initialize (AtkObject *obj,
widget = GTK_WIDGET (data);
g_signal_connect_after (widget, "event", G_CALLBACK (focus_cb), NULL);
g_signal_connect (widget, "notify", G_CALLBACK (notify_cb), NULL);
g_signal_connect (widget, "size-allocate", G_CALLBACK (size_allocate_cb), NULL);
g_signal_connect (widget, "map", G_CALLBACK (map_cb), NULL);
@ -466,11 +434,10 @@ gtk_widget_accessible_notify_gtk (GObject *obj,
gboolean value;
if (g_strcmp0 (pspec->name, "has-focus") == 0)
/*
* We use focus change events to catch
* focus changes so we ignore this.
*/
return;
{
state = ATK_STATE_FOCUSED;
value = gtk_widget_has_focus (widget);
}
else if (g_strcmp0 (pspec->name, "tooltip-text") == 0)
{
gtk_widget_accessible_update_tooltip (GTK_WIDGET_ACCESSIBLE (atk_obj),
@ -545,7 +512,6 @@ gtk_widget_accessible_class_init (GtkWidgetAccessibleClass *klass)
class->get_index_in_parent = gtk_widget_accessible_get_index_in_parent;
class->initialize = gtk_widget_accessible_initialize;
class->get_attributes = gtk_widget_accessible_get_attributes;
class->focus_event = gtk_widget_accessible_focus_event;
}
static void