Skip to content

Commit 6ed0ee1

Browse files
mickaelalbertusclefebvre
authored andcommitted
Fix Epub thumbnails (#200)
* BugFix Fix the bug of the epub thumbnails * Fix indentation and trailing spaces
1 parent 69d0795 commit 6ed0ee1

File tree

2 files changed

+30
-27
lines changed

2 files changed

+30
-27
lines changed

backend/epub/epub-document.c

Lines changed: 4 additions & 3 deletions
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

Lines changed: 26 additions & 24 deletions
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 };
@@ -827,6 +822,7 @@ ev_job_thumbnail_dispose (GObject *object)
827822
}
828823

829824
#if ENABLE_EPUB
825+
830826
static void
831827
snapshot_callback(WebKitWebView *webview,
832828
GAsyncResult *results,
@@ -859,8 +855,12 @@ snapshot_callback(WebKitWebView *webview,
859855

860856
ev_document_doc_mutex_unlock ();
861857
ev_job_succeeded (EV_JOB(job_thumb));
858+
859+
gtk_widget_destroy (gtk_widget_get_toplevel (webview));
862860
}
863861

862+
#endif /* ENABLE_EPUB */
863+
864864
static void
865865
web_thumbnail_get_screenshot_cb (WebKitWebView *webview,
866866
WebKitLoadEvent event,
@@ -888,9 +888,11 @@ webview_load_failed_cb (WebKitWebView *webview,
888888
GError *e = (GError *) error;
889889
g_warning ("Error loading data from %s: %s", failing_uri, e->message);
890890
ev_job_failed_from_error (EV_JOB(job_thumb), e);
891+
892+
gtk_widget_destroy (gtk_widget_get_toplevel (webview));
893+
891894
return TRUE;
892895
}
893-
#endif /* ENABLE_EPUB */
894896

895897
static gboolean
896898
ev_job_thumbnail_run (EvJob *job)
@@ -921,24 +923,24 @@ ev_job_thumbnail_run (EvJob *job)
921923

922924
#if ENABLE_EPUB
923925
if (job->document->iswebdocument == TRUE) {
924-
if (!webview) {
925-
webview = webkit_web_view_new();
926-
g_signal_connect(WEBKIT_WEB_VIEW(webview),"load-changed",
927-
G_CALLBACK(web_thumbnail_get_screenshot_cb),
928-
g_object_ref (job_thumb));
929-
g_signal_connect(WEBKIT_WEB_VIEW(webview),"load-failed",
930-
G_CALLBACK(webview_load_failed_cb),
931-
g_object_ref (job_thumb));
932-
}
933-
934-
if (!offscreenwindow) {
935-
offscreenwindow = gtk_offscreen_window_new();
936-
gtk_container_add(GTK_CONTAINER(offscreenwindow),GTK_WIDGET(webview));
937-
gtk_window_set_default_size (GTK_WINDOW(offscreenwindow),800,1080);
938-
gtk_widget_show_all(offscreenwindow);
939-
}
940-
941-
webkit_web_view_load_uri(WEBKIT_WEB_VIEW(webview),(gchar*)rc->page->backend_page);
926+
927+
GtkWidget *webview;
928+
GtkWidget *offscreenwindow;
929+
930+
webview = webkit_web_view_new ();
931+
offscreenwindow = gtk_offscreen_window_new ();
932+
933+
gtk_container_add (GTK_CONTAINER(offscreenwindow), GTK_WIDGET (webview));
934+
gtk_window_set_default_size (GTK_WINDOW(offscreenwindow), 800, 1080);
935+
gtk_widget_show_all (offscreenwindow);
936+
937+
g_signal_connect (WEBKIT_WEB_VIEW (webview), "load-changed",
938+
G_CALLBACK (web_thumbnail_get_screenshot_cb),
939+
g_object_ref (job_thumb));
940+
g_signal_connect (WEBKIT_WEB_VIEW(webview), "load-failed",
941+
G_CALLBACK(webview_load_failed_cb),
942+
g_object_ref (job_thumb));
943+
webkit_web_view_load_uri (webview, (gchar*) rc->page->backend_page);
942944
}
943945
else
944946
#endif /* ENABLE_EPUB */

0 commit comments

Comments
 (0)