Title: [108069] trunk/Source/WebKit2
Revision
108069
Author
[email protected]
Date
2012-02-17 06:32:17 -0800 (Fri, 17 Feb 2012)

Log Message

[GTK] Rename WebKitPrintOperation::done signal to ::finished in WebKit2
https://bugs.webkit.org/show_bug.cgi?id=78893

Reviewed by Gustavo Noronha Silva.

And it's not emitted anynmore when the print dialog has been
cancelled. Since it's not possible to know whether the print
dialog was cancelled or not, the enum WebKitPrintOperationResponse
has been added, with Print and Cancel values, and it's used as
return value of webkit_print_operation_run_dialog().

* UIProcess/API/gtk/WebKitPrintOperation.cpp:
(webkit_print_operation_class_init): Rename done as finished.
(webkitPrintOperationRunDialogUnix): Return a
WebKitPrintOperationResponse instead of bool.
(webkitPrintOperationRunDialogWin32): Ditto.
(drawPagesForPrintingCompleted): Emit finished instead of done.
(webkitPrintOperationRunDialogForFrame): Do not emit finished if
the dialog was cancelled and return a WebKitPrintOperationResponse.
(webkit_print_operation_run_dialog): Return
WebKitPrintOperationResponse.
* UIProcess/API/gtk/WebKitPrintOperation.h: Add
WebKitPrintOperationResponse enum.
* UIProcess/API/gtk/WebKitPrintOperationPrivate.h:
* UIProcess/API/gtk/WebKitWebView.cpp:
(webkitWebViewPrintFrame): Check whether the dialog has been
cancelled or not and connect to finish when the print operation is
in progress to release the print operation object when printing
finishes.
* UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add
WebKitPrintOperationResponse symbol.
* UIProcess/API/gtk/tests/TestPrinting.cpp:
(testPrintOperationPrintFinished): Use finished instead of done.
(testPrintOperationPrint): Ditto.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (108068 => 108069)


--- trunk/Source/WebKit2/ChangeLog	2012-02-17 14:25:58 UTC (rev 108068)
+++ trunk/Source/WebKit2/ChangeLog	2012-02-17 14:32:17 UTC (rev 108069)
@@ -1,5 +1,42 @@
 2012-02-17  Carlos Garcia Campos  <[email protected]>
 
+        [GTK] Rename WebKitPrintOperation::done signal to ::finished in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=78893
+
+        Reviewed by Gustavo Noronha Silva.
+
+        And it's not emitted anynmore when the print dialog has been
+        cancelled. Since it's not possible to know whether the print
+        dialog was cancelled or not, the enum WebKitPrintOperationResponse
+        has been added, with Print and Cancel values, and it's used as
+        return value of webkit_print_operation_run_dialog().
+
+        * UIProcess/API/gtk/WebKitPrintOperation.cpp:
+        (webkit_print_operation_class_init): Rename done as finished.
+        (webkitPrintOperationRunDialogUnix): Return a
+        WebKitPrintOperationResponse instead of bool.
+        (webkitPrintOperationRunDialogWin32): Ditto.
+        (drawPagesForPrintingCompleted): Emit finished instead of done.
+        (webkitPrintOperationRunDialogForFrame): Do not emit finished if
+        the dialog was cancelled and return a WebKitPrintOperationResponse.
+        (webkit_print_operation_run_dialog): Return
+        WebKitPrintOperationResponse.
+        * UIProcess/API/gtk/WebKitPrintOperation.h: Add
+        WebKitPrintOperationResponse enum.
+        * UIProcess/API/gtk/WebKitPrintOperationPrivate.h:
+        * UIProcess/API/gtk/WebKitWebView.cpp:
+        (webkitWebViewPrintFrame): Check whether the dialog has been
+        cancelled or not and connect to finish when the print operation is
+        in progress to release the print operation object when printing
+        finishes.
+        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add
+        WebKitPrintOperationResponse symbol.
+        * UIProcess/API/gtk/tests/TestPrinting.cpp:
+        (testPrintOperationPrintFinished): Use finished instead of done.
+        (testPrintOperationPrint): Ditto.
+
+2012-02-17  Carlos Garcia Campos  <[email protected]>
+
         [GTK] Add webkit_print_operation_print() to WebKit2 GTK+ API
         https://bugs.webkit.org/show_bug.cgi?id=76536
 

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp (108068 => 108069)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp	2012-02-17 14:25:58 UTC (rev 108068)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp	2012-02-17 14:32:17 UTC (rev 108069)
@@ -45,7 +45,7 @@
 };
 
 enum {
-    DONE,
+    FINISHED,
 
     LAST_SIGNAL
 };
@@ -179,14 +179,14 @@
                                                          WEBKIT_PARAM_READWRITE));
 
     /**
-     * WebKitPrintOperation::done:
+     * WebKitPrintOperation::finished:
      * @print_operation: the #WebKitPrintOperation on which the signal was emitted
      *
      * Emitted when the print operation has finished doing everything
      * required for printing.
      */
-    signals[DONE] =
-        g_signal_new("done",
+    signals[FINISHED] =
+        g_signal_new("finished",
                      G_TYPE_FROM_CLASS(gObjectClass),
                      G_SIGNAL_RUN_LAST,
                      0, 0, 0,
@@ -197,7 +197,7 @@
 }
 
 #ifdef HAVE_GTK_UNIX_PRINTING
-static bool webkitPrintOperationRunDialogUnix(WebKitPrintOperation* printOperation, GtkWindow* parent)
+static WebKitPrintOperationResponse webkitPrintOperationRunDialogUnix(WebKitPrintOperation* printOperation, GtkWindow* parent)
 {
     GtkPrintUnixDialog* printDialog = GTK_PRINT_UNIX_DIALOG(gtk_print_unix_dialog_new(0, parent));
     gtk_print_unix_dialog_set_manual_capabilities(printDialog, static_cast<GtkPrintCapabilities>(0));
@@ -211,11 +211,11 @@
 
     gtk_print_unix_dialog_set_embed_page_setup(printDialog, TRUE);
 
-    bool returnValue = false;
+    WebKitPrintOperationResponse returnValue = WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL;
     if (gtk_dialog_run(GTK_DIALOG(printDialog)) == GTK_RESPONSE_OK) {
         priv->printSettings = adoptGRef(gtk_print_unix_dialog_get_settings(printDialog));
         priv->pageSetup = gtk_print_unix_dialog_get_page_setup(printDialog);
-        returnValue = true;
+        returnValue = WEBKIT_PRINT_OPERATION_RESPONSE_PRINT;
     }
 
     gtk_widget_destroy(GTK_WIDGET(printDialog));
@@ -225,10 +225,10 @@
 #endif // HAVE_GTK_UNIX_PRINTING
 
 #ifdef G_OS_WIN32
-static bool webkitPrintOperationRunDialogWin32(WebKitPrintOperation*, GtkWindow*)
+static WebKitPrintOperationResponse webkitPrintOperationRunDialogWin32(WebKitPrintOperation*, GtkWindow*)
 {
     notImplemented();
-    return false;
+    return WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL;
 }
 #endif
 
@@ -237,7 +237,7 @@
     GRefPtr<WebKitPrintOperation> printOperation = adoptGRef(WEBKIT_PRINT_OPERATION(context));
     WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(printOperation->priv->webView));
     page->endPrinting();
-    g_signal_emit(printOperation.get(), signals[DONE], 0, NULL);
+    g_signal_emit(printOperation.get(), signals[FINISHED], 0, NULL);
 }
 
 static void webkitPrintOperationPrintPagesForFrame(WebKitPrintOperation* printOperation, WebFrameProxy* webFrame, GtkPrintSettings* printSettings, GtkPageSetup* pageSetup)
@@ -247,7 +247,7 @@
     page->drawPagesForPrinting(webFrame, printInfo, VoidCallback::create(g_object_ref(printOperation), &drawPagesForPrintingCompleted));
 }
 
-void webkitPrintOperationRunDialogForFrame(WebKitPrintOperation* printOperation, GtkWindow* parent, WebFrameProxy* webFrame)
+WebKitPrintOperationResponse webkitPrintOperationRunDialogForFrame(WebKitPrintOperation* printOperation, GtkWindow* parent, WebFrameProxy* webFrame)
 {
     WebKitPrintOperationPrivate* priv = printOperation->priv;
     if (!parent) {
@@ -256,18 +256,17 @@
             parent = GTK_WINDOW(toplevel);
     }
 #ifdef HAVE_GTK_UNIX_PRINTING
-    bool shouldPrint = webkitPrintOperationRunDialogUnix(printOperation, parent);
+    WebKitPrintOperationResponse response = webkitPrintOperationRunDialogUnix(printOperation, parent);
 #endif
 #ifdef G_OS_WIN32
-    bool shouldPrint = webkitPrintOperationRunDialogWin32(printOperation, parent);
+    WebKitPrintOperationResponse response = webkitPrintOperationRunDialogWin32(printOperation, parent);
 #endif
 
-    if (!shouldPrint) {
-        g_signal_emit(printOperation, signals[DONE], 0, NULL);
-        return;
-    }
+    if (response == WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL)
+        return response;
 
     webkitPrintOperationPrintPagesForFrame(printOperation, webFrame, priv->printSettings.get(), priv->pageSetup.get());
+    return response;
 }
 
 /**
@@ -364,22 +363,26 @@
  * @print_operation: a #WebKitPrintOperation
  * @parent: (allow-none): transient parent of the print dialog
  *
- * Run the print dialog using and start printing using the options selected by
- * the user. This method returns when the print operation is closed.
- * The WebKitPrintOperation::done signal is emitted when the printing
- * operation finishes.
- * 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.
+ * Run the print dialog and start printing using the options selected by
+ * the user. This method returns when the print dialog is closed.
+ * 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.
+ * 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
  * webkit_print_operation_get_print_settings() and webkit_print_operation_get_page_setup()
  * after this method.
+ *
+ * Returns: the #WebKitPrintOperationResponse of the print dialog
  */
-void webkit_print_operation_run_dialog(WebKitPrintOperation* printOperation, GtkWindow* parent)
+WebKitPrintOperationResponse webkit_print_operation_run_dialog(WebKitPrintOperation* printOperation, GtkWindow* parent)
 {
-    g_return_if_fail(WEBKIT_IS_PRINT_OPERATION(printOperation));
+    g_return_val_if_fail(WEBKIT_IS_PRINT_OPERATION(printOperation), WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL);
 
     WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(printOperation->priv->webView));
-    webkitPrintOperationRunDialogForFrame(printOperation, parent, page->mainFrame());
+    return webkitPrintOperationRunDialogForFrame(printOperation, parent, page->mainFrame());
 }
 
 /**
@@ -391,6 +394,8 @@
  * are not set with webkit_print_operation_set_print_settings() and
  * 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.
  */
 void webkit_print_operation_print(WebKitPrintOperation* printOperation)
 {

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.h (108068 => 108069)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.h	2012-02-17 14:25:58 UTC (rev 108068)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.h	2012-02-17 14:32:17 UTC (rev 108069)
@@ -40,6 +40,19 @@
 typedef struct _WebKitPrintOperationClass   WebKitPrintOperationClass;
 typedef struct _WebKitPrintOperationPrivate WebKitPrintOperationPrivate;
 
+/**
+ * WebKitPrintOperationResponse:
+ * @WEBKIT_PRINT_OPERATION_RESPONSE_PRINT: Print button was cliked in print dialog
+ * @WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL: Print dialog was cancelled
+ *
+ * Enum values representing the response of the print dialog shown with
+ * webkit_print_operation_run_dialog().
+ */
+typedef enum {
+    WEBKIT_PRINT_OPERATION_RESPONSE_PRINT,
+    WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL
+} WebKitPrintOperationResponse;
+
 struct _WebKitPrintOperation {
     GObject parent;
 
@@ -70,7 +83,7 @@
 webkit_print_operation_set_page_setup     (WebKitPrintOperation *print_operation,
                                            GtkPageSetup         *page_setup);
 
-WEBKIT_API void
+WEBKIT_API WebKitPrintOperationResponse
 webkit_print_operation_run_dialog         (WebKitPrintOperation *print_operation,
                                            GtkWindow            *parent);
 

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperationPrivate.h (108068 => 108069)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperationPrivate.h	2012-02-17 14:25:58 UTC (rev 108068)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperationPrivate.h	2012-02-17 14:32:17 UTC (rev 108069)
@@ -23,6 +23,6 @@
 #include "WebFrameProxy.h"
 #include "WebKitPrintOperation.h"
 
-void webkitPrintOperationRunDialogForFrame(WebKitPrintOperation*, GtkWindow* parent, WebKit::WebFrameProxy*);
+WebKitPrintOperationResponse webkitPrintOperationRunDialogForFrame(WebKitPrintOperation*, GtkWindow* parent, WebKit::WebFrameProxy*);
 
 #endif // WebKitPrintOperationPrivate_h

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (108068 => 108069)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp	2012-02-17 14:25:58 UTC (rev 108068)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp	2012-02-17 14:32:17 UTC (rev 108069)
@@ -809,8 +809,10 @@
     if (returnValue)
         return;
 
-    g_signal_connect(printOperation.get(), "done", G_CALLBACK(g_object_unref), 0);
-    webkitPrintOperationRunDialogForFrame(printOperation.leakRef(), 0, toImpl(wkFrame));
+    WebKitPrintOperationResponse response = webkitPrintOperationRunDialogForFrame(printOperation.get(), 0, toImpl(wkFrame));
+    if (response == WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL)
+        return;
+    g_signal_connect(printOperation.leakRef(), "finished", G_CALLBACK(g_object_unref), 0);
 }
 
 /**

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt (108068 => 108069)


--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt	2012-02-17 14:25:58 UTC (rev 108068)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt	2012-02-17 14:32:17 UTC (rev 108069)
@@ -420,6 +420,7 @@
 <SECTION>
 <FILE>WebKitPrintOperation</FILE>
 WebKitPrintOperation
+WebKitPrintOperationResponse
 webkit_print_operation_new
 webkit_print_operation_get_print_settings
 webkit_print_operation_set_print_settings

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestPrinting.cpp (108068 => 108069)


--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestPrinting.cpp	2012-02-17 14:25:58 UTC (rev 108068)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestPrinting.cpp	2012-02-17 14:32:17 UTC (rev 108069)
@@ -79,7 +79,7 @@
     g_main_loop_quit(test->m_mainLoop);
 }
 
-static void testPrintOperationPrintDone(WebKitPrintOperation* printOperation, WebViewTest* test)
+static void testPrintOperationPrintFinished(WebKitPrintOperation* printOperation, WebViewTest* test)
 {
     g_object_unref(printOperation);
     g_main_loop_quit(test->m_mainLoop);
@@ -119,7 +119,7 @@
 
     GRefPtr<WebKitPrintOperation> printOperation = webkit_print_operation_new(test->m_webView);
     test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(printOperation.get()));
-    g_signal_connect(printOperation.get(), "done", G_CALLBACK(testPrintOperationPrintDone), test);
+    g_signal_connect(printOperation.get(), "finished", G_CALLBACK(testPrintOperationPrintFinished), test);
     webkit_print_operation_set_print_settings(printOperation.get(), printSettings.get());
     webkit_print_operation_print(printOperation.get());
     g_main_loop_run(test->m_mainLoop);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to