Commit 8246fa2b authored by Joanmarie Diggs's avatar Joanmarie Diggs

libview: Emit accessible focused-changed signals for form fields

https://bugzilla.gnome.org/show_bug.cgi?id=733662
parent 61d3a03e
......@@ -239,3 +239,9 @@ ev_form_field_accessible_new (EvPageAccessible *page,
return EV_FORM_FIELD_ACCESSIBLE (atk_form_field);
}
EvFormField *
ev_form_field_accessible_get_field (EvFormFieldAccessible *accessible)
{
return accessible->priv->form_field;
}
......@@ -51,5 +51,6 @@ GType ev_form_field_accessible_get_type (void);
EvFormFieldAccessible *ev_form_field_accessible_new (EvPageAccessible *page,
EvFormField *form_field,
EvRectangle *area);
EvFormField *ev_form_field_accessible_get_field (EvFormFieldAccessible *accessible);
#endif /* __EV_FORM_FIELD_ACCESSIBLE_H__ */
......@@ -1223,3 +1223,25 @@ ev_page_accessible_new (EvViewAccessible *view_accessible,
return EV_PAGE_ACCESSIBLE (atk_page);
}
AtkObject *
ev_page_accessible_get_accessible_for_mapping (EvPageAccessible *page_accessible,
EvMapping *mapping)
{
gint i;
ev_page_accessible_initialize_children (page_accessible);
if (!mapping || !page_accessible->priv->children)
return NULL;
for (i = 0; i < page_accessible->priv->children->len; i++) {
AtkObject *child;
child = g_ptr_array_index (page_accessible->priv->children, i);
if (EV_IS_FORM_FIELD_ACCESSIBLE (child) &&
ev_form_field_accessible_get_field (EV_FORM_FIELD_ACCESSIBLE (child)) == mapping->data)
return child;
}
return NULL;
}
......@@ -51,6 +51,8 @@ EvPageAccessible *ev_page_accessible_new (EvViewAccessible *view
gint ev_page_accessible_get_page (EvPageAccessible *page_accessible);
EvViewAccessible *ev_page_accessible_get_view_accessible (EvPageAccessible *page_accessible);
EvView *ev_page_accessible_get_view (EvPageAccessible *page_accessible);
AtkObject *ev_page_accessible_get_accessible_for_mapping (EvPageAccessible *page_accessible,
EvMapping *mapping);
#endif /* __EV_PAGE_ACCESSIBLE_H__ */
......@@ -63,6 +63,7 @@ struct _EvViewAccessiblePrivate {
gint previous_cursor_page;
gint start_page;
gint end_page;
AtkObject *focused_element;
GPtrArray *children;
};
......@@ -593,3 +594,24 @@ ev_view_accessible_set_page_range (EvViewAccessible *accessible,
accessible->priv->start_page = start;
accessible->priv->end_page = end;
}
void
ev_view_accessible_set_focused_element (EvViewAccessible *accessible,
EvMapping *new_focus,
gint new_focus_page)
{
EvPageAccessible *page;
if (accessible->priv->focused_element) {
atk_object_notify_state_change (accessible->priv->focused_element, ATK_STATE_FOCUSED, FALSE);
accessible->priv->focused_element = NULL;
}
if (!new_focus || new_focus_page == -1)
return;
page = g_ptr_array_index (accessible->priv->children, new_focus_page);
accessible->priv->focused_element = ev_page_accessible_get_accessible_for_mapping (page, new_focus);
if (accessible->priv->focused_element)
atk_object_notify_state_change (accessible->priv->focused_element, ATK_STATE_FOCUSED, TRUE);
}
......@@ -65,6 +65,9 @@ void _transform_doc_rect_to_atk_rect (EvViewAccessible *accessible,
gboolean ev_view_accessible_is_doc_rect_showing (EvViewAccessible *accessible,
gint page,
EvRectangle *doc_rect);
void ev_view_accessible_set_focused_element (EvViewAccessible *accessible,
EvMapping *new_focus,
gint new_focus_page);
#endif /* __EV_VIEW_ACCESSIBLE_H__ */
......@@ -2156,6 +2156,9 @@ _ev_view_set_focused_element (EvView *view,
if (view->focused_element == element_mapping)
return;
if (view->accessible)
ev_view_accessible_set_focused_element (EV_VIEW_ACCESSIBLE (view->accessible), element_mapping, page);
if (ev_view_get_focused_area (view, &view_rect))
region = cairo_region_create_rectangle (&view_rect);
......@@ -2312,6 +2315,10 @@ ev_view_form_field_button_create_widget (EvView *view,
EvMappingList *form_mapping;
EvMapping *mapping;
/* We need to do this focus grab prior to setting the focused element for accessibility */
if (!gtk_widget_has_focus (GTK_WIDGET (view)))
gtk_widget_grab_focus (GTK_WIDGET (view));
form_mapping = ev_page_cache_get_form_field_mapping (view->page_cache,
field->page->index);
mapping = ev_mapping_list_find (form_mapping, field);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment