diff options
Diffstat (limited to 'Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp')
-rw-r--r-- | Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp index d79d40149..7da0b197a 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp @@ -28,7 +28,9 @@ #include <WebCore/GtkUtilities.h> #include <WebCore/NotImplemented.h> #include <glib/gi18n-lib.h> +#include <wtf/gobject/GOwnPtr.h> #include <wtf/gobject/GRefPtr.h> +#include <wtf/text/CString.h> #ifdef HAVE_GTK_UNIX_PRINTING #include <gtk/gtkunixprint.h> @@ -46,6 +48,7 @@ enum { enum { FINISHED, + FAILED, LAST_SIGNAL }; @@ -193,6 +196,24 @@ static void webkit_print_operation_class_init(WebKitPrintOperationClass* printOp g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + /** + * WebKitPrintOperation::failed: + * @print_operation: the #WebKitPrintOperation on which the signal was emitted + * @error: the #GError that was triggered + * + * Emitted when an error occurs while printing. The given @error, of the domain + * %WEBKIT_PRINT_ERROR, contains further details of the failure. + * The #WebKitPrintOperation::finished signal is emitted after this one. + */ + signals[FAILED] = + g_signal_new("failed", + G_TYPE_FROM_CLASS(gObjectClass), + G_SIGNAL_RUN_LAST, + 0, 0, 0, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, 1, + G_TYPE_POINTER); + g_type_class_add_private(printOperationClass, sizeof(WebKitPrintOperationPrivate)); } @@ -237,11 +258,19 @@ static WebKitPrintOperationResponse webkitPrintOperationRunDialog(WebKitPrintOpe } #endif -static void drawPagesForPrintingCompleted(WKErrorRef, void* context) +static void drawPagesForPrintingCompleted(WKErrorRef wkPrintError, WKErrorRef, void* context) { GRefPtr<WebKitPrintOperation> printOperation = adoptGRef(WEBKIT_PRINT_OPERATION(context)); WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(printOperation->priv->webView)); page->endPrinting(); + + const WebCore::ResourceError& resourceError = toImpl(wkPrintError)->platformError(); + if (!resourceError.isNull()) { + GOwnPtr<GError> printError(g_error_new_literal(g_quark_from_string(resourceError.domain().utf8().data()), + resourceError.errorCode(), + resourceError.localizedDescription().utf8().data())); + g_signal_emit(printOperation.get(), signals[FAILED], 0, printError.get()); + } g_signal_emit(printOperation.get(), signals[FINISHED], 0, NULL); } @@ -249,7 +278,7 @@ static void webkitPrintOperationPrintPagesForFrame(WebKitPrintOperation* printOp { PrintInfo printInfo(printSettings, pageSetup); WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(printOperation->priv->webView)); - page->drawPagesForPrinting(webFrame, printInfo, VoidCallback::create(g_object_ref(printOperation), &drawPagesForPrintingCompleted)); + page->drawPagesForPrinting(webFrame, printInfo, PrintFinishedCallback::create(g_object_ref(printOperation), &drawPagesForPrintingCompleted)); } WebKitPrintOperationResponse webkitPrintOperationRunDialogForFrame(WebKitPrintOperation* printOperation, GtkWindow* parent, WebFrameProxy* webFrame) @@ -368,7 +397,8 @@ void webkit_print_operation_set_page_setup(WebKitPrintOperation* printOperation, * If the print dialog is cancelled %WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL * is returned. If the user clicks on the print button, %WEBKIT_PRINT_OPERATION_RESPONSE_PRINT * is returned and the print operation starts. In this case, the #WebKitPrintOperation::finished - * signal is emitted when the operation finishes. + * signal is emitted when the operation finishes. If an error occurs while printing, the signal + * #WebKitPrintOperation::failed is emitted before #WebKitPrintOperation::finished. * If the print dialog is not cancelled current print settings and page setup of @print_operation * are updated with options selected by the user when Print button is pressed in print dialog. * You can get the updated print settings and page setup by calling @@ -395,7 +425,8 @@ WebKitPrintOperationResponse webkit_print_operation_run_dialog(WebKitPrintOperat * webkit_print_operation_set_page_setup(), the default options will be used * and the print job will be sent to the default printer. * The #WebKitPrintOperation::finished signal is emitted when the printing - * operation finishes. + * operation finishes. If an error occurs while printing the signal + * #WebKitPrintOperation::failed is emitted before #WebKitPrintOperation::finished. */ void webkit_print_operation_print(WebKitPrintOperation* printOperation) { |