summaryrefslogtreecommitdiff
path: root/libview/ev-jobs.c
diff options
context:
space:
mode:
authorrootavish <[email protected]>2014-08-09 20:48:25 +0530
committerrootavish <[email protected]>2014-08-09 20:48:25 +0530
commit3a013d3b19c5a81372560e735cf6f9f5c3ebdd37 (patch)
treeec2b0c0265a8435bda737439d7923878f763afe5 /libview/ev-jobs.c
parentff0a79e545356046c7145bff0630a7cd50ad977c (diff)
downloadatril-3a013d3b19c5a81372560e735cf6f9f5c3ebdd37.tar.bz2
atril-3a013d3b19c5a81372560e735cf6f9f5c3ebdd37.tar.xz
GTK3, Webkit2 support for epub
I added the code to make it possible to build Atril with GTK3 and webkit2. Everything runs fine with both GTK3 and GTK2. The find module for epub was also tested and changed. Now I shall first attempt to fix some Glib errors, and the problem of the temporary directory not getting deleted, that arose when I stabilized the thumbnails.
Diffstat (limited to 'libview/ev-jobs.c')
-rw-r--r--libview/ev-jobs.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/libview/ev-jobs.c b/libview/ev-jobs.c
index e7f0ba35..b5a147f1 100644
--- a/libview/ev-jobs.c
+++ b/libview/ev-jobs.c
@@ -790,6 +790,7 @@ ev_job_thumbnail_dispose (GObject *object)
(* G_OBJECT_CLASS (ev_job_thumbnail_parent_class)->dispose) (object);
}
+#if !GTK_CHECK_VERSION(3, 0, 0)
static void
web_thumbnail_get_screenshot_cb(WebKitWebView *webview,
WebKitWebFrame *webframe,
@@ -815,6 +816,50 @@ web_thumbnail_get_screenshot_cb(WebKitWebView *webview,
ev_document_doc_mutex_unlock();
ev_job_succeeded(EV_JOB(job_thumb));
}
+#else
+
+static void
+snapshot_callback(WebKitWebView *webview,
+ GAsyncResult *results,
+ EvJobThumbnail *job_thumb)
+{
+ EvPage *page = ev_document_get_page (EV_JOB(job_thumb)->document, job_thumb->page);
+ job_thumb->surface = webkit_web_view_get_snapshot_finish (webview,
+ results,
+ NULL);
+ EvRenderContext *rc = ev_render_context_new (page, job_thumb->rotation, job_thumb->scale);
+ EvPage *screenshotpage;
+ screenshotpage = ev_page_new(job_thumb->page);
+ screenshotpage->backend_page = (EvBackendPage)job_thumb->surface;
+ screenshotpage->backend_destroy_func = (EvBackendPageDestroyFunc)cairo_surface_destroy ;
+ ev_render_context_set_page(rc,screenshotpage);
+
+ job_thumb->thumbnail = ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (EV_JOB(job_thumb)->document),
+ rc, TRUE);
+ g_object_unref(screenshotpage);
+ g_object_unref(rc);
+
+ ev_document_doc_mutex_unlock();
+ ev_job_succeeded(EV_JOB(job_thumb));
+}
+
+static void
+web_thumbnail_get_screenshot_cb (WebKitWebView *webview,
+ WebKitLoadEvent event,
+ EvJobThumbnail *job_thumb)
+{
+ if (event != WEBKIT_LOAD_FINISHED) {
+ return;
+ }
+
+ webkit_web_view_get_snapshot (webview,
+ WEBKIT_SNAPSHOT_REGION_VISIBLE,
+ WEBKIT_SNAPSHOT_OPTIONS_NONE,
+ NULL,
+ (GAsyncReadyCallback)snapshot_callback,
+ g_object_ref(job_thumb));
+}
+#endif
static gboolean
ev_job_thumbnail_run (EvJob *job)
@@ -859,9 +904,17 @@ ev_job_thumbnail_run (EvJob *job)
}
webkit_web_view_load_uri(WEBKIT_WEB_VIEW(webview),(gchar*)rc->page->backend_page);
+#if !GTK_CHECK_VERSION (3, 0, 0)
g_signal_connect(WEBKIT_WEB_VIEW(webview),"notify::load-status",
G_CALLBACK(web_thumbnail_get_screenshot_cb),
g_object_ref(job_thumb));
+#else
+ g_signal_connect(WEBKIT_WEB_VIEW(webview),"load-changed",
+ G_CALLBACK(web_thumbnail_get_screenshot_cb),
+ 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),