diff options
author | rootavish <[email protected]> | 2014-07-21 19:22:22 +0530 |
---|---|---|
committer | rootavish <[email protected]> | 2014-07-21 19:25:36 +0530 |
commit | b1bed03353e98b968e3f371446b02837f9e3baf7 (patch) | |
tree | f0a8de0c252567610df8fdd12885af1811d856ff /libview/ev-jobs.c | |
parent | c8b63e55987f0ee6d4067a7309ef2fac8119b0cc (diff) | |
download | atril-b1bed03353e98b968e3f371446b02837f9e3baf7.tar.bz2 atril-b1bed03353e98b968e3f371446b02837f9e3baf7.tar.xz |
Program no longer segfaults, but does not give thumbnails
The loading icons for all thumbnails are displayed, but the program does not segfault. Also realized that the absurd resizing of the window was due to the ephy-zoom action on the webview window. Will fix that in the next commit. Will also think of some workaround for screenshots.
For now committed this code so that this can act as a clean slate if I screw up somewhere.
Diffstat (limited to 'libview/ev-jobs.c')
-rw-r--r-- | libview/ev-jobs.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/libview/ev-jobs.c b/libview/ev-jobs.c index 8a9f6727..89807474 100644 --- a/libview/ev-jobs.c +++ b/libview/ev-jobs.c @@ -98,10 +98,8 @@ enum { FIND_LAST_SIGNAL }; -typedef struct _WebKitScreenShot { - cairo_surface_t *surface; - gboolean completed; -}WebKitScreenShot; +static GtkWidget* webview; +static GtkWidget* offscreenwindow; static guint job_signals[LAST_SIGNAL] = { 0 }; static guint job_fonts_signals[FONTS_LAST_SIGNAL] = { 0 }; @@ -924,18 +922,17 @@ ev_job_web_thumbnail_dispose (GObject *object) } static void -web_thumbnail_get_screenshot_cb(WebKitWebView *webview, - GParamSpec *spec, +web_thumbnail_get_screenshot_cb(WebKitWebView *webview, + WebKitWebFrame *webframe, EvJobWebThumbnail *web_thumb_job) { WebKitLoadStatus status = webkit_web_view_get_load_status(webview); if (status == WEBKIT_LOAD_FINISHED) { - g_rw_lock_writer_unlock (&web_thumb_job->screenlock); - g_rw_lock_reader_trylock (&web_thumb_job->screenlock); web_thumb_job->surface = webkit_web_view_get_snapshot (WEBKIT_WEB_VIEW(webview)); - g_rw_lock_reader_unlock (&web_thumb_job->screenlock); - *(web_thumb_job->completed) = TRUE; + if (web_thumb_job->surface) { + *(web_thumb_job->completed) = TRUE; + } } } @@ -943,12 +940,17 @@ static gboolean ev_job_web_thumbnail_run (EvJob *job) { EvJobWebThumbnail *web_thumb_job = EV_JOB_WEB_THUMBNAIL(job); + if (!webview) { + webview = webkit_web_view_new(); + } + + if (!offscreenwindow) { + offscreenwindow = gtk_offscreen_window_new(); + + gtk_container_add(GTK_CONTAINER(offscreenwindow),GTK_WIDGET(webview)); - web_thumb_job->webview = webkit_web_view_new(); - web_thumb_job->offscreenwindow = gtk_offscreen_window_new(); - gtk_container_add(GTK_CONTAINER(web_thumb_job->offscreenwindow),GTK_WIDGET(web_thumb_job->webview)); - - gtk_window_set_default_size (GTK_WINDOW(web_thumb_job->offscreenwindow),800,1080); + gtk_window_set_default_size (GTK_WINDOW(offscreenwindow),800,1080); + } ev_debug_message (DEBUG_JOBS, "%s (%p)", web_thumb_job->page, job); @@ -958,11 +960,9 @@ ev_job_web_thumbnail_run (EvJob *job) ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job); #endif - - g_rw_lock_writer_trylock (&web_thumb_job->screenlock); - webkit_web_view_load_uri(WEBKIT_WEB_VIEW(web_thumb_job->webview),web_thumb_job->page); - g_signal_connect(WEBKIT_WEB_VIEW(web_thumb_job->webview),"notify::load-status",G_CALLBACK(web_thumbnail_get_screenshot_cb),web_thumb_job); - gtk_widget_show_all(web_thumb_job->offscreenwindow); + webkit_web_view_load_uri(WEBKIT_WEB_VIEW(webview),web_thumb_job->page); + g_signal_connect(WEBKIT_WEB_VIEW(webview),"document-load-finished",G_CALLBACK(web_thumbnail_get_screenshot_cb),web_thumb_job); + gtk_widget_show_all(offscreenwindow); ev_job_succeeded (EV_JOB(job)); |