]> www.fi.muni.cz Git - evince.git/blobdiff - libdocument/ev-document.c
Install ev-backends-manager.h and ev-document-type-builtins.h. Fixes bug
[evince.git] / libdocument / ev-document.c
index 2c6db95a0a552b8acec54f285bfdec0e9be91b3e..1ca362e07c7f45355b0b0dc167d023641087ceba 100644 (file)
 
 #include "ev-document.h"
 
-#include "ev-backend-marshalers.h"
-
 static void ev_document_class_init (gpointer g_class);
 
 
 GMutex *ev_doc_mutex = NULL;
 GMutex *ev_fc_mutex = NULL;
 
-#define LOG(x) 
 GType
 ev_document_get_type (void)
 {
@@ -49,6 +46,8 @@ ev_document_get_type (void)
                type = g_type_register_static (G_TYPE_INTERFACE,
                                               "EvDocument",
                                               &our_info, (GTypeFlags)0);
+               
+               g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
        }
 
        return type;
@@ -90,6 +89,12 @@ ev_document_doc_mutex_unlock (void)
        g_mutex_unlock (ev_document_get_doc_mutex ());
 }
 
+gboolean
+ev_document_doc_mutex_trylock (void)
+{
+       return g_mutex_trylock (ev_document_get_doc_mutex ());
+}
+
 GMutex *
 ev_document_get_fc_mutex (void)
 {
@@ -111,6 +116,12 @@ ev_document_fc_mutex_unlock (void)
        g_mutex_unlock (ev_document_get_fc_mutex ());
 }
 
+gboolean
+ev_document_fc_mutex_trylock (void)
+{
+       return g_mutex_trylock (ev_document_get_fc_mutex ());
+}
+
 gboolean
 ev_document_load (EvDocument  *document,
                  const char  *uri,
@@ -118,7 +129,7 @@ ev_document_load (EvDocument  *document,
 {
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
        gboolean retval;
-       LOG ("ev_document_load");
+
        retval = iface->load (document, uri, error);
 
        return retval;
@@ -132,7 +143,6 @@ ev_document_save (EvDocument  *document,
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
        gboolean retval;
 
-       LOG ("ev_document_save");
        retval = iface->save (document, uri, error);
 
        return retval;
@@ -144,31 +154,43 @@ ev_document_get_n_pages (EvDocument  *document)
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
        gint retval;
 
-       LOG ("ev_document_get_n_pages");
        retval = iface->get_n_pages (document);
 
        return retval;
 }
 
+EvPage *
+ev_document_get_page (EvDocument *document,
+                     gint        index)
+{
+       EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+       EvPage *retval;
+
+       if (iface->get_page)
+               retval = iface->get_page (document, index);
+       else
+               retval = ev_page_new (index);
+
+       return retval;
+}
+
 void
-ev_document_get_page_size   (EvDocument   *document,
-                            int           page,
-                            double       *width,
-                            double       *height)
+ev_document_get_page_size (EvDocument *document,
+                          EvPage     *page,
+                          double     *width,
+                          double     *height)
 {
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
 
-       LOG ("ev_document_get_page_size");
        iface->get_page_size (document, page, width, height);
 }
 
 char *
-ev_document_get_page_label(EvDocument    *document,
-                          int             page)
+ev_document_get_page_label (EvDocument *document,
+                           EvPage     *page)
 {
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
 
-       LOG ("ev_document_get_page_label");
        if (iface->get_page_label == NULL)
                return NULL;
 
@@ -200,7 +222,6 @@ ev_document_get_attachments (EvDocument *document)
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
        GList *retval;
 
-       LOG ("ev_document_get_attachments");
        if (iface->get_attachments == NULL)
                return NULL;
        retval = iface->get_attachments (document);
@@ -215,7 +236,6 @@ ev_document_render (EvDocument      *document,
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
        cairo_surface_t *retval;
 
-       LOG ("ev_document_render_pixbuf");
        g_assert (iface->render);
 
        retval = iface->render (document, rc);
@@ -223,6 +243,48 @@ ev_document_render (EvDocument      *document,
        return retval;
 }
 
+/* EvDocumentInfo */
+GType
+ev_document_info_get_type (void)
+{
+       static GType type = 0;
+       if (type == 0)
+               type = g_boxed_type_register_static ("EvDocumentInfo",
+                                                    (GBoxedCopyFunc)ev_document_info_copy,
+                                                    (GBoxedFreeFunc)ev_document_info_free);
+       return type;
+}
+
+EvDocumentInfo *
+ev_document_info_copy (EvDocumentInfo *info)
+{
+       EvDocumentInfo *copy;
+       
+       g_return_val_if_fail (info != NULL, NULL);
+
+       copy = g_new0 (EvDocumentInfo, 1);
+       copy->title = info->title ? g_strdup (info->title) : NULL;
+       copy->format = info->format ? g_strdup (info->format) : NULL;
+       copy->author = info->author ? g_strdup (info->author) : NULL;
+       copy->subject = info->subject ? g_strdup (info->subject) : NULL;
+       copy->keywords = info->keywords ? g_strdup (info->keywords) : NULL;
+       copy->security = info->security ? g_strdup (info->security) : NULL;
+       copy->creator = info->creator ? g_strdup (info->creator) : NULL;
+       copy->producer = info->producer ? g_strdup (info->producer) : NULL;
+       copy->linearized = info->linearized ? g_strdup (info->linearized) : NULL;
+       
+       copy->creation_date = info->creation_date;
+       copy->modified_date = info->modified_date;
+       copy->layout = info->layout;
+       copy->mode = info->mode;
+       copy->ui_hints = info->ui_hints;
+       copy->permissions = info->permissions;
+       copy->n_pages = info->n_pages;
+       copy->fields_mask = info->fields_mask;
+
+       return copy;
+}
+
 void
 ev_document_info_free (EvDocumentInfo *info)
 {
@@ -239,7 +301,6 @@ ev_document_info_free (EvDocumentInfo *info)
        g_free (info->linearized);
        g_free (info->security);
        
-
        g_free (info);
 }