summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrootavish <[email protected]>2014-07-26 12:26:32 +0530
committerrootavish <[email protected]>2014-07-26 12:26:32 +0530
commit57a3618d9254364157a12df39caebbf9247d5aca (patch)
tree3cf1198144056d5d0f2c49486047f0da74ac9fbe
parentd4ea4f2056a2863c7a37ad83e73bb63301de5022 (diff)
downloadatril-57a3618d9254364157a12df39caebbf9247d5aca.tar.bz2
atril-57a3618d9254364157a12df39caebbf9247d5aca.tar.xz
Reading epub documents possible
Alebit with a bit of bugs as far as navigation etc. are possible, we can read an epub document in Atril. The document will be displayed with thumbnails, and all keyboard shortcuts work. Menu options, the ones that I have currently added do work. I Will now move on to features such as inverted colors, document index, etc, most of which should be simple to add. Also made changes so that the presentation view does not fire up while displaying an epub document. Also added the feature to copy text to clipboard using the Atril menu.
-rw-r--r--libview/ev-web-view.c26
-rw-r--r--libview/ev-web-view.h9
-rw-r--r--shell/ev-window.c22
3 files changed, 40 insertions, 17 deletions
diff --git a/libview/ev-web-view.c b/libview/ev-web-view.c
index b28befd7..a1caba36 100644
--- a/libview/ev-web-view.c
+++ b/libview/ev-web-view.c
@@ -1,7 +1,7 @@
/* this file is part of atril, a mate document viewer
*
* Copyright (C) 2014 Avishkar Gupta
- * Based on ev-view.c
+ * Based on ev-view.c, also a part of atril, a mate document viewer.
*
* Atril is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
@@ -28,8 +28,10 @@
#else
#include <webkit/webkit.h>
#endif
+
#include "ev-web-view.h"
#include "ev-document-model.h"
+
#define EV_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EV_TYPE_WEB_VIEW, EvWebViewClass))
#define EV_IS_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EV_TYPE_WEB_VIEW))
#define EV_WEB_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EV_TYPE_WEB_VIEW, EvWebViewClass))
@@ -133,11 +135,12 @@ ev_web_view_change_page (EvWebView *webview,
g_return_if_fail(EV_IS_WEB_VIEW(webview));
EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS(webview->document);
+
EvPage *page = klass->get_page(webview->document,new_page);
- webkit_web_view_load_uri(WEBKIT_WEB_VIEW(webview),(gchar*)page->backend_page);
webview->current_page = new_page;
ev_document_model_set_page(webview->model,new_page);
+ webkit_web_view_load_uri(WEBKIT_WEB_VIEW(webview),(gchar*)page->backend_page);
}
static void
@@ -187,11 +190,8 @@ ev_web_view_document_changed_cb (EvDocumentModel *model,
}
gint current_page = ev_document_model_get_page(model);
- if (webview->current_page != current_page) {
- ev_web_view_change_page (webview, current_page);
- } else {
- webkit_web_view_reload (WEBKIT_WEB_VIEW(webview));
- }
+
+ ev_web_view_change_page (webview, current_page);
}
}
@@ -365,6 +365,18 @@ ev_web_view_select_all(EvWebView *webview)
webkit_web_view_select_all(WEBKIT_WEB_VIEW(webview));
}
+void
+ev_web_view_copy(EvWebView *webview)
+{
+ /* If for some reason we don't have a selection any longer,best to be safe*/
+ if (ev_web_view_get_has_selection(webview) == FALSE)
+ return;
+ if (webkit_web_view_can_copy_clipboard(WEBKIT_WEB_VIEW(webview))) {
+ webkit_web_view_copy_clipboard(WEBKIT_WEB_VIEW(webview));
+ }
+
+}
+
gboolean
ev_web_view_zoom_in(EvWebView *webview)
{
diff --git a/libview/ev-web-view.h b/libview/ev-web-view.h
index ac957f5d..2c920434 100644
--- a/libview/ev-web-view.h
+++ b/libview/ev-web-view.h
@@ -1,7 +1,7 @@
-/* this file is part of atril, a mate document web_viewer
+/* this file is part of atril, a mate document viewer
*
* Copyright (C) 2014 Avishkar Gupta
- * Based on ev-view.h
+ * Based on ev-view.h, also a part of atril, a mate document viewer
*
* Atril is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
@@ -63,8 +63,9 @@ void ev_web_view_find_next (EvWebView *webview);
void ev_web_view_find_previous (EvWebView *webview);
/*Selection*/
-gboolean ev_web_view_get_has_selection (EvWebView *webview);
-void ev_web_view_select_all (EvWebView *webview);
+gboolean ev_web_view_get_has_selection (EvWebView *webview);
+void ev_web_view_select_all (EvWebView *webview);
+void ev_web_view_copy (EvWebView *webview);
/*Zoom control*/
gboolean ev_web_view_zoom_in (EvWebView *webview);
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 89b64307..a59658f3 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -1021,8 +1021,7 @@ 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."));
+ ev_window_warning_message(window,_("Cannot enter presentation mode with ePub documents use fullscreen mode instead."));
return;
}
}
@@ -3797,9 +3796,12 @@ static void
ev_window_cmd_edit_copy (GtkAction *action, EvWindow *ev_window)
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
- if ( ev_window->priv->document->iswebdocument == TRUE ) return;
- ev_view_copy (EV_VIEW (ev_window->priv->view));
+ if (ev_window->priv->document->iswebdocument) {
+ ev_web_view_copy(EV_WEB_VIEW(ev_window->priv->webview));
+ } else {
+ ev_view_copy (EV_VIEW (ev_window->priv->view));
+ }
}
static void
@@ -3986,7 +3988,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;
@@ -7180,9 +7186,13 @@ ev_window_init (EvWindow *ev_window)
ev_window->priv->view = ev_view_new ();
-#ifdef ENABLE_EPUB
+#ifdef 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);
+
+ g_signal_connect_object (ev_window->priv->webview,"selection-changed",
+ G_CALLBACK(web_view_selection_changed_cb),
+ ev_window, 0);
#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);