summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrootavish <[email protected]>2014-08-10 01:05:45 +0530
committerrootavish <[email protected]>2014-08-10 01:05:45 +0530
commit1548bcb4629a6a41641a0188003215b3098aa5fc (patch)
tree368ef186c9aa1a60eeeba84fabcaceb6d30bd30f
parent3a013d3b19c5a81372560e735cf6f9f5c3ebdd37 (diff)
downloadatril-1548bcb4629a6a41641a0188003215b3098aa5fc.tar.bz2
atril-1548bcb4629a6a41641a0188003215b3098aa5fc.tar.xz
Page Label handling, other fixes
Added the function to handle links from the toolbar, also added functions to disconnect all ev-view handlers once it has been replaced by ev-web-view, and vice-versa(to drop all handler associated to ev-web-view). Also the unref call to job_thumb was causing thumbnail jobs to crash with GTK2, so had to revert that, now we're back to the document folder not getting deleted from disk.
-rw-r--r--libview/ev-jobs.c1
-rwxr-xr-x[-rw-r--r--]libview/ev-view.c38
-rwxr-xr-x[-rw-r--r--]libview/ev-view.h2
-rw-r--r--libview/ev-web-view.c32
-rw-r--r--libview/ev-web-view.h12
-rw-r--r--shell/ev-window.c13
6 files changed, 88 insertions, 10 deletions
diff --git a/libview/ev-jobs.c b/libview/ev-jobs.c
index b5a147f1..c4324a1c 100644
--- a/libview/ev-jobs.c
+++ b/libview/ev-jobs.c
@@ -914,7 +914,6 @@ ev_job_thumbnail_run (EvJob *job)
g_object_ref(job_thumb));
#endif
- g_object_unref(job_thumb);
}
else {
job_thumb->thumbnail = ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (job->document),
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 7bb56cae..ec378758 100644..100755
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -6568,3 +6568,41 @@ ev_view_previous_page (EvView *view)
}
}
+/**
+ * ev_view_disconnect_handlers
+ * @view: #EvView instance
+ *
+ * Disconnect all signal handlers from the model, to ensure error free operation of the webview,
+ * we have an equivalent function for the webview.
+ */
+void
+ev_view_disconnect_handlers(EvView *view)
+{
+ g_signal_handlers_disconnect_by_func(view->model,
+ G_CALLBACK (ev_view_rotation_changed_cb),
+ view);
+ g_signal_handlers_disconnect_by_func(view->model,
+ G_CALLBACK (ev_view_inverted_colors_changed_cb),
+ view);
+ g_signal_handlers_disconnect_by_func(view->model,
+ G_CALLBACK (ev_view_sizing_mode_changed_cb),
+ view);
+ g_signal_handlers_disconnect_by_func(view->model,
+ G_CALLBACK (ev_view_scale_changed_cb),
+ view);
+ g_signal_handlers_disconnect_by_func(view->model,
+ G_CALLBACK (ev_view_continuous_changed_cb),
+ view);
+ g_signal_handlers_disconnect_by_func(view->model,
+ G_CALLBACK (ev_view_dual_page_changed_cb),
+ view);
+ g_signal_handlers_disconnect_by_func(view->model,
+ G_CALLBACK (ev_view_fullscreen_changed_cb),
+ view);
+ g_signal_handlers_disconnect_by_func(view->model,
+ G_CALLBACK (ev_view_page_changed_cb),
+ view);
+ g_signal_handlers_disconnect_by_func(view->model,
+ G_CALLBACK (ev_view_document_changed_cb),
+ view);
+} \ No newline at end of file
diff --git a/libview/ev-view.h b/libview/ev-view.h
index 402b9895..0a9e1718 100644..100755
--- a/libview/ev-view.h
+++ b/libview/ev-view.h
@@ -110,6 +110,8 @@ void ev_view_begin_add_annotation (EvView *view,
EvAnnotationType annot_type);
void ev_view_cancel_add_annotation (EvView *view);
+/*For epub*/
+void ev_view_disconnect_handlers (EvView *view);
G_END_DECLS
#endif /* __EV_VIEW_H__ */
diff --git a/libview/ev-web-view.c b/libview/ev-web-view.c
index f88dd84a..b1fe3b08 100644
--- a/libview/ev-web-view.c
+++ b/libview/ev-web-view.c
@@ -22,6 +22,7 @@
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
+#include <stdlib.h>
#if GTK_CHECK_VERSION (3, 0, 0)
#include <webkit2/webkit2.h>
@@ -420,6 +421,15 @@ ev_web_view_handle_link(EvWebView *webview,EvLink *link)
break;
}
+ case EV_LINK_DEST_TYPE_PAGE_LABEL: {
+ const gchar *text = ev_link_dest_get_page_label (dest);
+ gint page = atoi(text);
+
+ if (page <= ev_document_get_n_pages(webview->document) && page > 0) {
+ ev_document_model_set_page(webview->model,page-1);
+ }
+ break;
+ }
case EV_LINK_DEST_TYPE_HLINK: {
const gchar *uri = ev_link_dest_get_named_dest(dest);
ev_document_model_set_page(webview->model,ev_link_dest_get_page(dest));
@@ -430,7 +440,6 @@ ev_web_view_handle_link(EvWebView *webview,EvLink *link)
}
}
}
-
/* Searching */
#if !GTK_CHECK_VERSION (3, 0, 0)
@@ -841,4 +850,25 @@ ev_web_view_zoom_out(EvWebView *webview)
webkit_web_view_zoom_out(WEBKIT_WEB_VIEW(webview));
#endif
return TRUE;
+}
+
+/**
+ * ev_web_view_disconnect_handlers
+ * @webview : #EvWebView instance
+ *
+ * This function call will disconnect all model signal handlers from the webview, to ensure smooth operation of the Atril-view.
+ * Equivalent to function ev_view_disconnect_handlers in ev-view.c
+ */
+void
+ev_web_view_disconnect_handlers(EvWebView *webview)
+{
+ g_signal_handlers_disconnect_by_func(webview->model,
+ ev_web_view_document_changed_cb,
+ webview);
+ g_signal_handlers_disconnect_by_func(webview->model,
+ ev_web_view_inverted_colors_changed_cb,
+ webview);
+ g_signal_handlers_disconnect_by_func(webview->model,
+ ev_web_view_page_changed_cb,
+ webview);
} \ No newline at end of file
diff --git a/libview/ev-web-view.h b/libview/ev-web-view.h
index 661ed9d0..74b7eb6b 100644
--- a/libview/ev-web-view.h
+++ b/libview/ev-web-view.h
@@ -74,14 +74,16 @@ void ev_web_view_find_cancel (EvWebView *webview);
void ev_web_view_find_set_highlight_search (EvWebView *webview,gboolean visible);
void ev_web_view_set_handler (EvWebView *webview,gboolean visible);
/* Selection */
-gboolean ev_web_view_get_has_selection (EvWebView *webview);
-void ev_web_view_select_all (EvWebView *webview);
-void ev_web_view_copy (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);
-gboolean ev_web_view_zoom_out (EvWebView *webview);
+gboolean ev_web_view_zoom_in (EvWebView *webview);
+gboolean ev_web_view_zoom_out (EvWebView *webview);
+/*For safe replacement by an EvView*/
+void ev_web_view_disconnect_handlers (EvWebView *webview);
G_END_DECLS
#endif /* __EV_WEB_VIEW_H__ */
diff --git a/shell/ev-window.c b/shell/ev-window.c
index bb870976..fda6f68b 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -1502,7 +1502,7 @@ ev_window_set_document (EvWindow *ev_window, EvDocument *document)
/*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),
@@ -1511,6 +1511,7 @@ ev_window_set_document (EvWindow *ev_window, EvDocument *document)
}
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);
}
@@ -5887,8 +5888,14 @@ sidebar_links_link_activated_cb (EvSidebarLinks *sidebar_links, EvLink *link, Ev
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);
+ }
+ else {
+ ev_web_view_handle_link (EV_WEB_VIEW (window->priv->webview), link);
+ gtk_widget_grab_focus (window->priv->webview);
+ }
}
static void