[evince/gnome_3_36_tooltip_feature: 3/3] pdf: add back 'de facto' tooltip feature
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/gnome_3_36_tooltip_feature: 3/3] pdf: add back 'de facto' tooltip feature
- Date: Sat, 27 Jun 2020 02:24:47 +0000 (UTC)
commit ce03847aeb27eb08943b17b0a99f80080752a4d8
Author: Nelson Benítez León <nbenitezl gmail com>
Date: Fri Jun 19 23:30:58 2020 -0400
pdf: add back 'de facto' tooltip feature
without breaking ABI in gnome-3-36 branch.
By setting the tooltip on the EvFormField
via g_object_set_data() instead of using
a new EvFormField struct field.
Evince issue #842
backend/pdf/ev-poppler.cc | 7 +++++++
libview/ev-view.c | 37 ++++++++++++++++++++++++++++++++++++-
2 files changed, 43 insertions(+), 1 deletion(-)
---
diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc
index a6383a15..dac2bb62 100644
--- a/backend/pdf/ev-poppler.cc
+++ b/backend/pdf/ev-poppler.cc
@@ -2763,6 +2763,13 @@ ev_form_field_from_poppler_field (PdfDocument *pdf_document,
if (action)
ev_field->activation_link = ev_link_from_action (pdf_document, action);
+#if POPPLER_CHECK_VERSION(0, 88, 0)
+ gchar *alt_name = poppler_form_field_get_alternate_ui_name (poppler_field);
+ if (alt_name) {
+ g_object_set_data_full (G_OBJECT (ev_field), "alt-name", alt_name, (GDestroyNotify) g_free);
+ }
+#endif
+
return ev_field;
}
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 032414e3..8485d142 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -2205,7 +2205,7 @@ ev_view_handle_cursor_over_xy (EvView *view, gint x, gint y)
ev_view_set_cursor (view, EV_VIEW_CURSOR_NORMAL);
}
- if (link || annot)
+ if (link || annot || (field && g_object_get_data (G_OBJECT (field), "alt-name")))
g_object_set (view, "has-tooltip", TRUE, NULL);
}
@@ -4961,6 +4961,26 @@ get_annot_area (EvView *view,
annot, area);
}
+static void
+get_field_area (EvView *view,
+ gint x,
+ gint y,
+ EvFormField *field,
+ GdkRectangle *area)
+{
+ EvMappingList *field_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);
+
+ field_mapping = ev_page_cache_get_form_field_mapping (view->page_cache, page);
+ ev_view_get_area_from_mapping (view, page, field_mapping, field, area);
+}
+
static gboolean
ev_view_query_tooltip (GtkWidget *widget,
gint x,
@@ -4969,6 +4989,7 @@ ev_view_query_tooltip (GtkWidget *widget,
GtkTooltip *tooltip)
{
EvView *view = EV_VIEW (widget);
+ EvFormField *field;
EvLink *link;
EvAnnotation *annot;
gchar *text;
@@ -4989,6 +5010,20 @@ ev_view_query_tooltip (GtkWidget *widget,
}
}
+ field = ev_view_get_form_field_at_location (view, x, y);
+ if (field) {
+ text = g_object_get_data (G_OBJECT (field), "alt-name");
+ if (text && *text != '\0') {
+ GdkRectangle field_area;
+
+ get_field_area (view, x, y, field, &field_area);
+ gtk_tooltip_set_text (tooltip, text);
+ gtk_tooltip_set_tip_area (tooltip, &field_area);
+
+ return TRUE;
+ }
+ }
+
link = ev_view_get_link_at_location (view, x, y);
if (!link)
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]