static void ev_page_accessible_initialize_children (EvPageAccessible *self) { EvView *view; EvMappingList *images; EvMappingList *links; EvMappingList *fields; GList *children = NULL; GList *list; if (self->priv->children_initialized) return; view = ev_page_accessible_get_view (self); if (!ev_page_cache_is_page_cached (view->page_cache, self->priv->page)) return; self->priv->children_initialized = TRUE; links = ev_page_cache_get_link_mapping (view->page_cache, self->priv->page); images = ev_page_cache_get_image_mapping (view->page_cache, self->priv->page); fields = ev_page_cache_get_form_field_mapping (view->page_cache, self->priv->page); if (!links && !images && !fields) return; children = g_list_copy (ev_mapping_list_get_list (links)); children = g_list_concat (children, g_list_copy (ev_mapping_list_get_list (images))); children = g_list_concat (children, g_list_copy (ev_mapping_list_get_list (fields))); children = g_list_sort (children, (GCompareFunc) compare_mappings); self->priv->children = g_ptr_array_new_full (g_list_length (children), (GDestroyNotify) g_object_unref); for (list = children; list && list->data; list = list->next) { EvMapping *mapping = list->data; AtkObject *child = NULL; if (links && ev_mapping_list_find (links, mapping->data)) { EvLinkAccessible *link = ev_link_accessible_new (self, EV_LINK (mapping->data), &mapping->area); AtkHyperlink *atk_link = atk_hyperlink_impl_get_hyperlink (ATK_HYPERLINK_IMPL (link)); child = atk_hyperlink_get_object (atk_link, 0); } else if (images && ev_mapping_list_find (images, mapping->data)) child = ATK_OBJECT (ev_image_accessible_new (self, EV_IMAGE (mapping->data), &mapping->area)); else if (fields && ev_mapping_list_find (fields, mapping->data)) child = ATK_OBJECT (ev_form_field_accessible_new (self, EV_FORM_FIELD (mapping->data), &mapping->area)); if (child) g_ptr_array_add (self->priv->children, child); } g_list_free (children); }
static gboolean press (EvView * view, GdkEventButton *event, EvDocumentModel *model) { EvDocument *doc = ev_document_model_get_document (model); gint i = ev_document_model_get_page (model); if (event->button != 1) infodialog (help_text); nearest_annotation_text = NULL; extern EvMappingList * ev_document_annotations_get_annotations(); EvMappingList *mapping_list = ev_document_annotations_get_annotations (doc, ev_document_get_page(doc, i)); if(mapping_list) { gdouble nearest = G_MAXDOUBLE; GList *g = ev_mapping_list_get_list (mapping_list); for (;g;g=g->next) { EvMapping *mapping = g->data; EvAnnotation *annot = mapping->data; gdouble annottx = ev_document_model_get_scale (model)*(mapping->area.x1 + mapping->area.x2)/2; gdouble annotty = ev_document_model_get_scale (model)*(mapping->area.y1 + mapping->area.y2)/2; gdouble dist = (annottx-event->x)*(annottx-event->x) + (annotty-event->y)*(annotty-event->y); if(dist < nearest) { nearest = dist; nearest_annotation_text = ev_annotation_get_contents (annot); } } } //g_print("\n\npress signal (%f, %f) %s\n", event->x, event->y, nearest_annotation_text); return FALSE; }