summaryrefslogtreecommitdiff
path: root/libdocument
diff options
context:
space:
mode:
Diffstat (limited to 'libdocument')
-rw-r--r--libdocument/ev-backends-manager.c13
-rw-r--r--libdocument/ev-backends-manager.h2
-rw-r--r--libdocument/ev-document-find.c9
-rw-r--r--libdocument/ev-document-find.h9
-rw-r--r--libdocument/ev-document-thumbnails.c3
-rw-r--r--libdocument/ev-document-thumbnails.h4
-rw-r--r--libdocument/ev-document.c118
-rw-r--r--libdocument/ev-document.h10
-rw-r--r--libdocument/ev-link-dest.c10
-rw-r--r--libdocument/ev-link-dest.h2
-rw-r--r--libdocument/ev-mapping-list.c2
11 files changed, 135 insertions, 47 deletions
diff --git a/libdocument/ev-backends-manager.c b/libdocument/ev-backends-manager.c
index dd62642d..74fc09a0 100644
--- a/libdocument/ev-backends-manager.c
+++ b/libdocument/ev-backends-manager.c
@@ -63,6 +63,19 @@ backends_dir (void)
return backendsdir;
}
+gchar*
+ev_backends_manager_get_backends_dir(void)
+{
+ gchar *retval;
+ if (!backendsdir) {
+ retval = backends_dir();
+ }
+ else {
+ retval = backendsdir;
+ }
+ return retval;
+}
+
static void
ev_backend_info_free (EvBackendInfo *info)
{
diff --git a/libdocument/ev-backends-manager.h b/libdocument/ev-backends-manager.h
index 42f597ee..1d660eac 100644
--- a/libdocument/ev-backends-manager.h
+++ b/libdocument/ev-backends-manager.h
@@ -42,7 +42,7 @@ EvDocument *ev_backends_manager_get_document (const gchar *mime_typ
const gchar *ev_backends_manager_get_document_module_name (EvDocument *document);
EvTypeInfo *ev_backends_manager_get_document_type_info (EvDocument *document);
GList *ev_backends_manager_get_all_types_info (void);
-
+gchar *ev_backends_manager_get_backends_dir (void);
G_END_DECLS
#endif /* EV_BACKENDS_MANAGER */
diff --git a/libdocument/ev-document-find.c b/libdocument/ev-document-find.c
index 0b5fac01..92dfffe5 100644
--- a/libdocument/ev-document-find.c
+++ b/libdocument/ev-document-find.c
@@ -40,3 +40,12 @@ ev_document_find_find_text (EvDocumentFind *document_find,
return iface->find_text (document_find, page, text, case_sensitive);
}
+guint
+ev_document_find_check_for_hits(EvDocumentFind *document_find,
+ EvPage *page,
+ const gchar *text,
+ gboolean case_sensitive)
+{
+ EvDocumentFindInterface *iface = EV_DOCUMENT_FIND_GET_IFACE (document_find);
+ return iface->check_for_hits (document_find, page, text, case_sensitive);
+} \ No newline at end of file
diff --git a/libdocument/ev-document-find.h b/libdocument/ev-document-find.h
index 7fcf49c7..2b6ba68b 100644
--- a/libdocument/ev-document-find.h
+++ b/libdocument/ev-document-find.h
@@ -52,6 +52,11 @@ struct _EvDocumentFindInterface
EvPage *page,
const gchar *text,
gboolean case_sensitive);
+
+ guint (* check_for_hits) (EvDocumentFind *document_find,
+ EvPage *page,
+ const gchar *text,
+ gboolean case_sensitive);
};
GType ev_document_find_get_type (void) G_GNUC_CONST;
@@ -60,6 +65,10 @@ GList *ev_document_find_find_text (EvDocumentFind *document_find,
const gchar *text,
gboolean case_sensitive);
+guint ev_document_find_check_for_hits (EvDocumentFind *document_find,
+ EvPage *page,
+ const gchar *text,
+ gboolean case_sensitive);
G_END_DECLS
#endif /* EV_DOCUMENT_FIND_H */
diff --git a/libdocument/ev-document-thumbnails.c b/libdocument/ev-document-thumbnails.c
index 9482e09e..65248683 100644
--- a/libdocument/ev-document-thumbnails.c
+++ b/libdocument/ev-document-thumbnails.c
@@ -59,5 +59,4 @@ ev_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
iface = EV_DOCUMENT_THUMBNAILS_GET_IFACE (document);
iface->get_dimensions (document, rc, width, height);
-}
-
+} \ No newline at end of file
diff --git a/libdocument/ev-document-thumbnails.h b/libdocument/ev-document-thumbnails.h
index 1a7cb9fd..5f425ef0 100644
--- a/libdocument/ev-document-thumbnails.h
+++ b/libdocument/ev-document-thumbnails.h
@@ -26,7 +26,7 @@
#define EV_DOCUMENT_THUMBNAILS_H
#include <gdk-pixbuf/gdk-pixbuf.h>
-
+#include <gtk/gtk.h>
#include "ev-render-context.h"
G_BEGIN_DECLS
@@ -52,6 +52,7 @@ struct _EvDocumentThumbnailsInterface {
EvRenderContext *rc,
gint *width,
gint *height);
+
};
GType ev_document_thumbnails_get_type (void) G_GNUC_CONST;
@@ -63,7 +64,6 @@ void ev_document_thumbnails_get_dimensions (EvDocumentThumbnails *document
EvRenderContext *rc,
gint *width,
gint *height);
-
G_END_DECLS
#endif /* EV_DOCUMENT_THUMBNAILS_H */
diff --git a/libdocument/ev-document.c b/libdocument/ev-document.c
index 19d51d9b..fc45830d 100644
--- a/libdocument/ev-document.c
+++ b/libdocument/ev-document.c
@@ -26,6 +26,7 @@
#include "ev-document.h"
#include "synctex_parser.h"
+#include "ev-file-helpers.h"
#define EV_DOCUMENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EV_TYPE_DOCUMENT, EvDocumentPrivate))
@@ -68,8 +69,8 @@ static gchar *_ev_document_get_page_label (EvDocument *document,
static EvDocumentInfo *_ev_document_get_info (EvDocument *document);
static gboolean _ev_document_support_synctex (EvDocument *document);
-GMutex *ev_doc_mutex = NULL;
-GMutex *ev_fc_mutex = NULL;
+static GMutex ev_doc_mutex;
+static GMutex ev_fc_mutex;
G_DEFINE_ABSTRACT_TYPE (EvDocument, ev_document, G_TYPE_OBJECT)
@@ -141,6 +142,8 @@ ev_document_init (EvDocument *document)
/* Assume all pages are the same size until proven otherwise */
document->priv->uniform = TRUE;
+ /* Assume that the document is not a web document*/
+ document->iswebdocument = FALSE ;
}
static void
@@ -157,58 +160,40 @@ ev_document_class_init (EvDocumentClass *klass)
g_object_class->finalize = ev_document_finalize;
}
-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 ());
+ g_mutex_lock (&ev_doc_mutex);
}
void
ev_document_doc_mutex_unlock (void)
{
- g_mutex_unlock (ev_document_get_doc_mutex ());
+ g_mutex_unlock (&ev_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)
-{
- if (ev_fc_mutex == NULL) {
- ev_fc_mutex = g_mutex_new ();
- }
- return ev_fc_mutex;
+ return g_mutex_trylock (&ev_doc_mutex);
}
void
ev_document_fc_mutex_lock (void)
{
- g_mutex_lock (ev_document_get_fc_mutex ());
+ g_mutex_lock (&ev_fc_mutex);
}
void
ev_document_fc_mutex_unlock (void)
{
- g_mutex_unlock (ev_document_get_fc_mutex ());
+ g_mutex_unlock (&ev_fc_mutex);
}
gboolean
ev_document_fc_mutex_trylock (void)
{
- return g_mutex_trylock (ev_document_get_fc_mutex ());
+ return g_mutex_trylock (&ev_fc_mutex);
}
/**
@@ -237,6 +222,14 @@ ev_document_load (EvDocument *document,
gboolean retval;
GError *err = NULL;
+ /*
+ * Hardcoding a check for ePub documents, cause it needs a web document DOM
+ * and webkit, support for any other web document types can be added similarly.
+ */
+
+ if ( !g_strcmp0 (ev_file_get_mime_type(uri,TRUE,&err),"application/epub+zip") )
+ document->iswebdocument=TRUE ;
+
retval = klass->load (document, uri, &err);
if (!retval) {
if (err) {
@@ -258,18 +251,34 @@ ev_document_load (EvDocument *document,
/* Cache some info about the document to avoid
* going to the backends since it requires locks
*/
+
priv->uri = g_strdup (uri);
- priv->n_pages = _ev_document_get_n_pages (document);
+ priv->n_pages = _ev_document_get_n_pages (document);
+
for (i = 0; i < priv->n_pages; i++) {
+
+ /*
+ * Since there is no sense of paging in an ePub,it makes no sense to have pages sizes.
+ * We are however geeneralising the scenario by considering epub as a type of web document.
+ * FIXME: Labels, or bookmarks though, can be done.
+ */
+
EvPage *page = ev_document_get_page (document, i);
gdouble page_width = 0;
gdouble page_height = 0;
EvPageSize *page_size;
gchar *page_label;
-
- _ev_document_get_page_size (document, page, &page_width, &page_height);
-
+
+ if ( document->iswebdocument == FALSE ) {
+ _ev_document_get_page_size (document, page, &page_width, &page_height);
+ }
+ else {
+ //Fixed page sized to resolve the X-windowing system error.
+ page_width = 800;
+ page_height= 600;
+ }
+
if (i == 0) {
priv->uniform_width = page_width;
priv->uniform_height = page_height;
@@ -277,14 +286,21 @@ ev_document_load (EvDocument *document,
priv->max_height = priv->uniform_height;
priv->min_width = priv->uniform_width;
priv->min_height = priv->uniform_height;
+ if (document->iswebdocument == TRUE ) {
+ priv->page_sizes = g_new0 (EvPageSize, 1);
+ priv->page_sizes->width = priv->uniform_width;
+ priv->page_sizes->height = priv->uniform_height;
+ priv->uniform = TRUE ;
+ break;
+ }
} else if (priv->uniform &&
(priv->uniform_width != page_width ||
priv->uniform_height != page_height)) {
/* It's a different page size. Backfill the array. */
int j;
-
+
priv->page_sizes = g_new0 (EvPageSize, priv->n_pages);
-
+
for (j = 0; j < i; j++) {
page_size = &(priv->page_sizes[j]);
page_size->width = priv->uniform_width;
@@ -511,15 +527,21 @@ ev_document_get_page_size (EvDocument *document,
{
g_return_if_fail (EV_IS_DOCUMENT (document));
g_return_if_fail (page_index >= 0 || page_index < document->priv->n_pages);
-
- if (width)
- *width = document->priv->uniform ?
- document->priv->uniform_width :
- document->priv->page_sizes[page_index].width;
- if (height)
- *height = document->priv->uniform ?
- document->priv->uniform_height :
- document->priv->page_sizes[page_index].height;
+ if (document->iswebdocument == TRUE ) {
+ if (width)
+ *width = document->priv->uniform_width;
+ if (height)
+ *height = document->priv->uniform_height;
+ } else {
+ if (width)
+ *width = document->priv->uniform ?
+ document->priv->uniform_width :
+ document->priv->page_sizes[page_index].width;
+ if (height)
+ *height = document->priv->uniform ?
+ document->priv->uniform_height :
+ document->priv->page_sizes[page_index].height;
+ }
}
static gchar *
@@ -870,3 +892,17 @@ ev_rect_cmp (EvRectangle *a,
(ABS (a->x2 - b->x2) < EPSILON) &&
(ABS (a->y2 - b->y2) < EPSILON));
}
+
+void
+ev_document_toggle_night_mode(EvDocument *document,gboolean night)
+{
+ EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS(document);
+ return klass->toggle_night_mode(document,night) ;
+}
+
+void
+ev_document_check_add_night_sheet(EvDocument *document)
+{
+ EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS(document);
+ return klass->check_add_night_sheet(document) ;
+} \ No newline at end of file
diff --git a/libdocument/ev-document.h b/libdocument/ev-document.h
index d10d261a..46a0971c 100644
--- a/libdocument/ev-document.h
+++ b/libdocument/ev-document.h
@@ -85,6 +85,11 @@ struct _EvDocument
GObject base;
EvDocumentPrivate *priv;
+ /*
+ * Since we can only access the members of this structure from the window frontend,
+ * we need a flag to detemine whether to replace the atril-view with a web-view.
+ */
+ gboolean iswebdocument;
};
struct _EvDocumentClass
@@ -113,6 +118,9 @@ struct _EvDocumentClass
gboolean (* get_backend_info)(EvDocument *document,
EvDocumentBackendInfo *info);
gboolean (* support_synctex) (EvDocument *document);
+
+ void (* toggle_night_mode) (EvDocument *document,gboolean night);
+ void (*check_add_night_sheet)(EvDocument *document);
};
GType ev_document_get_type (void) G_GNUC_CONST;
@@ -179,6 +187,8 @@ EvMapping *ev_document_synctex_forward_search
gint ev_rect_cmp (EvRectangle *a,
EvRectangle *b);
+void ev_document_toggle_night_mode (EvDocument *document,gboolean night);
+void ev_document_check_add_night_sheet (EvDocument *document);
#define EV_TYPE_RECTANGLE (ev_rectangle_get_type ())
struct _EvRectangle
diff --git a/libdocument/ev-link-dest.c b/libdocument/ev-link-dest.c
index 62f2cd47..b9ea0dfd 100644
--- a/libdocument/ev-link-dest.c
+++ b/libdocument/ev-link-dest.c
@@ -509,3 +509,13 @@ ev_link_dest_new_page_label (const gchar *page_label)
"type", EV_LINK_DEST_TYPE_PAGE_LABEL,
NULL));
}
+
+EvLinkDest *
+ev_link_dest_new_hlink(const gchar* hlink,gint page)
+{
+ return EV_LINK_DEST(g_object_new(EV_TYPE_LINK_DEST,
+ "named",hlink,
+ "page",page,
+ "type", EV_LINK_DEST_TYPE_HLINK,
+ NULL));
+} \ No newline at end of file
diff --git a/libdocument/ev-link-dest.h b/libdocument/ev-link-dest.h
index a0e2539f..dd1f10a1 100644
--- a/libdocument/ev-link-dest.h
+++ b/libdocument/ev-link-dest.h
@@ -49,6 +49,7 @@ typedef enum {
EV_LINK_DEST_TYPE_FITR,
EV_LINK_DEST_TYPE_NAMED,
EV_LINK_DEST_TYPE_PAGE_LABEL,
+ EV_LINK_DEST_TYPE_HLINK,
EV_LINK_DEST_TYPE_UNKNOWN
} EvLinkDestType;
@@ -89,6 +90,7 @@ EvLinkDest *ev_link_dest_new_fitr (gint page,
gdouble top);
EvLinkDest *ev_link_dest_new_named (const gchar *named_dest);
EvLinkDest *ev_link_dest_new_page_label (const gchar *page_label);
+EvLinkDest *ev_link_dest_new_hlink (const gchar* hlink,gint page);
G_END_DECLS
diff --git a/libdocument/ev-mapping-list.c b/libdocument/ev-mapping-list.c
index 6c670158..44628b09 100644
--- a/libdocument/ev-mapping-list.c
+++ b/libdocument/ev-mapping-list.c
@@ -136,7 +136,7 @@ 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) {
+ if (g_atomic_int_add (&mapping_list->ref_count, -1) - 1 == 0) {
g_list_foreach (mapping_list->list,
(GFunc)mapping_list_free_foreach,
mapping_list->data_destroy_func);