summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrootavish <[email protected]>2014-07-21 19:22:22 +0530
committerrootavish <[email protected]>2014-07-21 19:25:36 +0530
commitb1bed03353e98b968e3f371446b02837f9e3baf7 (patch)
treef0a8de0c252567610df8fdd12885af1811d856ff
parentc8b63e55987f0ee6d4067a7309ef2fac8119b0cc (diff)
downloadatril-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.
-rw-r--r--libview/ev-jobs.c40
-rw-r--r--shell/ev-sidebar-thumbnails.c3
-rw-r--r--shell/ev-window.c6
3 files changed, 24 insertions, 25 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));
diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c
index 92f24c2a..5c4cb4be 100644
--- a/shell/ev-sidebar-thumbnails.c
+++ b/shell/ev-sidebar-thumbnails.c
@@ -374,9 +374,6 @@ clear_range (EvSidebarThumbnails *sidebar_thumbnails,
result = gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->list_store), &iter), start_page ++) {
EvJobThumbnail *job;
- if (priv->document->iswebdocument == TRUE) {
- EV_JOB(job)->run_mode = EV_JOB_RUN_MAIN_LOOP ;
- }
GdkPixbuf *loading_icon = NULL;
gint width, height;
diff --git a/shell/ev-window.c b/shell/ev-window.c
index d73cfba6..277488c6 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -682,8 +682,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);
+ }
}
}