+#if GTK_CHECK_VERSION (2, 11, 7)
+static void
+get_link_area (EvView *view,
+ gint x,
+ gint y,
+ EvLink *link,
+ GdkRectangle *area)
+{
+ EvRectangle ev_rect;
+ GList *link_mapping;
+ gint page;
+ gint x_offset = 0, y_offset = 0;
+
+ x += view->scroll_x;
+ y += view->scroll_y;
+
+ find_page_at_location (view, x, y, &page, &x_offset, &y_offset);
+
+ link_mapping = ev_pixbuf_cache_get_link_mapping (view->pixbuf_cache, page);
+ ev_link_mapping_get_area (link_mapping, link, &ev_rect);
+
+ doc_rect_to_view_rect (view, page, &ev_rect, area);
+ area->y -= view->scroll_y ;
+}
+
+static gboolean
+ev_view_query_tooltip (GtkWidget *widget,
+ gint x,
+ gint y,
+ gboolean keyboard_tip,
+ GtkTooltip *tooltip)
+{
+ EvView *view = EV_VIEW (widget);
+ EvLink *link;
+ gchar *text;
+
+ link = ev_view_get_link_at_location (view, x, y);
+ if (!link)
+ return FALSE;
+
+ text = tip_from_link (view, link);
+ if (text && g_utf8_validate (text, -1, NULL)) {
+ GdkRectangle link_area;
+
+ get_link_area (view, x, y, link, &link_area);
+ gtk_tooltip_set_text (tooltip, text);
+ gtk_tooltip_set_tip_area (tooltip, &link_area);
+ }
+ g_free (text);
+
+ return TRUE;
+}
+#endif /* GTK_CHECK_VERSION (2, 11, 7) */
+
+static void
+start_selection_for_event (EvView *view,
+ GdkEventButton *event)
+{
+ EvSelectionStyle style;
+
+ clear_selection (view);
+
+ view->selection_info.start.x = event->x + view->scroll_x;
+ view->selection_info.start.y = event->y + view->scroll_y;
+
+ switch (event->type) {
+ case GDK_2BUTTON_PRESS:
+ style = EV_SELECTION_STYLE_WORD;
+ break;
+ case GDK_3BUTTON_PRESS:
+ style = EV_SELECTION_STYLE_LINE;
+ break;
+ default:
+ style = EV_SELECTION_STYLE_GLYPH;
+ break;
+ }
+
+ view->selection_info.style = style;
+}
+