[Xfce4-commits] <midori:master> Implement printing with WebKit2

Christian Dywan noreply at xfce.org
Sat Apr 6 22:04:02 CEST 2013


Updating branch refs/heads/master
         to e9e7e7d39bcb30f653508c737d713768fa28d465 (commit)
       from cf1040dbcacee62a6099b33f5e54c9dc3f1fdd77 (commit)

commit e9e7e7d39bcb30f653508c737d713768fa28d465
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sat Apr 6 22:01:14 2013 +0200

    Implement printing with WebKit2
    
    There's no 'Print backgrounds' option for now, there doesn't
    seem to be API to hook into GtkPrintOperation.

 midori/midori-view.c |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/midori/midori-view.c b/midori/midori-view.c
index e6fdafc..fb03457 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -5559,6 +5559,7 @@ midori_view_get_next_page (MidoriView* view)
     return midori_view_get_related_page (view, "next", _("next"));
 }
 
+#ifndef HAVE_WEBKIT2
 static GtkWidget*
 midori_view_print_create_custom_widget_cb (GtkPrintOperation* operation,
                                            MidoriView*        view)
@@ -5576,6 +5577,7 @@ midori_view_print_create_custom_widget_cb (GtkPrintOperation* operation,
 
     return box;
 }
+#endif
 
 /**
  * midori_view_print
@@ -5586,22 +5588,26 @@ midori_view_print_create_custom_widget_cb (GtkPrintOperation* operation,
 void
 midori_view_print (MidoriView* view)
 {
-#ifndef HAVE_WEBKIT2
-    WebKitWebFrame* frame;
-    GtkPrintOperation* operation;
-    GError* error;
-
     g_return_if_fail (MIDORI_IS_VIEW (view));
 
-    frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
-    operation = gtk_print_operation_new ();
+#ifdef HAVE_WEBKIT2
+    WebKitPrintOperation* operation = webkit_print_operation_new (WEBKIT_WEB_VIEW (view->web_view));
+    GtkPrintSettings* settings = gtk_print_settings_new ();
+    webkit_print_operation_set_print_settings (operation, settings);
+    g_object_unref (settings);
+    webkit_print_operation_run_dialog (operation,
+        GTK_WINDOW (midori_browser_get_for_widget (view->web_view)));
+    g_object_unref (operation);
+#else
+    WebKitWebFrame* frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
+    GtkPrintOperation* operation = gtk_print_operation_new ();
     gtk_print_operation_set_custom_tab_label (operation, _("Features"));
     #if GTK_CHECK_VERSION (2, 18, 0)
     gtk_print_operation_set_embed_page_setup (operation, TRUE);
     #endif
     g_signal_connect (operation, "create-custom-widget",
         G_CALLBACK (midori_view_print_create_custom_widget_cb), view);
-    error = NULL;
+    GError* error = NULL;
     webkit_web_frame_print_full (frame, operation,
         GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, &error);
     g_object_unref (operation);


More information about the Xfce4-commits mailing list