diff options
author | Jose Millan Soto <jmillan@igalia.com> | 2010-02-09 01:58:53 +0800 |
---|---|---|
committer | Xan Lopez <xan@gnome.org> | 2010-02-09 04:37:35 +0800 |
commit | 9dd27664308a8dcd007d3ff17b55b7f5c93cdf62 (patch) | |
tree | 8a0cffada5ed97bfadbc18d6809d0d41180dd7b0 /embed/ephy-web-view.c | |
parent | 4d62a3fca6eaab2d1f8c0af29f230012f99a4dd1 (diff) | |
download | gsoc2013-epiphany-9dd27664308a8dcd007d3ff17b55b7f5c93cdf62.tar.gz gsoc2013-epiphany-9dd27664308a8dcd007d3ff17b55b7f5c93cdf62.tar.zst gsoc2013-epiphany-9dd27664308a8dcd007d3ff17b55b7f5c93cdf62.zip |
Implemented print preview
Created function ephy_web_view_show_print_preview, which replaces the
old implementation of print preview, which was not working now.
Preview is displayed in an external viewer, so print preview mode does
no longer exist.
All functions of the old implementation of print preview have been
removed, PPViewToolbar was removed also. Also, as EphyWebView has no
more a print preview mode, all functions which checked if a view was
in print preview mode were modified.
Bug #609021
Diffstat (limited to 'embed/ephy-web-view.c')
-rw-r--r-- | embed/ephy-web-view.c | 73 |
1 files changed, 40 insertions, 33 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c index 44143b97e..ed745aecc 100644 --- a/embed/ephy-web-view.c +++ b/embed/ephy-web-view.c @@ -3011,46 +3011,53 @@ ephy_web_view_show_page_certificate (EphyWebView *view) } /** - * ephy_web_view_set_print_preview_mode: + * ephy_web_view_show_print_preview * @view: an #EphyWebView - * @preview_mode: Whether the print preview mode is enabled. * - * Enable and disable the print preview mode. + * Generates a print preview of the specified view. + * An external viewer is used to display the preview. + * + * Since: 2.30 **/ void -ephy_web_view_set_print_preview_mode (EphyWebView *view, - gboolean preview_mode) +ephy_web_view_show_print_preview (EphyWebView *view) { -} + WebKitWebFrame *main_frame; + GtkPrintOperation *operation; + GError *error; + EphyEmbedShell *shell; -/** - * ephy_web_view_print_preview_n_pages: - * @view: an #EphyWebView - * - * Returns the number of pages which would appear in @view's loaded document - * if it were to be printed. - * - * Return value: the number of pages in @view's loaded document - **/ -int -ephy_web_view_print_preview_n_pages (EphyWebView *view) -{ - return 0; -} + shell = ephy_embed_shell_get_default (); + error = NULL; + main_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view)); -/** - * ephy_web_view_print_preview_navigate: - * @view: an #EphyWebView - * @type: an #EphyPrintPreviewNavType which determines where to navigate - * @page: if @type is %EPHY_WEB_VIEW_PRINTPREVIEW_GOTO_PAGENUM, the desired page number - * - * Navigates @view's print preview. - **/ -void -ephy_web_view_print_preview_navigate (EphyWebView *view, - EphyWebViewPrintPreviewNavType type, - int page) -{ + 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); + g_object_unref (operation); + + if (error) { + GtkWidget *info_bar; + GtkWidget *label; + GtkContainer *content_area; + EphyEmbed *embed = EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (view); + + info_bar = gtk_info_bar_new_with_buttons (GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); + label = gtk_label_new (error->message); + content_area = GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar))); + g_error_free (error); + + gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_ERROR); + gtk_container_add (content_area, label); + g_signal_connect (info_bar, "response", + G_CALLBACK (gtk_widget_destroy), NULL); + + ephy_embed_add_top_widget (embed, info_bar, FALSE); + gtk_widget_show_all (info_bar); + } + + return; } /** |