[epiphany] Improve page print implementation



commit 21250dde74250883831a107821bb23fc0232e160
Author: Jose Millan Soto <jmillan igalia com>
Date:   Fri Feb 19 18:35:51 2010 +0100

    Improve page print implementation
    
    Use the already existing functions we have for print preview also for
    printing; fixes a bunch of usability issues.
    
    Bug #609756
    
    Signed-off-by: Xan Lopez <xan gnome org>

 embed/ephy-web-view.c |   44 +++++++++++++++++++++++++++++++-------------
 embed/ephy-web-view.h |    1 +
 src/window-commands.c |    4 +++-
 3 files changed, 35 insertions(+), 14 deletions(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index cbb70c9..e7f47b4 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -3026,17 +3026,8 @@ ephy_web_view_show_page_certificate (EphyWebView *view)
 {
 }
 
-/**
- * ephy_web_view_show_print_preview
- * @view: an #EphyWebView
- *
- * Generates a print preview of the specified view.
- * An external viewer is used to display the preview.
- *
- * Since: 2.30
- **/
-void
-ephy_web_view_show_print_preview (EphyWebView *view)
+static void
+ephy_web_view_run_print_action (EphyWebView *view, GtkPrintOperationAction action)
 {
   WebKitWebFrame *main_frame;
   GtkPrintOperation *operation;
@@ -3050,7 +3041,7 @@ ephy_web_view_show_print_preview (EphyWebView *view)
   operation = gtk_print_operation_new ();
   gtk_print_operation_set_default_page_setup (operation, ephy_embed_shell_get_page_setup  (shell));
 
-  webkit_web_frame_print_full (main_frame, operation, GTK_PRINT_OPERATION_ACTION_PREVIEW, &error);
+  webkit_web_frame_print_full (main_frame, operation, action, &error);
   g_object_unref (operation);
 
   if (error) {
@@ -3072,8 +3063,35 @@ ephy_web_view_show_print_preview (EphyWebView *view)
     ephy_embed_add_top_widget (embed, info_bar, FALSE);
     gtk_widget_show_all (info_bar);
   }
+}
 
-  return;
+/**
+ * ephy_web_view_show_print_preview
+ * @view: an #EphyWebView
+ *
+ * Generates a print preview of the specified view.
+ * An external viewer is used to display the preview.
+ *
+ * Since: 2.30
+ **/
+void
+ephy_web_view_show_print_preview (EphyWebView *view)
+{
+  ephy_web_view_run_print_action (view, GTK_PRINT_OPERATION_ACTION_PREVIEW);
+}
+
+/**
+ * ephy_web_view_print
+ * @view: an #EphyWebView
+ *
+ * Opens a dialog to print the specified view.
+ *
+ * Since: 2.30
+ **/
+void
+ephy_web_view_print (EphyWebView *view)
+{
+  ephy_web_view_run_print_action (view, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG);
 }
 
 /**
diff --git a/embed/ephy-web-view.h b/embed/ephy-web-view.h
index 57dde0b..7b71625 100644
--- a/embed/ephy-web-view.h
+++ b/embed/ephy-web-view.h
@@ -183,6 +183,7 @@ void                       ephy_web_view_get_security_level      (EphyWebView
                                                                   char                           **description);
 void                       ephy_web_view_show_page_certificate   (EphyWebView                     *view);
 void                       ephy_web_view_show_print_preview      (EphyWebView                     *view);
+void                       ephy_web_view_print                   (EphyWebView                     *view);
 GSList *                   ephy_web_view_get_go_up_list          (EphyWebView                     *view);
 void                       ephy_web_view_set_title               (EphyWebView                     *view,
                                                                   const char                      *view_title);
diff --git a/src/window-commands.c b/src/window-commands.c
index b93c046..8473399 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -102,12 +102,14 @@ window_cmd_file_print (GtkAction *action,
 		       EphyWindow *window)
 {
 	EphyEmbed *embed;
+	EphyWebView *view;
 
 	embed = ephy_embed_container_get_active_child 
           (EPHY_EMBED_CONTAINER (window));
 	g_return_if_fail (EPHY_IS_EMBED (embed));
+	view = ephy_embed_get_web_view (embed);
 
-	webkit_web_view_execute_script (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed), "print();");
+	ephy_web_view_print (view);
 }
 
 void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]