]> www.fi.muni.cz Git - evince.git/blobdiff - backend/ev-document.c
Make frontends depend on just libev. Rework and group CFLAGS/LIBS
[evince.git] / backend / ev-document.c
index 2f50dcc832d05bdbdc14254f00d47f8c12b2ea93..3395bf7c4ac40173364190840fb53483db9fbeab 100644 (file)
 #include "config.h"
 
 #include "ev-document.h"
-#include "ev-backend-marshal.c"
 
-static void ev_document_base_init (gpointer g_class);
+#include "ev-backend-marshalers.h"
 
+static void ev_document_class_init (gpointer g_class);
+
+
+GMutex *ev_doc_mutex = NULL;
+
+#define LOG(x) 
 GType
 ev_document_get_type (void)
 {
@@ -35,8 +40,9 @@ ev_document_get_type (void)
                static const GTypeInfo our_info =
                {
                        sizeof (EvDocumentIface),
-                       ev_document_base_init,
                        NULL,
+                       NULL,
+                       (GClassInitFunc)ev_document_class_init
                };
 
                type = g_type_register_static (G_TYPE_INTERFACE,
@@ -47,127 +53,218 @@ ev_document_get_type (void)
        return type;
 }
 
+GQuark
+ev_document_error_quark (void)
+{
+  static GQuark q = 0;
+  if (q == 0)
+    q = g_quark_from_static_string ("ev-document-error-quark");
+
+  return q;
+}
+
 static void
-ev_document_base_init (gpointer g_class)
-{
-       static gboolean initialized = FALSE;
-
-       if (!initialized) {
-               g_signal_new ("found",
-                             EV_TYPE_DOCUMENT,
-                             G_SIGNAL_RUN_LAST,
-                             G_STRUCT_OFFSET (EvDocumentIface, found),
-                             NULL, NULL,
-                             _ev_backend_marshal_VOID__POINTER_INT_DOUBLE,
-                             G_TYPE_NONE, 3,
-                             G_TYPE_POINTER,
-                             G_TYPE_INT,
-                             G_TYPE_DOUBLE);
-
-               initialized = TRUE;
+ev_document_class_init (gpointer g_class)
+{
+}
+
+GMutex *
+ev_document_get_doc_mutex (void)
+{
+       if (ev_doc_mutex == NULL) {
+               ev_doc_mutex = g_mutex_new ();
        }
+       return ev_doc_mutex;
+}
+
+void
+ev_document_doc_mutex_lock (void)
+{
+       g_mutex_lock (ev_document_get_doc_mutex ());
+}
+
+void
+ev_document_doc_mutex_unlock (void)
+{
+       g_mutex_unlock (ev_document_get_doc_mutex ());
 }
 
+
+
 gboolean
 ev_document_load (EvDocument  *document,
                  const char  *uri,
                  GError     **error)
 {
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
-       return iface->load (document, uri, error);
+       gboolean retval;
+       LOG ("ev_document_load");
+       retval = iface->load (document, uri, error);
+
+       return retval;
+}
+
+gboolean
+ev_document_save (EvDocument  *document,
+                 const char  *uri,
+                 GError     **error)
+{
+       EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+       gboolean retval;
+
+       LOG ("ev_document_save");
+       retval = iface->save (document, uri, error);
+
+       return retval;
 }
 
 int
 ev_document_get_n_pages (EvDocument  *document)
 {
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
-       return iface->get_n_pages (document);
+       gint retval;
+
+       LOG ("ev_document_get_n_pages");
+       retval = iface->get_n_pages (document);
+
+       return retval;
 }
 
 void
-ev_document_set_page (EvDocument  *document,
-                     int          page)
+ev_document_get_page_size   (EvDocument   *document,
+                            int           page,
+                            double       *width,
+                            double       *height)
 {
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
-       iface->set_page (document, page);
+
+       LOG ("ev_document_get_page_size");
+       iface->get_page_size (document, page, width, height);
 }
 
-int
-ev_document_get_page (EvDocument *document)
+char *
+ev_document_get_page_label(EvDocument    *document,
+                          int             page)
 {
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
-       return iface->get_page (document);
+
+       LOG ("ev_document_get_page_label");
+       if (iface->get_page_label == NULL)
+               return NULL;
+
+       return iface->get_page_label (document, page);
 }
 
-void
-ev_document_set_target (EvDocument  *document,
-                       GdkDrawable *target)
+gboolean
+ev_document_can_get_text (EvDocument  *document)
 {
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
-       iface->set_target (document, target);
+
+       return iface->can_get_text (document);
 }
 
-void
-ev_document_set_scale (EvDocument   *document,
-                      double        scale)
+EvDocumentInfo *
+ev_document_get_info (EvDocument *document)
 {
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
-       iface->set_scale (document, scale);
+
+       return iface->get_info (document);
 }
 
-void
-ev_document_set_page_offset (EvDocument  *document,
-                            int          x,
-                            int          y)
+char *
+ev_document_get_text (EvDocument  *document,
+                     int          page,
+                     EvRectangle *rect)
 {
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
-       iface->set_page_offset (document, x, y);
+       char *retval;
+
+       LOG ("ev_document_get_text");
+       retval = iface->get_text (document, page, rect);
+
+       return retval;
 }
 
-void
-ev_document_get_page_size   (EvDocument   *document,
-                            int          *width,
-                            int          *height)
+GList *
+ev_document_get_links (EvDocument *document,
+                      int         page)
 {
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
-       iface->get_page_size (document, width, height);
+       GList *retval;
+
+       LOG ("ev_document_get_link");
+       if (iface->get_links == NULL)
+               return NULL;
+       retval = iface->get_links (document, page);
+
+       return retval;
 }
 
-void
-ev_document_render (EvDocument  *document,
-                   int          clip_x,
-                   int          clip_y,
-                   int          clip_width,
-                   int          clip_height)
+
+
+GdkPixbuf *
+ev_document_render_pixbuf (EvDocument      *document,
+                          EvRenderContext *rc)
 {
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
-       iface->render (document, clip_x, clip_y, clip_width, clip_height);
+       GdkPixbuf *retval;
+
+       LOG ("ev_document_render_pixbuf");
+       g_assert (iface->render_pixbuf);
+
+       retval = iface->render_pixbuf (document, rc);
+
+       return retval;
 }
 
-void
-ev_document_begin_find (EvDocument   *document,
-                       const char   *search_string,
-                       gboolean      case_sensitive)
+EvOrientation
+ev_document_get_orientation (EvDocument *document)
 {
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
-       iface->begin_find (document, search_string, case_sensitive);
+
+       return iface->get_orientation (document);
 }
 
 void
-ev_document_end_find (EvDocument   *document)
+ev_document_set_orientation (EvDocument     *document,
+                            EvOrientation   orientation)
 {
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
-       iface->end_find (document);
+
+       iface->set_orientation (document, orientation);
 }
 
 void
-ev_document_found (EvDocument         *document,
-                  const EvFindResult *results,
-                  int                 n_results,
-                  double              percent_complete)
+ev_document_info_free (EvDocumentInfo *info)
 {
-       g_signal_emit_by_name (document,
-                              "found",
-                              results, n_results, percent_complete);
+       if (info == NULL)
+               return;
+
+       g_free (info->title);
+       g_free (info->format);
+       g_free (info->author);
+       g_free (info->subject);
+       g_free (info->keywords);
+       g_free (info->security);
+
+       g_free (info);
+}
+
+
+/* Compares two rects.  returns 0 if they're equal */
+#define EPSILON 0.0000001
+
+gint
+ev_rect_cmp (EvRectangle *a,
+            EvRectangle *b)
+{
+       if (a == b)
+               return 0;
+       if (a == NULL || b == NULL)
+               return 1;
+
+       return ! ((ABS (a->x1 - b->x1) < EPSILON) &&
+                 (ABS (a->y1 - b->y1) < EPSILON) &&
+                 (ABS (a->x2 - b->x2) < EPSILON) &&
+                 (ABS (a->y2 - b->y2) < EPSILON));
 }
-