void wk_html_print(WkHtml *html) { #ifdef USE_WEBKIT2 WebKitPrintOperation *print_operation; print_operation = webkit_print_operation_new(WEBKIT_WEB_VIEW(html)); webkit_print_operation_run_dialog(print_operation, NULL); #else webkit_web_frame_print(webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(html))); webkit_web_view_execute_script(WEBKIT_WEB_VIEW(html), "print();"); #endif }
void wxWebViewWebKit::Print() { WebKitPrintOperation* printop = webkit_print_operation_new(m_web_view); webkit_print_operation_run_dialog(printop, NULL); g_object_unref(printop); }
static gboolean mail_printer_print_timeout_cb (GTask *task) { AsyncContext *async_context; gpointer source_object; const gchar *export_filename; GtkPrintSettings *print_settings = NULL; WebKitPrintOperation *print_operation = NULL; WebKitPrintOperationResponse response; /* FIXME WK2 gulong draw_page_handler_id; gulong create_custom_widget_handler_id; gulong custom_widget_apply_handler_id;*/ async_context = g_task_get_task_data (task); g_return_val_if_fail (async_context != NULL, G_SOURCE_REMOVE); source_object = g_task_get_source_object (task); g_return_val_if_fail (E_IS_MAIL_PRINTER (source_object), G_SOURCE_REMOVE); print_settings = gtk_print_settings_new (); export_filename = e_mail_printer_get_export_filename (E_MAIL_PRINTER (source_object)); gtk_print_settings_set ( print_settings, GTK_PRINT_SETTINGS_OUTPUT_BASENAME, export_filename); print_operation = webkit_print_operation_new (async_context->web_view); webkit_print_operation_set_print_settings (print_operation, print_settings); g_signal_connect_data ( print_operation, "failed", G_CALLBACK (mail_printer_print_failed_cb), g_object_ref (task), (GClosureNotify) g_object_unref, 0); g_signal_connect_data ( print_operation, "finished", G_CALLBACK (mail_printer_print_finished_cb), g_object_ref (task), (GClosureNotify) g_object_unref, 0); /* FIXME WK2 create_custom_widget_handler_id = g_signal_connect ( print_operation, "create-custom-widget", G_CALLBACK (mail_printer_create_custom_widget_cb), async_context); custom_widget_apply_handler_id = g_signal_connect ( print_operation, "custom-widget-apply", G_CALLBACK (mail_printer_custom_widget_apply_cb), async_context); */ /* FIXME WK2 - this will be hard to add back to WK2 API.. There is a CSS draft * that can be used to add a page numbers, but it is not in WebKit yet. * http://www.w3.org/TR/css3-page/ draw_page_handler_id = g_signal_connect ( print_operation, "draw-page", G_CALLBACK (mail_printer_draw_footer_cb), async_context->cancellable); */ response = webkit_print_operation_run_dialog (print_operation, NULL); /* FIXME WK2 g_signal_handler_disconnect ( print_operation, create_custom_widget_handler_id); g_signal_handler_disconnect ( print_operation, custom_widget_apply_handler_id); g_signal_handler_disconnect ( print_operation, draw_page_handler_id); */ g_clear_object (&print_operation); g_clear_object (&print_settings); if (response == WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL) { async_context->print_result = GTK_PRINT_OPERATION_RESULT_CANCEL; g_task_return_boolean (task, TRUE); } return G_SOURCE_REMOVE; }