Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Garcia Campos <carlosgc@gnome.org>2010-07-11 08:52:34 (GMT)
committer Carlos Garcia Campos <carlosgc@gnome.org>2010-07-12 17:12:01 (GMT)
commit356536f6b8b44bfcf13c644a26ecdd583465bc0f (patch)
tree8b9cb701358fccc2d3a269f02308fd99fe853b0c
parentc3f6c6c0006922557b54e263513c38ac7c88a12d (diff)
Add EvMappingList data struct instead of using a GList
It just wraps the GList and adds reference counting
-rw-r--r--backend/djvu/djvu-document.c2
-rw-r--r--backend/djvu/djvu-links.c6
-rw-r--r--backend/djvu/djvu-links.h14
-rw-r--r--backend/pdf/ev-poppler.cc19
-rw-r--r--evince-document.h1
-rw-r--r--libdocument/Makefile.am4
-rw-r--r--libdocument/ev-document-annotations.c2
-rw-r--r--libdocument/ev-document-annotations.h23
-rw-r--r--libdocument/ev-document-forms.c2
-rw-r--r--libdocument/ev-document-forms.h135
-rw-r--r--libdocument/ev-document-images.c2
-rw-r--r--libdocument/ev-document-images.h19
-rw-r--r--libdocument/ev-document-links.c7
-rw-r--r--libdocument/ev-document-links.h35
-rw-r--r--libdocument/ev-mapping-list.c146
-rw-r--r--libdocument/ev-mapping-list.h (renamed from libdocument/ev-mapping.h)34
-rw-r--r--libdocument/ev-mapping.c93
-rw-r--r--libview/ev-jobs.h8
-rw-r--r--libview/ev-page-cache.c26
-rw-r--r--libview/ev-page-cache.h8
-rw-r--r--libview/ev-pixbuf-cache.c4
-rw-r--r--libview/ev-view-accessible.c1
-rw-r--r--libview/ev-view-presentation.c13
-rw-r--r--libview/ev-view.c63
24 files changed, 364 insertions, 303 deletions
diff --git a/backend/djvu/djvu-document.c b/backend/djvu/djvu-document.c
index 0023a1c..aa0e595 100644
--- a/backend/djvu/djvu-document.c
+++ b/backend/djvu/djvu-document.c
@@ -689,7 +689,7 @@ djvu_document_find_iface_init (EvDocumentFindInterface *iface)
iface->find_text = djvu_document_find_find_text;
}
-static GList *
+static EvMappingList *
djvu_document_links_get_links (EvDocumentLinks *document_links,
EvPage *page)
{
diff --git a/backend/djvu/djvu-links.c b/backend/djvu/djvu-links.c
index 72d68f9..d13af0b 100644
--- a/backend/djvu/djvu-links.c
+++ b/backend/djvu/djvu-links.c
@@ -26,7 +26,7 @@
#include "djvu-links.h"
#include "djvu-document-private.h"
#include "ev-document-links.h"
-#include "ev-mapping.h"
+#include "ev-mapping-list.h"
static gboolean number_from_miniexp(miniexp_t sexp, int *number)
{
@@ -354,7 +354,7 @@ djvu_links_has_document_links (EvDocumentLinks *document_links)
return FALSE;
}
-GList *
+EvMappingList *
djvu_links_get_links (EvDocumentLinks *document_links,
gint page,
double scale_factor)
@@ -390,7 +390,7 @@ djvu_links_get_links (EvDocumentLinks *document_links,
ddjvu_miniexp_release (djvu_document->d_document, page_annotations);
}
- return retval;
+ return ev_mapping_list_new (page, retval, (GDestroyNotify)g_object_unref);
}
EvLinkDest *
diff --git a/backend/djvu/djvu-links.h b/backend/djvu/djvu-links.h
index 3a3c5d6..76d9072 100644
--- a/backend/djvu/djvu-links.h
+++ b/backend/djvu/djvu-links.h
@@ -24,12 +24,12 @@
#include <glib.h>
-GtkTreeModel *djvu_links_get_links_model (EvDocumentLinks *document_links);
-GList *djvu_links_get_links (EvDocumentLinks *document_links,
- gint page,
- double scale_factor);
-EvLinkDest *djvu_links_find_link_dest (EvDocumentLinks *document_links,
- const gchar *link_name);
-gboolean djvu_links_has_document_links (EvDocumentLinks *document_links);
+GtkTreeModel *djvu_links_get_links_model (EvDocumentLinks *document_links);
+EvMappingList *djvu_links_get_links (EvDocumentLinks *document_links,
+ gint page,
+ double scale_factor);
+EvLinkDest *djvu_links_find_link_dest (EvDocumentLinks *document_links,
+ const gchar *link_name);
+gboolean djvu_links_has_document_links (EvDocumentLinks *document_links);
#endif /* __DJVU_LINK_H__ */
diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc
index 64ac308..83bccdf 100644
--- a/backend/pdf/ev-poppler.cc
+++ b/backend/pdf/ev-poppler.cc
@@ -37,7 +37,6 @@
#include "ev-poppler.h"
#include "ev-file-exporter.h"
-#include "ev-mapping.h"
#include "ev-document-find.h"
#include "ev-document-misc.h"
#include "ev-document-links.h"
@@ -1242,7 +1241,7 @@ pdf_document_links_get_links_model (EvDocumentLinks *document_links)
return model;
}
-static GList *
+static EvMappingList *
pdf_document_links_get_links (EvDocumentLinks *document_links,
EvPage *page)
{
@@ -1277,7 +1276,7 @@ pdf_document_links_get_links (EvDocumentLinks *document_links,
poppler_page_free_link_mapping (mapping_list);
- return g_list_reverse (retval);
+ return ev_mapping_list_new (page->index, g_list_reverse (retval), (GDestroyNotify)g_object_unref);
}
static EvLinkDest *
@@ -1308,7 +1307,7 @@ pdf_document_document_links_iface_init (EvDocumentLinksInterface *iface)
iface->find_link_dest = pdf_document_links_find_link_dest;
}
-static GList *
+static EvMappingList *
pdf_document_images_get_image_mapping (EvDocumentImages *document_images,
EvPage *page)
{
@@ -1341,7 +1340,7 @@ pdf_document_images_get_image_mapping (EvDocumentImages *document_images,
poppler_page_free_image_mapping (mapping_list);
- return g_list_reverse (retval);
+ return ev_mapping_list_new (page->index, g_list_reverse (retval), (GDestroyNotify)g_object_unref);
}
GdkPixbuf *
@@ -2265,7 +2264,7 @@ ev_form_field_from_poppler_field (PopplerFormField *poppler_field)
return ev_field;
}
-static GList *
+static EvMappingList *
pdf_document_forms_get_form_fields (EvDocumentForms *document,
EvPage *page)
{
@@ -2310,7 +2309,9 @@ pdf_document_forms_get_form_fields (EvDocumentForms *document,
poppler_page_free_form_field_mapping (fields);
- return g_list_reverse (retval);
+ return retval ? ev_mapping_list_new (page->index,
+ g_list_reverse (retval),
+ (GDestroyNotify)g_object_unref) : NULL;
}
static gchar *
@@ -2664,7 +2665,7 @@ ev_annot_from_poppler_annot (PopplerAnnot *poppler_annot,
return ev_annot;
}
-static GList *
+static EvMappingList *
pdf_document_annotations_get_annotations (EvDocumentAnnotations *document_annotations,
EvPage *page)
{
@@ -2715,7 +2716,7 @@ pdf_document_annotations_get_annotations (EvDocumentAnnotations *document_annota
poppler_page_free_annot_mapping (annots);
- return g_list_reverse (retval);
+ return ev_mapping_list_new (page->index, g_list_reverse (retval), (GDestroyNotify)g_object_unref);
}
static void
diff --git a/evince-document.h b/evince-document.h
index 6d7e248..4da2d67 100644
--- a/evince-document.h
+++ b/evince-document.h
@@ -49,6 +49,7 @@
#include <libdocument/ev-link-action.h>
#include <libdocument/ev-link-dest.h>
#include <libdocument/ev-link.h>
+#include <libdocument/ev-mapping-list.h>
#include <libdocument/ev-page.h>
#include <libdocument/ev-render-context.h>
#include <libdocument/ev-selection.h>
diff --git a/libdocument/Makefile.am b/libdocument/Makefile.am
index dae6953..facf17c 100644
--- a/libdocument/Makefile.am
+++ b/libdocument/Makefile.am
@@ -35,7 +35,7 @@ INST_H_SRC_FILES = \
ev-link-action.h \
ev-link-dest.h \
ev-link.h \
- ev-mapping.h \
+ ev-mapping-list.h \
ev-page.h \
ev-render-context.h \
ev-selection.h \
@@ -80,7 +80,7 @@ libevdocument_la_SOURCES= \
ev-debug.c \
ev-file-exporter.c \
ev-file-helpers.c \
- ev-mapping.c \
+ ev-mapping-list.c \
ev-module.c \
ev-page.c \
ev-render-context.c \
diff --git a/libdocument/ev-document-annotations.c b/libdocument/ev-document-annotations.c
index 4523fb4..6ccdd57 100644
--- a/libdocument/ev-document-annotations.c
+++ b/libdocument/ev-document-annotations.c
@@ -28,7 +28,7 @@ ev_document_annotations_default_init (EvDocumentAnnotationsInterface *klass)
{
}
-GList *
+EvMappingList *
ev_document_annotations_get_annotations (EvDocumentAnnotations *document_annots,
EvPage *page)
{
diff --git a/libdocument/ev-document-annotations.h b/libdocument/ev-document-annotations.h
index 8f06b11..6da49d9 100644
--- a/libdocument/ev-document-annotations.h
+++ b/libdocument/ev-document-annotations.h
@@ -29,6 +29,7 @@
#include "ev-document.h"
#include "ev-annotation.h"
+#include "ev-mapping-list.h"
G_BEGIN_DECLS
@@ -47,20 +48,20 @@ struct _EvDocumentAnnotationsInterface
GTypeInterface base_iface;
/* Methods */
- GList *(* get_annotations) (EvDocumentAnnotations *document_annots,
- EvPage *page);
- void (* annotation_set_contents) (EvDocumentAnnotations *document_annots,
- EvAnnotation *annot,
- const gchar *contents);
+ EvMappingList *(* get_annotations) (EvDocumentAnnotations *document_annots,
+ EvPage *page);
+ void (* annotation_set_contents) (EvDocumentAnnotations *document_annots,
+ EvAnnotation *annot,
+ const gchar *contents);
};
-GType ev_document_annotations_get_type (void) G_GNUC_CONST;
-GList *ev_document_annotations_get_annotations (EvDocumentAnnotations *document_annots,
- EvPage *page);
+GType ev_document_annotations_get_type (void) G_GNUC_CONST;
+EvMappingList *ev_document_annotations_get_annotations (EvDocumentAnnotations *document_annots,
+ EvPage *page);
-void ev_document_annotations_annotation_set_contents (EvDocumentAnnotations *document_annots,
- EvAnnotation *annot,
- const gchar *contents);
+void ev_document_annotations_annotation_set_contents (EvDocumentAnnotations *document_annots,
+ EvAnnotation *annot,
+ const gchar *contents);
G_END_DECLS
diff --git a/libdocument/ev-document-forms.c b/libdocument/ev-document-forms.c
index 9e8fb0e..c6d558b 100644
--- a/libdocument/ev-document-forms.c
+++ b/libdocument/ev-document-forms.c
@@ -28,7 +28,7 @@ ev_document_forms_default_init (EvDocumentFormsInterface *klass)
{
}
-GList *
+EvMappingList *
ev_document_forms_get_form_fields (EvDocumentForms *document_forms,
EvPage *page)
{
diff --git a/libdocument/ev-document-forms.h b/libdocument/ev-document-forms.h
index 3552467..32ec6a1 100644
--- a/libdocument/ev-document-forms.h
+++ b/libdocument/ev-document-forms.h
@@ -29,6 +29,7 @@
#include "ev-document.h"
#include "ev-form-field.h"
+#include "ev-mapping-list.h"
G_BEGIN_DECLS
@@ -47,78 +48,78 @@ struct _EvDocumentFormsInterface
GTypeInterface base_iface;
/* Methods */
- GList *(* get_form_fields) (EvDocumentForms *document_forms,
- EvPage *page);
- gchar *(* form_field_text_get_text) (EvDocumentForms *document_forms,
- EvFormField *field);
- void (* form_field_text_set_text) (EvDocumentForms *document_forms,
- EvFormField *field,
- const gchar *text);
- gboolean (* form_field_button_get_state) (EvDocumentForms *document_forms,
- EvFormField *field);
- void (* form_field_button_set_state) (EvDocumentForms *document_forms,
- EvFormField *field,
- gboolean state);
- gchar *(* form_field_choice_get_item) (EvDocumentForms *document_forms,
- EvFormField *field,
- gint index);
- gint (* form_field_choice_get_n_items) (EvDocumentForms *document_forms,
- EvFormField *field);
- gboolean (* form_field_choice_is_item_selected) (EvDocumentForms *document_forms,
- EvFormField *field,
- gint index);
- void (* form_field_choice_select_item) (EvDocumentForms *document_forms,
- EvFormField *field,
- gint index);
- void (* form_field_choice_toggle_item) (EvDocumentForms *document_forms,
- EvFormField *field,
- gint index);
- void (* form_field_choice_unselect_all) (EvDocumentForms *document_forms,
- EvFormField *field);
- void (* form_field_choice_set_text) (EvDocumentForms *document_forms,
- EvFormField *field,
- const gchar *text);
- gchar *(* form_field_choice_get_text) (EvDocumentForms *document_forms,
- EvFormField *field);
+ EvMappingList *(* get_form_fields) (EvDocumentForms *document_forms,
+ EvPage *page);
+ gchar *(* form_field_text_get_text) (EvDocumentForms *document_forms,
+ EvFormField *field);
+ void (* form_field_text_set_text) (EvDocumentForms *document_forms,
+ EvFormField *field,
+ const gchar *text);
+ gboolean (* form_field_button_get_state) (EvDocumentForms *document_forms,
+ EvFormField *field);
+ void (* form_field_button_set_state) (EvDocumentForms *document_forms,
+ EvFormField *field,
+ gboolean state);
+ gchar *(* form_field_choice_get_item) (EvDocumentForms *document_forms,
+ EvFormField *field,
+ gint index);
+ gint (* form_field_choice_get_n_items) (EvDocumentForms *document_forms,
+ EvFormField *field);
+ gboolean (* form_field_choice_is_item_selected) (EvDocumentForms *document_forms,
+ EvFormField *field,
+ gint index);
+ void (* form_field_choice_select_item) (EvDocumentForms *document_forms,
+ EvFormField *field,
+ gint index);
+ void (* form_field_choice_toggle_item) (EvDocumentForms *document_forms,
+ EvFormField *field,
+ gint index);
+ void (* form_field_choice_unselect_all) (EvDocumentForms *document_forms,
+ EvFormField *field);
+ void (* form_field_choice_set_text) (EvDocumentForms *document_forms,
+ EvFormField *field,
+ const gchar *text);
+ gchar *(* form_field_choice_get_text) (EvDocumentForms *document_forms,
+ EvFormField *field);
};
-GType ev_document_forms_get_type (void) G_GNUC_CONST;
-GList *ev_document_forms_get_form_fields (EvDocumentForms *document_forms,
- EvPage *page);
+GType ev_document_forms_get_type (void) G_GNUC_CONST;
+EvMappingList *ev_document_forms_get_form_fields (EvDocumentForms *document_forms,
+ EvPage *page);
-gchar *ev_document_forms_form_field_text_get_text (EvDocumentForms *document_forms,
- EvFormField *field);
-void ev_document_forms_form_field_text_set_text (EvDocumentForms *document_forms,
- EvFormField *field,
- const gchar *text);
+gchar *ev_document_forms_form_field_text_get_text (EvDocumentForms *document_forms,
+ EvFormField *field);
+void ev_document_forms_form_field_text_set_text (EvDocumentForms *document_forms,
+ EvFormField *field,
+ const gchar *text);
-gboolean ev_document_forms_form_field_button_get_state (EvDocumentForms *document_forms,
- EvFormField *field);
-void ev_document_forms_form_field_button_set_state (EvDocumentForms *document_forms,
- EvFormField *field,
- gboolean state);
+gboolean ev_document_forms_form_field_button_get_state (EvDocumentForms *document_forms,
+ EvFormField *field);
+void ev_document_forms_form_field_button_set_state (EvDocumentForms *document_forms,
+ EvFormField *field,
+ gboolean state);
-gchar *ev_document_forms_form_field_choice_get_item (EvDocumentForms *document_forms,
- EvFormField *field,
- gint index);
-gint ev_document_forms_form_field_choice_get_n_items (EvDocumentForms *document_forms,
- EvFormField *field);
-gboolean ev_document_forms_form_field_choice_is_item_selected (EvDocumentForms *document_forms,
- EvFormField *field,
- gint index);
-void ev_document_forms_form_field_choice_select_item (EvDocumentForms *document_forms,
- EvFormField *field,
- gint index);
-void ev_document_forms_form_field_choice_toggle_item (EvDocumentForms *document_forms,
- EvFormField *field,
- gint index);
-void ev_document_forms_form_field_choice_unselect_all (EvDocumentForms *document_forms,
- EvFormField *field);
-void ev_document_forms_form_field_choice_set_text (EvDocumentForms *document_forms,
- EvFormField *field,
- const gchar *text);
-gchar *ev_document_forms_form_field_choice_get_text (EvDocumentForms *document_forms,
- EvFormField *field);
+gchar *ev_document_forms_form_field_choice_get_item (EvDocumentForms *document_forms,
+ EvFormField *field,
+ gint index);
+gint ev_document_forms_form_field_choice_get_n_items (EvDocumentForms *document_forms,
+ EvFormField *field);
+gboolean ev_document_forms_form_field_choice_is_item_selected (EvDocumentForms *document_forms,
+ EvFormField *field,
+ gint index);
+void ev_document_forms_form_field_choice_select_item (EvDocumentForms *document_forms,
+ EvFormField *field,
+ gint index);
+void ev_document_forms_form_field_choice_toggle_item (EvDocumentForms *document_forms,
+ EvFormField *field,
+ gint index);
+void ev_document_forms_form_field_choice_unselect_all (EvDocumentForms *document_forms,
+ EvFormField *field);
+void ev_document_forms_form_field_choice_set_text (EvDocumentForms *document_forms,
+ EvFormField *field,
+ const gchar *text);
+gchar *ev_document_forms_form_field_choice_get_text (EvDocumentForms *document_forms,
+ EvFormField *field);
G_END_DECLS
diff --git a/libdocument/ev-document-images.c b/libdocument/ev-document-images.c
index c03b8f9..a312bc7 100644
--- a/libdocument/ev-document-images.c
+++ b/libdocument/ev-document-images.c
@@ -28,7 +28,7 @@ ev_document_images_default_init (EvDocumentImagesInterface *klass)
{
}
-GList *
+EvMappingList *
ev_document_images_get_image_mapping (EvDocumentImages *document_images,
EvPage *page)
{
diff --git a/libdocument/ev-document-images.h b/libdocument/ev-document-images.h
index d9f6b02..8a02869 100644
--- a/libdocument/ev-document-images.h
+++ b/libdocument/ev-document-images.h
@@ -30,6 +30,7 @@
#include "ev-document.h"
#include "ev-image.h"
+#include "ev-mapping-list.h"
G_BEGIN_DECLS
@@ -47,17 +48,17 @@ struct _EvDocumentImagesInterface {
GTypeInterface base_iface;
/* Methods */
- GList *(* get_image_mapping) (EvDocumentImages *document_images,
- EvPage *page);
- GdkPixbuf *(* get_image) (EvDocumentImages *document_images,
- EvImage *image);
+ EvMappingList *(* get_image_mapping) (EvDocumentImages *document_images,
+ EvPage *page);
+ GdkPixbuf *(* get_image) (EvDocumentImages *document_images,
+ EvImage *image);
};
-GType ev_document_images_get_type (void) G_GNUC_CONST;
-GList *ev_document_images_get_image_mapping (EvDocumentImages *document_images,
- EvPage *page);
-GdkPixbuf *ev_document_images_get_image (EvDocumentImages *document_images,
- EvImage *image);
+GType ev_document_images_get_type (void) G_GNUC_CONST;
+EvMappingList *ev_document_images_get_image_mapping (EvDocumentImages *document_images,
+ EvPage *page);
+GdkPixbuf *ev_document_images_get_image (EvDocumentImages *document_images,
+ EvImage *image);
G_END_DECLS
diff --git a/libdocument/ev-document-links.c b/libdocument/ev-document-links.c
index 7b31c4d..b8aae5d 100644
--- a/libdocument/ev-document-links.c
+++ b/libdocument/ev-document-links.c
@@ -54,16 +54,13 @@ ev_document_links_get_links_model (EvDocumentLinks *document_links)
return retval;
}
-GList *
+EvMappingList *
ev_document_links_get_links (EvDocumentLinks *document_links,
EvPage *page)
{
EvDocumentLinksInterface *iface = EV_DOCUMENT_LINKS_GET_IFACE (document_links);
- GList *retval;
- retval = iface->get_links (document_links, page);
-
- return retval;
+ return iface->get_links (document_links, page);
}
EvLinkDest *
diff --git a/libdocument/ev-document-links.h b/libdocument/ev-document-links.h
index e6d9020..3614840 100644
--- a/libdocument/ev-document-links.h
+++ b/libdocument/ev-document-links.h
@@ -34,6 +34,7 @@
#include "ev-document.h"
#include "ev-link.h"
+#include "ev-mapping-list.h"
G_BEGIN_DECLS
@@ -60,26 +61,26 @@ struct _EvDocumentLinksInterface
GTypeInterface base_iface;
/* Methods */
- gboolean (* has_document_links) (EvDocumentLinks *document_links);
- GtkTreeModel *(* get_links_model) (EvDocumentLinks *document_links);
- GList *(* get_links) (EvDocumentLinks *document_links,
- EvPage *page);
- EvLinkDest *(* find_link_dest) (EvDocumentLinks *document_links,
- const gchar *link_name);
+ gboolean (* has_document_links) (EvDocumentLinks *document_links);
+ GtkTreeModel *(* get_links_model) (EvDocumentLinks *document_links);
+ EvMappingList *(* get_links) (EvDocumentLinks *document_links,
+ EvPage *page);
+ EvLinkDest *(* find_link_dest) (EvDocumentLinks *document_links,
+ const gchar *link_name);
};
-GType ev_document_links_get_type (void);
-gboolean ev_document_links_has_document_links (EvDocumentLinks *document_links);
-GtkTreeModel *ev_document_links_get_links_model (EvDocumentLinks *document_links);
+GType ev_document_links_get_type (void) G_GNUC_CONST;
+gboolean ev_document_links_has_document_links (EvDocumentLinks *document_links);
+GtkTreeModel *ev_document_links_get_links_model (EvDocumentLinks *document_links);
-GList *ev_document_links_get_links (EvDocumentLinks *document_links,
- EvPage *page);
-EvLinkDest *ev_document_links_find_link_dest (EvDocumentLinks *document_links,
- const gchar *link_name);
-gint ev_document_links_get_dest_page (EvDocumentLinks *document_links,
- EvLinkDest *dest);
-gchar *ev_document_links_get_dest_page_label(EvDocumentLinks *document_links,
- EvLinkDest *dest);
+EvMappingList *ev_document_links_get_links (EvDocumentLinks *document_links,
+ EvPage *page);
+EvLinkDest *ev_document_links_find_link_dest (EvDocumentLinks *document_links,
+ const gchar *link_name);
+gint ev_document_links_get_dest_page (EvDocumentLinks *document_links,
+ EvLinkDest *dest);
+gchar *ev_document_links_get_dest_page_label (EvDocumentLinks *document_links,
+ EvLinkDest *dest);
G_END_DECLS
diff --git a/libdocument/ev-mapping-list.c b/libdocument/ev-mapping-list.c
new file mode 100644
index 0000000..024cb49
--- /dev/null
+++ b/libdocument/ev-mapping-list.c
@@ -0,0 +1,146 @@
+/* ev-mapping.c
+ * this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
+ *
+ * Evince is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "ev-mapping-list.h"
+
+struct _EvMappingList {
+ guint page;
+ GList *list;
+ GDestroyNotify data_destroy_func;
+ volatile gint ref_count;
+};
+
+EvMapping *
+ev_mapping_list_find (EvMappingList *mapping_list,
+ gconstpointer data)
+{
+ GList *list;
+
+ for (list = mapping_list->list; list; list = list->next) {
+ EvMapping *mapping = list->data;
+
+ if (mapping->data == data)
+ return mapping;
+ }
+
+ return NULL;
+}
+
+EvMapping *
+ev_mapping_list_find_custom (EvMappingList *mapping_list,
+ gconstpointer data,
+ GCompareFunc func)
+{
+ GList *list;
+
+ for (list = mapping_list->list; list; list = list->next) {
+ EvMapping *mapping = list->data;
+
+ if (!func (mapping->data, data))
+ return mapping;
+ }
+
+ return NULL;
+}
+
+gpointer
+ev_mapping_list_get_data (EvMappingList *mapping_list,
+ gdouble x,
+ gdouble y)
+{
+ GList *list;
+
+ 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)) {
+ return mapping->data;
+ }
+ }
+
+ return NULL;
+}
+
+GList *
+ev_mapping_list_get_list (EvMappingList *mapping_list)
+{
+ return mapping_list ? mapping_list->list : NULL;
+}
+
+guint
+ev_mapping_list_get_page (EvMappingList *mapping_list)
+{
+ return mapping_list->page;
+}
+
+EvMappingList *
+ev_mapping_list_new (guint page,
+ GList *list,
+ GDestroyNotify data_destroy_func)
+{
+ EvMappingList *mapping_list;
+
+ g_return_val_if_fail (data_destroy_func != NULL, NULL);
+
+ mapping_list = g_slice_new (EvMappingList);
+ mapping_list->page = page;
+ mapping_list->list = list;
+ mapping_list->data_destroy_func = data_destroy_func;
+ mapping_list->ref_count = 1;
+
+ return mapping_list;
+}
+
+EvMappingList *
+ev_mapping_list_ref (EvMappingList *mapping_list)
+{
+ g_return_val_if_fail (mapping_list != NULL, NULL);
+ g_return_val_if_fail (mapping_list->ref_count > 0, mapping_list);
+
+ g_atomic_int_add (&mapping_list->ref_count, 1);
+
+ return mapping_list;
+}
+
+static void
+mapping_list_free_foreach (EvMapping *mapping,
+ GDestroyNotify destroy_func)
+{
+ destroy_func (mapping->data);
+ g_free (mapping);
+}
+
+void
+ev_mapping_list_unref (EvMappingList *mapping_list)
+{
+ g_return_if_fail (mapping_list != NULL);
+ g_return_if_fail (mapping_list->ref_count > 0);
+
+ if (g_atomic_int_exchange_and_add (&mapping_list->ref_count, -1) - 1 == 0) {
+ g_list_foreach (mapping_list->list,
+ (GFunc)mapping_list_free_foreach,
+ mapping_list->data_destroy_func);
+ g_list_free (mapping_list->list);
+ g_slice_free (EvMappingList, mapping_list);
+ }
+}
diff --git a/libdocument/ev-mapping.h b/libdocument/ev-mapping-list.h
index b6024c5..b207736 100644
--- a/libdocument/ev-mapping.h
+++ b/libdocument/ev-mapping-list.h
@@ -22,24 +22,32 @@
#error "Only <evince-document.h> can be included directly."
#endif
-#ifndef EV_MAPPING_H
-#define EV_MAPPING_H
+#ifndef EV_MAPPING_LIST_H
+#define EV_MAPPING_LIST_H
#include "ev-document.h"
G_BEGIN_DECLS
-EvMapping *ev_mapping_list_find (GList *mapping_list,
- gconstpointer data);
-EvMapping *ev_mapping_list_find_custom (GList *mapping_list,
- gconstpointer data,
- GCompareFunc func);
-gpointer ev_mapping_list_get_data (GList *mapping_list,
- gdouble x,
- gdouble y);
-void ev_mapping_list_free (GList *mapping_list,
- GDestroyNotify destroy_func);
+typedef struct _EvMappingList EvMappingList;
+
+EvMappingList *ev_mapping_list_new (guint page,
+ GList *list,
+ GDestroyNotify data_destroy_func);
+EvMappingList *ev_mapping_list_ref (EvMappingList *mapping_list);
+void ev_mapping_list_unref (EvMappingList *mapping_list);
+
+guint ev_mapping_list_get_page (EvMappingList *mapping_list);
+GList *ev_mapping_list_get_list (EvMappingList *mapping_list);
+EvMapping *ev_mapping_list_find (EvMappingList *mapping_list,
+ gconstpointer data);
+EvMapping *ev_mapping_list_find_custom (EvMappingList *mapping_list,
+ gconstpointer data,
+ GCompareFunc func);
+gpointer ev_mapping_list_get_data (EvMappingList *mapping_list,
+ gdouble x,
+ gdouble y);
G_END_DECLS
-#endif /* EV_MAPPING_H */
+#endif /* EV_MAPPING_LIST_H */
diff --git a/libdocument/ev-mapping.c b/libdocument/ev-mapping.c
deleted file mode 100644
index 2b2c653..0000000
--- a/libdocument/ev-mapping.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ev-mapping.c
- * this file is part of evince, a gnome document viewer
- *
- * Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
- *
- * Evince is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Evince is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "ev-mapping.h"
-
-EvMapping *
-ev_mapping_list_find (GList *mapping_list,
- gconstpointer data)
-{
- GList *list;
-
- for (list = mapping_list; list; list = list->next) {
- EvMapping *mapping = list->data;
-
- if (mapping->data == data)
- return mapping;
- }
-
- return NULL;
-}
-
-EvMapping *
-ev_mapping_list_find_custom (GList *mapping_list,
- gconstpointer data,
- GCompareFunc func)
-{
- GList *list;
-
- for (list = mapping_list; list; list = list->next) {
- EvMapping *mapping = list->data;
-
- if (!func (mapping->data, data))
- return mapping;
- }
-
- return NULL;
-}
-
-gpointer
-ev_mapping_list_get_data (GList *mapping_list,
- gdouble x,
- gdouble y)
-{
- GList *list;
-
- for (list = mapping_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)) {
- return mapping->data;
- }
- }
-
- return NULL;
-}
-
-static void
-mapping_list_free_foreach (EvMapping *mapping,
- GDestroyNotify destroy_func)
-{
- destroy_func (mapping->data);
- g_free (mapping);
-}
-
-void
-ev_mapping_list_free (GList *mapping_list,
- GDestroyNotify destroy_func)
-{
- g_list_foreach (mapping_list,
- (GFunc)mapping_list_free_foreach,
- destroy_func);
- g_list_free (mapping_list);
-}
diff --git a/libview/ev-jobs.h b/libview/ev-jobs.h
index 6844520..7690731 100644
--- a/libview/ev-jobs.h
+++ b/libview/ev-jobs.h
@@ -243,10 +243,10 @@ struct _EvJobPageData
gint page;
EvJobPageDataFlags flags;
- GList *link_mapping;
- GList *image_mapping;
- GList *form_field_mapping;
- GList *annot_mapping;
+ EvMappingList *link_mapping;
+ EvMappingList *image_mapping;
+ EvMappingList *form_field_mapping;
+ EvMappingList *annot_mapping;
cairo_region_t *text_mapping;
gchar *text;
EvRectangle *text_layout;
diff --git a/libview/ev-page-cache.c b/libview/ev-page-cache.c
index a2ae8c5..d814144 100644
--- a/libview/ev-page-cache.c
+++ b/libview/ev-page-cache.c
@@ -22,7 +22,7 @@
#include <glib.h>
#include "ev-jobs.h"
#include "ev-job-scheduler.h"
-#include "ev-mapping.h"
+#include "ev-mapping-list.h"
#include "ev-selection.h"
#include "ev-document-links.h"
#include "ev-document-forms.h"
@@ -35,10 +35,10 @@ typedef struct _EvPageCacheData {
EvJob *job;
gboolean done : 1;
- GList *link_mapping;
- GList *image_mapping;
- GList *form_field_mapping;
- GList *annot_mapping;
+ EvMappingList *link_mapping;
+ EvMappingList *image_mapping;
+ EvMappingList *form_field_mapping;
+ EvMappingList *annot_mapping;
cairo_region_t *text_mapping;
EvRectangle *text_layout;
guint text_layout_length;
@@ -72,22 +72,22 @@ ev_page_cache_data_free (EvPageCacheData *data)
}
if (data->link_mapping) {
- ev_mapping_list_free (data->link_mapping, g_object_unref);
+ ev_mapping_list_unref (data->link_mapping);
data->link_mapping = NULL;
}
if (data->image_mapping) {
- ev_mapping_list_free (data->image_mapping, g_object_unref);
+ ev_mapping_list_unref (data->image_mapping);
data->image_mapping = NULL;
}
if (data->form_field_mapping) {
- ev_mapping_list_free (data->form_field_mapping, g_object_unref);
+ ev_mapping_list_unref (data->form_field_mapping);
data->form_field_mapping = NULL;
}
if (data->annot_mapping) {
- ev_mapping_list_free (data->annot_mapping, g_object_unref);
+ ev_mapping_list_unref (data->annot_mapping);
data->annot_mapping = NULL;
}
@@ -252,7 +252,7 @@ ev_page_cache_set_flags (EvPageCache *cache,
cache->flags = flags;
}
-GList *
+EvMappingList *
ev_page_cache_get_link_mapping (EvPageCache *cache,
gint page)
{
@@ -274,7 +274,7 @@ ev_page_cache_get_link_mapping (EvPageCache *cache,
return data->link_mapping;
}
-GList *
+EvMappingList *
ev_page_cache_get_image_mapping (EvPageCache *cache,
gint page)
{
@@ -296,7 +296,7 @@ ev_page_cache_get_image_mapping (EvPageCache *cache,
return data->image_mapping;
}
-GList *
+EvMappingList *
ev_page_cache_get_form_field_mapping (EvPageCache *cache,
gint page)
{
@@ -318,7 +318,7 @@ ev_page_cache_get_form_field_mapping (EvPageCache *cache,
return data->form_field_mapping;
}
-GList *
+EvMappingList *
ev_page_cache_get_annot_mapping (EvPageCache *cache,
gint page)
{
diff --git a/libview/ev-page-cache.h b/libview/ev-page-cache.h
index c6ccfd3..4c2effb 100644
--- a/libview/ev-page-cache.h
+++ b/libview/ev-page-cache.h
@@ -47,13 +47,13 @@ void ev_page_cache_set_page_range (EvPageCache *cach
EvJobPageDataFlags ev_page_cache_get_flags (EvPageCache *cache);
void ev_page_cache_set_flags (EvPageCache *cache,
EvJobPageDataFlags flags);
-GList *ev_page_cache_get_link_mapping (EvPageCache *cache,
+EvMappingList *ev_page_cache_get_link_mapping (EvPageCache *cache,
gint page);
-GList *ev_page_cache_get_image_mapping (EvPageCache *cache,
+EvMappingList *ev_page_cache_get_image_mapping (EvPageCache *cache,
gint page);
-GList *ev_page_cache_get_form_field_mapping (EvPageCache *cache,
+EvMappingList *ev_page_cache_get_form_field_mapping (EvPageCache *cache,
gint page);
-GList *ev_page_cache_get_annot_mapping (EvPageCache *cache,
+EvMappingList *ev_page_cache_get_annot_mapping (EvPageCache *cache,
gint page);
cairo_region_t *ev_page_cache_get_text_mapping (EvPageCache *cache,
gint page);
diff --git a/libview/ev-pixbuf-cache.c b/libview/ev-pixbuf-cache.c
index 4eb5c0e..74b8674 100644
--- a/libview/ev-pixbuf-cache.c
+++ b/libview/ev-pixbuf-cache.c
@@ -1,10 +1,6 @@
#include <config.h>
#include "ev-pixbuf-cache.h"
#include "ev-job-scheduler.h"
-#include "ev-mapping.h"
-#include "ev-document-forms.h"
-#include "ev-document-images.h"
-#include "ev-document-annotations.h"
#include "ev-view-private.h"
typedef struct _CacheJobInfo
diff --git a/libview/ev-view-accessible.c b/libview/ev-view-accessible.c
index 9dfab20..7f891aa 100644
--- a/libview/ev-view-accessible.c
+++ b/libview/ev-view-accessible.c
@@ -28,7 +28,6 @@
#include "ev-page-cache.h"
#include "ev-view-accessible.h"
#include "ev-view-private.h"
-#include "ev-mapping.h"
#define EV_TYPE_VIEW_ACCESSIBLE (ev_view_accessible_get_type ())
#define EV_VIEW_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EV_TYPE_VIEW_ACCESSIBLE, EvViewAccessible))
diff --git a/libview/ev-view-presentation.c b/libview/ev-view-presentation.c
index 459272c..0a11ce1 100644
--- a/libview/ev-view-presentation.c
+++ b/libview/ev-view-presentation.c
@@ -30,7 +30,6 @@
#include "ev-transition-animation.h"
#include "ev-view-cursor.h"
#include "ev-page-cache.h"
-#include "ev-mapping.h"
enum {
PROP_0,
@@ -749,12 +748,12 @@ ev_view_presentation_get_link_at_location (EvViewPresentation *pview,
gdouble x,
gdouble y)
{
- GdkRectangle page_area;
- GList *link_mapping;
- EvLink *link;
- gdouble width, height;
- gdouble new_x, new_y;
- gdouble scale;
+ GdkRectangle page_area;
+ EvMappingList *link_mapping;
+ EvLink *link;
+ gdouble width, height;
+ gdouble new_x, new_y;
+ gdouble scale;
if (!pview->page_cache)
return NULL;
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 71470fb..1d6377f 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -28,7 +28,7 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
-#include "ev-mapping.h"
+#include "ev-mapping-list.h"
#include "ev-document-forms.h"
#include "ev-document-images.h"
#include "ev-document-links.h"
@@ -1462,11 +1462,11 @@ get_doc_point_from_location (EvView *view,
}
static void
-ev_view_get_area_from_mapping (EvView *view,
- guint page,
- GList *mapping_list,
- gconstpointer data,
- GdkRectangle *area)
+ev_view_get_area_from_mapping (EvView *view,
+ guint page,
+ EvMappingList *mapping_list,
+ gconstpointer data,
+ GdkRectangle *area)
{
EvMapping *mapping;
@@ -1485,7 +1485,7 @@ ev_view_get_link_at_location (EvView *view,
{
gint page = -1;
gint x_new = 0, y_new = 0;
- GList *link_mapping;
+ EvMappingList *link_mapping;
if (!EV_IS_DOCUMENT_LINKS (view->document))
return NULL;
@@ -1879,7 +1879,7 @@ ev_view_get_image_at_location (EvView *view,
{
gint page = -1;
gint x_new = 0, y_new = 0;
- GList *image_mapping;
+ EvMappingList *image_mapping;
if (!EV_IS_DOCUMENT_IMAGES (view->document))
return NULL;
@@ -1903,7 +1903,7 @@ ev_view_get_form_field_at_location (EvView *view,
{
gint page = -1;
gint x_new = 0, y_new = 0;
- GList *forms_mapping;
+ EvMappingList *forms_mapping;
if (!EV_IS_DOCUMENT_FORMS (view->document))
return NULL;
@@ -1923,8 +1923,8 @@ static cairo_region_t *
ev_view_form_field_get_region (EvView *view,
EvFormField *field)
{
- GdkRectangle view_area;
- GList *forms_mapping;
+ GdkRectangle view_area;
+ EvMappingList *forms_mapping;
forms_mapping = ev_page_cache_get_form_field_mapping (view->page_cache,
field->page->index);
@@ -1962,8 +1962,9 @@ ev_view_form_field_button_create_widget (EvView *view,
return NULL;
case EV_FORM_FIELD_BUTTON_CHECK:
case EV_FORM_FIELD_BUTTON_RADIO: {
- gboolean state;
- GList *forms_mapping, *l;
+ gboolean state;
+ EvMappingList *forms_mapping;
+ GList *l;
state = ev_document_forms_form_field_button_get_state (EV_DOCUMENT_FORMS (view->document),
field);
@@ -1980,7 +1981,7 @@ ev_view_form_field_button_create_widget (EvView *view,
*/
forms_mapping = ev_page_cache_get_form_field_mapping (view->page_cache,
field->page->index);
- for (l = forms_mapping; l; l = g_list_next (l)) {
+ for (l = ev_mapping_list_get_list (forms_mapping); l; l = g_list_next (l)) {
EvFormField *button = ((EvMapping *)(l->data))->data;
cairo_region_t *button_region;
@@ -2338,9 +2339,9 @@ ev_view_handle_form_field (EvView *view,
gdouble x,
gdouble y)
{
- GtkWidget *field_widget = NULL;
- GList *form_field_mapping;
- GdkRectangle view_area;
+ GtkWidget *field_widget = NULL;
+ EvMappingList *form_field_mapping;
+ GdkRectangle view_area;
if (field->is_read_only)
return;
@@ -2591,14 +2592,15 @@ static void
show_annotation_windows (EvView *view,
gint page)
{
- GList *annots, *l;
- GtkWindow *parent;
+ EvMappingList *annots;
+ GList *l;
+ GtkWindow *parent;
parent = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view)));
annots = ev_page_cache_get_annot_mapping (view->page_cache, page);
- for (l = annots; l && l->data; l = g_list_next (l)) {
+ for (l = ev_mapping_list_get_list (annots); l && l->data; l = g_list_next (l)) {
EvAnnotation *annot;
EvViewWindowChild *child;
GtkWidget *window;
@@ -2659,11 +2661,12 @@ static void
hide_annotation_windows (EvView *view,
gint page)
{
- GList *annots, *l;
+ EvMappingList *annots;
+ GList *l;
annots = ev_page_cache_get_annot_mapping (view->page_cache, page);
- for (l = annots; l && l->data; l = g_list_next (l)) {
+ for (l = ev_mapping_list_get_list (annots); l && l->data; l = g_list_next (l)) {
EvAnnotation *annot;
GtkWidget *window;
@@ -2685,7 +2688,7 @@ ev_view_get_annotation_at_location (EvView *view,
{
gint page = -1;
gint x_new = 0, y_new = 0;
- GList *annotations_mapping;
+ EvMappingList *annotations_mapping;
if (!EV_IS_DOCUMENT_ANNOTATIONS (view->document))
return NULL;
@@ -2967,7 +2970,7 @@ ev_view_size_allocate (GtkWidget *widget,
for (l = children; l && l->data; l = g_list_next (l)) {
EvFormField *field;
GdkRectangle view_area;
- GList *form_field_mapping;
+ EvMappingList *form_field_mapping;
GtkAllocation child_allocation;
GtkRequisition child_requisition;
GtkWidget *child = (GtkWidget *)l->data;
@@ -3229,9 +3232,9 @@ get_link_area (EvView *view,
EvLink *link,
GdkRectangle *area)
{
- GList *link_mapping;
- gint page;
- gint x_offset = 0, y_offset = 0;
+ EvMappingList *link_mapping;
+ gint page;
+ gint x_offset = 0, y_offset = 0;
x += view->scroll_x;
y += view->scroll_y;
@@ -3251,9 +3254,9 @@ get_annot_area (EvView *view,
EvAnnotation *annot,
GdkRectangle *area)
{
- GList *annot_mapping;
- gint page;
- gint x_offset = 0, y_offset = 0;
+ EvMappingList *annot_mapping;
+ gint page;
+ gint x_offset = 0, y_offset = 0;
x += view->scroll_x;
y += view->scroll_y;