GNOME Bugzilla – Bug 609021
[Patch] Print Preview does not work
Last modified: 2010-02-08 20:47:41 UTC
Created attachment 153037 [details] [review] Print preview implementation Print preview is not working now. If File->Print Preview is selected, the window layout changes but the web page displayes remains without changes. This patch implements print preview by using webkit_web_frame_print_full with GTK_PRINT_OPERATION_ACTION_PREVIEW as action, so evince is used to display the print preview. This patch also removes all the code which remained from the old implementation of printing previewing, so print preview mode dissapears from EphyWebView and EphyWindow. PPViewToolbar is also removed in this patch. This patch also solves bug #109063.
Comment on attachment 153037 [details] [review] Print preview implementation A small comment, in the future if you can post patches done with 'git format-patch', makes things easier. Would be good to document this function, the old one was documented. >+ephy_web_view_show_print_preview (EphyWebView *view) >+{ >+ WebKitWebFrame *main_frame; >+ GtkPrintOperationResult result; You are not really using 'result', you can get rid of it. >+ GtkPrintOperation *operation; >+ GError *error; >+ EphyEmbedShell *shell; >+ >+ shell = ephy_embed_shell_get_default (); >+ error = NULL; >+ main_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view)); >+ >+ operation = gtk_print_operation_new(); You are leaking this object. >+ gtk_print_operation_set_default_page_setup (operation, ephy_embed_shell_get_page_setup (shell)); >+ >+ result = webkit_web_frame_print_full(main_frame, operation, GTK_PRINT_OPERATION_ACTION_PREVIEW, &error); >+ >+ if (error) { >+ GtkWidget* dialog = gtk_message_dialog_new (NULL, >+ GTK_DIALOG_DESTROY_WITH_PARENT, >+ GTK_MESSAGE_ERROR, >+ GTK_BUTTONS_CLOSE, >+ "%s", error->message); >+ g_error_free(error); >+ >+ g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL); >+ gtk_widget_show(dialog); I think it would be nicer to do this with an infobar, but we can do it in a follow-up patch. >+ } A new line here. >+ return; > } > > /** Everything else looks good to me, thanks!
Created attachment 153279 [details] [review] Print preview implementation New patch, solves operation leaking, documents function and uses infobar.
I pushed this in commit 9dd27664308a8dcd007d3ff17b55b7f5c93cdf62 with a couple of tweaks (adding Since: 2.30 to the doc and removing the ppview toolbar from POTFILES.in).