[evince/wip/highlight: 52/59] document: ev_mapping_list_get_all
- From: Giselle Reis <gisellemnr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/wip/highlight: 52/59] document: ev_mapping_list_get_all
- Date: Sun, 2 Nov 2014 10:59:25 +0000 (UTC)
commit 535d2ef9559e44ad986d22af9d5e06cf79946914
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.
libdocument/ev-mapping-list.c | 41 +++++++++++++++++++++++++++++++++++++++++
libdocument/ev-mapping-list.h | 3 +++
2 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/libdocument/ev-mapping-list.c b/libdocument/ev-mapping-list.c
index f1cb198..74275c6 100644
--- a/libdocument/ev-mapping-list.c
+++ b/libdocument/ev-mapping-list.c
@@ -133,6 +133,47 @@ ev_mapping_list_get (EvMappingList *mapping_list,
}
/**
+ * 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
* @x: X coordinate
diff --git a/libdocument/ev-mapping-list.h b/libdocument/ev-mapping-list.h
index dcbb50b..35c2517 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]