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
This commit is contained in:
@ -41,6 +41,7 @@ struct _GtkLabelAccessibleLink
|
|||||||
|
|
||||||
GtkLabelAccessible *label;
|
GtkLabelAccessible *label;
|
||||||
gint index;
|
gint index;
|
||||||
|
gboolean focused;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GtkLabelAccessibleLinkClass
|
struct _GtkLabelAccessibleLinkClass
|
||||||
@ -109,13 +110,42 @@ gtk_label_accessible_link_impl_get_hyperlink (AtkHyperlinkImpl *atk_impl)
|
|||||||
return g_object_ref (impl->link);
|
return g_object_ref (impl->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
atk_hyperlink_impl_interface_init (AtkHyperlinkImplIface *iface)
|
atk_hyperlink_impl_interface_init (AtkHyperlinkImplIface *iface)
|
||||||
{
|
{
|
||||||
iface->get_hyperlink = gtk_label_accessible_link_impl_get_hyperlink;
|
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
|
static void
|
||||||
_gtk_label_accessible_link_impl_init (GtkLabelAccessibleLinkImpl *impl)
|
_gtk_label_accessible_link_impl_init (GtkLabelAccessibleLinkImpl *impl)
|
||||||
{
|
{
|
||||||
@ -136,8 +166,10 @@ static void
|
|||||||
_gtk_label_accessible_link_impl_class_init (GtkLabelAccessibleLinkImplClass *class)
|
_gtk_label_accessible_link_impl_class_init (GtkLabelAccessibleLinkImplClass *class)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (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;
|
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 *
|
static gchar *
|
||||||
@ -1110,6 +1142,33 @@ _gtk_label_accessible_update_links (GtkLabel *label)
|
|||||||
create_links (GTK_LABEL_ACCESSIBLE (obj));
|
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 *
|
static AtkHyperlink *
|
||||||
gtk_label_accessible_get_link (AtkHypertext *hypertext,
|
gtk_label_accessible_get_link (AtkHypertext *hypertext,
|
||||||
gint idx)
|
gint idx)
|
||||||
|
|||||||
@ -25,6 +25,7 @@ G_BEGIN_DECLS
|
|||||||
void _gtk_label_accessible_text_deleted (GtkLabel *label);
|
void _gtk_label_accessible_text_deleted (GtkLabel *label);
|
||||||
void _gtk_label_accessible_text_inserted (GtkLabel *label);
|
void _gtk_label_accessible_text_inserted (GtkLabel *label);
|
||||||
void _gtk_label_accessible_update_links (GtkLabel *label);
|
void _gtk_label_accessible_update_links (GtkLabel *label);
|
||||||
|
void _gtk_label_accessible_focus_link_changed (GtkLabel *label);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|||||||
@ -4514,6 +4514,7 @@ gtk_label_grab_focus (GtkWidget *widget)
|
|||||||
link = priv->select_info->links->data;
|
link = priv->select_info->links->data;
|
||||||
priv->select_info->selection_anchor = link->start;
|
priv->select_info->selection_anchor = link->start;
|
||||||
priv->select_info->selection_end = link->start;
|
priv->select_info->selection_end = link->start;
|
||||||
|
_gtk_label_accessible_focus_link_changed (label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4540,6 +4541,7 @@ gtk_label_focus (GtkWidget *widget,
|
|||||||
focus_link = l->data;
|
focus_link = l->data;
|
||||||
info->selection_anchor = focus_link->start;
|
info->selection_anchor = focus_link->start;
|
||||||
info->selection_end = focus_link->start;
|
info->selection_end = focus_link->start;
|
||||||
|
_gtk_label_accessible_focus_link_changed (label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4566,6 +4568,7 @@ gtk_label_focus (GtkWidget *widget,
|
|||||||
if (link->start > index)
|
if (link->start > index)
|
||||||
{
|
{
|
||||||
gtk_label_select_region_index (label, link->start, link->start);
|
gtk_label_select_region_index (label, link->start, link->start);
|
||||||
|
_gtk_label_accessible_focus_link_changed (label);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4577,6 +4580,7 @@ gtk_label_focus (GtkWidget *widget,
|
|||||||
if (link->end < index)
|
if (link->end < index)
|
||||||
{
|
{
|
||||||
gtk_label_select_region_index (label, link->start, link->start);
|
gtk_label_select_region_index (label, link->start, link->start);
|
||||||
|
_gtk_label_accessible_focus_link_changed (label);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4617,6 +4621,7 @@ gtk_label_focus (GtkWidget *widget,
|
|||||||
focus_link = l->data;
|
focus_link = l->data;
|
||||||
info->selection_anchor = focus_link->start;
|
info->selection_anchor = focus_link->start;
|
||||||
info->selection_end = focus_link->start;
|
info->selection_end = focus_link->start;
|
||||||
|
_gtk_label_accessible_focus_link_changed (label);
|
||||||
gtk_widget_queue_draw (widget);
|
gtk_widget_queue_draw (widget);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|||||||
Reference in New Issue
Block a user