aboutsummaryrefslogtreecommitdiffstats
path: root/embed/ephy-web-view.c
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2012-06-22 15:37:31 +0800
committerCarlos Garcia Campos <carlosgc@gnome.org>2012-06-25 19:20:10 +0800
commit94e9d47168cce812b5265507d97da157a5dcf77b (patch)
treea267e80a59036f66ae576eb581a2230cc3e5f874 /embed/ephy-web-view.c
parentd1ffe68fe73afa424ee86834ad3ec7be7cb245a2 (diff)
downloadgsoc2013-epiphany-94e9d47168cce812b5265507d97da157a5dcf77b.tar.gz
gsoc2013-epiphany-94e9d47168cce812b5265507d97da157a5dcf77b.tar.zst
gsoc2013-epiphany-94e9d47168cce812b5265507d97da157a5dcf77b.zip
Port printing to WebKit2
https://bugzilla.gnome.org/show_bug.cgi?id=678600
Diffstat (limited to 'embed/ephy-web-view.c')
-rw-r--r--embed/ephy-web-view.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 5c3ff395b..cc9469aa2 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -3803,12 +3803,10 @@ ephy_web_view_print_failed (EphyWebView *view, GError *error)
gtk_widget_show_all (info_bar);
}
+#ifndef HAVE_WEBKIT2
static void
ephy_web_view_run_print_action (EphyWebView *view, GtkPrintOperationAction action)
{
-#ifdef HAVE_WEBKIT2
- /* TODO: Printing */
-#else
WebKitWebFrame *main_frame;
GtkPrintOperation *operation;
GError *error;
@@ -3831,9 +3829,28 @@ ephy_web_view_run_print_action (EphyWebView *view, GtkPrintOperationAction actio
ephy_embed_shell_set_page_setup (shell, gtk_print_operation_get_default_page_setup (operation));
g_object_unref (operation);
+}
#endif
+
+#ifdef HAVE_WEBKIT2
+static void
+print_operation_finished_cb (WebKitPrintOperation *operation,
+ EphyWebView *view)
+{
+ ephy_embed_shell_set_page_setup (ephy_embed_shell_get_default (),
+ webkit_print_operation_get_page_setup (operation));
}
+static void
+print_operation_failed_cb (WebKitPrintOperation *operation,
+ GError *error,
+ EphyWebView *view)
+{
+ g_signal_handlers_disconnect_by_func (operation, print_operation_finished_cb, view);
+ ephy_web_view_print_failed (view, error);
+}
+#endif
+
/**
* ephy_web_view_print:
* @view: an #EphyWebView
@@ -3845,7 +3862,25 @@ ephy_web_view_run_print_action (EphyWebView *view, GtkPrintOperationAction actio
void
ephy_web_view_print (EphyWebView *view)
{
+#ifdef HAVE_WEBKIT2
+ WebKitPrintOperation *operation;
+ EphyEmbedShell *shell;
+
+ shell = ephy_embed_shell_get_default ();
+
+ operation = webkit_print_operation_new (WEBKIT_WEB_VIEW (view));
+ g_signal_connect (operation, "finished",
+ G_CALLBACK (print_operation_finished_cb),
+ view);
+ g_signal_connect (operation, "failed",
+ G_CALLBACK (print_operation_failed_cb),
+ view);
+ webkit_print_operation_set_page_setup (operation, ephy_embed_shell_get_page_setup (shell));
+ webkit_print_operation_run_dialog (operation, NULL);
+ g_object_unref (operation);
+#else
ephy_web_view_run_print_action (view, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG);
+#endif
}
/**