summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/epub/epub-document.c64
-rw-r--r--libdocument/ev-document.c48
-rw-r--r--shell/ev-window.c11
3 files changed, 67 insertions, 56 deletions
diff --git a/backend/epub/epub-document.c b/backend/epub/epub-document.c
index 18c4f4dc..7539fef8 100644
--- a/backend/epub/epub-document.c
+++ b/backend/epub/epub-document.c
@@ -2,7 +2,7 @@
#include "epub-document.h"
#include "unzip.h"
#include "ev-document-thumbnails.h"
-
+#include "ev-document-misc.h"
#include <libxml/parser.h>
#include <libxml/xmlmemory.h>
@@ -56,12 +56,26 @@ EV_BACKEND_REGISTER_WITH_CODE (EpubDocument, epub_document,
epub_document_document_thumbnails_iface_init);
} );
+static void
+epub_webkit_render(cairo_surface_t **surface,
+ const char* uri);
static GdkPixbuf *
epub_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
EvRenderContext *rc,
gboolean border)
{
GdkPixbuf *thumbnail;
+ cairo_surface_t* surface=NULL;
+ gchar* uri = (gchar*) rc->page->backend_page;
+ epub_webkit_render (&surface,uri);
+ while ( !surface )
+ ;
+ gint width = cairo_image_surface_get_width (surface);
+ gint height = cairo_image_surface_get_height (surface);
+ if (surface) {
+ thumbnail = ev_document_misc_pixbuf_from_surface (surface);
+ cairo_surface_destroy (surface);
+ }
return thumbnail;
}
@@ -71,19 +85,10 @@ epub_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
gint *width,
gint *height)
{
- gdouble page_width, page_height;
-
- /*epub_document_get_page_size (EV_DOCUMENT (document), rc->page,
- &page_width, &page_height);*/
- page_width = 800 ;
- page_width = 600 ;
- if (rc->rotation == 90 || rc->rotation == 270) {
- *width = (gint) (page_height * rc->scale);
- *height = (gint) (page_width * rc->scale);
- } else {
- *width = (gint) (page_width * rc->scale);
- *height = (gint) (page_height * rc->scale);
- }
+ gdouble page_width = 800;
+ gdouble page_height = 600;
+ *width = MAX ((gint)(page_width * rc->scale + 0.5), 1);
+ *height = MAX ((gint)(page_height * rc->scale + 0.5), 1);
}
static void
@@ -115,9 +120,9 @@ epub_document_get_n_pages (EvDocument *document)
}
static void
-render_cb_function(GtkWidget *web_view,
- GParamSpec *specification,
- cairo_surface_t **surface)
+webkit_render_cb(GtkWidget *web_view,
+ GParamSpec *specification,
+ cairo_surface_t **surface)
{
WebKitLoadStatus status = webkit_web_view_get_load_status (WEBKIT_WEB_VIEW(web_view));
@@ -126,34 +131,23 @@ render_cb_function(GtkWidget *web_view,
*(surface) = webkit_web_view_get_snapshot (WEBKIT_WEB_VIEW(web_view));
}
}
+
static void
-epub_webkit_render(cairo_surface_t **surface,EpubDocument *epub_document,
- const char* uri)
+epub_webkit_render(cairo_surface_t **surface,
+ const char* uri)
{
GtkWidget *offscreen_window = gtk_offscreen_window_new ();
gtk_window_set_default_size(GTK_WINDOW(offscreen_window),800,600);
- GtkWidget* web_view = webkit_web_view_new ();
GtkWidget* scroll_view = gtk_scrolled_window_new (NULL,NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(scroll_view),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
- webkit_web_view_load_uri(WEBKIT_WEB_VIEW(web_view),epub_document->currentpageuri);
+ GtkWidget* web_view = webkit_web_view_new ();
+ g_signal_connect(WEBKIT_WEB_VIEW(web_view),"notify::load-status",G_CALLBACK(webkit_render_cb),surface);
gtk_container_add(GTK_CONTAINER(scroll_view),web_view);
gtk_container_add(GTK_CONTAINER(offscreen_window),scroll_view);
- g_signal_connect(WEBKIT_WEB_VIEW(web_view),"notify::load-status",G_CALLBACK(render_cb_function),surface);
gtk_widget_show_all (offscreen_window);
- g_object_unref(web_view);
- g_object_unref(scroll_view);
- g_object_unref(offscreen_window);
+ webkit_web_view_load_uri(WEBKIT_WEB_VIEW(web_view),uri);
}
-/*static void
-epub_document_render (EvDocument *document)
-{
- EpubDocument *epub_document = EPUB_DOCUMENT(document);
- epub_document->contentList = epub_document->contentList->next;
- contentListNode *current = contentList->data;
-
-}*/
-
/**
* epub_remove_temporary_dir : Removes a directory recursively.
* This function is same as comics_remove_temporary_dir
@@ -963,7 +957,7 @@ epub_document_get_page(EvDocument *document,
{
EpubDocument *epub_document = EPUB_DOCUMENT(document);
EvPage* page = ev_page_new(index);
- contentListNode *listptr = g_list_nth_data (epub_document->contentList,--index);
+ contentListNode *listptr = g_list_nth_data (epub_document->contentList,index);
page->backend_page = g_strdup(listptr->value);
return page ;
}
diff --git a/libdocument/ev-document.c b/libdocument/ev-document.c
index 9353417e..fee64ed1 100644
--- a/libdocument/ev-document.c
+++ b/libdocument/ev-document.c
@@ -281,8 +281,6 @@ ev_document_load (EvDocument *document,
* 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;
@@ -290,9 +288,15 @@ ev_document_load (EvDocument *document,
EvPageSize *page_size;
gchar *page_label;
+ 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;
+ }
- _ev_document_get_page_size (document, page, &page_width, &page_height);
-
if (i == 0) {
priv->uniform_width = page_width;
priv->uniform_height = page_height;
@@ -300,15 +304,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;
@@ -535,15 +545,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 *
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 8b32ce97..1c80bd52 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -150,7 +150,7 @@ struct _EvWindowPrivate {
GtkWidget *sidebar_annots;
#ifdef ENABLE_EPUB
- /*For web documents.(epub)*/
+ /* For web documents.(epub) */
GtkWidget *web_view ;
#endif
/* Settings */
@@ -1312,6 +1312,9 @@ static void
ev_window_set_icon_from_thumbnail (EvJobThumbnail *job,
EvWindow *ev_window)
{
+ if (ev_window->priv->document->iswebdocument == TRUE) {
+ return;
+ }
if (job->thumbnail) {
if (ev_document_model_get_inverted_colors (ev_window->priv->model))
ev_document_misc_invert_pixbuf (job->thumbnail);
@@ -1563,9 +1566,7 @@ ev_window_load_job_cb (EvJob *job,
g_assert (job_load->uri);
- if (document->iswebdocument == FALSE) {
- ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE);
- }
+ ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE);
/* Success! */
if (!ev_job_is_failed (job)) {
ev_document_model_set_document (ev_window->priv->model, document);
@@ -4289,7 +4290,7 @@ static void
ev_window_cmd_go_previous_page (GtkAction *action, EvWindow *ev_window)
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
-
+/* webkit_web_view_load_uri(WEBKIT_WEB_VIEW(ev_window->web_view),"");*/
ev_view_previous_page (EV_VIEW (ev_window->priv->view));
}