summaryrefslogtreecommitdiff
path: root/libdocument
diff options
context:
space:
mode:
authorrootavish <[email protected]>2014-06-23 23:42:11 +0530
committerrootavish <[email protected]>2014-06-23 23:42:11 +0530
commit5028995e3725c264b2487a1101c22e941b04c8fd (patch)
treefb8cbf4100bfe3d28e1e128fd82e3c4492c0c55a /libdocument
parente817bd447789cd670fb00b6507debfe84f8cf64f (diff)
downloadatril-5028995e3725c264b2487a1101c22e941b04c8fd.tar.bz2
atril-5028995e3725c264b2487a1101c22e941b04c8fd.tar.xz
Functions for document info and EvPage,other changes
Summary: I added functions in the backend to get document info. Added a member to evdocument to deal with web documents(ePub) on the frontend. Added a webview to the window, that shall replace the Atril view. Due to removing the view from the main Atril window, I have given rise to various GTK-critical errors in response to signals, will be sure to suppress these in the next commit. Worked towards overall blending in of ePub documents.
Diffstat (limited to 'libdocument')
-rw-r--r--libdocument/ev-document.c28
-rw-r--r--libdocument/ev-document.h5
2 files changed, 31 insertions, 2 deletions
diff --git a/libdocument/ev-document.c b/libdocument/ev-document.c
index 19d51d9b..588d0d89 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))
@@ -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
@@ -237,6 +240,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,16 +269,28 @@ 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.
+ */
+ if ( document->iswebdocument == TRUE )
+ break;
+
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 (i == 0) {
@@ -277,6 +300,7 @@ ev_document_load (EvDocument *document,
priv->max_height = priv->uniform_height;
priv->min_width = priv->uniform_width;
priv->min_height = priv->uniform_height;
+
} else if (priv->uniform &&
(priv->uniform_width != page_width ||
priv->uniform_height != page_height)) {
diff --git a/libdocument/ev-document.h b/libdocument/ev-document.h
index d10d261a..940c7c80 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