diff options
author | Matthias Clasen <mclasen@redhat.com> | 2014-01-04 09:43:23 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-01-04 10:54:03 -0500 |
commit | b85a8001e0806bf83a641c901447d6da2e2abf52 (patch) | |
tree | ffb42697c88e5f42a941ec721e82aa8ee7ca9bfa /gtk/a11y | |
parent | 3bc5ab4fcd3aa4f01b8a783eb6f0b084cacd53ec (diff) | |
download | gtk+-b85a8001e0806bf83a641c901447d6da2e2abf52.tar.gz |
GtkLabelAccessible: update state of links
This commit makes the LinkImpl children of label accessibles
inherit all their state, except for focused and visited, which
are handled directly.
https://bugzilla.gnome.org/show_bug.cgi?id=721406
Diffstat (limited to 'gtk/a11y')
-rw-r--r-- | gtk/a11y/gtklabelaccessible.c | 61 | ||||
-rw-r--r-- | gtk/a11y/gtklabelaccessibleprivate.h | 1 |
2 files changed, 61 insertions, 1 deletions
diff --git a/gtk/a11y/gtklabelaccessible.c b/gtk/a11y/gtklabelaccessible.c index 58cbc8dac5..fdcd74ca09 100644 --- a/gtk/a11y/gtklabelaccessible.c +++ b/gtk/a11y/gtklabelaccessible.c @@ -41,6 +41,7 @@ struct _GtkLabelAccessibleLink GtkLabelAccessible *label; gint index; + gboolean focused; }; struct _GtkLabelAccessibleLinkClass @@ -109,13 +110,42 @@ gtk_label_accessible_link_impl_get_hyperlink (AtkHyperlinkImpl *atk_impl) return g_object_ref (impl->link); } - static void atk_hyperlink_impl_interface_init (AtkHyperlinkImplIface *iface) { iface->get_hyperlink = gtk_label_accessible_link_impl_get_hyperlink; } +static AtkStateSet * +gtk_label_accessible_link_impl_ref_state_set (AtkObject *obj) +{ + AtkStateSet *state_set; + GtkLabelAccessibleLink *link; + GtkWidget *widget; + + link = ((GtkLabelAccessibleLinkImpl *)obj)->link; + + state_set = atk_object_ref_state_set (atk_object_get_parent (obj)); + + widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (atk_object_get_parent (obj))); + if (widget) + { + if (gtk_widget_get_can_focus (widget)) + { + atk_state_set_add_state (state_set, ATK_STATE_FOCUSABLE); + if (_gtk_label_get_link_focused (GTK_LABEL (widget), link->index)) + atk_state_set_add_state (state_set, ATK_STATE_FOCUSED); + else + atk_state_set_remove_state (state_set, ATK_STATE_FOCUSED); + } + + if (_gtk_label_get_link_visited (GTK_LABEL (widget), link->index)) + atk_state_set_add_state (state_set, ATK_STATE_VISITED); + } + + return state_set; +} + static void _gtk_label_accessible_link_impl_init (GtkLabelAccessibleLinkImpl *impl) { @@ -136,8 +166,10 @@ static void _gtk_label_accessible_link_impl_class_init (GtkLabelAccessibleLinkImplClass *class) { GObjectClass *object_class = G_OBJECT_CLASS (class); + AtkObjectClass *atk_obj_class = ATK_OBJECT_CLASS (class); object_class->finalize = _gtk_label_accessible_link_impl_finalize; + atk_obj_class->ref_state_set = gtk_label_accessible_link_impl_ref_state_set; } static gchar * @@ -1110,6 +1142,33 @@ _gtk_label_accessible_update_links (GtkLabel *label) create_links (GTK_LABEL_ACCESSIBLE (obj)); } +void +_gtk_label_accessible_focus_link_changed (GtkLabel *label) +{ + AtkObject *obj; + GtkLabelAccessible *accessible; + GList *l; + GtkLabelAccessibleLinkImpl *impl; + gboolean focused; + + obj = _gtk_widget_peek_accessible (GTK_WIDGET (label)); + if (obj == NULL) + return; + + accessible = GTK_LABEL_ACCESSIBLE (obj); + + for (l = accessible->priv->links; l; l = l->next) + { + impl = l->data; + focused = _gtk_label_get_link_focused (label, impl->link->index); + if (impl->link->focused != focused) + { + impl->link->focused = focused; + atk_object_notify_state_change (ATK_OBJECT (impl), ATK_STATE_FOCUSED, focused); + } + } +} + static AtkHyperlink * gtk_label_accessible_get_link (AtkHypertext *hypertext, gint idx) diff --git a/gtk/a11y/gtklabelaccessibleprivate.h b/gtk/a11y/gtklabelaccessibleprivate.h index 33597f25e1..a4c61c2461 100644 --- a/gtk/a11y/gtklabelaccessibleprivate.h +++ b/gtk/a11y/gtklabelaccessibleprivate.h @@ -25,6 +25,7 @@ G_BEGIN_DECLS void _gtk_label_accessible_text_deleted (GtkLabel *label); void _gtk_label_accessible_text_inserted (GtkLabel *label); void _gtk_label_accessible_update_links (GtkLabel *label); +void _gtk_label_accessible_focus_link_changed (GtkLabel *label); G_END_DECLS |