[evince/gpoo/fix-hover-for-highlight-annotations: 1/3] document: ev_mapping_list_get_all
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/gpoo/fix-hover-for-highlight-annotations: 1/3] document: ev_mapping_list_get_all
- Date: Sun, 9 Feb 2020 12:53:26 +0000 (UTC)
commit 86d483f2ec639df0168aeb89023d4d9f7742e09d
Author: Giselle Reis <gisellemnr src gnome org>
Date: Mon Aug 18 20:20:01 2014 +0200
document: ev_mapping_list_get_all
Implements a function that returns all EvMappings
at a certain point. Needed for annotations
(especially text markups), whose bounding boxes
might overlap.
https://bugzilla.gnome.org/show_bug.cgi?id=769133
libdocument/ev-mapping-list.c | 41 +++++++++++++++++++++++++++++++++++++++++
libdocument/ev-mapping-list.h | 3 +++
2 files changed, 44 insertions(+)
---
diff --git a/libdocument/ev-mapping-list.c b/libdocument/ev-mapping-list.c
index 3efd42e0..ea874f78 100644
--- a/libdocument/ev-mapping-list.c
+++ b/libdocument/ev-mapping-list.c
@@ -162,6 +162,47 @@ ev_mapping_list_get (EvMappingList *mapping_list,
return found;
}
+/**
+ * ev_mapping_list_get_all:
+ * @mapping_list: an #EvMappingList
+ * @x: X coordinate
+ * @y: Y coordinate
+ *
+ * Returns: (transfer none): a #GArray of all the #EvMapping in the list at coordinates (x, y)
+ *
+ * Since: 3.14
+ */
+GArray *
+ev_mapping_list_get_all (EvMappingList *mapping_list,
+ gdouble x,
+ gdouble y)
+{
+ g_return_val_if_fail (mapping_list != NULL, NULL);
+
+ GList *list;
+ GArray *mapping_array;
+
+ mapping_array = g_array_new (FALSE, FALSE, sizeof (EvMapping));
+
+ for (list = mapping_list->list; list; list = list->next) {
+ EvMapping *mapping = list->data;
+
+ if ((x >= mapping->area.x1) &&
+ (y >= mapping->area.y1) &&
+ (x <= mapping->area.x2) &&
+ (y <= mapping->area.y2)) {
+ g_array_append_val (mapping_array, *mapping);
+ }
+ }
+ g_list_free (list);
+
+ if (mapping_array->len > 0) return mapping_array;
+ else {
+ g_array_unref (mapping_array);
+ return NULL;
+ }
+}
+
/**
* ev_mapping_list_get_data:
* @mapping_list: an #EvMappingList
diff --git a/libdocument/ev-mapping-list.h b/libdocument/ev-mapping-list.h
index dcbb50b7..35c25179 100644
--- a/libdocument/ev-mapping-list.h
+++ b/libdocument/ev-mapping-list.h
@@ -52,6 +52,9 @@ EvMapping *ev_mapping_list_find_custom (EvMappingList *mapping_list,
EvMapping *ev_mapping_list_get (EvMappingList *mapping_list,
gdouble x,
gdouble y);
+GArray *ev_mapping_list_get_all (EvMappingList *mapping_list,
+ gdouble x,
+ gdouble y);
gpointer ev_mapping_list_get_data (EvMappingList *mapping_list,
gdouble x,
gdouble y);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]