Skip to content

Commit ea3dfb1

Browse files
mickaelalbertusraveit65
authored andcommitted
epub: fix loading epub thumbnails
origin commit: linuxmint/xreader@6ed0ee1 Note: origin commit causes some serious build warnings, ......fixed.
1 parent e79d266 commit ea3dfb1

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

backend/epub/epub-document.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,10 @@ epub_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
124124
cairo_surface_t *webpage;
125125
GdkPixbuf *thumbnailpix = NULL ;
126126
gint width,height;
127-
epub_document_thumbnails_get_dimensions(document,rc,&width,&height);
128-
webpage = ev_document_misc_surface_rotate_and_scale(rc->page->backend_page,width,height,0);
129-
thumbnailpix = ev_document_misc_pixbuf_from_surface(webpage);
127+
epub_document_thumbnails_get_dimensions (document, rc, &width, &height);
128+
webpage = ev_document_misc_surface_rotate_and_scale (rc->page->backend_page,
129+
width, height, 0);
130+
thumbnailpix = ev_document_misc_pixbuf_from_surface (webpage);
130131
return thumbnailpix;
131132
}
132133

libview/ev-jobs.c

+23-24
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@ enum {
9292
FIND_LAST_SIGNAL
9393
};
9494

95-
#if ENABLE_EPUB
96-
static GtkWidget* webview;
97-
static GtkWidget* offscreenwindow;
98-
#endif
99-
10095
static guint job_signals[LAST_SIGNAL] = { 0 };
10196
static guint job_fonts_signals[FONTS_LAST_SIGNAL] = { 0 };
10297
static guint job_find_signals[FIND_LAST_SIGNAL] = { 0 };
@@ -877,8 +872,12 @@ snapshot_callback(WebKitWebView *webview,
877872

878873
ev_document_doc_mutex_unlock ();
879874
ev_job_succeeded (EV_JOB(job_thumb));
875+
876+
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (webview)));
880877
}
881878

879+
#endif /* ENABLE_EPUB */
880+
882881
static void
883882
web_thumbnail_get_screenshot_cb (WebKitWebView *webview,
884883
WebKitLoadEvent event,
@@ -906,9 +905,10 @@ webview_load_failed_cb (WebKitWebView *webview,
906905
GError *e = (GError *) error;
907906
g_warning ("Error loading data from %s: %s", failing_uri, e->message);
908907
ev_job_failed_from_error (EV_JOB(job_thumb), e);
908+
909+
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (webview)));
909910
return TRUE;
910911
}
911-
#endif /* ENABLE_EPUB */
912912

913913
static gboolean
914914
ev_job_thumbnail_run (EvJob *job)
@@ -939,24 +939,23 @@ ev_job_thumbnail_run (EvJob *job)
939939

940940
#if ENABLE_EPUB
941941
if (job->document->iswebdocument == TRUE) {
942-
if (!webview) {
943-
webview = webkit_web_view_new();
944-
g_signal_connect(WEBKIT_WEB_VIEW(webview),"load-changed",
945-
G_CALLBACK(web_thumbnail_get_screenshot_cb),
946-
g_object_ref (job_thumb));
947-
g_signal_connect(WEBKIT_WEB_VIEW(webview),"load-failed",
948-
G_CALLBACK(webview_load_failed_cb),
949-
g_object_ref (job_thumb));
950-
}
951-
952-
if (!offscreenwindow) {
953-
offscreenwindow = gtk_offscreen_window_new();
954-
gtk_container_add(GTK_CONTAINER(offscreenwindow),GTK_WIDGET(webview));
955-
gtk_window_set_default_size (GTK_WINDOW(offscreenwindow),800,1080);
956-
gtk_widget_show_all(offscreenwindow);
957-
}
958-
959-
webkit_web_view_load_uri(WEBKIT_WEB_VIEW(webview),(gchar*)rc->page->backend_page);
942+
GtkWidget *webview;
943+
GtkWidget *offscreenwindow;
944+
945+
webview = webkit_web_view_new ();
946+
offscreenwindow = gtk_offscreen_window_new ();
947+
948+
gtk_container_add (GTK_CONTAINER(offscreenwindow), GTK_WIDGET (webview));
949+
gtk_window_set_default_size (GTK_WINDOW(offscreenwindow), 800, 1080);
950+
gtk_widget_show_all (offscreenwindow);
951+
952+
g_signal_connect (WEBKIT_WEB_VIEW (webview), "load-changed",
953+
G_CALLBACK (web_thumbnail_get_screenshot_cb),
954+
g_object_ref (job_thumb));
955+
g_signal_connect (WEBKIT_WEB_VIEW(webview), "load-failed",
956+
G_CALLBACK(webview_load_failed_cb),
957+
g_object_ref (job_thumb));
958+
webkit_web_view_load_uri (WEBKIT_WEB_VIEW (webview), (gchar*) rc->page->backend_page);
960959
}
961960
else
962961
#endif /* ENABLE_EPUB */

0 commit comments

Comments
 (0)