summaryrefslogtreecommitdiff
path: root/libview
diff options
context:
space:
mode:
authorJoanmarie Diggs <[email protected]>2014-04-22 07:54:23 -0400
committerraveit65 <[email protected]>2017-11-27 10:13:51 +0100
commite2326c25e1249cf921dd1b878c42d6b51b032bcf (patch)
treea3a4b8070c69180091532f4150030361d7ed301a /libview
parente6672a875c89cfd81d4e54ae8b1a8a834eb6fe8b (diff)
downloadatril-e2326c25e1249cf921dd1b878c42d6b51b032bcf.tar.bz2
atril-e2326c25e1249cf921dd1b878c42d6b51b032bcf.tar.xz
libview: Implement AtkComponent for pages
https://bugzilla.gnome.org/show_bug.cgi?id=728673 origin commit: https://git.gnome.org/browse/evince/commit/?h=gnome-3-14&id=7d1bf5a
Diffstat (limited to 'libview')
-rw-r--r--libview/ev-page-accessible.c38
-rw-r--r--libview/ev-view-accessible.c36
-rw-r--r--libview/ev-view-accessible.h5
3 files changed, 79 insertions, 0 deletions
diff --git a/libview/ev-page-accessible.c b/libview/ev-page-accessible.c
index 2fcc0680..99e970a1 100644
--- a/libview/ev-page-accessible.c
+++ b/libview/ev-page-accessible.c
@@ -40,10 +40,12 @@ enum {
PROP_PAGE,
};
+static void ev_page_accessible_component_iface_init (AtkComponentIface *iface);
static void ev_page_accessible_hypertext_iface_init (AtkHypertextIface *iface);
static void ev_page_accessible_text_iface_init (AtkTextIface *iface);
G_DEFINE_TYPE_WITH_CODE (EvPageAccessible, ev_page_accessible, ATK_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, ev_page_accessible_component_iface_init)
G_IMPLEMENT_INTERFACE (ATK_TYPE_HYPERTEXT, ev_page_accessible_hypertext_iface_init)
G_IMPLEMENT_INTERFACE (ATK_TYPE_TEXT, ev_page_accessible_text_iface_init))
@@ -1054,6 +1056,42 @@ ev_page_accessible_hypertext_iface_init (AtkHypertextIface *iface)
iface->get_link_index = ev_page_accessible_get_link_index;
}
+static void
+ev_page_accessible_get_extents (AtkComponent *atk_component,
+ gint *x,
+ gint *y,
+ gint *width,
+ gint *height,
+ AtkCoordType coord_type)
+{
+ EvPageAccessible *self;
+ EvView *view;
+ GdkRectangle page_area;
+ GtkBorder border;
+ EvRectangle doc_rect, atk_rect;
+
+ self = EV_PAGE_ACCESSIBLE (atk_component);
+ view = ev_page_accessible_get_view (self);
+ ev_view_get_page_extents (view, self->priv->page, &page_area, &border);
+
+ doc_rect.x1 = page_area.x;
+ doc_rect.y1 = page_area.y;
+ doc_rect.x2 = page_area.x + page_area.width;
+ doc_rect.y2 = page_area.y + page_area.height;
+ _transform_doc_rect_to_atk_rect (self->priv->view_accessible, self->priv->page, &doc_rect, &atk_rect, coord_type);
+
+ *x = atk_rect.x1;
+ *y = atk_rect.y1;
+ *width = atk_rect.x2 - atk_rect.x1;
+ *height = atk_rect.y2 - atk_rect.y1;
+}
+
+static void
+ev_page_accessible_component_iface_init (AtkComponentIface *iface)
+{
+ iface->get_extents = ev_page_accessible_get_extents;
+}
+
EvPageAccessible *
ev_page_accessible_new (EvViewAccessible *view_accessible,
gint page)
diff --git a/libview/ev-view-accessible.c b/libview/ev-view-accessible.c
index 2932c5e1..c063e366 100644
--- a/libview/ev-view-accessible.c
+++ b/libview/ev-view-accessible.c
@@ -493,3 +493,39 @@ ev_view_accessible_get_relevant_page (EvViewAccessible *accessible)
return get_relevant_page (view);
}
+
+void
+_transform_doc_rect_to_atk_rect (EvViewAccessible *accessible,
+ gint page,
+ EvRectangle *doc_rect,
+ EvRectangle *atk_rect,
+ AtkCoordType coord_type)
+{
+ EvView *view;
+ GdkRectangle view_rect;
+ GtkWidget *widget, *toplevel;
+ gint x_widget, y_widget;
+
+ view = EV_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)));
+ _ev_view_transform_doc_rect_to_view_rect (view, page, doc_rect, &view_rect);
+ view_rect.x -= view->scroll_x;
+ view_rect.y -= view->scroll_y;
+
+ widget = GTK_WIDGET (view);
+ toplevel = gtk_widget_get_toplevel (widget);
+ gtk_widget_translate_coordinates (widget, toplevel, 0, 0, &x_widget, &y_widget);
+ view_rect.x += x_widget;
+ view_rect.y += y_widget;
+
+ if (coord_type == ATK_XY_SCREEN) {
+ gint x_window, y_window;
+ gdk_window_get_origin (gtk_widget_get_window (toplevel), &x_window, &y_window);
+ view_rect.x += x_window;
+ view_rect.y += y_window;
+ }
+
+ atk_rect->x1 = view_rect.x;
+ atk_rect->y1 = view_rect.y;
+ atk_rect->x2 = view_rect.x + view_rect.width;
+ atk_rect->y2 = view_rect.y + view_rect.height;
+}
diff --git a/libview/ev-view-accessible.h b/libview/ev-view-accessible.h
index 38af95a4..34369682 100644
--- a/libview/ev-view-accessible.h
+++ b/libview/ev-view-accessible.h
@@ -54,6 +54,11 @@ void ev_view_accessible_set_model (EvViewAccessible *accessible,
EvDocumentModel *model);
gint ev_view_accessible_get_n_pages (EvViewAccessible *accessible);
gint ev_view_accessible_get_relevant_page (EvViewAccessible *accessible);
+void _transform_doc_rect_to_atk_rect (EvViewAccessible *accessible,
+ gint page,
+ EvRectangle *doc_rect,
+ EvRectangle *atk_rect,
+ AtkCoordType coord_type);
#endif /* __EV_VIEW_ACCESSIBLE_H__ */