#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)
{
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,
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)
+gboolean
+ev_document_has_attachments (EvDocument *document)
{
EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
- iface->get_page_size (document, width, height);
+
+ if (iface->has_attachments == NULL)
+ return FALSE;
+
+ return iface->has_attachments (document);
}
-void
-ev_document_render (EvDocument *document,
- int clip_x,
- int clip_y,
- int clip_width,
- int clip_height)
+GList *
+ev_document_get_attachments (EvDocument *document)
{
EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
- iface->render (document, clip_x, clip_y, clip_width, clip_height);
+ GList *retval;
+
+ LOG ("ev_document_get_attachments");
+ if (iface->get_attachments == NULL)
+ return NULL;
+ retval = iface->get_attachments (document);
+
+ return retval;
}
-void
-ev_document_begin_find (EvDocument *document,
- const char *search_string,
- gboolean case_sensitive)
+GdkPixbuf *
+ev_document_render_pixbuf (EvDocument *document,
+ EvRenderContext *rc)
{
EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
- iface->begin_find (document, search_string, case_sensitive);
+ GdkPixbuf *retval;
+
+ LOG ("ev_document_render_pixbuf");
+ g_assert (iface->render_pixbuf);
+
+ retval = iface->render_pixbuf (document, rc);
+
+ return retval;
}
void
-ev_document_end_find (EvDocument *document)
+ev_document_info_free (EvDocumentInfo *info)
{
- EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
- iface->end_find (document);
+ 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);
}
-void
-ev_document_found (EvDocument *document,
- const EvFindResult *results,
- int n_results,
- double percent_complete)
+
+/* Compares two rects. returns 0 if they're equal */
+#define EPSILON 0.0000001
+
+gint
+ev_rect_cmp (EvRectangle *a,
+ EvRectangle *b)
{
- g_signal_emit_by_name (document,
- "found",
- results, n_results, percent_complete);
+ 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));
}
-