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 | |
parent | 4d62a3fca6eaab2d1f8c0af29f230012f99a4dd1 (diff) | |
download | gsoc2013-epiphany-9dd27664308a8dcd007d3ff17b55b7f5c93cdf62.tar gsoc2013-epiphany-9dd27664308a8dcd007d3ff17b55b7f5c93cdf62.tar.gz gsoc2013-epiphany-9dd27664308a8dcd007d3ff17b55b7f5c93cdf62.tar.bz2 gsoc2013-epiphany-9dd27664308a8dcd007d3ff17b55b7f5c93cdf62.tar.lz gsoc2013-epiphany-9dd27664308a8dcd007d3ff17b55b7f5c93cdf62.tar.xz 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')
-rw-r--r-- | embed/ephy-embed-container.c | 4 | ||||
-rw-r--r-- | embed/ephy-web-view.c | 73 | ||||
-rw-r--r-- | embed/ephy-web-view.h | 16 |
3 files changed, 41 insertions, 52 deletions
diff --git a/embed/ephy-embed-container.c b/embed/ephy-embed-container.c index 50d1c143c..75ca72e78 100644 --- a/embed/ephy-embed-container.c +++ b/embed/ephy-embed-container.c @@ -47,10 +47,6 @@ ephy_embed_container_base_init (gpointer g_class) g_param_spec_object ("active-child", NULL, NULL, GTK_TYPE_WIDGET /* Can't use an interface type here */, G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); - g_object_interface_install_property (g_class, - g_param_spec_boolean ("is-print-preview", NULL, NULL, - FALSE, - G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); } } 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; } /** diff --git a/embed/ephy-web-view.h b/embed/ephy-web-view.h index 37852bccd..57dde0bff 100644 --- a/embed/ephy-web-view.h +++ b/embed/ephy-web-view.h @@ -83,15 +83,6 @@ typedef enum typedef enum { - EPHY_WEB_VIEW_PRINTPREVIEW_GOTO_PAGENUM = 0, - EPHY_WEB_VIEW_PRINTPREVIEW_PREV_PAGE = 1, - EPHY_WEB_VIEW_PRINTPREVIEW_NEXT_PAGE = 2, - EPHY_WEB_VIEW_PRINTPREVIEW_HOME = 3, - EPHY_WEB_VIEW_PRINTPREVIEW_END = 4 -} EphyWebViewPrintPreviewNavType; - -typedef enum -{ EPHY_WEB_VIEW_STATE_IS_UNKNOWN, EPHY_WEB_VIEW_STATE_IS_INSECURE, EPHY_WEB_VIEW_STATE_IS_BROKEN, @@ -191,12 +182,7 @@ void ephy_web_view_get_security_level (EphyWebView EphyWebViewSecurityLevel *level, char **description); void ephy_web_view_show_page_certificate (EphyWebView *view); -void ephy_web_view_set_print_preview_mode (EphyWebView *view, - gboolean preview_mode); -int ephy_web_view_print_preview_n_pages (EphyWebView *view); -void ephy_web_view_print_preview_navigate (EphyWebView *view, - EphyWebViewPrintPreviewNavType type, - int page); +void ephy_web_view_show_print_preview (EphyWebView *view); GSList * ephy_web_view_get_go_up_list (EphyWebView *view); void ephy_web_view_set_title (EphyWebView *view, const char *view_title); |