]> www.fi.muni.cz Git - evince.git/commitdiff
Add EvMappingList data struct instead of using a GList
authorCarlos Garcia Campos <carlosgc@gnome.org>
Sun, 11 Jul 2010 08:52:34 +0000 (10:52 +0200)
committerCarlos Garcia Campos <carlosgc@gnome.org>
Mon, 12 Jul 2010 17:12:01 +0000 (19:12 +0200)
It just wraps the GList and adds reference counting

24 files changed:
backend/djvu/djvu-document.c
backend/djvu/djvu-links.c
backend/djvu/djvu-links.h
backend/pdf/ev-poppler.cc
evince-document.h
libdocument/Makefile.am
libdocument/ev-document-annotations.c
libdocument/ev-document-annotations.h
libdocument/ev-document-forms.c
libdocument/ev-document-forms.h
libdocument/ev-document-images.c
libdocument/ev-document-images.h
libdocument/ev-document-links.c
libdocument/ev-document-links.h
libdocument/ev-mapping-list.c [new file with mode: 0644]
libdocument/ev-mapping-list.h [moved from libdocument/ev-mapping.h with 53% similarity]
libdocument/ev-mapping.c [deleted file]
libview/ev-jobs.h
libview/ev-page-cache.c
libview/ev-page-cache.h
libview/ev-pixbuf-cache.c
libview/ev-view-accessible.c
libview/ev-view-presentation.c
libview/ev-view.c

index 0023a1c2678d397c8cabb70426e82bb64ce8e419..aa0e595d78b3e1d9919798fde5186bf7e08d6427 100644 (file)
@@ -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)
 {
index 72d68f96b9bee595c5ca74a198d39345baab1ad3..d13af0be49ab4ecf1a76399ad499022b6d324c4e 100644 (file)
@@ -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 *
index 3a3c5d693b2a99b7e4ff5d8c0301d600583e39f9..76d9072cfe5a5db017761d608fd4a97d02a28a5b 100644 (file)
 
 #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__ */
index 64ac3089c1b871b43614350e6b64a9eae3ae250e..83bccdf568aef28548d88e16f91989af6d91ea7f 100644 (file)
@@ -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
index 6d7e2483137b716195740df33c4221a6dd63cbb8..4da2d6754f3bee0efcedbf9e4b24d4a634dbfc1b 100644 (file)
@@ -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>
index dae6953436b83b81664fa826e126b18fa10a682b..facf17ccf1fc3a2a8845af3f320e439a01db6101 100644 (file)
@@ -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                     \
index 4523fb40db5b9c19555238418f424925d3d00e8f..6ccdd57d1fb69f66233bb451e6491757f4b191d2 100644 (file)
@@ -28,7 +28,7 @@ ev_document_annotations_default_init (EvDocumentAnnotationsInterface *klass)
 {
 }
 
-GList *
+EvMappingList *
 ev_document_annotations_get_annotations (EvDocumentAnnotations *document_annots,
                                         EvPage                *page)
 {
index 8f06b11a0a1a8a84407454695e2c14fc1f45f30f..6da49d9567fb528209967bc250bacdbee0cbeca8 100644 (file)
@@ -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
 
index 9e8fb0e3e78a4e2dc520878db74e9b0640723d4e..c6d558ba33587432082048de87bb2398963ec890 100644 (file)
@@ -28,7 +28,7 @@ ev_document_forms_default_init (EvDocumentFormsInterface *klass)
 {
 }
 
-GList *
+EvMappingList *
 ev_document_forms_get_form_fields (EvDocumentForms *document_forms,
                                   EvPage          *page)
 {
index 35524676b07d70281a10a5a794f2e2f65abf350d..32ec6a171e598fcd9e8c4b8462342e9cfb2289a9 100644 (file)
@@ -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
 
index c03b8f9087154aebc3ddcab92777f40a4d8fba65..a312bc7db829e8e7c59b7acba40fe6675b86933f 100644 (file)
@@ -28,7 +28,7 @@ ev_document_images_default_init (EvDocumentImagesInterface *klass)
 {
 }
 
-GList *
+EvMappingList *
 ev_document_images_get_image_mapping (EvDocumentImages *document_images,
                                      EvPage           *page)
 {
index d9f6b027ecdaaf4c806a23bf857d73d8bd1fe84d..8a028695e73f1d32b025f9829193ec9c7e90eec0 100644 (file)
@@ -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
 
index 7b31c4d4173458c9d534fd9b2cbc2f90e7b18284..b8aae5d71a5ac424671c6336e4b5567276350e89 100644 (file)
@@ -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 *
index e6d90204489fa03f97d5d1cebc9ff14dfc11b08d..36148403a420f5a4197fa4d34c3d365c7bb2e070 100644 (file)
@@ -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 (file)
index 0000000..024cb49
--- /dev/null
@@ -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);
+       }
+}
similarity index 53%
rename from libdocument/ev-mapping.h
rename to libdocument/ev-mapping-list.h
index b6024c5cf92580cf8e0ce384990c3547f59251ae..b207736223cbfdbaa92e046496f90f93dcda0931 100644 (file)
 #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 (file)
index 2b2c653..0000000
+++ /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);
-}
index 6844520ca89b46901f4e249f11ccd07e1645a806..76907311d00718ff89db142d2b9bb41aaa025cab 100644 (file)
@@ -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;
index a2ae8c5779f9eed8479ea4cb0f75767f48de265a..d81414417438e2c6bc5bc4619b4742dec1af821c 100644 (file)
@@ -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)
 {
index c6ccfd39f6184129d5bc0c1e9fa140f82c1a4d5d..4c2effb7587a53e3d02302174b31dba57cd27d1e 100644 (file)
@@ -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);
index 4eb5c0e0e06b9dddc66a776136250e56389223fc..74b8674f293685a68f006d165b6c29add76254f5 100644 (file)
@@ -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
index 9dfab200c26d3c2d40475919a36a3161e90e6594..7f891aaba21a5a39e804703ae610d9944a0b77ab 100644 (file)
@@ -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))
index 459272c1a00418831146a10da1ec90f6f6f300d1..0a11ce1cb5f6a95495e851d74fdef4e338d4a009 100644 (file)
@@ -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;
index 71470fbe43c20b511a8a489436f40afca67579ff..1d6377f7f9feb2b8940aa299150f67321b56f37d 100644 (file)
@@ -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;