[epiphany] Implemented print preview
- From: Xan Lopez <xan src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [epiphany] Implemented print preview
- Date: Mon, 8 Feb 2010 20:47:11 +0000 (UTC)
commit 9dd27664308a8dcd007d3ff17b55b7f5c93cdf62
Author: Jose Millan Soto <jmillan igalia com>
Date: Mon Feb 8 18:58:53 2010 +0100
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
embed/ephy-embed-container.c | 4 -
embed/ephy-web-view.c | 73 +++++----
embed/ephy-web-view.h | 16 +--
po/POTFILES.in | 1 -
src/Makefile.am | 2 -
src/ephy-find-toolbar.c | 4 -
src/ephy-window.c | 117 +-------------
src/ephy-window.h | 4 -
src/ppview-toolbar.c | 375 ------------------------------------------
src/ppview-toolbar.h | 60 -------
src/window-commands.c | 9 +-
11 files changed, 49 insertions(+), 616 deletions(-)
---
diff --git a/embed/ephy-embed-container.c b/embed/ephy-embed-container.c
index 50d1c14..75ca72e 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 44143b9..ed745ae 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 37852bc..57dde0b 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);
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 95eaadc..a4a50ab 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -71,6 +71,5 @@ src/ephy-toolbars-model.c
src/ephy-window.c
src/pdm-dialog.c
src/popup-commands.c
-src/ppview-toolbar.c
src/prefs-dialog.c
src/window-commands.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 0a984d7..712b7f5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -36,7 +36,6 @@ NOINST_H_FILES = \
pdm-dialog.h \
popup-commands.h \
prefs-dialog.h \
- ppview-toolbar.h \
window-commands.h
INST_H_FILES = \
@@ -86,7 +85,6 @@ libephymain_la_SOURCES = \
pdm-dialog.c \
popup-commands.c \
prefs-dialog.c \
- ppview-toolbar.c \
window-commands.c \
$(INST_H_FILES) \
$(NOINST_H_FILES) \
diff --git a/src/ephy-find-toolbar.c b/src/ephy-find-toolbar.c
index 196957d..0241b15 100644
--- a/src/ephy-find-toolbar.c
+++ b/src/ephy-find-toolbar.c
@@ -187,14 +187,10 @@ tab_search_key_press_cb (EphyEmbed *embed,
GdkEventKey *event,
EphyFindToolbar *toolbar)
{
- EphyFindToolbarPrivate *priv = toolbar->priv;
GtkWidget *widget = (GtkWidget *) toolbar;
g_return_val_if_fail (event != NULL, FALSE);
- /* don't do anything in PPV mode */
- if (ephy_window_get_is_print_preview (priv->window)) return FALSE;
-
/* check for / and ' which open the find toolbar in text resp. link mode */
if (gtk_widget_get_visible (widget) == FALSE)
{
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 714d5ce..594f79a 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -25,7 +25,6 @@
#include "ephy-type-builtins.h"
#include "ephy-embed-type-builtins.h"
#include "ephy-state.h"
-#include "ppview-toolbar.h"
#include "window-commands.h"
#include "ephy-embed-container.h"
#include "ephy-embed-shell.h"
@@ -441,7 +440,6 @@ struct _EphyWindowPrivate
GtkActionGroup *popups_action_group;
EphyEncodingMenu *enc_menu;
EphyTabsMenu *tabs_menu;
- PPViewToolbar *ppview_toolbar;
GtkNotebook *notebook;
EphyEmbed *active_embed;
EphyFindToolbar *find_toolbar;
@@ -465,7 +463,6 @@ struct _EphyWindowPrivate
guint closing : 1;
guint has_size : 1;
guint fullscreen_mode : 1;
- guint ppv_mode : 1;
guint should_save_chrome : 1;
guint is_popup : 1;
guint present_on_insert : 1;
@@ -477,7 +474,6 @@ enum
PROP_0,
PROP_ACTIVE_CHILD,
PROP_CHROME,
- PROP_PPV_MODE,
PROP_SINGLE_TAB_MODE
};
@@ -747,8 +743,7 @@ exit_fullscreen_clicked_cb (EphyWindow *window)
static gboolean
get_toolbar_visibility (EphyWindow *window)
{
- return ((window->priv->chrome & EPHY_WEB_VIEW_CHROME_TOOLBAR) != 0) &&
- !window->priv->ppv_mode;
+ return ((window->priv->chrome & EPHY_WEB_VIEW_CHROME_TOOLBAR) != 0);
}
static void
@@ -761,14 +756,7 @@ get_chromes_visibility (EphyWindow *window,
EphyWindowPrivate *priv = window->priv;
EphyWebViewChrome flags = priv->chrome;
- if (window->priv->ppv_mode)
- {
- *show_menubar = *show_statusbar
- = *show_toolbar
- = *show_tabsbar
- = FALSE;
- }
- else if (window->priv->fullscreen_mode)
+ if (window->priv->fullscreen_mode)
{
*show_toolbar = (flags & EPHY_WEB_VIEW_CHROME_TOOLBAR) != 0;
*show_menubar = *show_statusbar = FALSE;
@@ -988,8 +976,8 @@ ephy_window_key_press_event (GtkWidget *widget,
}
}
- /* Don't activate menubar in ppv mode, or in lockdown mode */
- if (priv->ppv_mode || eel_gconf_get_boolean (CONF_LOCKDOWN_HIDE_MENUBAR))
+ /* Don't activate menubar in lockdown mode */
+ if (eel_gconf_get_boolean (CONF_LOCKDOWN_HIDE_MENUBAR))
{
return GTK_WIDGET_CLASS (ephy_window_parent_class)->key_press_event (widget, event);
}
@@ -1017,48 +1005,11 @@ ephy_window_key_press_event (GtkWidget *widget,
return GTK_WIDGET_CLASS (ephy_window_parent_class)->key_press_event (widget, event);
}
-void
-_ephy_window_set_print_preview (EphyWindow *window,
- gboolean enabled)
-{
- EphyWindowPrivate *priv = window->priv;
- GtkAccelGroup *accel_group;
-
- accel_group = gtk_ui_manager_get_accel_group (window->priv->manager);
-
- if (priv->ppv_mode == enabled) return;
-
- priv->ppv_mode = enabled;
-
- sync_chromes_visibility (window);
-
- if (enabled)
- {
- g_return_if_fail (priv->ppview_toolbar == NULL);
-
- ephy_find_toolbar_request_close (priv->find_toolbar);
-
- priv->ppview_toolbar = ppview_toolbar_new (window);
- gtk_window_remove_accel_group (GTK_WINDOW (window), accel_group);
- }
- else
- {
- g_return_if_fail (priv->ppview_toolbar != NULL);
-
- g_object_unref (priv->ppview_toolbar);
- priv->ppview_toolbar = NULL;
- gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
- }
-
- g_object_notify (G_OBJECT (window), "is-print-preview");
-}
-
static gboolean
ephy_window_delete_event (GtkWidget *widget,
GdkEventAny *event)
{
EphyWindow *window = EPHY_WINDOW (widget);
- EphyWindowPrivate *priv = window->priv;
EphyEmbed *modified_embed = NULL;
GList *tabs, *l;
gboolean modified = FALSE;
@@ -1067,22 +1018,6 @@ ephy_window_delete_event (GtkWidget *widget,
*/
if (eel_gconf_get_boolean("/apps/epiphany/lockdown/disable_quit")) return TRUE;
- /* Workaround a crash when closing a window while in print preview mode. See
- * mozilla bug #241809. /
- * Go back to normal mode instead of closing, see bug #326136.
- */
- if (priv->ppv_mode)
- {
- EphyEmbed *embed;
-
- embed = window->priv->active_embed;
- ephy_web_view_set_print_preview_mode (ephy_embed_get_web_view (embed), FALSE);
-
- _ephy_window_set_print_preview (window, FALSE);
-
- return TRUE;
- }
-
tabs = impl_get_children (EPHY_EMBED_CONTAINER (window));
for (l = tabs; l != NULL; l = l->next)
{
@@ -2188,12 +2123,6 @@ show_embed_popup (EphyWindow *window,
char *uri;
EphyEmbedEvent *embed_event;
- /* Do not show the menu in print preview mode */
- if (priv->ppv_mode)
- {
- return;
- }
-
#if 0
value = ephy_embed_event_get_property (event, "framed_page");
framed = g_value_get_int (value);
@@ -2924,9 +2853,6 @@ embed_modal_alert_cb (EphyEmbed *embed,
EphyWindowPrivate *priv = window->priv;
const char *address;
- /* if we're in ppv mode, we cannot switch tabs, so inhibit the alert */
- if (priv->ppv_mode) return TRUE;
-
/* switch the window to the tab, and bring the window to the foreground
* (since the alert is modal, the user won't be able to do anything
* with his current window anyway :|)
@@ -3315,12 +3241,6 @@ ephy_window_dispose (GObject *object)
g_object_unref (priv->tabs_menu);
priv->tabs_menu = NULL;
- if (priv->ppview_toolbar)
- {
- g_object_unref (priv->ppview_toolbar);
- priv->ppview_toolbar = NULL;
- }
-
priv->action_group = NULL;
priv->popups_action_group = NULL;
@@ -3345,9 +3265,6 @@ ephy_window_set_property (GObject *object,
switch (prop_id)
{
- case PROP_PPV_MODE:
- /* Read only */
- break;
case PROP_ACTIVE_CHILD:
impl_set_active_child (EPHY_EMBED_CONTAINER (window),
g_value_get_object (value));
@@ -3380,9 +3297,6 @@ ephy_window_get_property (GObject *object,
case PROP_CHROME:
g_value_set_flags (value, window->priv->chrome);
break;
- case PROP_PPV_MODE:
- g_value_set_boolean (value, window->priv->ppv_mode);
- break;
case PROP_SINGLE_TAB_MODE:
g_value_set_boolean (value, window->priv->is_popup);
break;
@@ -3503,10 +3417,6 @@ ephy_window_class_init (EphyWindowClass *klass)
"is-popup");
g_object_class_override_property (object_class,
- PROP_PPV_MODE,
- "is-print-preview");
-
- g_object_class_override_property (object_class,
PROP_CHROME,
"chrome");
@@ -3565,9 +3475,6 @@ ephy_window_open_link (EphyLink *link,
g_return_val_if_fail (address != NULL, NULL);
- /* don't do anything in ppv mode */
- if (window->priv->ppv_mode) return NULL;
-
if (embed == NULL)
{
embed = window->priv->active_embed;
@@ -4184,22 +4091,6 @@ ephy_window_view_popup_windows_cb (GtkAction *action,
}
/**
- * ephy_window_get_is_print_preview:
- * @window: an #EphyWindow
- *
- * Returns whether this window is in print preview mode.
- *
- * Return value: %TRUE if it is in print preview mode
- **/
-gboolean
-ephy_window_get_is_print_preview (EphyWindow *window)
-{
- g_return_val_if_fail (EPHY_IS_WINDOW (window), FALSE);
-
- return window->priv->ppv_mode;
-}
-
-/**
* ephy_window_get_context_event:
* @window: an #EphyWindow
*
diff --git a/src/ephy-window.h b/src/ephy-window.h
index e40c8db..ab0e35b 100644
--- a/src/ephy-window.h
+++ b/src/ephy-window.h
@@ -63,9 +63,6 @@ EphyWindow *ephy_window_new (void);
EphyWindow *ephy_window_new_with_chrome (EphyWebViewChrome chrome,
gboolean is_popup);
-void _ephy_window_set_print_preview (EphyWindow *window,
- gboolean enabled);
-
GObject *ephy_window_get_ui_manager (EphyWindow *window);
GtkWidget *ephy_window_get_toolbar (EphyWindow *window);
@@ -84,7 +81,6 @@ void ephy_window_set_zoom (EphyWindow *window,
void ephy_window_activate_location (EphyWindow *window);
-gboolean ephy_window_get_is_print_preview(EphyWindow *window);
EphyEmbedEvent *ephy_window_get_context_event (EphyWindow *window);
diff --git a/src/window-commands.c b/src/window-commands.c
index bcd1c90..2615d78 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -89,13 +89,12 @@ window_cmd_file_print_preview (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));
-
- ephy_web_view_set_print_preview_mode (ephy_embed_get_web_view (embed), TRUE);
- _ephy_window_set_print_preview (window, TRUE);
+ (EPHY_EMBED_CONTAINER (window));
+ view = ephy_embed_get_web_view (embed);
+ ephy_web_view_show_print_preview (view);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]