summaryrefslogtreecommitdiff
path: root/shell/ev-window.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/ev-window.c')
-rw-r--r--shell/ev-window.c495
1 files changed, 395 insertions, 100 deletions
diff --git a/shell/ev-window.c b/shell/ev-window.c
index d3a8181d..58985c03 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -88,6 +88,7 @@
#include "ev-utils.h"
#include "ev-keyring.h"
#include "ev-view.h"
+#include "ev-web-view.h"
#include "ev-view-presentation.h"
#include "ev-view-type-builtins.h"
#include "ev-window.h"
@@ -142,7 +143,9 @@ struct _EvWindowPrivate {
GtkWidget *sidebar_attachments;
GtkWidget *sidebar_layers;
GtkWidget *sidebar_annots;
-
+#if ENABLE_EPUB
+ GtkWidget *webview;
+#endif
/* Settings */
GSettings *settings;
GSettings *default_settings;
@@ -406,7 +409,9 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window)
if (has_document && EV_IS_SELECTION (document)) {
can_get_text = TRUE;
}
-
+ else if (has_document && document->iswebdocument) {
+ can_get_text = TRUE;
+ }
if (has_pages && EV_IS_DOCUMENT_FIND (document)) {
can_find = TRUE;
}
@@ -445,18 +450,21 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window)
ev_window_set_action_sensitive (ev_window, "EditSelectAll", has_pages && can_get_text);
ev_window_set_action_sensitive (ev_window, "EditFind", can_find);
ev_window_set_action_sensitive (ev_window, "Slash", can_find);
- ev_window_set_action_sensitive (ev_window, "EditRotateLeft", has_pages);
- ev_window_set_action_sensitive (ev_window, "EditRotateRight", has_pages);
+ ev_window_set_action_sensitive (ev_window, "EditRotateLeft", has_pages && !(document->iswebdocument));
+ ev_window_set_action_sensitive (ev_window, "EditRotateRight", has_pages && !(document->iswebdocument));
/* View menu */
- ev_window_set_action_sensitive (ev_window, "ViewContinuous", has_pages);
- ev_window_set_action_sensitive (ev_window, "ViewDual", has_pages);
- ev_window_set_action_sensitive (ev_window, "ViewBestFit", has_pages);
- ev_window_set_action_sensitive (ev_window, "ViewPageWidth", has_pages);
+ /*If it has pages it is a document, so our check for a webdocument won't lead to a crash. We need to switch these view modes off since more than one
+ *webview is hard to manage, and would lead to unexpected behaviour in case the number of webviews gets too large.
+ */
+ ev_window_set_action_sensitive (ev_window, "ViewContinuous", has_pages && !(document->iswebdocument));
+ ev_window_set_action_sensitive (ev_window, "ViewDual", has_pages && !(document->iswebdocument));
+ ev_window_set_action_sensitive (ev_window, "ViewBestFit", has_pages && !(document->iswebdocument));
+ ev_window_set_action_sensitive (ev_window, "ViewPageWidth", has_pages && !(document->iswebdocument));
ev_window_set_action_sensitive (ev_window, "ViewReload", has_pages);
- ev_window_set_action_sensitive (ev_window, "ViewAutoscroll", has_pages);
+ ev_window_set_action_sensitive (ev_window, "ViewAutoscroll", has_pages && !(document->iswebdocument));
ev_window_set_action_sensitive (ev_window, "ViewInvertedColors", has_pages);
- ev_window_set_action_sensitive (ev_window, "ViewExpandWindow", has_pages);
+ ev_window_set_action_sensitive (ev_window, "ViewExpandWindow", has_pages && !(document->iswebdocument));
/* Toolbar-specific actions: */
ev_window_set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
@@ -469,7 +477,11 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window)
static void
ev_window_update_actions (EvWindow *ev_window)
{
- EvView *view = EV_VIEW (ev_window->priv->view);
+#if ENABLE_EPUB
+ EvWebView *webview = NULL;
+#endif
+ EvView *view = NULL;
+
int n_pages = 0, page = -1;
gboolean has_pages = FALSE;
gboolean presentation_mode;
@@ -481,13 +493,41 @@ ev_window_update_actions (EvWindow *ev_window)
n_pages = ev_document_get_n_pages (ev_window->priv->document);
has_pages = n_pages > 0;
}
-
+#if ENABLE_EPUB
+ if (ev_window->priv->document && ev_window->priv->document->iswebdocument == TRUE ) {
+ webview = EV_WEB_VIEW(ev_window->priv->webview);
+ } else
+#endif
+ {
+ view = EV_VIEW (ev_window->priv->view);
+ }
+
can_find_in_page = (ev_window->priv->find_job &&
ev_job_find_has_results (EV_JOB_FIND (ev_window->priv->find_job)));
-
- ev_window_set_action_sensitive (ev_window, "EditCopy",
- has_pages &&
- ev_view_get_has_selection (view));
+ if (view) {
+ ev_window_set_action_sensitive (ev_window, "EditCopy",
+ has_pages &&
+ ev_view_get_has_selection (view));
+ }
+#if ENABLE_EPUB
+#if GTK_CHECK_VERSION (3, 0, 0)
+ else if (webview) {
+ /*
+ * The webkit2 function for this is an asynchronous call,
+ * so our only option is to set this to always on, and we'll take care of whether we can copy
+ * or not when this command is actually given.
+ */
+ ev_window_set_action_sensitive (ev_window,"EditCopy",
+ has_pages);
+ }
+#else
+ else if(webview) {
+ ev_window_set_action_sensitive (ev_window, "EditCopy",
+ has_pages &&
+ ev_web_view_get_has_selection (webview));
+ }
+#endif
+#endif
ev_window_set_action_sensitive (ev_window, "EditFindNext",
has_pages && can_find_in_page);
ev_window_set_action_sensitive (ev_window, "EditFindPrevious",
@@ -497,15 +537,16 @@ ev_window_update_actions (EvWindow *ev_window)
presentation_mode = EV_WINDOW_IS_PRESENTATION (ev_window);
- ev_window_set_action_sensitive (ev_window, "ViewZoomIn",
- has_pages &&
- ev_view_can_zoom_in (view) &&
- !presentation_mode);
- ev_window_set_action_sensitive (ev_window, "ViewZoomOut",
- has_pages &&
- ev_view_can_zoom_out (view) &&
- !presentation_mode);
-
+ if (ev_window->priv->document && ev_window->priv->document->iswebdocument == FALSE ) {
+ ev_window_set_action_sensitive (ev_window, "ViewZoomIn",
+ has_pages &&
+ ev_view_can_zoom_in (view) &&
+ !presentation_mode);
+ ev_window_set_action_sensitive (ev_window, "ViewZoomOut",
+ has_pages &&
+ ev_view_can_zoom_out (view) &&
+ !presentation_mode);
+ }
/* Go menu */
if (has_pages) {
ev_window_set_action_sensitive (ev_window, "GoPreviousPage", page > 0);
@@ -660,8 +701,10 @@ update_sizing_buttons (EvWindow *window)
ephy_zoom_action_set_zoom_level (EPHY_ZOOM_ACTION (action),
EPHY_ZOOM_BEST_FIT);
} else if (page_width) {
- ephy_zoom_action_set_zoom_level (EPHY_ZOOM_ACTION (action),
- EPHY_ZOOM_FIT_WIDTH);
+ if (!window->priv->document || (window->priv->document && !window->priv->document->iswebdocument)) {
+ ephy_zoom_action_set_zoom_level (EPHY_ZOOM_ACTION (action),
+ EPHY_ZOOM_FIT_WIDTH);
+ }
}
}
@@ -904,6 +947,17 @@ view_selection_changed_cb (EvView *view,
ev_window_set_action_sensitive (window, "EditCopy",
ev_view_get_has_selection (view));
}
+#if ENABLE_EPUB
+#if !GTK_CHECK_VERSION (3, 0, 0)
+static void
+web_view_selection_changed_cb(EvWebView *webview,
+ EvWindow *window)
+{
+ ev_window_set_action_sensitive (window,"EditCopy",
+ ev_web_view_get_has_selection(webview));
+}
+#endif
+#endif
static void
ev_window_page_changed_cb (EvWindow *ev_window,
@@ -987,6 +1041,12 @@ static void
update_document_mode (EvWindow *window, EvDocumentMode mode)
{
if (mode == EV_DOCUMENT_MODE_PRESENTATION) {
+ if (window->priv->document) {
+ if (window->priv->document->iswebdocument) {
+ ev_window_warning_message(window,_("Cannot enter presentation mode with ePub documents use fullscreen mode instead."));
+ return;
+ }
+ }
ev_window_run_presentation (window);
}
else if (mode == EV_DOCUMENT_MODE_FULL_SCREEN) {
@@ -1278,7 +1338,12 @@ setup_view_from_metadata (EvWindow *window)
/* Presentation */
if (ev_metadata_get_boolean (window->priv->metadata, "presentation", &presentation)) {
if (presentation) {
- ev_window_run_presentation (window);
+ if (window->priv->document->iswebdocument == TRUE ) {
+ return;
+ }
+ else {
+ ev_window_run_presentation (window);
+ }
}
}
}
@@ -1333,6 +1398,10 @@ ev_window_refresh_window_thumbnail (EvWindow *ev_window)
rotation = ev_document_model_get_rotation (ev_window->priv->model);
ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, 0, rotation, scale);
+
+ if (document->iswebdocument) {
+ ev_job_set_run_mode(EV_JOB(ev_window->priv->thumbnail_job), EV_JOB_RUN_MAIN_LOOP);
+ }
g_signal_connect (ev_window->priv->thumbnail_job, "finished",
G_CALLBACK (ev_window_set_icon_from_thumbnail),
ev_window);
@@ -1363,10 +1432,10 @@ ev_window_setup_document (EvWindow *ev_window)
GtkAction *action;
ev_window->priv->setup_document_idle = 0;
-
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);
@@ -1403,12 +1472,18 @@ ev_window_setup_document (EvWindow *ev_window)
info = ev_document_get_info (document);
update_document_mode (ev_window, info->mode);
-
- if (EV_WINDOW_IS_PRESENTATION (ev_window))
+ /*FIXME*/
+ if (EV_WINDOW_IS_PRESENTATION (ev_window) && document->iswebdocument == FALSE)
gtk_widget_grab_focus (ev_window->priv->presentation_view);
- else
- gtk_widget_grab_focus (ev_window->priv->view);
+ else {
+ if ( document->iswebdocument == FALSE )
+ gtk_widget_grab_focus (ev_window->priv->view);
+ #if ENABLE_EPUB
+ else
+ gtk_widget_grab_focus (ev_window->priv->webview);
+ #endif
+ }
return FALSE;
}
@@ -1429,15 +1504,40 @@ ev_window_set_document (EvWindow *ev_window, EvDocument *document)
if (ev_document_get_n_pages (document) <= 0) {
ev_window_warning_message (ev_window, "%s",
_("The document contains no pages"));
- } else if (!ev_document_check_dimensions (document)) {
+ } else if (!ev_document_check_dimensions (document) && document->iswebdocument == FALSE) {
ev_window_warning_message (ev_window, "%s",
_("The document contains only empty pages"));
}
-
- if (EV_WINDOW_IS_PRESENTATION (ev_window)) {
+#if ENABLE_EPUB
+ GtkWidget *parent= gtk_widget_get_parent(ev_window->priv->webview);
+ 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);
+ ev_view_disconnect_handlers(EV_VIEW(ev_window->priv->view));
+ g_object_unref(ev_window->priv->view);
+ ev_window->priv->view = NULL;
+ gtk_container_add (GTK_CONTAINER (ev_window->priv->scrolled_window),
+ ev_window->priv->webview);
+ gtk_widget_show(ev_window->priv->webview);
+ }
+ else {
+ /*Since the document is not a webdocument might as well get rid of the webview now*/
+ ev_web_view_disconnect_handlers(EV_WEB_VIEW(ev_window->priv->webview));
+ g_object_ref_sink(ev_window->priv->webview);
+ g_object_unref(ev_window->priv->webview);
+ }
+#endif
+ if (EV_WINDOW_IS_PRESENTATION (ev_window) && document->iswebdocument == FALSE) {
gtk_widget_destroy (ev_window->priv->presentation_view);
ev_window->priv->presentation_view = NULL;
ev_window_run_presentation (ev_window);
+ } else if ( EV_WINDOW_IS_PRESENTATION (ev_window) && document->iswebdocument == TRUE )
+ {
+ ev_window_warning_message (ev_window, "%s",
+ _("Presentation mode is not supported for ePub documents."));
}
if (ev_window->priv->setup_document_idle > 0)
@@ -1505,6 +1605,9 @@ static void
ev_window_handle_link (EvWindow *ev_window,
EvLinkDest *dest)
{
+ if (ev_window->priv->document->iswebdocument == FALSE ) {
+ return;
+ }
if (dest) {
EvLink *link;
EvLinkAction *link_action;
@@ -1535,9 +1638,8 @@ ev_window_load_job_cb (EvJob *job,
g_assert (job_load->uri);
ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE);
-
/* Success! */
- if (!ev_job_is_failed (job)) {
+ if (!ev_job_is_failed (job)) {
ev_document_model_set_document (ev_window->priv->model, document);
#ifdef ENABLE_DBUS
@@ -1799,6 +1901,8 @@ static void
ev_window_load_remote_failed (EvWindow *ev_window,
GError *error)
{
+ if ( !ev_window->priv->view ) return;
+
ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE);
ev_window->priv->in_reload = FALSE;
ev_window_error_message (ev_window, error,
@@ -2054,9 +2158,6 @@ ev_window_open_document (EvWindow *ev_window,
EvWindowRunMode mode,
const gchar *search_string)
{
- if (document == ev_window->priv->document)
- return;
-
ev_window_close_dialogs (ev_window);
ev_window_clear_load_job (ev_window);
ev_window_clear_local_uri (ev_window);
@@ -2078,7 +2179,7 @@ ev_window_open_document (EvWindow *ev_window,
setup_document_from_metadata (ev_window);
setup_view_from_metadata (ev_window);
- if (dest) {
+ if (dest && document->iswebdocument == FALSE) {
EvLink *link;
EvLinkAction *link_action;
@@ -2272,13 +2373,10 @@ ev_window_reload_document (EvWindow *ev_window,
EvLinkDest *dest)
{
gint page;
-
-
ev_window_clear_reload_job (ev_window);
ev_window->priv->in_reload = TRUE;
page = ev_document_model_get_page (ev_window->priv->model);
-
if (ev_window->priv->dest)
g_object_unref (ev_window->priv->dest);
ev_window->priv->dest = dest ? g_object_ref (dest) : NULL;
@@ -3605,12 +3703,18 @@ ev_window_cmd_focus_page_selector (GtkAction *act, EvWindow *window)
static void
ev_window_cmd_scroll_forward (GtkAction *action, EvWindow *window)
{
+ /*If the webview is occupying the window*/
+ if ( window->priv->document->iswebdocument == TRUE) return ;
+
ev_view_scroll (EV_VIEW (window->priv->view), GTK_SCROLL_PAGE_FORWARD, FALSE);
}
static void
ev_window_cmd_scroll_backward (GtkAction *action, EvWindow *window)
{
+ /*If the webview is occupying the window*/
+ if ( window->priv->document->iswebdocument == TRUE ) return ;
+
ev_view_scroll (EV_VIEW (window->priv->view), GTK_SCROLL_PAGE_BACKWARD, FALSE);
}
@@ -3673,9 +3777,14 @@ ev_window_cmd_edit_select_all (GtkAction *action, EvWindow *ev_window)
*/
if (ev_window->priv->chrome & EV_CHROME_FINDBAR) {
egg_find_bar_grab_focus(ev_window->priv->find_bar);
- } else {
+ } else if (ev_window->priv->document->iswebdocument == FALSE ) {
ev_view_select_all (EV_VIEW (ev_window->priv->view));
}
+#if ENABLE_EPUB
+ else {
+ ev_web_view_select_all(EV_WEB_VIEW(ev_window->priv->webview));
+ }
+#endif
}
static void
@@ -3701,7 +3810,14 @@ ev_window_cmd_edit_find_next (GtkAction *action, EvWindow *ev_window)
update_chrome_flag (ev_window, EV_CHROME_FINDBAR, TRUE);
update_chrome_visibility (ev_window);
gtk_widget_grab_focus (ev_window->priv->find_bar);
- ev_view_find_next (EV_VIEW (ev_window->priv->view));
+ if (ev_window->priv->document->iswebdocument == FALSE) {
+ ev_view_find_next (EV_VIEW (ev_window->priv->view));
+ }
+#if ENABLE_EPUB
+ else {
+ ev_web_view_find_next(EV_WEB_VIEW(ev_window->priv->webview));
+ }
+#endif
}
static void
@@ -3712,15 +3828,28 @@ ev_window_cmd_edit_find_previous (GtkAction *action, EvWindow *ev_window)
update_chrome_flag (ev_window, EV_CHROME_FINDBAR, TRUE);
update_chrome_visibility (ev_window);
gtk_widget_grab_focus (ev_window->priv->find_bar);
- ev_view_find_previous (EV_VIEW (ev_window->priv->view));
+ if (ev_window->priv->document->iswebdocument == FALSE) {
+ ev_view_find_previous (EV_VIEW (ev_window->priv->view));
+ }
+#if ENABLE_EPUB
+ else {
+ ev_web_view_find_previous(EV_WEB_VIEW(ev_window->priv->webview));
+ }
+#endif
}
static void
ev_window_cmd_edit_copy (GtkAction *action, EvWindow *ev_window)
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
-
- ev_view_copy (EV_VIEW (ev_window->priv->view));
+#if ENABLE_EPUB
+ if (ev_window->priv->document->iswebdocument) {
+ ev_web_view_copy(EV_WEB_VIEW(ev_window->priv->webview));
+ } else
+#endif
+ {
+ ev_view_copy (EV_VIEW (ev_window->priv->view));
+ }
}
static void
@@ -3832,8 +3961,14 @@ ev_window_run_fullscreen (EvWindow *window)
if (fullscreen_window)
gtk_window_fullscreen (GTK_WINDOW (window));
- gtk_widget_grab_focus (window->priv->view);
-
+ if (window->priv->view) {
+ gtk_widget_grab_focus (window->priv->view);
+ }
+#if ENABLE_EPUB
+ else {
+ gtk_widget_grab_focus(window->priv->webview);
+ }
+#endif
if (window->priv->metadata && !ev_window_is_empty (window))
ev_metadata_set_boolean (window->priv->metadata, "fullscreen", TRUE);
}
@@ -3903,7 +4038,11 @@ ev_window_run_presentation (EvWindow *window)
if (EV_WINDOW_IS_PRESENTATION (window))
return;
-
+
+ if (window->priv->document->iswebdocument) {
+ ev_window_warning_message(window,_("Presentation mode is not supported for ePub documents"));
+ return;
+ }
if (ev_document_model_get_fullscreen (window->priv->model)) {
ev_window_stop_fullscreen (window, FALSE);
fullscreen_window = FALSE;
@@ -3961,9 +4100,15 @@ ev_window_stop_presentation (EvWindow *window,
update_chrome_visibility (window);
if (unfullscreen_window)
gtk_window_unfullscreen (GTK_WINDOW (window));
-
- gtk_widget_grab_focus (window->priv->view);
-
+
+ if (window->priv->view) {
+ gtk_widget_grab_focus (window->priv->view);
+ }
+#if ENABLE_EPUB
+ else {
+ gtk_widget_grab_focus (window->priv->webview);
+ }
+#endif
ev_application_screensaver_enable (EV_APP);
if (window->priv->metadata && !ev_window_is_empty (window))
@@ -4099,7 +4244,14 @@ 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;
+ }
+#if ENABLE_EPUB
+ else {
+ child=window->priv->webview;
+ }
+#endif
break;
case PAGE_MODE_PASSWORD:
child = window->priv->password_view;
@@ -4181,9 +4333,6 @@ ev_window_cmd_edit_toolbar (GtkAction *action, EvWindow *ev_window)
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)), 5);
gtk_box_set_spacing (GTK_BOX (content_area), 2);
-#if !GTK_CHECK_VERSION (3, 0, 0)
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
-#endif
gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 400);
toolbar = EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar);
@@ -4241,7 +4390,15 @@ ev_window_cmd_view_zoom_in (GtkAction *action, EvWindow *ev_window)
g_return_if_fail (EV_IS_WINDOW (ev_window));
ev_document_model_set_sizing_mode (ev_window->priv->model, EV_SIZING_FREE);
- ev_view_zoom_in (EV_VIEW (ev_window->priv->view));
+#if ENABLE_EPUB
+ if (ev_window->priv->document->iswebdocument) {
+ ev_web_view_zoom_in(EV_WEB_VIEW(ev_window->priv->webview));
+ }
+ else
+#endif
+ {
+ ev_view_zoom_in (EV_VIEW (ev_window->priv->view));
+ }
}
static void
@@ -4250,23 +4407,44 @@ ev_window_cmd_view_zoom_out (GtkAction *action, EvWindow *ev_window)
g_return_if_fail (EV_IS_WINDOW (ev_window));
ev_document_model_set_sizing_mode (ev_window->priv->model, EV_SIZING_FREE);
- ev_view_zoom_out (EV_VIEW (ev_window->priv->view));
+#if ENABLE_EPUB
+ if ( ev_window->priv->document->iswebdocument) {
+ ev_web_view_zoom_out(EV_WEB_VIEW(ev_window->priv->webview));
+ }
+ else
+#endif
+ {
+ ev_view_zoom_out (EV_VIEW (ev_window->priv->view));
+ }
}
static void
ev_window_cmd_go_previous_page (GtkAction *action, EvWindow *ev_window)
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
-
- ev_view_previous_page (EV_VIEW (ev_window->priv->view));
+#if ENABLE_EPUB
+ if ( ev_window->priv->document->iswebdocument == TRUE ) {
+ ev_web_view_previous_page(EV_WEB_VIEW(ev_window->priv->webview));
+ }
+ else
+#endif
+ {
+ ev_view_previous_page (EV_VIEW (ev_window->priv->view));
+ }
}
static void
ev_window_cmd_go_next_page (GtkAction *action, EvWindow *ev_window)
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
-
- ev_view_next_page (EV_VIEW (ev_window->priv->view));
+#if ENABLE_EPUB
+ if ( ev_window->priv->document->iswebdocument == TRUE ) {
+ ev_web_view_next_page(EV_WEB_VIEW(ev_window->priv->webview));
+ } else
+#endif
+ {
+ ev_view_next_page (EV_VIEW (ev_window->priv->view));
+ }
}
static void
@@ -4332,7 +4510,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"
@@ -4370,13 +4553,20 @@ ev_window_cmd_escape (GtkAction *action, EvWindow *window)
{
GtkWidget *widget;
- ev_view_autoscroll_stop (EV_VIEW (window->priv->view));
+ if (!window->priv->document->iswebdocument && window->priv->view)
+ ev_view_autoscroll_stop (EV_VIEW (window->priv->view));
widget = gtk_window_get_focus (GTK_WINDOW (window));
if (widget && gtk_widget_get_ancestor (widget, EGG_TYPE_FIND_BAR)) {
update_chrome_flag (window, EV_CHROME_FINDBAR, FALSE);
update_chrome_visibility (window);
- gtk_widget_grab_focus (window->priv->view);
+
+ if (window->priv->view)
+ gtk_widget_grab_focus (window->priv->view);
+#if ENABLE_EPUB
+ else
+ gtk_widget_grab_focus (window->priv->webview);
+#endif
} else {
gboolean fullscreen;
@@ -4388,7 +4578,12 @@ ev_window_cmd_escape (GtkAction *action, EvWindow *window)
ev_window_stop_presentation (window, TRUE);
gtk_widget_grab_focus (window->priv->view);
} else {
- gtk_widget_grab_focus (window->priv->view);
+ if (window->priv->view)
+ gtk_widget_grab_focus (window->priv->view);
+#if ENABLE_EPUB
+ else
+ gtk_widget_grab_focus (window->priv->webview);
+#endif
}
if (fullscreen && EV_WINDOW_IS_PRESENTATION (window))
@@ -4585,6 +4780,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
};
@@ -4707,6 +4903,8 @@ view_menu_link_popup (EvWindow *ev_window,
gboolean show_external = FALSE;
gboolean show_internal = FALSE;
GtkAction *action;
+
+ if ( ev_window->priv->document->iswebdocument == TRUE ) return ;
if (ev_window->priv->link)
g_object_unref (ev_window->priv->link);
@@ -4759,7 +4957,8 @@ view_menu_image_popup (EvWindow *ev_window,
{
GtkAction *action;
gboolean show_image = FALSE;
-
+
+ if (ev_window->priv->document->iswebdocument == TRUE ) return ;
if (ev_window->priv->image)
g_object_unref (ev_window->priv->image);
@@ -4785,7 +4984,7 @@ view_menu_annot_popup (EvWindow *ev_window,
{
GtkAction *action;
gboolean show_annot = FALSE;
-
+ if (ev_window->priv->document->iswebdocument == TRUE ) return ;
if (ev_window->priv->annot)
g_object_unref (ev_window->priv->annot);
ev_window->priv->annot = (annot) ? g_object_ref (annot) : NULL;
@@ -4934,10 +5133,18 @@ ev_window_find_job_updated_cb (EvJobFind *job,
EvWindow *ev_window)
{
ev_window_update_actions (ev_window);
-
- ev_view_find_changed (EV_VIEW (ev_window->priv->view),
- ev_job_find_get_results (job),
- page);
+#if ENABLE_EPUB
+ if (ev_window->priv->document->iswebdocument == TRUE ) {
+ ev_web_view_find_changed(EV_WEB_VIEW(ev_window->priv->webview),
+ job->results,job->text, job->case_sensitive);
+ }
+ else
+#endif
+ {
+ ev_view_find_changed (EV_VIEW (ev_window->priv->view),
+ ev_job_find_get_results (job),
+ page);
+ }
ev_window_update_find_status_message (ev_window);
}
@@ -4963,21 +5170,43 @@ static void
find_bar_previous_cb (EggFindBar *find_bar,
EvWindow *ev_window)
{
- ev_view_find_previous (EV_VIEW (ev_window->priv->view));
+#if ENABLE_EPUB
+ if (ev_window->priv->document->iswebdocument == TRUE ) {
+ ev_web_view_find_previous(EV_WEB_VIEW(ev_window->priv->webview));
+ }else
+#endif
+ {
+ ev_view_find_previous (EV_VIEW (ev_window->priv->view));
+ }
}
static void
find_bar_next_cb (EggFindBar *find_bar,
EvWindow *ev_window)
{
- ev_view_find_next (EV_VIEW (ev_window->priv->view));
+#if ENABLE_EPUB
+ if (ev_window->priv->document->iswebdocument == TRUE ) {
+ ev_web_view_find_next(EV_WEB_VIEW(ev_window->priv->webview));
+ } else
+#endif
+ {
+ ev_view_find_next (EV_VIEW (ev_window->priv->view));
+ }
}
static void
find_bar_close_cb (EggFindBar *find_bar,
EvWindow *ev_window)
{
- ev_view_find_cancel (EV_VIEW (ev_window->priv->view));
+#if ENABLE_EPUB
+ if (ev_window->priv->document->iswebdocument == TRUE ) {
+ ev_web_view_find_cancel(EV_WEB_VIEW(ev_window->priv->webview));
+ }
+ else
+#endif
+ {
+ ev_view_find_cancel (EV_VIEW (ev_window->priv->view));
+ }
ev_window_clear_find_job (ev_window);
update_chrome_flag (ev_window, EV_CHROME_FINDBAR, FALSE);
update_chrome_visibility (ev_window);
@@ -4997,9 +5226,14 @@ find_bar_search_changed_cb (EggFindBar *find_bar,
/* Either the string or case sensitivity could have changed. */
case_sensitive = egg_find_bar_get_case_sensitive (find_bar);
search_string = egg_find_bar_get_search_string (find_bar);
-
- ev_view_find_search_changed (EV_VIEW (ev_window->priv->view));
-
+#if ENABLE_EPUB
+ if (ev_window->priv->document->iswebdocument) {
+ ev_web_view_find_search_changed(EV_WEB_VIEW(ev_window->priv->webview));
+ } else
+#endif
+ {
+ ev_view_find_search_changed (EV_VIEW (ev_window->priv->view));
+ }
ev_window_clear_find_job (ev_window);
if (search_string && search_string[0]) {
@@ -5008,6 +5242,7 @@ find_bar_search_changed_cb (EggFindBar *find_bar,
ev_document_get_n_pages (ev_window->priv->document),
search_string,
case_sensitive);
+
g_signal_connect (ev_window->priv->find_job, "finished",
G_CALLBACK (ev_window_find_job_finished_cb),
ev_window);
@@ -5019,7 +5254,9 @@ find_bar_search_changed_cb (EggFindBar *find_bar,
ev_window_update_actions (ev_window);
egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar),
NULL);
- gtk_widget_queue_draw (GTK_WIDGET (ev_window->priv->view));
+ if (ev_window->priv->document->iswebdocument == FALSE) {
+ gtk_widget_queue_draw (GTK_WIDGET (ev_window->priv->view));
+ }
}
}
@@ -5029,13 +5266,24 @@ find_bar_visibility_changed_cb (EggFindBar *find_bar,
EvWindow *ev_window)
{
gboolean visible;
-
visible = gtk_widget_get_visible (GTK_WIDGET (find_bar));
if (ev_window->priv->document &&
EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
- ev_view_find_set_highlight_search (EV_VIEW (ev_window->priv->view), visible);
- ev_view_find_search_changed (EV_VIEW (ev_window->priv->view));
+
+ if (!ev_window->priv->document->iswebdocument) {
+ ev_view_find_set_highlight_search (EV_VIEW (ev_window->priv->view), visible);
+ ev_view_find_search_changed (EV_VIEW (ev_window->priv->view));
+ }
+#if ENABLE_EPUB
+ else {
+#if !GTK_CHECK_VERSION(3, 0, 0)
+ ev_web_view_find_set_highlight_search(EV_WEB_VIEW(ev_window->priv->webview),visible);
+#endif
+ ev_web_view_find_search_changed(EV_WEB_VIEW(ev_window->priv->webview));
+ ev_web_view_set_handler(EV_WEB_VIEW(ev_window->priv->webview),visible);
+ }
+#endif
ev_window_update_actions (ev_window);
if (visible)
@@ -5050,6 +5298,7 @@ find_bar_scroll (EggFindBar *find_bar,
GtkScrollType scroll,
EvWindow *ev_window)
{
+ if (ev_window->priv->document->iswebdocument == TRUE ) return ;
ev_view_scroll (EV_VIEW (ev_window->priv->view), scroll, FALSE);
}
@@ -5296,7 +5545,7 @@ ev_window_dispose (GObject *object)
}
if (priv->view) {
- g_object_unref (priv->view);
+ g_object_unref (priv->view);
priv->view = NULL;
}
@@ -5422,13 +5671,13 @@ ev_window_key_press_event (GtkWidget *widget,
* It's needed to be able to type in
* annot popups windows
*/
- if (priv->view) {
+ if ( priv->view) {
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);
}
-
+
if (!handled && !EV_WINDOW_IS_PRESENTATION (ev_window)) {
guint modifier = event->state & gtk_accelerator_get_default_mod_mask ();
@@ -5689,20 +5938,41 @@ static const GtkActionEntry attachment_popup_entries [] = {
static void
sidebar_links_link_activated_cb (EvSidebarLinks *sidebar_links, EvLink *link, EvWindow *window)
{
- ev_view_handle_link (EV_VIEW (window->priv->view), link);
+ if (window->priv->document->iswebdocument == FALSE ) {
+ ev_view_handle_link (EV_VIEW (window->priv->view), link);
+ }
+#if ENABLE_EPUB
+ else {
+ ev_web_view_handle_link(EV_WEB_VIEW(window->priv->webview), link);
+ }
+#endif
}
static void
activate_link_cb (EvPageAction *page_action, EvLink *link, EvWindow *window)
{
- ev_view_handle_link (EV_VIEW (window->priv->view), link);
- gtk_widget_grab_focus (window->priv->view);
+ if (window->priv->view) {
+ ev_view_handle_link (EV_VIEW (window->priv->view), link);
+ gtk_widget_grab_focus (window->priv->view);
+ }
+#if ENABLE_EPUB
+ else {
+ ev_web_view_handle_link (EV_WEB_VIEW (window->priv->webview), link);
+ gtk_widget_grab_focus (window->priv->webview);
+ }
+#endif
}
static void
navigation_action_activate_link_cb (EvNavigationAction *action, EvLink *link, EvWindow *window)
{
-
+#if ENABLE_EPUB
+ if (window->priv->document->iswebdocument == TRUE ) {
+ ev_web_view_handle_link(EV_WEB_VIEW(window->priv->webview),link);
+ gtk_widget_grab_focus (window->priv->webview);
+ return;
+ }
+#endif
ev_view_handle_link (EV_VIEW (window->priv->view), link);
gtk_widget_grab_focus (window->priv->view);
}
@@ -5711,7 +5981,15 @@ static void
sidebar_layers_visibility_changed (EvSidebarLayers *layers,
EvWindow *window)
{
- ev_view_reload (EV_VIEW (window->priv->view));
+ if (window->priv->document->iswebdocument == FALSE ) {
+ ev_view_reload (EV_VIEW (window->priv->view));
+ }
+#if ENABLE_EPUB
+ else
+ {
+ ev_web_view_reload(EV_WEB_VIEW(window->priv->webview));
+ }
+#endif
}
static void
@@ -5719,6 +5997,7 @@ sidebar_annots_annot_activated_cb (EvSidebarAnnotations *sidebar_annots,
EvMapping *annot_mapping,
EvWindow *window)
{
+ if (window->priv->document->iswebdocument == TRUE ) return;
ev_view_focus_annotation (EV_VIEW (window->priv->view), annot_mapping);
}
@@ -5727,6 +6006,7 @@ sidebar_annots_begin_annot_add (EvSidebarAnnotations *sidebar_annots,
EvAnnotationType annot_type,
EvWindow *window)
{
+ if (window->priv->document->iswebdocument == TRUE ) return;
ev_view_begin_add_annotation (EV_VIEW (window->priv->view), annot_type);
}
@@ -5743,6 +6023,7 @@ static void
sidebar_annots_annot_add_cancelled (EvSidebarAnnotations *sidebar_annots,
EvWindow *window)
{
+ if (window->priv->document->iswebdocument == TRUE ) return;
ev_view_cancel_add_annotation (EV_VIEW (window->priv->view));
}
@@ -6146,6 +6427,7 @@ view_external_link_cb (EvView *view, EvLinkAction *action, EvWindow *window)
static void
ev_view_popup_cmd_open_link (GtkAction *action, EvWindow *window)
{
+ if (window->priv->document->iswebdocument == TRUE ) return;
ev_view_handle_link (EV_VIEW (window->priv->view), window->priv->link);
}
@@ -6170,7 +6452,7 @@ static void
ev_view_popup_cmd_copy_link_address (GtkAction *action, EvWindow *window)
{
EvLinkAction *ev_action;
-
+ if (window->priv->document->iswebdocument == TRUE ) return;
ev_action = ev_link_get_action (window->priv->link);
if (!ev_action)
return;
@@ -6345,6 +6627,8 @@ static void
ev_view_popup_cmd_annot_properties (GtkAction *action,
EvWindow *window)
{
+ if (window->priv->document->iswebdocument == TRUE ) return;
+
const gchar *author;
GdkColor color;
gdouble opacity;
@@ -6730,8 +7014,9 @@ method_call_cb (GDBusConnection *connection,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- EvWindow *window = EV_WINDOW (user_data);
-
+ EvWindow *window = EV_WINDOW (user_data);
+ if (window->priv->document->iswebdocument == TRUE ) return;
+
if (g_strcmp0 (method_name, "SyncView") != 0)
return;
@@ -7025,6 +7310,16 @@ ev_window_init (EvWindow *ev_window)
gtk_widget_show (ev_window->priv->view_box);
ev_window->priv->view = ev_view_new ();
+
+#if ENABLE_EPUB /*The webview, we won't add it now but it will replace the atril-view if a web(epub) document is encountered.*/
+ ev_window->priv->webview = ev_web_view_new();
+ ev_web_view_set_model(EV_WEB_VIEW(ev_window->priv->webview),ev_window->priv->model);
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ g_signal_connect_object (ev_window->priv->webview,"selection-changed",
+ G_CALLBACK(web_view_selection_changed_cb),
+ ev_window, 0);
+#endif
+#endif
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);
@@ -7071,9 +7366,9 @@ ev_window_init (EvWindow *ev_window)
/* We own a ref on these widgets, as we can swap them in and out */
g_object_ref (ev_window->priv->view);
g_object_ref (ev_window->priv->password_view);
-
+
gtk_container_add (GTK_CONTAINER (ev_window->priv->scrolled_window),
- ev_window->priv->view);
+ ev_window->priv->view);
/* Connect to model signals */
g_signal_connect_swapped (ev_window->priv->model,