diff options
-rw-r--r-- | backend/epub/epub-document.c | 20 | ||||
-rw-r--r-- | configure.ac | 21 | ||||
-rw-r--r-- | help/reference/shell/Makefile.am | 2 | ||||
-rw-r--r-- | libdocument/ev-document.c | 7 | ||||
-rw-r--r-- | libdocument/ev-document.h | 1 | ||||
-rw-r--r-- | libview/ev-document-model.c | 27 | ||||
-rw-r--r-- | libview/ev-document-model.h | 4 | ||||
-rw-r--r-- | libview/ev-jobs.c | 18 | ||||
-rw-r--r-- | shell/ev-window.c | 71 |
9 files changed, 136 insertions, 35 deletions
diff --git a/backend/epub/epub-document.c b/backend/epub/epub-document.c index b61d2eac..18c4f4dc 100644 --- a/backend/epub/epub-document.c +++ b/backend/epub/epub-document.c @@ -145,14 +145,14 @@ epub_webkit_render(cairo_surface_t **surface,EpubDocument *epub_document, g_object_unref(offscreen_window); } -static cairo_surface_t * +/*static void epub_document_render (EvDocument *document) { - cairo_surface_t *surface; EpubDocument *epub_document = EPUB_DOCUMENT(document); - epub_webkit_render(&surface,epub_document,epub_document->currentpageuri); - return surface; -} + epub_document->contentList = epub_document->contentList->next; + contentListNode *current = contentList->data; + +}*/ /** * epub_remove_temporary_dir : Removes a directory recursively. @@ -927,15 +927,15 @@ epub_document_get_info(EvDocument *document) if ( metanode == NULL ) epubinfo->author = g_strdup("unknown"); else - epubinfo->author = xml_get_data_from_node(metanode,XML_KEYWORD,NULL); + epubinfo->author = (char*)xml_get_data_from_node(metanode,XML_KEYWORD,NULL); metanode = xml_get_pointer_to_node((xmlChar*)"subject",NULL,NULL); if ( metanode == NULL ) epubinfo->subject = g_strdup("unknown"); else - epubinfo->subject = xml_get_data_from_node(metanode,XML_KEYWORD,NULL); + epubinfo->subject = (char*)xml_get_data_from_node(metanode,XML_KEYWORD,NULL); - buffer = g_string_new(xml_get_data_from_node (xmlroot,XML_ATTRIBUTE,(xmlChar*)"version")); + buffer = g_string_new((gchar*)xml_get_data_from_node (xmlroot,XML_ATTRIBUTE,(xmlChar*)"version")); g_string_prepend(buffer,"epub "); epubinfo->format = g_strdup(buffer->str); @@ -948,7 +948,7 @@ epub_document_get_info(EvDocument *document) if ( metanode == NULL ) epubinfo->creator = g_strdup("unknown"); else - epubinfo->creator = xml_get_data_from_node(metanode,XML_KEYWORD,NULL); + epubinfo->creator = (char*)xml_get_data_from_node(metanode,XML_KEYWORD,NULL); /*TODO : Add a function to get date*/ g_free(uri); @@ -979,7 +979,7 @@ epub_document_class_init (EpubDocumentClass *klass) ev_document_class->load = epub_document_load; ev_document_class->save = epub_document_save; ev_document_class->get_n_pages = epub_document_get_n_pages; - ev_document_class->render = epub_document_render; +/* ev_document_class->wekit_render->render = epub_document_render;*/ ev_document_class->get_info = epub_document_get_info; ev_document_class->get_page = epub_document_get_page; } diff --git a/configure.ac b/configure.ac index b7d1070a..fc297187 100644 --- a/configure.ac +++ b/configure.ac @@ -690,7 +690,7 @@ dnl ================== End of XPS checks ======================================= dnl ================== EPUB checks =================================================== -dnl TODO : complete this once library dependencies are added and finalized + AC_ARG_ENABLE(epub, [AS_HELP_STRING([--enable-epub], [Compile with support for epub documents.])], @@ -699,13 +699,26 @@ AC_ARG_ENABLE(epub, if test "x$enable_epub" = "xyes"; then WEBKIT_REQUIRED=2.4.2 - PKG_CHECK_MODULES(WEBKIT, webkit-1.0 >= $WEBKIT_REQUIRED libxml-2.0 >= $LIBXML_REQUIRED zlib,enable_epub=yes,enable_epub=no) - - if test "x$enable_epub" = "xyes"; then + case "$with_gtk" in + 2.0) + PKG_CHECK_MODULES(WEBKIT, webkit-1.0 >= $WEBKIT_REQUIRED libxml-2.0 >= $LIBXML_REQUIRED zlib,enable_epub=yes,enable_epub=no) + ;; + 3.0) + PKG_CHECK_MODULES(WEBKIT, webkit2gtk-3.0 >= $WEBKIT_REQUIRED libxml-2.0 >= $LIBXML_REQUIRED zlib,enable_epub=yes,enable_epub=no) + ;; + esac + if test "x$enable_epub" = "xyes"; then AC_DEFINE([ENABLE_EPUB], [1], [Enable support for ePub documents.]) else enable_epub="no" AC_MSG_WARN(["ePub support is disabled since webkit-1.0( version >= $WEBKIT_REQUIRED ) is needed"]) + case "$with_gtk" in + 2.0) + AC_MSG_WARN(["ePub support is disabled since webkit-1.0( version >= $WEBKIT_REQUIRED ) is needed"]) + ;; + 3.0)AC_MSG_WARN(["ePub support is disabled since webkit2gtk-3.0( version >= $WEBKIT_REQUIRED ) is needed"]) + ;; + esac fi fi diff --git a/help/reference/shell/Makefile.am b/help/reference/shell/Makefile.am index a78201d7..40ece8fc 100644 --- a/help/reference/shell/Makefile.am +++ b/help/reference/shell/Makefile.am @@ -106,6 +106,7 @@ GTKDOC_CFLAGS = \ -DATRIL_COMPILATION \ $(SHELL_CFLAGS) \ $(WARN_CFLAGS) \ + $(WEBKIT_CFLAGS) \ $(DISABLE_DEPRECATED) \ $(GTK_PRINT_CFLAGS) @@ -126,6 +127,7 @@ GTKDOC_LIBS = \ $(top_builddir)/libmisc/libevmisc.la \ $(SHELL_LIBS) \ $(GTK_PRINT_LIBS) \ + $(WEBKIT_LIBS) \ $(filter-out $(FILTER_OUT),$(wildcard $(top_builddir)/shell/*.o)) # This includes the standard gtk-doc make rules, copied by gtkdocize. diff --git a/libdocument/ev-document.c b/libdocument/ev-document.c index 588d0d89..9353417e 100644 --- a/libdocument/ev-document.c +++ b/libdocument/ev-document.c @@ -605,6 +605,13 @@ ev_document_render (EvDocument *document, return klass->render (document, rc); } +/*gchar* +ev_web_document_render(EvDocument *document) +{ + Layout engine takes care of the rendering, so what we are essentially doing is serving pages to the webview + EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document); + klass->webkit_render(document); +}*/ const gchar * ev_document_get_uri (EvDocument *document) { diff --git a/libdocument/ev-document.h b/libdocument/ev-document.h index 940c7c80..578b0937 100644 --- a/libdocument/ev-document.h +++ b/libdocument/ev-document.h @@ -114,6 +114,7 @@ struct _EvDocumentClass EvPage *page); cairo_surface_t * (* render) (EvDocument *document, EvRenderContext *rc); +/* void * (*webkit_render) (EvDocument *document);*/ EvDocumentInfo * (* get_info) (EvDocument *document); gboolean (* get_backend_info)(EvDocument *document, EvDocumentBackendInfo *info); diff --git a/libview/ev-document-model.c b/libview/ev-document-model.c index 403df466..00ce782b 100644 --- a/libview/ev-document-model.c +++ b/libview/ev-document-model.c @@ -106,10 +106,22 @@ ev_document_model_set_property (GObject *object, ev_document_model_set_page (model, g_value_get_int (value)); break; case PROP_ROTATION: - ev_document_model_set_rotation (model, g_value_get_int (value)); - break; + { + if ( model->document->iswebdocument == TRUE ) { + model->rotation=0; + } + else { + ev_document_model_set_rotation (model, g_value_get_int (value)); + } + break; + } case PROP_INVERTED_COLORS: - ev_document_model_set_inverted_colors (model, g_value_get_boolean (value)); + if ( model->document->iswebdocument == TRUE ) { + atril_web_document_set_inverted_colors(model,g_value_get_boolean(value)); + } + else { + ev_document_model_set_inverted_colors (model, g_value_get_boolean (value)); + } break; case PROP_SCALE: ev_document_model_set_scale (model, g_value_get_double (value)); @@ -490,6 +502,15 @@ ev_document_model_set_inverted_colors (EvDocumentModel *model, g_object_notify (G_OBJECT (model), "inverted-colors"); } +void +atril_web_document_set_inverted_colors (EvDocumentModel *model, + gboolean inverted_colors) +{ + //TODO + model->inverted_colors = FALSE; + g_object_notify (G_OBJECT (model), "inverted-colors"); +} + gboolean ev_document_model_get_inverted_colors (EvDocumentModel *model) { diff --git a/libview/ev-document-model.h b/libview/ev-document-model.h index b8bea62c..f9d175c0 100644 --- a/libview/ev-document-model.h +++ b/libview/ev-document-model.h @@ -69,7 +69,9 @@ EvSizingMode ev_document_model_get_sizing_mode (EvDocumentModel *model); void ev_document_model_set_rotation (EvDocumentModel *model, gint rotation); gint ev_document_model_get_rotation (EvDocumentModel *model); -void ev_document_model_set_inverted_colors (EvDocumentModel *model, +void ev_document_model_set_inverted_colors (EvDocumentModel *model, + gboolean inverted_colors); +void atril_web_document_set_inverted_colors(EvDocumentModel *model, gboolean inverted_colors); gboolean ev_document_model_get_inverted_colors (EvDocumentModel *model); void ev_document_model_set_continuous (EvDocumentModel *model, diff --git a/libview/ev-jobs.c b/libview/ev-jobs.c index d8d3043d..76e183a1 100644 --- a/libview/ev-jobs.c +++ b/libview/ev-jobs.c @@ -568,6 +568,24 @@ ev_job_render_run (EvJob *job) ev_document_fc_mutex_lock (); ev_page = ev_document_get_page (job->document, job_render->page); + + if ( job->document->iswebdocument == TRUE ) + { + return TRUE; + + if (g_cancellable_is_cancelled (job->cancellable)) { + ev_document_fc_mutex_unlock (); + ev_document_doc_mutex_unlock (); + g_object_unref (rc); + + return FALSE; + } + + ev_document_fc_mutex_unlock (); + ev_document_doc_mutex_unlock (); + ev_job_succeeded (job); + return FALSE; + } rc = ev_render_context_new (ev_page, job_render->rotation, job_render->scale); g_object_unref (ev_page); diff --git a/shell/ev-window.c b/shell/ev-window.c index a423da98..8b32ce97 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -100,7 +100,11 @@ #endif /* ENABLE_DBUS */ #ifdef ENABLE_EPUB -#include <webkit/webkit.h> + #if GTK_CHECK_VERSION(3, 0, 0) + #include <webkit2/webkit2.h> + #else + #include <webkit/webkit.h> + #endif #endif typedef enum { PAGE_MODE_DOCUMENT, @@ -144,7 +148,9 @@ struct _EvWindowPrivate { GtkWidget *sidebar_attachments; GtkWidget *sidebar_layers; GtkWidget *sidebar_annots; + #ifdef ENABLE_EPUB + /*For web documents.(epub)*/ GtkWidget *web_view ; #endif /* Settings */ @@ -1367,10 +1373,11 @@ ev_window_setup_document (EvWindow *ev_window) GtkAction *action; ev_window->priv->setup_document_idle = 0; - - ev_window_refresh_window_thumbnail (ev_window); - if ( document->iswebdocument == FALSE ) - ev_window_set_page_mode (ev_window, PAGE_MODE_DOCUMENT); + if ( document->iswebdocument == FALSE ) { + ev_window_refresh_window_thumbnail (ev_window); + } + ev_window_set_page_mode (ev_window, PAGE_MODE_DOCUMENT); + ev_window_title_set_document (ev_window->priv->title, document); ev_window_title_set_uri (ev_window->priv->title, ev_window->priv->uri); @@ -1411,7 +1418,7 @@ ev_window_setup_document (EvWindow *ev_window) else { if ( gtk_widget_get_parent(ev_window->priv->view) != NULL ) gtk_widget_grab_focus (ev_window->priv->view); - else + else if ( document->iswebdocument == TRUE ) gtk_widget_grab_focus (ev_window->priv->web_view); } return FALSE; @@ -1439,13 +1446,17 @@ ev_window_set_document (EvWindow *ev_window, EvDocument *document) _("The document contains only empty pages")); } #ifdef ENABLE_EPUB - else if (document->iswebdocument == TRUE){ - - /*We have encountered a web document, replace the atril view with a web view.*/ - gtk_container_remove (GTK_CONTAINER(ev_window->priv->scrolled_window),ev_window->priv->view); + GtkWidget *parent= gtk_widget_get_parent(ev_window->priv->web_view); + if (document->iswebdocument == TRUE && + parent == NULL ) + { + /*We have encountered a web document, replace the atril view with a web view, if the web view is not already loaded.*/ + gtk_container_remove (GTK_CONTAINER(ev_window->priv->scrolled_window), + ev_window->priv->view); gtk_container_add (GTK_CONTAINER (ev_window->priv->scrolled_window), ev_window->priv->web_view); gtk_widget_show(ev_window->priv->web_view); + g_object_ref_sink (ev_window->priv->view); } #endif if (EV_WINDOW_IS_PRESENTATION (ev_window) && document->iswebdocument == FALSE) { @@ -1552,8 +1563,9 @@ ev_window_load_job_cb (EvJob *job, g_assert (job_load->uri); - ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE); - + if (document->iswebdocument == 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); @@ -4114,7 +4126,12 @@ ev_window_set_page_mode (EvWindow *window, switch (page_mode) { case PAGE_MODE_DOCUMENT: - child = window->priv->view; + if ( window->priv->document && window->priv->document->iswebdocument == FALSE ) { + child = window->priv->view; + } + else { + child=window->priv->web_view; + } break; case PAGE_MODE_PASSWORD: child = window->priv->password_view; @@ -4347,7 +4364,12 @@ ev_window_cmd_view_expand_window (GtkAction *action, EvWindow *ev_window) static void ev_window_cmd_view_autoscroll (GtkAction *action, EvWindow *ev_window) { - ev_view_autoscroll_start (EV_VIEW (ev_window->priv->view)); + EvDocument* document = ev_window->priv->document; + if (document->iswebdocument == TRUE ) { + return ; + }else { + ev_view_autoscroll_start (EV_VIEW (ev_window->priv->view)); + } } #define EV_HELP "help:atril" @@ -4600,6 +4622,7 @@ ev_window_cmd_help_about (GtkAction *action, EvWindow *ev_window) "Perberos <[email protected]>", "Stefano Karapetsas <[email protected]>", "Steve Zesch <[email protected]>", + "Avishkar Gupta <[email protected]>", NULL }; @@ -5314,6 +5337,7 @@ ev_window_dispose (GObject *object) if ( gtk_widget_get_parent (priv->view) == NULL ) { g_object_ref_sink (priv->view); + g_object_unref(priv->view); } else { @@ -5326,6 +5350,7 @@ ev_window_dispose (GObject *object) if ( priv->web_view ) { if (gtk_widget_get_parent(priv->web_view) == NULL ) { g_object_ref_sink (priv->web_view); + g_object_unref (priv->web_view); }else { g_object_unref (priv->web_view); } @@ -5454,13 +5479,21 @@ ev_window_key_press_event (GtkWidget *widget, * It's needed to be able to type in * annot popups windows */ - if (priv->view) { + GtkWidget* parent = gtk_widget_get_parent(priv->view); + if (priv->view && parent != NULL) { g_object_ref (priv->view); if (gtk_widget_is_sensitive (priv->view)) handled = gtk_widget_event (priv->view, (GdkEvent*) event); g_object_unref (priv->view); } - + + else if ( priv->web_view && (parent=gtk_widget_get_parent(priv->web_view) ) != NULL) { + g_object_ref (priv->web_view); + if (gtk_widget_is_sensitive (priv->web_view)) + handled = gtk_widget_event (priv->web_view, (GdkEvent*) event); + g_object_unref (priv->web_view); + } + if (!handled && !EV_WINDOW_IS_PRESENTATION (ev_window)) { guint modifier = event->state & gtk_accelerator_get_default_mod_mask (); @@ -7056,10 +7089,14 @@ ev_window_init (EvWindow *ev_window) ev_window->priv->view_box); gtk_widget_show (ev_window->priv->view_box); - ev_window->priv->view = ev_view_new (); + #ifdef ENABLE_EPUB ev_window->priv->web_view = webkit_web_view_new () ; + + /*Signals for the web view*/ + g_signal_connect_swapped(ev_window,"destroy",G_CALLBACK(gtk_widget_destroy),ev_window->priv->web_view); #endif + ev_window->priv->view = ev_view_new (); ev_view_set_page_cache_size (EV_VIEW (ev_window->priv->view), PAGE_CACHE_SIZE); ev_view_set_model (EV_VIEW (ev_window->priv->view), ev_window->priv->model); |