aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog22
-rw-r--r--embed/ephy-embed.c18
-rw-r--r--embed/ephy-embed.h12
-rw-r--r--embed/mozilla/EphyBrowser.cpp56
-rw-r--r--embed/mozilla/EphyBrowser.h5
-rw-r--r--embed/mozilla/PrintingPromptService.cpp2
-rw-r--r--embed/mozilla/mozilla-embed.cpp32
-rwxr-xr-xembed/print-dialog.c31
-rw-r--r--embed/print-dialog.h3
-rw-r--r--src/ephy-window.c64
-rwxr-xr-xsrc/ppview-toolbar.c2
-rw-r--r--src/window-commands.c16
12 files changed, 83 insertions, 180 deletions
diff --git a/ChangeLog b/ChangeLog
index 0770d47dd..626420dc6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2004-06-25 Marco Pesenti Gritti <marco@gnome.org>
+
+ * embed/ephy-embed.c: (ephy_embed_print),
+ (ephy_embed_set_print_preview_mode):
+ * embed/ephy-embed.h:
+ * embed/mozilla/EphyBrowser.cpp:
+ * embed/mozilla/EphyBrowser.h:
+ * embed/mozilla/PrintingPromptService.cpp:
+ * embed/mozilla/mozilla-embed.cpp:
+ * embed/print-dialog.c: (ephy_print_dialog_response_cb),
+ (ephy_print_dialog_new):
+ * embed/print-dialog.h:
+ * src/ephy-window.c: (ephy_window_delete_event_cb),
+ (ephy_window_finalize), (update_embed_dialogs), (ephy_window_find):
+ * src/ppview-toolbar.c: (toolbar_cmd_ppv_close):
+ * src/window-commands.c: (window_cmd_file_print_preview),
+ (window_cmd_file_print):
+
+ Simplify print code. Now there is only one case to deal with,
+ the mozilla prompt dialog.
+ This should help with xprint.
+
2004-06-24 Marco Pesenti Gritti <marco@gnome.org>
* lib/ephy-node.c: (ephy_node_new_with_id), (ephy_node_get_id),
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index 9893c1ac0..76e8ea0c8 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -736,32 +736,30 @@ ephy_embed_has_automatic_encoding (EphyEmbed *embed)
/**
* ephy_embed_print:
* @embed: an #EphyEmbed
- * @info: an #EmbedPrintInfo with all printing settings
*
* Sends a document to the printer.
*
- * Normally one would use ephy_window_print() to display the print dialog, which
- * will build its own #EmbedPrintInfo and then call this function.
**/
void
-ephy_embed_print (EphyEmbed *embed,
- EmbedPrintInfo *info)
+ephy_embed_print (EphyEmbed *embed)
{
EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed);
- iface->print (embed, info);
+ iface->print (embed);
}
/**
- * ephy_embed_print_preview_close:
+ * ephy_embed_set_print_preview_mode:
* @embed: an #EphyEmbed
+ * @preview_mode: Whether the print preview mode is enabled.
*
- * Closes @embed's print preview dialog.
+ * Enable and disable the print preview mode.
**/
void
-ephy_embed_print_preview_close (EphyEmbed *embed)
+ephy_embed_set_print_preview_mode (EphyEmbed *embed,
+ gboolean preview_mode)
{
EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed);
- iface->print_preview_close (embed);
+ iface->set_print_preview_mode (embed, preview_mode);
}
/**
diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h
index 5820b7b43..831b16285 100644
--- a/embed/ephy-embed.h
+++ b/embed/ephy-embed.h
@@ -214,9 +214,9 @@ struct _EphyEmbedIface
gboolean (* has_automatic_encoding) (EphyEmbed *embed);
void (* set_encoding) (EphyEmbed *embed,
const char *encoding);
- void (* print) (EphyEmbed *embed,
- EmbedPrintInfo *info);
- void (* print_preview_close) (EphyEmbed *embed);
+ void (* print) (EphyEmbed *embed);
+ void (* set_print_preview_mode) (EphyEmbed *embed,
+ gboolean mode);
int (* print_preview_n_pages) (EphyEmbed *embed);
void (* print_preview_navigate) (EphyEmbed *embed,
EmbedPrintPreviewNavType type,
@@ -303,10 +303,10 @@ void ephy_embed_set_encoding (EphyEmbed *embed,
const char *encoding);
/* Print */
-void ephy_embed_print (EphyEmbed *embed,
- EmbedPrintInfo *info);
+void ephy_embed_print (EphyEmbed *embed);
-void ephy_embed_print_preview_close (EphyEmbed *embed);
+void ephy_embed_set_print_preview_mode (EphyEmbed *embed,
+ gboolean preview_mode);
int ephy_embed_print_preview_n_pages (EphyEmbed *embed);
diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp
index 8481cee56..b9db2c2a0 100644
--- a/embed/mozilla/EphyBrowser.cpp
+++ b/embed/mozilla/EphyBrowser.cpp
@@ -24,9 +24,11 @@
#include "EphyBrowser.h"
#include "EphyUtils.h"
+#include "MozillaPrivate.h"
#include "ephy-embed.h"
#include "ephy-string.h"
#include "ephy-debug.h"
+#include "print-dialog.h"
#include <gtkmozembed_internal.h>
#include <unistd.h>
@@ -311,43 +313,49 @@ EphyBrowser::DetachListeners(void)
return NS_OK;
}
-nsresult EphyBrowser::Print (nsIPrintSettings *options, PRBool preview)
+nsresult EphyBrowser::Print ()
{
- nsresult result;
-
NS_ENSURE_TRUE (mWebBrowser, NS_ERROR_FAILURE);
nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(mWebBrowser));
NS_ENSURE_TRUE (print, NS_ERROR_FAILURE);
- if (!preview)
- {
- result = print->Print (options, nsnull);
- }
- else
- {
- result = print->PrintPreview(options, nsnull, nsnull);
- }
-
- return result;
+ return print->Print (nsnull, nsnull);
}
-nsresult EphyBrowser::PrintPreviewClose (void)
+nsresult EphyBrowser::SetPrintPreviewMode (PRBool previewMode)
{
nsresult rv;
- PRBool isPreview = PR_FALSE;
NS_ENSURE_TRUE (mWebBrowser, NS_ERROR_FAILURE);
nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(mWebBrowser));
NS_ENSURE_TRUE (print, NS_ERROR_FAILURE);
- rv = print->GetDoingPrintPreview(&isPreview);
- NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+ if (previewMode)
+ {
+ EmbedPrintInfo *info;
- if (isPreview == PR_TRUE)
+ nsCOMPtr<nsIPrintSettings> settings;
+ print->GetGlobalPrintSettings (getter_AddRefs(settings));
+
+ info = ephy_print_get_print_info ();
+ MozillaCollatePrintSettings (info, settings);
+ ephy_print_info_free (info);
+
+ rv = print->PrintPreview (nsnull, mDOMWindow, nsnull);
+ }
+ else
{
- rv = print->ExitPrintPreview();
+ PRBool isPreview = PR_FALSE;
+
+ rv = print->GetDoingPrintPreview(&isPreview);
+ NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+
+ if (isPreview == PR_TRUE)
+ {
+ rv = print->ExitPrintPreview();
+ }
}
return rv;
@@ -373,16 +381,6 @@ nsresult EphyBrowser::PrintPreviewNavigate(PRInt16 navType, PRInt32 pageNum)
return print->PrintPreviewNavigate(navType, pageNum);
}
-nsresult EphyBrowser::GetPrintSettings (nsIPrintSettings **options)
-{
- NS_ENSURE_TRUE (mWebBrowser, NS_ERROR_FAILURE);
-
- nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(mWebBrowser));
- NS_ENSURE_TRUE (print, NS_ERROR_FAILURE);
-
- return print->GetGlobalPrintSettings(options);
-}
-
nsresult EphyBrowser::GetSHistory (nsISHistory **aSHistory)
{
nsresult result;
diff --git a/embed/mozilla/EphyBrowser.h b/embed/mozilla/EphyBrowser.h
index 72d69a8a7..d5bacb97d 100644
--- a/embed/mozilla/EphyBrowser.h
+++ b/embed/mozilla/EphyBrowser.h
@@ -87,9 +87,8 @@ public:
nsresult SetZoom (float aTextZoom);
nsresult GetZoom (float *aTextZoom);
- nsresult Print (nsIPrintSettings *options, PRBool preview);
- nsresult GetPrintSettings (nsIPrintSettings * *options);
- nsresult PrintPreviewClose (void);
+ nsresult Print ();
+ nsresult SetPrintPreviewMode (PRBool previewMode);
nsresult PrintPreviewNumPages (int *numPages);
nsresult PrintPreviewNavigate(PRInt16 navType, PRInt32 pageNum);
diff --git a/embed/mozilla/PrintingPromptService.cpp b/embed/mozilla/PrintingPromptService.cpp
index 16dc3c2e9..e69f35ed8 100644
--- a/embed/mozilla/PrintingPromptService.cpp
+++ b/embed/mozilla/PrintingPromptService.cpp
@@ -71,7 +71,7 @@ NS_IMETHODIMP GPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIW
GtkWidget *gtkParent = MozillaFindGtkParent(parent);
NS_ENSURE_TRUE (gtkParent, NS_ERROR_FAILURE);
- dialog = ephy_print_dialog_new (gtkParent, embed, TRUE);
+ dialog = ephy_print_dialog_new (gtkParent, embed);
ephy_dialog_set_modal (dialog, TRUE);
int ret = ephy_dialog_run (dialog);
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index 5d7e30bc8..cdbd4ea8c 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -683,39 +683,19 @@ impl_get_security_level (EphyEmbed *embed,
}
static void
-impl_print (EphyEmbed *embed,
- EmbedPrintInfo *info)
+impl_print (EphyEmbed *embed)
{
MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv;
- nsresult result;
-
- nsCOMPtr<nsIPrintSettings> options;
- result = mpriv->browser->GetPrintSettings(getter_AddRefs(options));
- if (NS_FAILED (result) || !options) return;
-
- /* work around mozilla bug which borks when printing selection without having one */
- if (info->pages == 2 && ephy_command_manager_can_do_command
- (EPHY_COMMAND_MANAGER (embed), "cmd_copy") == FALSE)
- {
- info->pages = 0;
- }
-
- MozillaCollatePrintSettings(info, options);
-
- options->SetPrintSilent (PR_TRUE);
-
- result = mpriv->browser->Print(options, info->preview);
-
- /* Workaround for bug 125984 */
- options->SetPrintSilent (PR_FALSE);
+
+ mpriv->browser->Print ();
}
static void
-impl_print_preview_close (EphyEmbed *embed)
+impl_set_print_preview_mode (EphyEmbed *embed, gboolean preview_mode)
{
MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv;
- mpriv->browser->PrintPreviewClose();
+ mpriv->browser->SetPrintPreviewMode (preview_mode);
}
static int
@@ -1203,7 +1183,7 @@ ephy_embed_iface_init (EphyEmbedIface *iface)
iface->get_encoding = impl_get_encoding;
iface->has_automatic_encoding = impl_has_automatic_encoding;
iface->print = impl_print;
- iface->print_preview_close = impl_print_preview_close;
+ iface->set_print_preview_mode = impl_set_print_preview_mode;
iface->print_preview_n_pages = impl_print_preview_n_pages;
iface->print_preview_navigate = impl_print_preview_navigate;
iface->has_modified_forms = impl_has_modified_forms;
diff --git a/embed/print-dialog.c b/embed/print-dialog.c
index 6e4b46e2c..93cecdbc7 100755
--- a/embed/print-dialog.c
+++ b/embed/print-dialog.c
@@ -218,39 +218,14 @@ ephy_print_dialog_response_cb (GtkWidget *widget,
int response,
EphyDialog *dialog)
{
- EphyEmbed *embed;
- EmbedPrintInfo *info;
- gboolean only_collect_info;
-
- only_collect_info = GPOINTER_TO_INT
- (g_object_get_data (G_OBJECT (dialog), "only-collect-info"));
-
- if (only_collect_info)
- {
- return;
- }
-
switch (response)
{
- case GTK_RESPONSE_OK:
- info = ephy_print_get_print_info ();
-
- embed = ephy_embed_dialog_get_embed (EPHY_EMBED_DIALOG (dialog));
- g_return_if_fail (EPHY_IS_EMBED (embed));
-
- ephy_embed_print (embed, info);
-
- ephy_print_info_free (info);
-
- break;
case GTK_RESPONSE_HELP:
ephy_gui_help (GTK_WINDOW (widget), "epiphany", "to-print-page");
return;
default:
break;
}
-
- g_object_unref (dialog);
}
static void
@@ -326,8 +301,7 @@ ephy_print_setup_dialog_help_button_cb (GtkWidget *widget,
EphyDialog *
ephy_print_dialog_new (GtkWidget *parent,
- EphyEmbed *embed,
- gboolean only_collect_info)
+ EphyEmbed *embed)
{
EphyDialog *dialog;
GtkWidget *window, *button;
@@ -359,9 +333,6 @@ ephy_print_dialog_new (GtkWidget *parent,
button = ephy_dialog_get_control (dialog, print_props[BROWSE_PROP].id);
gtk_widget_set_sensitive (button, eel_gconf_key_is_writable (CONF_PRINT_FILE));
- g_object_set_data (G_OBJECT (dialog), "only-collect-info",
- GINT_TO_POINTER (only_collect_info));
-
return dialog;
}
diff --git a/embed/print-dialog.h b/embed/print-dialog.h
index f7801d8f5..000a76154 100644
--- a/embed/print-dialog.h
+++ b/embed/print-dialog.h
@@ -32,8 +32,7 @@
G_BEGIN_DECLS
EphyDialog *ephy_print_dialog_new (GtkWidget *parent,
- EphyEmbed *embed,
- gboolean only_collect_info);
+ EphyEmbed *embed);
EphyDialog *ephy_print_setup_dialog_new (void);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 098624988..0482af01a 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -334,7 +334,6 @@ struct EphyWindowPrivate
GtkNotebook *notebook;
EphyTab *active_tab;
EphyDialog *find_dialog;
- EphyDialog *print_dialog;
gboolean closing;
gboolean has_size;
guint num_tabs;
@@ -688,7 +687,7 @@ ephy_window_delete_event_cb (GtkWidget *widget, GdkEvent *event, EphyWindow *win
EphyEmbed *embed;
embed = ephy_window_get_active_embed (window);
- ephy_embed_print_preview_close (embed);
+ ephy_embed_set_print_preview_mode (embed, FALSE);
ephy_window_set_print_preview (window, FALSE);
}
@@ -2084,11 +2083,6 @@ ephy_window_finalize (GObject *object)
g_object_unref (G_OBJECT (window->priv->find_dialog));
}
- if (window->priv->print_dialog)
- {
- g_object_unref (G_OBJECT (window->priv->print_dialog));
- }
-
g_object_unref (window->priv->fav_menu);
g_object_unref (window->priv->enc_menu);
g_object_unref (window->priv->tabs_menu);
@@ -2467,7 +2461,6 @@ update_embed_dialogs (EphyWindow *window,
{
EphyEmbed *embed;
EphyDialog *find_dialog = window->priv->find_dialog;
- EphyDialog *print_dialog = window->priv->print_dialog;
embed = ephy_tab_get_embed (tab);
@@ -2477,13 +2470,6 @@ update_embed_dialogs (EphyWindow *window,
(EPHY_EMBED_DIALOG(find_dialog),
embed);
}
-
- if (print_dialog)
- {
- ephy_embed_dialog_set_embed
- (EPHY_EMBED_DIALOG(print_dialog),
- embed);
- }
}
static void
@@ -2538,54 +2524,6 @@ ephy_window_find (EphyWindow *window)
}
/**
- * ephy_window_print:
- * @window: an #EphyWindow
- *
- * Displays @window's Print dialog.
- **/
-void
-ephy_window_print (EphyWindow *window)
-{
- if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_PRINTING))
- {
- return;
- }
-
- if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_PRINT_SETUP) ||
- eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_COMMAND_LINE))
- {
- EphyEmbed *embed;
- EmbedPrintInfo *info;
-
- info = ephy_print_get_print_info ();
-
- embed = ephy_window_get_active_embed (window);
- g_return_if_fail (EPHY_IS_EMBED (embed));
-
- ephy_embed_print (embed, info);
-
- ephy_print_info_free (info);
-
- return;
- }
-
- if (window->priv->print_dialog == NULL)
- {
- EphyDialog *dialog;
- EphyEmbed *embed;
-
- embed = ephy_window_get_active_embed (window);
- dialog = ephy_print_dialog_new (GTK_WIDGET (window), embed, FALSE);
-
- window->priv->print_dialog = dialog;
- g_object_add_weak_pointer(G_OBJECT (dialog),
- (gpointer *) &window->priv->print_dialog);
- }
-
- ephy_dialog_show (window->priv->print_dialog);
-}
-
-/**
* ephy_window_set_zoom:
* @window: an #EphyWindow
* @zoom: the desired zoom level
diff --git a/src/ppview-toolbar.c b/src/ppview-toolbar.c
index 70603ea67..9c3b70c64 100755
--- a/src/ppview-toolbar.c
+++ b/src/ppview-toolbar.c
@@ -392,6 +392,6 @@ toolbar_cmd_ppv_close (GtkUIManager *merge,
ephy_window_set_print_preview (window, FALSE);
- ephy_embed_print_preview_close (embed);
+ ephy_embed_set_print_preview_mode (embed, FALSE);
}
diff --git a/src/window-commands.c b/src/window-commands.c
index 4a6528cda..4139b6932 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -88,18 +88,11 @@ window_cmd_file_print_preview (GtkAction *action,
EphyWindow *window)
{
EphyEmbed *embed;
- EmbedPrintInfo *info;
embed = ephy_window_get_active_embed (window);
g_return_if_fail (EPHY_IS_EMBED (embed));
- info = ephy_print_get_print_info ();
- info->preview = TRUE;
-
- ephy_embed_print (embed, info);
-
- ephy_print_info_free (info);
-
+ ephy_embed_set_print_preview_mode (embed, TRUE);
ephy_window_set_print_preview (window, TRUE);
}
@@ -107,7 +100,12 @@ void
window_cmd_file_print (GtkAction *action,
EphyWindow *window)
{
- ephy_window_print (window);
+ EphyEmbed *embed;
+
+ embed = ephy_window_get_active_embed (window);
+ g_return_if_fail (EPHY_IS_EMBED (embed));
+
+ ephy_embed_print (embed);
}
void