Title: [210324] trunk/Tools
Revision
210324
Author
tpop...@redhat.com
Date
2017-01-05 04:07:38 -0800 (Thu, 05 Jan 2017)

Log Message

[GTK] Minibrowser: Add printing support
https://bugs.webkit.org/show_bug.cgi?id=165298

Open a print dialog when the Ctrl + P shortcut is pressed. If there is
an error during the print, it's printed on the console.

Reviewed by Michael Catanzaro.

* MiniBrowser/gtk/BrowserWindow.c:
(webKitPrintOperationFailedCallback):
(printPage):
(browser_window_init):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (210323 => 210324)


--- trunk/Tools/ChangeLog	2017-01-05 08:46:10 UTC (rev 210323)
+++ trunk/Tools/ChangeLog	2017-01-05 12:07:38 UTC (rev 210324)
@@ -1,3 +1,18 @@
+2017-01-04  Tomas Popela  <tpop...@redhat.com>
+
+        [GTK] Minibrowser: Add printing support
+        https://bugs.webkit.org/show_bug.cgi?id=165298
+
+        Open a print dialog when the Ctrl + P shortcut is pressed. If there is
+        an error during the print, it's printed on the console.
+
+        Reviewed by Michael Catanzaro.
+
+        * MiniBrowser/gtk/BrowserWindow.c:
+        (webKitPrintOperationFailedCallback):
+        (printPage):
+        (browser_window_init):
+
 2017-01-04  Manuel Rego Casasnovas  <r...@igalia.com>
 
         [css-grid] Fix crash clamping grid lines

Modified: trunk/Tools/MiniBrowser/gtk/BrowserWindow.c (210323 => 210324)


--- trunk/Tools/MiniBrowser/gtk/BrowserWindow.c	2017-01-05 08:46:10 UTC (rev 210323)
+++ trunk/Tools/MiniBrowser/gtk/BrowserWindow.c	2017-01-05 12:07:38 UTC (rev 210324)
@@ -516,6 +516,22 @@
     return TRUE;
 }
 
+static void webKitPrintOperationFailedCallback(WebKitPrintOperation *printOperation, GError *error)
+{
+    g_warning("Print failed: '%s'", error->message);
+}
+
+static gboolean printPage(BrowserWindow *window, gpointer user_data)
+{
+    WebKitWebView *webView = browser_tab_get_web_view(window->activeTab);
+    WebKitPrintOperation *printOperation = webkit_print_operation_new(webView);
+
+    g_signal_connect(printOperation, "failed", G_CALLBACK(webKitPrintOperationFailedCallback), NULL);
+    webkit_print_operation_run_dialog(printOperation, GTK_WINDOW(window));
+    g_object_unref(printOperation);
+
+    return TRUE;
+}
 static void editingCommandCallback(GtkWidget*widget, BrowserWindow *window)
 {
     WebKitWebView *webView = browser_tab_get_web_view(window->activeTab);
@@ -862,6 +878,10 @@
     gtk_accel_group_connect(window->accelGroup, GDK_KEY_W, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE,
         g_cclosure_new_swap(G_CALLBACK(gtk_widget_destroy), window, NULL));
 
+    /* Print */
+    gtk_accel_group_connect(window->accelGroup, GDK_KEY_P, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE,
+        g_cclosure_new_swap(G_CALLBACK(printPage), window, NULL));
+
     g_signal_connect(webkit_web_context_get_default(), "download-started", G_CALLBACK(downloadStarted), window);
 
     GtkWidget *toolbar = gtk_toolbar_new();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to