Bug 609021 - [Patch] Print Preview does not work
[Patch] Print Preview does not work
Status: RESOLVED FIXED
Product: epiphany
Classification: Core
Component: Printing
unspecified
Other All
: Normal normal
: ---
Assigned To: Epiphany Maintainers
Epiphany Maintainers
:
Depends on:
Blocks: 109063
  Show dependency tree
 
Reported: 2010-02-04 21:19 UTC by José Millán Soto
Modified: 2010-02-08 20:47 UTC (History)
2 users (show)

See Also:
GNOME target: ---
GNOME version: ---


Attachments
Print preview implementation (28.04 KB, patch)
2010-02-04 21:19 UTC, José Millán Soto
needs-work Details | Diff | Review
Print preview implementation (29.82 KB, patch)
2010-02-08 18:04 UTC, José Millán Soto
none Details | Diff | Review

Description José Millán Soto 2010-02-04 21:19:20 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 1 Xan Lopez 2010-02-05 10:35:44 UTC
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!
Comment 2 José Millán Soto 2010-02-08 18:04:31 UTC
Created attachment 153279 [details] [review]
Print preview implementation

New patch, solves operation leaking, documents function and uses infobar.
Comment 3 Xan Lopez 2010-02-08 20:47:41 UTC
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).

Note You need to log in before you can comment on or make changes to this bug.