aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog35
-rw-r--r--configure.ac3
-rw-r--r--data/default-prefs-common.js14
-rw-r--r--embed/Makefile.am4
-rw-r--r--embed/ephy-embed-shell.c95
-rw-r--r--embed/ephy-embed-shell.h14
-rw-r--r--embed/mozilla/EphyBrowser.cpp48
-rw-r--r--embed/mozilla/EphyBrowser.h1
-rw-r--r--embed/mozilla/EphyUtils.cpp235
-rw-r--r--embed/mozilla/EphyUtils.h11
-rw-r--r--embed/mozilla/GeckoPrintService.cpp500
-rw-r--r--embed/mozilla/GeckoPrintService.h52
-rw-r--r--embed/mozilla/GeckoPrintSession.cpp622
-rw-r--r--embed/mozilla/GeckoPrintSession.h93
-rw-r--r--embed/mozilla/Makefile.am6
-rw-r--r--embed/mozilla/MozRegisterComponents.cpp111
-rw-r--r--embed/mozilla/PrintingPromptService.cpp246
-rw-r--r--embed/mozilla/PrintingPromptService.h58
-rwxr-xr-xembed/print-dialog.c451
-rw-r--r--embed/print-dialog.h88
-rw-r--r--src/ephy-shell.c39
-rw-r--r--src/ephy-shell.h2
-rw-r--r--src/epiphany.defs6
-rw-r--r--src/window-commands.c23
24 files changed, 1603 insertions, 1154 deletions
diff --git a/ChangeLog b/ChangeLog
index 8736dc4f2..ad2be2194 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,40 @@
2006-06-18 Christian Persch <chpe@cvs.gnome.org>
+ * configure.ac:
+ * data/default-prefs-common.js:
+ * embed/Makefile.am:
+ * embed/ephy-embed-shell.c: (ephy_embed_shell_dispose),
+ (ephy_embed_shell_set_page_setup),
+ (ephy_embed_shell_get_page_setup),
+ (ephy_embed_shell_set_print_settings),
+ (ephy_embed_shell_get_print_settings):
+ * embed/ephy-embed-shell.h:
+ * embed/mozilla/EphyBrowser.cpp:
+ * embed/mozilla/EphyBrowser.h:
+ * embed/mozilla/EphyUtils.cpp:
+ * embed/mozilla/EphyUtils.h:
+ * embed/mozilla/Makefile.am:
+ A embed/mozilla/GeckoPrintService.cpp:
+ A embed/mozilla/GeckoPrintService.h:
+ A embed/mozilla/GeckoPrintSession.cpp:
+ A embed/mozilla/GeckoPrintSession.h:
+ * embed/mozilla/MozRegisterComponents.cpp:
+ R embed/mozilla/PrintingPromptService.cpp:
+ R embed/mozilla/PrintingPromptService.h:
+ * embed/mozilla/mozilla-embed-single.cpp:
+ R embed/print-dialog.c:
+ R embed/print-dialog.h:
+ * src/ephy-shell.c: (ephy_shell_dispose),
+ (ephy_shell_get_prefs_dialog):
+ * src/ephy-shell.h:
+ * src/epiphany.defs:
+ * src/window-commands.c: (page_setup_done_cb),
+ (window_cmd_file_print_setup):
+
+ Drop libgnomeprint[ui] and use gtk printing.
+
+2006-06-18 Christian Persch <chpe@cvs.gnome.org>
+
* embed/downloader-view.c: (status_icon_popup_menu_cb):
Fix context menu positioning.
diff --git a/configure.ac b/configure.ac
index 3243e9461..b45dc5815 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,7 +75,7 @@ if test "x$enable_maintainer_mode" = "xyes"; then
fi
GLIB_REQUIRED=2.10.1
-GTK_REQUIRED=2.9.2
+GTK_REQUIRED=2.9.3
LIBXML_REQUIRED=2.6.12
LIBXSLT_REQUIRED=1.1.7
LIBGLADE_REQUIRED=2.3.1
@@ -95,7 +95,6 @@ PKG_CHECK_MODULES([DEPENDENCIES], [
libxslt >= $LIBXSLT_REQUIRED
libgnome-2.0 >= $LIBGNOME_REQUIRED
libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED
- libgnomeprint-2.2 libgnomeprintui-2.2
libglade-2.0 >= $LIBGLADE_REQUIRED \
gnome-vfs-2.0 >= $LIBGNOMEVFS_REQUIRED
gnome-vfs-module-2.0
diff --git a/data/default-prefs-common.js b/data/default-prefs-common.js
index 874fd2993..824b3f11b 100644
--- a/data/default-prefs-common.js
+++ b/data/default-prefs-common.js
@@ -102,8 +102,9 @@ pref("browser.xul.error_pages.enabled", true);
// unset weird xulrunner default UA string
pref("general.useragent.extra.simple", "");
-// disable pings
+// we don't want ping(uin)s
pref("browser.send_pings", false);
+pref("browser.send_pings.require_same_host", true);
// disable blink tags
pref("browser.blink_allowed", false);
@@ -111,7 +112,18 @@ pref("browser.blink_allowed", false);
// enable spatial navigation (only works if the extension is built with gecko)
pref("snav.enabled", true);
+// don't leak UI language
+// pref("general.useragent.locale", "en")
+
// spellcheck
// pref("extensions.spellcheck.inline.max-misspellings", -1);
// 0: disabled, 1: only textareas, 2: check textareas and single-line input fields
pref("layout.spellcheckDefault", 1);
+
+// print settings
+pref("print.use_global_printsettings", false);
+pref("print.save_print_settings", false);
+pref("print.show_print_progress", true);
+pref("print.printer_list", "");
+pref("postscript.enabled", true);
+pref("postscript.cups.enabled", false);
diff --git a/embed/Makefile.am b/embed/Makefile.am
index 3be8a73b2..c1a44e282 100644
--- a/embed/Makefile.am
+++ b/embed/Makefile.am
@@ -13,8 +13,7 @@ NOINST_H_FILES = \
ephy-embed-dialog.h \
ephy-embed-find.h \
ephy-encodings.h \
- ephy-favicon-cache.h \
- print-dialog.h
+ ephy-favicon-cache.h
INST_H_FILES = \
ephy-adblock-manager.h \
@@ -53,7 +52,6 @@ libephyembed_la_SOURCES = \
ephy-history.c \
ephy-password-manager.c \
ephy-permission-manager.c \
- print-dialog.c \
$(INST_H_FILES) \
$(NOINST_H_FILES)
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 1ce52db44..45c48fa2e 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -46,6 +46,8 @@ struct _EphyEmbedShellPrivate
EphyEmbedSingle *embed_single;
EphyEncodings *encodings;
EphyAdBlockManager *adblock_manager;
+ GtkPageSetup *page_setup;
+ GtkPrintSettings *print_settings;
guint single_initialised : 1;
};
@@ -123,6 +125,18 @@ ephy_embed_shell_dispose (GObject *object)
priv->encodings = NULL;
}
+ if (priv->page_setup != NULL)
+ {
+ g_object_unref (priv->page_setup);
+ priv->page_setup = NULL;
+ }
+
+ if (priv->print_settings != NULL)
+ {
+ g_object_unref (priv->print_settings);
+ priv->print_settings = NULL;
+ }
+
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@@ -359,3 +373,84 @@ ephy_embed_shell_get_adblock_manager (EphyEmbedShell *shell)
return G_OBJECT (shell->priv->adblock_manager);
}
+void
+ephy_embed_shell_set_page_setup (EphyEmbedShell *shell,
+ GtkPageSetup *page_setup)
+{
+ EphyEmbedShellPrivate *priv;
+
+ g_return_val_if_fail (EPHY_IS_EMBED_SHELL (shell), NULL);
+ priv = shell->priv;
+
+ if (page_setup != NULL)
+ {
+ g_object_ref (page_setup);
+ }
+
+ if (priv->page_setup != NULL)
+ {
+ g_object_unref (priv->page_setup);
+ }
+
+ /* FIXME: save settings to disk! */
+
+ priv->page_setup = page_setup;
+}
+
+GtkPageSetup *
+ephy_embed_shell_get_page_setup (EphyEmbedShell *shell)
+{
+ EphyEmbedShellPrivate *priv;
+
+ g_return_val_if_fail (EPHY_IS_EMBED_SHELL (shell), NULL);
+ priv = shell->priv;
+
+ if (priv->page_setup == NULL)
+ {
+ /* FIXME: load stored settings! */
+ priv->page_setup = gtk_page_setup_new ();
+ }
+
+ return priv->page_setup;
+}
+
+void
+ephy_embed_shell_set_print_settings (EphyEmbedShell *shell,
+ GtkPrintSettings *settings)
+{
+ EphyEmbedShellPrivate *priv;
+
+ g_return_val_if_fail (EPHY_IS_EMBED_SHELL (shell), NULL);
+ priv = shell->priv;
+
+ if (settings != NULL)
+ {
+ g_object_ref (settings);
+ }
+
+ if (priv->print_settings != NULL)
+ {
+ g_object_unref (priv->print_settings);
+ }
+
+ /* FIXME: save settings to disk! */
+
+ priv->print_settings = settings;
+}
+
+GtkPrintSettings *
+ephy_embed_shell_get_print_settings (EphyEmbedShell *shell)
+{
+ EphyEmbedShellPrivate *priv;
+
+ g_return_val_if_fail (EPHY_IS_EMBED_SHELL (shell), NULL);
+ priv = shell->priv;
+
+ if (priv->print_settings == NULL)
+ {
+ /* FIXME: load stored settings! */
+ priv->print_settings = gtk_print_settings_new ();
+ }
+
+ return priv->print_settings;
+}
diff --git a/embed/ephy-embed-shell.h b/embed/ephy-embed-shell.h
index 74a25a22e..4c243f6e3 100644
--- a/embed/ephy-embed-shell.h
+++ b/embed/ephy-embed-shell.h
@@ -21,8 +21,10 @@
#ifndef EPHY_EMBED_SHELL_H
#define EPHY_EMBED_SHELL_H
-#include <glib-object.h>
#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtkpagesetup.h>
+#include <gtk/gtkprintsettings.h>
G_BEGIN_DECLS
@@ -77,6 +79,16 @@ GObject *ephy_embed_shell_get_adblock_manager (EphyEmbedShell *shell);
void ephy_embed_shell_prepare_close (EphyEmbedShell *shell);
+void ephy_embed_shell_set_page_setup (EphyEmbedShell *shell,
+ GtkPageSetup *page_setup);
+
+GtkPageSetup *ephy_embed_shell_get_page_setup (EphyEmbedShell *shell);
+
+void ephy_embed_shell_set_print_settings (EphyEmbedShell *shell,
+ GtkPrintSettings *settings);
+
+GtkPrintSettings *ephy_embed_shell_get_print_settings (EphyEmbedShell *shell);
+
G_END_DECLS
#endif /* !EPHY_EMBED_SHELL_H */
diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp
index afcc2b175..bfd3b9e92 100644
--- a/embed/mozilla/EphyBrowser.cpp
+++ b/embed/mozilla/EphyBrowser.cpp
@@ -67,6 +67,8 @@
#include <nsIHistoryEntry.h>
#include <nsIInterfaceRequestor.h>
#include <nsIInterfaceRequestorUtils.h>
+#include <nsIPrintSettings.h>
+#include <nsIPrintSettingsService.h>
#include <nsIScriptSecurityManager.h>
#include <nsIServiceManager.h>
#include <nsISHEntry.h>
@@ -98,14 +100,16 @@
#include "ephy-debug.h"
#include "ephy-embed.h"
+#include "ephy-embed-shell.h"
#include "ephy-string.h"
#include "ephy-zoom.h"
#include "mozilla-embed-event.h"
#include "mozilla-embed.h"
-#include "print-dialog.h"
+#include "AutoJSContextStack.h"
#include "EphyUtils.h"
#include "EventContext.h"
+#include "GeckoPrintService.h"
#include "EphyBrowser.h"
@@ -673,7 +677,20 @@ nsresult EphyBrowser::Print ()
nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(mWebBrowser));
NS_ENSURE_TRUE (print, NS_ERROR_FAILURE);
- return print->Print (nsnull, nsnull);
+ nsCOMPtr<nsIPrintSettingsService> printSettingsService
+ (do_GetService("@mozilla.org/gfx/printsettings-service;1"));
+ NS_ENSURE_STATE (printSettingsService);
+
+ nsCOMPtr<nsIPrintSettings> settings;
+ printSettingsService->GetNewPrintSettings (getter_AddRefs (settings));
+ NS_ENSURE_STATE (settings);
+
+ nsresult rv;
+ AutoJSContextStack stack;
+ rv = stack.Init ();
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ return print->Print (settings, nsnull);
}
nsresult EphyBrowser::SetPrintPreviewMode (PRBool previewMode)
@@ -682,21 +699,30 @@ nsresult EphyBrowser::SetPrintPreviewMode (PRBool previewMode)
NS_ENSURE_TRUE (mWebBrowser, NS_ERROR_FAILURE);
- nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(mWebBrowser));
- NS_ENSURE_TRUE (print, NS_ERROR_FAILURE);
+ nsCOMPtr<nsIWebBrowserPrint> print (do_GetInterface (mWebBrowser));
+ NS_ENSURE_STATE (print);
if (previewMode)
{
- EmbedPrintInfo *info;
+ nsCOMPtr<nsIPrintSettingsService> printSettingsService
+ (do_GetService("@mozilla.org/gfx/printsettings-service;1"));
+ NS_ENSURE_STATE (printSettingsService);
nsCOMPtr<nsIPrintSettings> settings;
- print->GetGlobalPrintSettings (getter_AddRefs(settings));
+ printSettingsService->GetNewPrintSettings (getter_AddRefs (settings));
+ NS_ENSURE_STATE (settings);
- info = ephy_print_get_print_info ();
- EphyUtils::CollatePrintSettings (info, settings, TRUE);
- ephy_print_info_free (info);
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+ rv = GeckoPrintService::TranslateSettings (ephy_embed_shell_get_print_settings (shell),
+ ephy_embed_shell_get_page_setup (shell),
+ nsCString(),
+ PR_FALSE,
+ settings);
- rv = print->PrintPreview (nsnull, mDOMWindow, nsnull);
+ if (NS_SUCCEEDED (rv))
+ {
+ rv = print->PrintPreview (settings, mDOMWindow, nsnull);
+ }
}
else
{
@@ -705,7 +731,7 @@ nsresult EphyBrowser::SetPrintPreviewMode (PRBool previewMode)
rv = print->GetDoingPrintPreview(&isPreview);
NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
- if (isPreview == PR_TRUE)
+ if (isPreview)
{
rv = print->ExitPrintPreview();
}
diff --git a/embed/mozilla/EphyBrowser.h b/embed/mozilla/EphyBrowser.h
index 6a775bf14..3a60dfd41 100644
--- a/embed/mozilla/EphyBrowser.h
+++ b/embed/mozilla/EphyBrowser.h
@@ -31,7 +31,6 @@
#include <nsIDOMEventListener.h>
#include <nsIDOMEventTarget.h>
#include <nsIDOMWindow.h>
-#include <nsIPrintSettings.h>
#include <nsIRequest.h>
#include <nsISHistory.h>
#include <nsIWebBrowserFocus.h>
diff --git a/embed/mozilla/EphyUtils.cpp b/embed/mozilla/EphyUtils.cpp
index b0ed8df4b..ab6d78e1a 100644
--- a/embed/mozilla/EphyUtils.cpp
+++ b/embed/mozilla/EphyUtils.cpp
@@ -35,11 +35,11 @@
#include <nsServiceManagerUtils.h>
#include <nsStringAPI.h>
#include <nsXPCOM.h>
+#include <nsIXPConnect.h>
#include "ephy-embed-shell.h"
#include "ephy-embed-single.h"
#include "ephy-file-helpers.h"
-#include "print-dialog.h"
#include "EphyUtils.h"
@@ -139,211 +139,38 @@ EphyUtils::FindGtkParent (nsIDOMWindow *aDOMWindow)
return toplevel;
}
-nsresult
-EphyUtils::CollatePrintSettings (EmbedPrintInfo *info,
- nsIPrintSettings *options,
- gboolean preview)
+char *
+EphyUtils::ConvertUTF16toUTF8 (const PRUnichar *aText,
+ PRInt32 aMaxLength)
{
- NS_ENSURE_ARG (options);
-
- /* FIXME: for CUPS printers, print directly instead of to a tmp file? */
- const static PRUnichar pName[] = { 'P', 'o', 's', 't', 'S', 'c', 'r', 'i', 'p', 't', '/', 'd', 'e', 'f', 'a', 'u', 'l', 't', '\0' };
- options->SetPrinterName(nsString(pName).get());
-
- const static int frame_types[] = {
- nsIPrintSettings::kFramesAsIs,
- nsIPrintSettings::kSelectedFrame,
- nsIPrintSettings::kEachFrameSep
- };
-
- switch (info->range)
- {
- case GNOME_PRINT_RANGE_CURRENT:
- case GNOME_PRINT_RANGE_SELECTION_UNSENSITIVE:
- case GNOME_PRINT_RANGE_ALL:
- options->SetPrintRange (nsIPrintSettings::kRangeAllPages);
- break;
- case GNOME_PRINT_RANGE_RANGE:
- options->SetPrintRange (nsIPrintSettings::kRangeSpecifiedPageRange);
- options->SetStartPageRange (info->from_page);
- options->SetEndPageRange (info->to_page);
- break;
- case GNOME_PRINT_RANGE_SELECTION:
- options->SetPrintRange (nsIPrintSettings::kRangeSelection);
- break;
- }
-
- const GnomePrintUnit *unit, *inch, *mm;
- double value;
-
- mm = gnome_print_unit_get_by_abbreviation ((const guchar *) "mm");
- inch = gnome_print_unit_get_by_abbreviation ((const guchar *) "in");
- g_assert (mm != NULL && inch != NULL);
-
- /* top margin */
- if (gnome_print_config_get_length (info->config,
- (const guchar *) GNOME_PRINT_KEY_PAGE_MARGIN_TOP,
- &value, &unit)
- && gnome_print_convert_distance (&value, unit, inch))
- {
- options->SetMarginTop (value);
- }
-
- /* bottom margin */
- if (gnome_print_config_get_length (info->config,
- (const guchar *) GNOME_PRINT_KEY_PAGE_MARGIN_BOTTOM,
- &value, &unit)
- && gnome_print_convert_distance (&value, unit, inch))
- {
- options->SetMarginBottom (value);
- }
-
- /* left margin */
- if (gnome_print_config_get_length (info->config,
- (const guchar *) GNOME_PRINT_KEY_PAGE_MARGIN_LEFT,
- &value, &unit)
- && gnome_print_convert_distance (&value, unit, inch))
- {
- options->SetMarginLeft (value);
- }
-
- /* right margin */
- if (gnome_print_config_get_length (info->config,
- (const guchar *) GNOME_PRINT_KEY_PAGE_MARGIN_RIGHT,
- &value, &unit)
- && gnome_print_convert_distance (&value, unit, inch))
- {
- options->SetMarginRight (value);
- }
-
-
- nsString tmp;
-
- NS_CStringToUTF16 (nsCString(info->header_left_string),
- NS_CSTRING_ENCODING_UTF8, tmp);
- options->SetHeaderStrLeft (tmp.get());
-
- NS_CStringToUTF16 (nsCString(info->header_center_string),
- NS_CSTRING_ENCODING_UTF8, tmp);
- options->SetHeaderStrCenter (tmp.get());
-
- NS_CStringToUTF16 (nsCString(info->header_right_string),
- NS_CSTRING_ENCODING_UTF8, tmp);
- options->SetHeaderStrRight (tmp.get());
-
- NS_CStringToUTF16 (nsCString(info->footer_left_string),
- NS_CSTRING_ENCODING_UTF8, tmp);
- options->SetFooterStrLeft (tmp.get());
-
- NS_CStringToUTF16 (nsCString(info->footer_center_string),
- NS_CSTRING_ENCODING_UTF8, tmp);
- options->SetFooterStrCenter(tmp.get());
-
- NS_CStringToUTF16 (nsCString(info->footer_right_string),
- NS_CSTRING_ENCODING_UTF8, tmp);
- options->SetFooterStrRight(tmp.get());
+ if (aText == nsnull) return NULL;
+
+ /* This depends on the assumption that
+ * typeof(PRUnichar) == typeof (gunichar2) == uint16,
+ * which should be pretty safe.
+ */
+ glong n_read = 0, n_written = 0;
+ char *converted = g_utf16_to_utf8 ((gunichar2*) aText, aMaxLength,
+ &n_read, &n_written, NULL);
+ /* FIXME loop from the end while !g_unichar_isspace (char)? */
+
+ return converted;
+}
- options->SetPrintToFile (PR_FALSE);
-
- if (preview)
- {
- options->SetPrintToFile (PR_FALSE);
- }
- else
- {
- char *base;
- const char *temp_dir;
-
- temp_dir = ephy_file_tmp_dir ();
- base = g_build_filename (temp_dir, "printXXXXXX", (char *) NULL);
- info->tempfile = ephy_file_tmp_filename (base, "ps");
- g_free (base);
-
- if (info->tempfile == NULL) return NS_ERROR_FAILURE;
+/* This isn't completely accurate: if you do window.prompt in one window, then
+ * call this in another window, it still returns TRUE ! Those are the wonders
+ * of recursive mainloops :-(
+ */
+PRBool
+EphyJSUtils::IsCalledFromScript ()
+{
+ nsresult rv;
+ nsCOMPtr<nsIXPConnect> xpc(do_GetService(nsIXPConnect::GetCID(), &rv));
+ NS_ENSURE_SUCCESS (rv, PR_FALSE);
- NS_CStringToUTF16 (nsCString(info->tempfile),
- NS_CSTRING_ENCODING_UTF8, tmp);
- options->SetPrintToFile (PR_TRUE);
- options->SetToFileName (tmp.get());
- }
-
- /* paper size */
- options->SetPaperSize (nsIPrintSettings::kPaperSizeDefined);
- options->SetPaperSizeUnit (nsIPrintSettings::kPaperSizeMillimeters);
-
- if (gnome_print_config_get_length (info->config,
- (const guchar *) GNOME_PRINT_KEY_PAPER_WIDTH,
- &value, &unit)
- && gnome_print_convert_distance (&value, unit, mm))
- {
- options->SetPaperWidth (value);
- }
-
- if (gnome_print_config_get_length (info->config,
- (const guchar *) GNOME_PRINT_KEY_PAPER_HEIGHT,
- &value, &unit)
- && gnome_print_convert_distance (&value, unit, mm))
- {
- options->SetPaperHeight (value);
- }
-
- /* Mozilla bug https://bugzilla.mozilla.org/show_bug.cgi?id=307404
- * means that we cannot actually use any paper sizes except mozilla's
- * builtin list, and we must refer to them *by name*!
- */
-#ifndef HAVE_GECKO_1_9
- /* Gnome-Print names some papers differently than what moz understands */
- static const struct
- {
- const char *gppaper;
- const char *mozpaper;
- }
- paper_table [] =
- {
- { "USLetter", "Letter" },
- { "USLegal", "Legal" }
- };
-#endif /* !HAVE_GECKO_1_9 */
-
- /* paper name */
- char *string = (char *) gnome_print_config_get (info->config,
- (const guchar *) GNOME_PRINT_KEY_PAPER_SIZE);
- const char *paper = string;
-
-#ifndef HAVE_GECKO_1_9
- for (PRUint32 i = 0; i < G_N_ELEMENTS (paper_table); i++)
- {
- if (string != NULL &&
- g_ascii_strcasecmp (paper_table[i].gppaper, string) == 0)
- {
- paper = paper_table[i].mozpaper;
- break;
- }
- }
-#endif /* !HAVE_GECKO_1_9 */
-
- NS_CStringToUTF16 (nsCString(paper),
- NS_CSTRING_ENCODING_UTF8, tmp);
- options->SetPaperName (tmp.get());
- g_free (string);
-
- /* paper orientation */
- string = (char *) gnome_print_config_get (info->config,
- (const guchar *) GNOME_PRINT_KEY_ORIENTATION);
- if (string == NULL) string = g_strdup ("R0");
-
- if (strncmp (string, "R90", 3) == 0 || strncmp (string, "R270", 4) == 0)
- {
- options->SetOrientation (nsIPrintSettings::kLandscapeOrientation);
- }
- else
- {
- options->SetOrientation (nsIPrintSettings::kPortraitOrientation);
- }
- g_free (string);
-
- options->SetPrintInColor (info->print_color);
- options->SetPrintFrameType (frame_types[info->frame_type]);
+ nsCOMPtr<nsIXPCNativeCallContext> ncc;
+ rv = xpc->GetCurrentNativeCallContext (getter_AddRefs (ncc));
+ NS_ENSURE_SUCCESS(rv, PR_FALSE);
- return NS_OK;
+ return nsnull != ncc;
}
diff --git a/embed/mozilla/EphyUtils.h b/embed/mozilla/EphyUtils.h
index cc607a9f9..c19ae088f 100644
--- a/embed/mozilla/EphyUtils.h
+++ b/embed/mozilla/EphyUtils.h
@@ -35,9 +35,7 @@ class nsAString;
class nsIDOMWindow;
class nsIFile;
class nsIIOService;
-class nsIPrintSettings;
class nsIURI;
-struct _EmbedPrintInfo;
namespace EphyUtils
{
@@ -59,10 +57,13 @@ namespace EphyUtils
GtkWidget *FindEmbed (nsIDOMWindow *aDOMWindow);
GtkWidget *FindGtkParent (nsIDOMWindow *aDOMWindow);
+
+ char * ConvertUTF16toUTF8 (const PRUnichar*, PRInt32);
+}
- nsresult CollatePrintSettings (_EmbedPrintInfo *info,
- nsIPrintSettings *settings,
- gboolean preview);
+namespace EphyJSUtils
+{
+ PRBool IsCalledFromScript ();
}
#endif
diff --git a/embed/mozilla/GeckoPrintService.cpp b/embed/mozilla/GeckoPrintService.cpp
new file mode 100644
index 000000000..81a5bcc08
--- /dev/null
+++ b/embed/mozilla/GeckoPrintService.cpp
@@ -0,0 +1,500 @@
+/*
+ * Copyright (C) 2006 Christian Persch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#include "mozilla-config.h"
+#include "config.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtkwindow.h>
+#include <gtk/gtkdialog.h>
+#include <gtk/gtkprintunixdialog.h>
+#include <gtk/gtkmessagedialog.h>
+#include <gtk/gtkstock.h>
+
+#include <nsStringAPI.h>
+
+#include <nsCOMPtr.h>
+#include <nsIDOMWindow.h>
+#include <nsIDOMWindowInternal.h>
+
+#include "eel-gconf-extensions.h"
+#include "ephy-debug.h"
+#include "ephy-embed-shell.h"
+#include "ephy-file-helpers.h"
+#include "ephy-prefs.h"
+
+#include "AutoJSContextStack.h"
+#include "EphyUtils.h"
+#include "GeckoPrintSession.h"
+
+#include "GeckoPrintService.h"
+
+#define LITERAL(s) NS_REINTERPRET_CAST(const nsAString::char_type*, NS_L(s))
+
+/* From nsIDeviceContext.h */
+#define NS_ERROR_GFX_PRINTER_BASE (1) /* adjustable :-) */
+#define NS_ERROR_GFX_PRINTER_ACCESS_DENIED \
+ NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+5)
+
+NS_IMPL_ISUPPORTS1 (GeckoPrintService,
+ nsIPrintingPromptService)
+
+GeckoPrintService::GeckoPrintService()
+{
+ LOG ("GeckoPrintService ctor [%p]", this);
+}
+
+GeckoPrintService::~GeckoPrintService()
+{
+ LOG ("GeckoPrintService dtor [%p]", this);
+}
+
+/* nsIPrintingPromptService implementation */
+
+/* void showPrintDialog (in nsIDOMWindow parent,
+ in nsIWebBrowserPrint webBrowserPrint,
+ in nsIPrintSettings printSettings); */
+NS_IMETHODIMP
+GeckoPrintService::ShowPrintDialog (nsIDOMWindow *aParent,
+ nsIWebBrowserPrint *aWebBrowserPrint,
+ nsIPrintSettings *aSettings)
+{
+ /* Locked down? */
+ if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_PRINTING)) {
+ return NS_ERROR_GFX_PRINTER_ACCESS_DENIED;
+ }
+
+ GeckoPrintSession *session = GeckoPrintSession::FromSettings (aSettings);
+ NS_ENSURE_TRUE (session, NS_ERROR_INVALID_POINTER);
+
+ GtkWidget *parent = EphyUtils::FindGtkParent (aParent);
+ NS_ENSURE_TRUE(parent, NS_ERROR_INVALID_POINTER);
+
+ PRBool isCalledFromScript = EphyJSUtils::IsCalledFromScript ();
+
+ nsresult rv;
+ AutoJSContextStack stack;
+ rv = stack.Init ();
+ if (NS_FAILED (rv)) {
+ return rv;
+ }
+
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+
+ /* Print settings changes disallowed, just translate the settings */
+ if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_PRINT_SETUP)) {
+ /* FIXME: we need to call session->SetSettings first, and for that we need a
+ * way to get the default printer object!
+ */
+ g_warning ("Printing with locked print setup doesn't work!");
+ return NS_ERROR_FAILURE;
+
+ /* If called from a script, give the user a way to cancel the print! */
+ if (isCalledFromScript) {
+ GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
+ GtkDialogFlags (0),
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_CANCEL,
+ "%s", _("Print this page?"));
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), "web-browser");
+ gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_PRINT,
+ GTK_RESPONSE_ACCEPT);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
+
+ int response = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ if (response != GTK_RESPONSE_ACCEPT) {
+ return NS_ERROR_ABORT;
+ }
+ }
+
+ nsCString sourceFile;
+ session->GetSourceFile (sourceFile);
+ if (!sourceFile.IsEmpty ()) {
+ rv = TranslateSettings (ephy_embed_shell_get_print_settings (shell),
+ ephy_embed_shell_get_page_setup (shell),
+ sourceFile, PR_TRUE, aSettings);
+ } else {
+ rv = NS_ERROR_ABORT;
+ }
+
+ return rv;
+ }
+
+ /* Not locked down, show the dialogue */
+
+#if 0
+ PRBool haveSelection = PR_FALSE;
+ rv = aSettings->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &haveSelection);
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ PRInt16 frameUI = 0;
+ rv = aSettings->GetHowToEnableFrameUI (&frameUI);
+ NS_ENSURE_SUCCESS (rv, rv);
+#endif
+
+ /* FIXME: this sucks! find some way to do all of this async! */
+ GtkWidget *dialog = gtk_print_unix_dialog_new (NULL /* FIXME title */,
+ GTK_WINDOW (parent));
+ GtkPrintUnixDialog *print_dialog = GTK_PRINT_UNIX_DIALOG (dialog);
+
+ gtk_print_unix_dialog_set_manual_capabilities
+ (print_dialog,
+ GtkPrintCapabilities (GTK_PRINT_CAPABILITY_PAGE_SET |
+ GTK_PRINT_CAPABILITY_COPIES |
+ GTK_PRINT_CAPABILITY_COLLATE |
+ GTK_PRINT_CAPABILITY_REVERSE |
+ GTK_PRINT_CAPABILITY_SCALE));
+ gtk_print_unix_dialog_set_page_setup (print_dialog,
+ ephy_embed_shell_get_page_setup (shell));
+ gtk_print_unix_dialog_set_settings (print_dialog,
+ ephy_embed_shell_get_print_settings (shell));
+
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), "web-browser");
+
+ int response = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_hide (dialog);
+
+ GtkPrinter *printer = gtk_print_unix_dialog_get_selected_printer (print_dialog);
+
+ if (response != GTK_RESPONSE_OK || !printer) {
+ gtk_widget_destroy (dialog);
+
+ return NS_ERROR_ABORT;
+ }
+
+ GtkPageSetup *pageSetup = gtk_print_unix_dialog_get_page_setup (print_dialog);
+ ephy_embed_shell_set_page_setup (shell, pageSetup);
+
+ GtkPrintSettings *settings = gtk_print_unix_dialog_get_settings (print_dialog);
+ ephy_embed_shell_set_print_settings (shell, settings);
+
+ /* This adopts the refcount of |settings| */
+ rv = session->SetSettings (settings, pageSetup, printer);
+
+ /* Now translate the settings to nsIPrintSettings */
+ if (NS_SUCCEEDED (rv)) {
+ nsCString sourceFile;
+ session->GetSourceFile (sourceFile);
+ if (!sourceFile.IsEmpty ()) {
+ rv = TranslateSettings (settings, pageSetup, sourceFile, PR_TRUE, aSettings);
+ } else {
+ rv = NS_ERROR_ABORT;
+ }
+ }
+
+ gtk_widget_destroy (dialog);
+
+ return rv;
+}
+
+/* void showProgress (in nsIDOMWindow parent,
+ in nsIWebBrowserPrint webBrowserPrint,
+ in nsIPrintSettings printSettings,
+ in nsIObserver openDialogObserver,
+ in boolean isForPrinting,
+ out nsIWebProgressListener webProgressListener,
+ out nsIPrintProgressParams printProgressParams,
+ out boolean notifyOnOpen); */
+NS_IMETHODIMP
+GeckoPrintService::ShowProgress (nsIDOMWindow *aParent,
+ nsIWebBrowserPrint *aWebBrowserPrint,
+ nsIPrintSettings *aPrintSettings,
+ nsIObserver *aOpenDialogObserver,
+ PRBool aIsForPrinting,
+ nsIWebProgressListener **_webProgressListener,
+ nsIPrintProgressParams **_printProgressParams,
+ PRBool *_notifyOnOpen)
+{
+ /* Print preview */
+ if (!aIsForPrinting) {
+ return NS_OK;
+ }
+
+ nsresult rv;
+ nsCOMPtr<nsIDOMWindowInternal> domWin (do_QueryInterface (aParent, &rv));
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ nsCOMPtr<nsIPrintSession> session;
+ rv = aPrintSettings->GetPrintSession (getter_AddRefs (session));
+ NS_ENSURE_TRUE (NS_SUCCEEDED (rv) && session, nsnull);
+
+ nsCOMPtr<nsIPrintProgress> progress (do_QueryInterface (session, &rv));
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ /* Out print session implements those interfaces */
+ rv = CallQueryInterface (session, _webProgressListener);
+ rv |= CallQueryInterface (session, _printProgressParams);
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ /* Setting this to PR_FALSE will make gecko immediately start printing
+ * when we return from this function.
+ * If we set this to PR_TRUE, we need to call aOpenDialogObserver::Observe
+ * (topic, subject and data don't matter) when we're ready for printing.
+ */
+ *_notifyOnOpen = PR_FALSE;
+
+ return progress->OpenProgressDialog (domWin, nsnull, nsnull, aOpenDialogObserver, _notifyOnOpen);
+}
+
+/* void showPageSetup (in nsIDOMWindow parent,
+ in nsIPrintSettings printSettings,
+ in nsIObserver aObs); */
+NS_IMETHODIMP GeckoPrintService::ShowPageSetup (nsIDOMWindow *aParent,
+ nsIPrintSettings *aPrintSettings,
+ nsIObserver *aObserver)
+{
+ /* Locked down? */
+ if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_PRINTING) ||
+ eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_PRINT_SETUP)) {
+ return NS_ERROR_ABORT;
+ }
+
+ GtkWidget *parent = EphyUtils::FindGtkParent (aParent);
+ NS_ENSURE_TRUE(parent, NS_ERROR_INVALID_POINTER);
+
+ AutoJSContextStack stack;
+ nsresult rv = stack.Init ();
+ if (NS_FAILED (rv)) {
+ return rv;
+ }
+
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+ GtkPageSetup *new_setup =
+ gtk_print_run_page_setup_dialog (GTK_WINDOW (parent),
+ ephy_embed_shell_get_page_setup (shell),
+ ephy_embed_shell_get_print_settings (shell));
+ if (new_setup) {
+ ephy_embed_shell_set_page_setup (shell, new_setup);
+ g_object_unref (new_setup);
+ }
+
+ /* FIXME do we need to notify aObserver somehow? */
+ return NS_OK;
+}
+
+/* void showPrinterProperties (in nsIDOMWindow parent,
+ in wstring printerName,
+ in nsIPrintSettings printSettings); */
+NS_IMETHODIMP
+GeckoPrintService::ShowPrinterProperties (nsIDOMWindow *aParent,
+ const PRUnichar *aPrinterName,
+ nsIPrintSettings *aPrintSettings)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* Static methods */
+
+/* static */ nsresult
+GeckoPrintService::TranslateSettings (GtkPrintSettings *aGtkSettings,
+ GtkPageSetup *aPageSetup,
+ const nsACString &aSourceFile,
+ PRBool aIsForPrinting,
+ nsIPrintSettings *aSettings)
+{
+ NS_ENSURE_ARG (aGtkSettings);
+ NS_ENSURE_ARG (aPageSetup);
+
+ /* Locked down? */
+ if (gtk_print_settings_get_print_to_file (aGtkSettings) &&
+ eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_SAVE_TO_DISK)) {
+ return NS_ERROR_GFX_PRINTER_ACCESS_DENIED;
+ }
+
+ /* Initialisation */
+ aSettings->SetIsInitializedFromPrinter (PR_FALSE);
+ aSettings->SetIsInitializedFromPrefs (PR_FALSE);
+ aSettings->SetPrintSilent (PR_FALSE);
+ aSettings->SetShowPrintProgress (PR_TRUE);
+ aSettings->SetNumCopies (1);
+
+ /* We always print PS to a file and then hand that off to gtk-print */
+ aSettings->SetPrinterName (LITERAL ("PostScript/default"));
+
+ if (aIsForPrinting) {
+ aSettings->SetPrintToFile (PR_TRUE);
+
+ nsString sourceFile;
+ NS_CStringToUTF16 (aSourceFile,
+ NS_CSTRING_ENCODING_NATIVE_FILESYSTEM,
+ sourceFile);
+
+ aSettings->SetToFileName (sourceFile.get ());
+ } else {
+ /* Otherwise mozilla will create the file nevertheless and
+ * fail since we haven't set a name!
+ */
+ aSettings->SetPrintToFile (PR_FALSE);
+ }
+
+ /* This is the time between printing each page, in ms.
+ * It 'gives the user more time to press cancel' !
+ * We don't want any of this nonsense, so set this to a low value,
+ * just enough to update the print dialogue.
+ */
+ aSettings->SetPrintPageDelay (50);
+
+ if (aIsForPrinting) {
+ GtkPageSet pageSet = gtk_print_settings_get_page_set (aGtkSettings);
+ aSettings->SetPrintOptions (nsIPrintSettings::kPrintEvenPages,
+ pageSet != GTK_PAGE_SET_ODD);
+ aSettings->SetPrintOptions (nsIPrintSettings::kPrintEvenPages,
+ pageSet != GTK_PAGE_SET_EVEN);
+
+ aSettings->SetPrintReversed (gtk_print_settings_get_reverse (aGtkSettings));
+
+ GtkPrintPages printPages = gtk_print_settings_get_print_pages (aGtkSettings);
+ switch (printPages) {
+ case GTK_PRINT_PAGES_RANGES: {
+ int numRanges = 0;
+ GtkPageRange *pageRanges = gtk_print_settings_get_page_ranges (aGtkSettings, &numRanges);
+ if (numRanges > 0) {
+ /* FIXME: We can only support one range, ignore more ranges or raise error? */
+ aSettings->SetPrintRange (nsIPrintSettings::kRangeSpecifiedPageRange);
+ aSettings->SetStartPageRange (pageRanges[0].start);
+ aSettings->SetEndPageRange (pageRanges[1].end);
+
+ g_free (pageRanges);
+ }
+ break;
+ }
+ case GTK_PRINT_PAGES_CURRENT:
+ /* not supported, fall through */
+ case GTK_PRINT_PAGES_ALL:
+ aSettings->SetPrintRange (nsIPrintSettings::kRangeAllPages);
+ break;
+ /* FIXME: we need some custom ranges here, "Selection" and "Focused Frame" */
+ }
+ } else {
+ aSettings->SetPrintOptions (nsIPrintSettings::kPrintEvenPages, PR_TRUE);
+ aSettings->SetPrintOptions (nsIPrintSettings::kPrintEvenPages, PR_TRUE);
+ aSettings->SetPrintReversed (PR_FALSE);
+ aSettings->SetPrintRange (nsIPrintSettings::kRangeAllPages);
+ }
+
+ switch (gtk_print_settings_get_orientation (aGtkSettings)) {
+ case GTK_PAGE_ORIENTATION_PORTRAIT:
+ case GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT: /* not supported */
+ aSettings->SetOrientation (nsIPrintSettings::kPortraitOrientation);
+ break;
+ case GTK_PAGE_ORIENTATION_LANDSCAPE:
+ case GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE: /* not supported */
+ aSettings->SetOrientation (nsIPrintSettings::kLandscapeOrientation);
+ break;
+ }
+
+ aSettings->SetPrintInColor (gtk_print_settings_get_use_color (aGtkSettings));
+
+ aSettings->SetPaperSizeUnit(nsIPrintSettings::kPaperSizeMillimeters);
+ aSettings->SetPaperSize (nsIPrintSettings::kPaperSizeDefined);
+
+ // FIXME for some reason this is always NULL ??
+ // GtkPaperSize *paperSize = gtk_print_settings_get_paper_size (aGtkSettings);
+ GtkPaperSize *paperSize = gtk_page_setup_get_paper_size (aPageSetup);
+ if (!paperSize) {
+ return NS_ERROR_FAILURE;
+ }
+
+ aSettings->SetPaperSizeType (nsIPrintSettings::kPaperSizeDefined);
+ aSettings->SetPaperWidth (gtk_paper_size_get_width (paperSize, GTK_UNIT_MM));
+ aSettings->SetPaperHeight (gtk_paper_size_get_height (paperSize, GTK_UNIT_MM));
+
+#ifdef HAVE_GECKO_1_9
+ aSettings->SetPaperName (NS_ConvertUTF8toUTF16 (gtk_paper_size_get_name (paperSize)).get ());
+#else
+{
+ /* Mozilla bug https://bugzilla.mozilla.org/show_bug.cgi?id=307404
+ * means that we cannot actually use any paper sizes except mozilla's
+ * builtin list, and we must refer to them *by name*!
+ */
+ static const struct {
+ const char gtkPaperName[13];
+ const char mozPaperName[10];
+ } paperTable [] = {
+ { GTK_PAPER_NAME_A5, "A5" },
+ { GTK_PAPER_NAME_A4, "A4" },
+ { GTK_PAPER_NAME_A3, "A3" },
+ { GTK_PAPER_NAME_LETTER, "Letter" },
+ { GTK_PAPER_NAME_LEGAL, "Legal" },
+ { GTK_PAPER_NAME_EXECUTIVE, "Executive" },
+ };
+
+ const char *paperName = gtk_paper_size_get_name (paperSize);
+
+ PRUint32 i;
+ for (i = 0; i < G_N_ELEMENTS (paperTable); i++) {
+ if (g_ascii_strcasecmp (paperTable[i].gtkPaperName, paperName) == 0) {
+ paperName = paperTable[i].mozPaperName;
+ break;
+ }
+ }
+ if (i == G_N_ELEMENTS (paperTable)) {
+ /* Not in table, fall back to A4 */
+ g_warning ("Unknown paper name '%s', falling back to A4", gtk_paper_size_get_name (paperSize));
+ paperName = paperTable[1].mozPaperName;
+ }
+
+ aSettings->SetPaperName (NS_ConvertUTF8toUTF16 (paperName).get ());
+}
+#endif /* !HAVE_GECKO_1_9 */
+
+ // gtk_paper_size_free (paperSize);
+
+ /* Sucky mozilla wants margins in inch! */
+ aSettings->SetMarginTop (gtk_page_setup_get_top_margin (aPageSetup, GTK_UNIT_INCH));
+ aSettings->SetMarginBottom (gtk_page_setup_get_bottom_margin (aPageSetup, GTK_UNIT_INCH));
+ aSettings->SetMarginLeft (gtk_page_setup_get_left_margin (aPageSetup, GTK_UNIT_INCH));
+ aSettings->SetMarginRight (gtk_page_setup_get_right_margin (aPageSetup, GTK_UNIT_INCH));
+
+#if 0
+ // FIXME !
+ aSettings->SetHeaderStrLeft(const PRUnichar * aHeaderStrLeft);
+ aSettings->SetHeaderStrCenter(const PRUnichar * aHeaderStrCenter);
+ aSettings->SetHeaderStrRight(const PRUnichar * aHeaderStrRight);
+ aSettings->SetFooterStrLeft(const PRUnichar * aFooterStrLeft);
+ aSettings->SetFooterStrCenter(const PRUnichar * aFooterStrCenter);
+ aSettings->SetFooterStrRight(const PRUnichar * aFooterStrRight);
+#endif
+
+ /* FIXME I think this is the right default, but this prevents the user
+ * from cancelling the print immediately, see the stupid comment in nsPrintEngine:
+ * "DO NOT allow the print job to be cancelled if it is Print FrameAsIs
+ * because it is only printing one page."
+ * We work around this by just not sending the job to the printer then.
+ */
+ aSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs); /* FIXME setting */
+ aSettings->SetPrintFrameTypeUsage (nsIPrintSettings::kUseSettingWhenPossible);
+
+ aSettings->SetScaling (gtk_print_settings_get_scale (aGtkSettings) / 100.0);
+ aSettings->SetShrinkToFit (PR_FALSE); /* FIXME setting */
+
+ aSettings->SetPrintBGColors (PR_FALSE); /* FIXME setting */
+ aSettings->SetPrintBGImages (PR_FALSE); /* FIXME setting */
+
+ /* aSettings->SetPlexName (LITERAL ("default")); */
+ /* aSettings->SetColorspace (LITERAL ("default")); */
+ /* aSettings->SetResolutionName (LITERAL ("default")); */
+ /* aSettings->SetDownloadFonts (PR_TRUE); */
+
+ return NS_OK;
+}
diff --git a/embed/mozilla/GeckoPrintService.h b/embed/mozilla/GeckoPrintService.h
new file mode 100644
index 000000000..c9e0eb6ad
--- /dev/null
+++ b/embed/mozilla/GeckoPrintService.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2006 Christian Persch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef GECKO_PRINT_SERVICE_H
+#define GECKO_PRINT_SERVICE_H
+
+#include <gtk/gtkpagesetup.h>
+#include <gtk/gtkprintsettings.h>
+
+#include <nsIPrintingPromptService.h>
+
+class nsIPrintSettings;
+
+/* 6a71ff30-7f4d-4d91-b71a-d5c9764b34be */
+#define GECKO_PRINT_SERVICE_IID \
+{ 0x6a71ff30, 0x7f4d, 0x4d91, \
+ { 0xb7, 0x1a, 0xd5, 0xc9, 0x76, 0x4b, 0x34, 0xbe } }
+
+#define GECKO_PRINT_SERVICE_CLASSNAME "Gecko Print Service"
+
+class GeckoPrintService : public nsIPrintingPromptService
+{
+public:
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIPRINTINGPROMPTSERVICE
+
+ GeckoPrintService();
+ virtual ~GeckoPrintService();
+
+ static nsresult TranslateSettings (GtkPrintSettings*, GtkPageSetup *, const nsACString&, PRBool, nsIPrintSettings*);
+
+private:
+};
+
+#endif /* GECKO_PRINT_SERVICE_H */
diff --git a/embed/mozilla/GeckoPrintSession.cpp b/embed/mozilla/GeckoPrintSession.cpp
new file mode 100644
index 000000000..4d184eb9f
--- /dev/null
+++ b/embed/mozilla/GeckoPrintSession.cpp
@@ -0,0 +1,622 @@
+/*
+ * Copyright (C) 2006 Christian Persch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#include "mozilla-config.h"
+#include "config.h"
+
+#include <unistd.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include <nsStringAPI.h>
+
+#include <nsIDOMWindow.h>
+#include <nsIDOMWindowInternal.h>
+#include <nsIPrintSettings.h>
+
+#include "ephy-debug.h"
+#include "ephy-embed-shell.h"
+#include "ephy-file-helpers.h"
+
+#include "EphyUtils.h"
+
+#include "GeckoPrintSession.h"
+
+#define MAX_STRING_LENGTH 512
+
+GeckoPrintSession::GeckoPrintSession ()
+: mSettings(NULL)
+, mPageSetup(NULL)
+, mPrinter(NULL)
+, mJob(NULL)
+, mProgressDialog(NULL)
+, mTitleLabel(NULL)
+, mProgressBar(NULL)
+, mStartPrintIdleID(0)
+, mSourceFileIsTemp(PR_FALSE)
+, mDone(PR_FALSE)
+, mCancelled(PR_FALSE)
+{
+ LOG ("GeckoPrintSession ctor [%p]", (void*) this);
+
+ /* FIXME: connect to "prepare-close" ? */
+ g_object_ref (ephy_embed_shell_get_default ());
+}
+
+GeckoPrintSession::~GeckoPrintSession ()
+{
+ LOG ("GeckoPrintSession dtor [%p]", (void*) this);
+
+ NS_ASSERTION (mStartPrintIdleID == 0, "Impossible");
+
+ if (!mDone && !mCancelled) {
+ Cancel ();
+ }
+ DestroyJob ();
+
+ if (mSettings) {
+ g_object_unref (mSettings);
+ }
+ if (mPageSetup) {
+ g_object_unref (mPageSetup);
+ }
+ if (mPrinter) {
+ g_object_unref (mPrinter);
+ }
+ if (mProgressDialog) {
+ gtk_widget_destroy (mProgressDialog);
+ }
+ if (mSourceFileIsTemp) {
+ unlink (mSourceFile.get ());
+ }
+
+ g_object_unref (ephy_embed_shell_get_default ());
+}
+
+void
+GeckoPrintSession::GetSourceFile (nsACString &aSource)
+{
+ aSource.Assign (mSourceFile);
+}
+
+nsresult
+GeckoPrintSession::SetSettings (GtkPrintSettings *aSettings,
+ GtkPageSetup *aPageSetup,
+ GtkPrinter *aPrinter)
+{
+ NS_ASSERTION (!mSettings && !mPageSetup && !mPrinter, "Already have settings!");
+
+ NS_ENSURE_ARG (aSettings);
+ mSettings = aSettings; /* this one is adopted */
+
+ NS_ENSURE_ARG (aPageSetup);
+ NS_ENSURE_ARG (aPrinter);
+
+ mPageSetup = (GtkPageSetup *) g_object_ref (aPageSetup);
+ mPrinter = (GtkPrinter *) g_object_ref (aPrinter);
+
+ /* Compute the source file name */
+ if (gtk_print_settings_get_print_to_file (mSettings)) {
+ /* FIXME: support gnome-VFS uris here! */
+ const char *fileURI = gtk_print_settings_get (aSettings, "export-uri");
+ NS_ENSURE_TRUE (fileURI, NS_ERROR_FAILURE);
+
+ char *fileName = g_filename_from_uri (fileURI, NULL, NULL);
+ NS_ENSURE_TRUE (fileURI, NS_ERROR_FAILURE);
+
+ mSourceFile.Assign (fileName);
+ g_free (fileName);
+ } else {
+ char *base, *tmpName;
+
+ /* FIXME: use pure glib here! */
+ base = g_build_filename (ephy_file_tmp_dir (), "print-XXXXXX", (const char *) NULL);
+ tmpName = ephy_file_tmp_filename (base, "ps");
+ g_free (base);
+
+ NS_ENSURE_TRUE (tmpName, NS_ERROR_FAILURE);
+ mSourceFile.Assign (tmpName);
+ g_free (tmpName);
+
+ mSourceFileIsTemp = PR_TRUE;
+ }
+
+ return NS_OK;
+}
+
+/* static methods */
+
+/* static */ GeckoPrintSession *
+GeckoPrintSession::FromSettings (nsIPrintSettings *aSettings)
+{
+ nsresult rv;
+ nsCOMPtr<nsIPrintSession> session;
+ rv = aSettings->GetPrintSession (getter_AddRefs (session));
+ NS_ENSURE_TRUE (NS_SUCCEEDED (rv) && session, nsnull);
+
+ /* this is ok since the caller holds a ref to the settings which hold a ref to the session */
+ nsIPrintSession *sessionPtr = session.get();
+ return NS_STATIC_CAST (GeckoPrintSession*, sessionPtr);
+}
+
+/* static functions */
+
+static void
+ReleaseSession (GeckoPrintSession *aSession)
+{
+ NS_RELEASE (aSession);
+}
+
+static gboolean
+ProgressDeleteCallback (GtkDialog *aDialog)
+{
+ gtk_dialog_response (aDialog, GTK_RESPONSE_DELETE_EVENT);
+ return TRUE;
+}
+
+static void
+ProgressResponseCallback (GtkDialog *aDialog,
+ int aResponse,
+ GeckoPrintSession *aSession)
+{
+ aSession->Cancel ();
+}
+
+static gboolean
+StartPrintIdleCallback (GeckoPrintSession *aSession)
+{
+ aSession->StartPrinting ();
+
+ return FALSE;
+}
+
+static void
+JobStatusChangedCallback (GtkPrintJob *aJob,
+ GeckoPrintSession *aSession)
+{
+ aSession->JobStatusChanged ();
+}
+
+static void
+JobCompletedCallback (GtkPrintJob *aJob,
+ GeckoPrintSession *aSession,
+ GError *aError)
+{
+ aSession->JobDone ();
+
+ if (aError) {
+ aSession->JobError (aError->message);
+ }
+}
+
+/* Private methods */
+
+void
+GeckoPrintSession::SetProgress (PRInt32 aCurrent,
+ PRInt32 aMaximum)
+{
+ NS_ENSURE_TRUE (mProgressDialog, );
+
+ if (mCancelled) return;
+
+ /* Mozilla is weird */
+ if (aCurrent > aMaximum || (aCurrent == 100 && aMaximum == 100)) return;
+
+ double fraction = 0.0;
+ if (aMaximum > 0 && aCurrent >= 0) {
+ char *text = g_strdup_printf (_("Page %d of %d"), aCurrent, aMaximum);
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (mProgressBar), text);
+ g_free (text);
+
+ fraction = (double) aCurrent / (double) aMaximum;
+ }
+
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (mProgressBar), CLAMP (fraction, 0.0, 1.0));
+}
+
+void
+GeckoPrintSession::SetProgressText (const char *aText)
+{
+ NS_ENSURE_TRUE (mProgressDialog, );
+
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (mProgressBar), aText);
+}
+
+void
+GeckoPrintSession::Cancel ()
+{
+ SetProcessCanceledByUser (PR_TRUE);
+
+ if (mProgressDialog) {
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (mProgressDialog),
+ GTK_RESPONSE_CANCEL, FALSE);
+
+ SetProgress (0, 0);
+ SetProgressText (_("Cancelling print"));
+ }
+
+ if (mJob) {
+ /* FIXME: There's no way to cancel mJob! Bug #339323 */
+ }
+}
+
+void
+GeckoPrintSession::StartPrinting ()
+{
+ mStartPrintIdleID = 0;
+
+ GError *error = NULL;
+
+ /* FIXME: this could also be a print job to a file which was
+ * printed to a temp file and now needs to be uploaded to its
+ * final location with gnome-vfs.
+ */
+ if (gtk_print_settings_get_print_to_file (mSettings)) return;
+
+ NS_ENSURE_TRUE (mSettings && mPageSetup && mPrinter, );
+
+ mJob = gtk_print_job_new (mTitle.get (),
+ mPrinter,
+ mSettings,
+ mPageSetup);
+ if (!gtk_print_job_set_source_file (mJob, mSourceFile.get (), &error)) {
+ g_warning ("Couldn't set print job source: %s", error->message);
+ g_error_free (error);
+
+ g_object_unref (mJob);
+ mJob = NULL;
+
+ return;
+ }
+
+ /* Keep us alive until the job is done! */
+ NS_ADDREF_THIS ();
+ if (!gtk_print_job_send (mJob,
+ (GtkPrintJobCompleteFunc) JobCompletedCallback,
+ this,
+ (GDestroyNotify) ReleaseSession,
+ &error)) {
+ g_warning ("Couldn't start print job: %s", error->message);
+ g_error_free (error);
+
+ g_object_unref (mJob);
+ mJob = NULL;
+
+ NS_RELEASE_THIS ();
+ return;
+ };
+
+ g_signal_connect (mJob, "status-changed",
+ G_CALLBACK (JobStatusChangedCallback), this);
+}
+
+void
+GeckoPrintSession::JobStatusChanged ()
+{
+ NS_ENSURE_TRUE (mProgressDialog, );
+
+ LOG ("print session %p status changed %d\n", this, gtk_print_job_get_status (mJob));
+
+ if (gtk_print_job_get_status (mJob) == GTK_PRINT_STATUS_SENDING_DATA) {
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (mProgressBar), 0.75);
+ SetProgressText (_("Spooling..."));
+ }
+}
+
+void
+GeckoPrintSession::JobError (const char *aErrorMessage)
+{
+ LOG ("print job error: %s", aErrorMessage);
+
+ /* FIXME better text */
+ GtkWidget *dialog = gtk_message_dialog_new (NULL,
+ GtkDialogFlags (0),
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Print error"));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s", aErrorMessage);
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy), NULL);
+
+ gtk_widget_show (dialog);
+}
+
+void
+GeckoPrintSession::JobDone ()
+{
+ NS_ENSURE_TRUE (mProgressDialog, );
+
+ mDone = PR_TRUE;
+
+ gtk_widget_hide (mProgressDialog);
+
+ DestroyJob ();
+}
+
+void
+GeckoPrintSession::DestroyJob ()
+{
+ NS_ENSURE_TRUE (mJob, );
+
+ g_signal_handlers_disconnect_by_func (mJob, (void*) JobStatusChangedCallback, this);
+ g_object_unref (mJob);
+ mJob = NULL;
+}
+
+void
+GeckoPrintSession::LaunchJobOnIdle ()
+{
+ NS_ASSERTION (!mStartPrintIdleID, "Already started printing!");
+
+ /* Don't send the job to the printer if the user cancelled the print */
+ if (mCancelled) return;
+
+ /* Keep us alive until the idle handler runs! */
+ NS_ADDREF_THIS ();
+ mStartPrintIdleID = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
+ (GSourceFunc) StartPrintIdleCallback,
+ this,
+ (GDestroyNotify) ReleaseSession);
+}
+
+/* XPCOM interfaces */
+
+NS_IMPL_THREADSAFE_ISUPPORTS5 (GeckoPrintSession,
+ nsIPrintSession,
+ nsIWebProgressListener,
+ nsIPrintProgress,
+ nsIPrintProgressParams,
+ nsISupportsWeakReference)
+
+/* nsIPrintSession implementation */
+
+/* nsIWebProgressListener implementation */
+
+/* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long aStateFlags, in nsresult aStatus); */
+NS_IMETHODIMP
+GeckoPrintSession::OnStateChange (nsIWebProgress *aWebProgress,
+ nsIRequest *aRequest,
+ PRUint32 aStateFlags,
+ nsresult aStatus)
+{
+ if (NS_SUCCEEDED (aStatus) &&
+ aStateFlags & nsIWebProgressListener::STATE_IS_DOCUMENT) {
+ if (aStateFlags & nsIWebProgressListener::STATE_START) {
+ /* Printing starts now */
+ SetProgress (0, 0);
+ } else if ((aStateFlags & nsIWebProgressListener::STATE_STOP)) {
+ /* Printing done, upload to printer */
+ LaunchJobOnIdle ();
+ }
+ }
+
+ return NS_OK;
+}
+
+/* void onProgressChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aCurSelfProgress, in long aMaxSelfProgress, in long aCurTotalProgress, in long aMaxTotalProgress); */
+NS_IMETHODIMP
+GeckoPrintSession::OnProgressChange (nsIWebProgress *aWebProgress,
+ nsIRequest *aRequest,
+ PRInt32 aCurSelfProgress,
+ PRInt32 aMaxSelfProgress,
+ PRInt32 aCurTotalProgress,
+ PRInt32 aMaxTotalProgress)
+{
+ SetProgress (aCurTotalProgress, aMaxTotalProgress);
+
+ return NS_OK;
+}
+
+/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI aLocation); */
+NS_IMETHODIMP
+GeckoPrintSession::OnLocationChange (nsIWebProgress *aWebProgress,
+ nsIRequest *aRequest,
+ nsIURI *aLocation)
+{
+ NS_ASSERTION (0, "OnLocationChange reached!");
+ return NS_OK;
+}
+
+/* void onStatusChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsresult aStatus, in wstring aMessage); */
+NS_IMETHODIMP
+GeckoPrintSession::OnStatusChange (nsIWebProgress *aWebProgress,
+ nsIRequest *aRequest,
+ nsresult aStatus,
+ const PRUnichar *aMessage)
+{
+ NS_ASSERTION (0, "OnStatusChange reached!");
+ return NS_OK;
+}
+
+/* void onSecurityChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long aState); */
+NS_IMETHODIMP
+GeckoPrintSession::OnSecurityChange (nsIWebProgress *aWebProgress,
+ nsIRequest *aRequest,
+ PRUint32 aState)
+{
+ NS_ASSERTION (0, "OnSecurityChange reached!");
+ return NS_OK;
+}
+
+/* nsIPrintProgress implementation */
+
+/* void openProgressDialog (in nsIDOMWindowInternal parent, in string dialogURL, in nsISupports parameters, in nsIObserver openDialogObserver, out boolean notifyOnOpen); */
+NS_IMETHODIMP
+GeckoPrintSession::OpenProgressDialog (nsIDOMWindowInternal *aParent,
+ const char *aDialogURL,
+ nsISupports *aParameters,
+ nsIObserver *aOpenDialogObserver,
+ PRBool *_notifyOnOpen)
+{
+ NS_ENSURE_STATE (!mProgressDialog);
+
+ nsCOMPtr<nsIDOMWindow> domWindow (do_QueryInterface (aParent));
+ GtkWidget *parent = EphyUtils::FindGtkParent (domWindow);
+
+ GtkWidget *vbox, *hbox, *image;
+
+ mProgressDialog = gtk_dialog_new ();
+ GtkDialog *dialog = GTK_DIALOG (mProgressDialog);
+
+ gtk_dialog_add_button (dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+
+ g_signal_connect (dialog, "delete-event",
+ G_CALLBACK (ProgressDeleteCallback), NULL);
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (ProgressResponseCallback), this);
+
+ /* FIXME do we need transient? initially on top should suffice */
+ gtk_window_set_transient_for (GTK_WINDOW (dialog),
+ GTK_WINDOW (parent));
+
+ gtk_dialog_set_has_separator (dialog, FALSE);
+ gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+ gtk_box_set_spacing (GTK_BOX (dialog->vbox), 14); /* 2 * 5 + 14 = 24 */
+ gtk_box_set_spacing (GTK_BOX (dialog->action_area), 6);
+
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+ gtk_container_add (GTK_CONTAINER (dialog->vbox), hbox);
+
+ image = gtk_image_new_from_stock (GTK_STOCK_PRINT, GTK_ICON_SIZE_DIALOG);
+ gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
+
+ vbox = gtk_vbox_new (FALSE, 12);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
+
+ mTitleLabel = gtk_label_new (NULL);
+ gtk_label_set_line_wrap (GTK_LABEL (mTitleLabel), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (mTitleLabel), 0.0, 0.0);
+ gtk_box_pack_start (GTK_BOX (vbox), mTitleLabel, FALSE, FALSE, 0);
+
+ mProgressBar = gtk_progress_bar_new ();
+ gtk_box_pack_start (GTK_BOX (vbox), mProgressBar, FALSE, FALSE, 0);
+
+ gtk_widget_show_all (hbox);
+ gtk_window_present (GTK_WINDOW (dialog));
+
+ *_notifyOnOpen = PR_FALSE;
+
+ return NS_OK;
+}
+
+/* void closeProgressDialog (in boolean forceClose); */
+NS_IMETHODIMP
+GeckoPrintSession::CloseProgressDialog (PRBool forceClose)
+{
+ return NS_OK;
+}
+
+/* void registerListener (in nsIWebProgressListener listener); */
+NS_IMETHODIMP
+GeckoPrintSession::RegisterListener (nsIWebProgressListener *listener)
+{
+ return NS_OK;
+}
+
+/* void unregisterListener (in nsIWebProgressListener listener); */
+NS_IMETHODIMP
+GeckoPrintSession::UnregisterListener (nsIWebProgressListener *listener)
+{
+ return NS_OK;
+}
+
+/* void doneIniting (); */
+NS_IMETHODIMP
+GeckoPrintSession::DoneIniting()
+{
+ return NS_OK;
+}
+
+/* nsIPrompt getPrompter (); */
+NS_IMETHODIMP
+GeckoPrintSession::GetPrompter (nsIPrompt **_retval)
+{
+ g_return_val_if_reached (NS_ERROR_NOT_IMPLEMENTED);
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* attribute boolean processCanceledByUser; */
+NS_IMETHODIMP
+GeckoPrintSession::GetProcessCanceledByUser (PRBool *aProcessCanceledByUser)
+{
+ *aProcessCanceledByUser = mCancelled;
+ return NS_OK;
+}
+NS_IMETHODIMP
+GeckoPrintSession::SetProcessCanceledByUser (PRBool aProcessCanceledByUser)
+{
+ mCancelled = aProcessCanceledByUser;
+ return NS_OK;
+}
+
+/* nsIPrintProgressParams implementation */
+
+/* attribute wstring docTitle; */
+NS_IMETHODIMP
+GeckoPrintSession::GetDocTitle (PRUnichar * *aDocTitle)
+{
+ g_return_val_if_reached (NS_ERROR_NOT_IMPLEMENTED);
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+GeckoPrintSession::SetDocTitle (const PRUnichar * aDocTitle)
+{
+ NS_ENSURE_STATE (mProgressDialog);
+
+ char *converted = EphyUtils::ConvertUTF16toUTF8 (aDocTitle, MAX_STRING_LENGTH);
+ if (converted) {
+ mTitle.Assign (converted);
+
+ char *title = g_strdup_printf (_("Printing ā€œ%sā€"), converted);
+ gtk_window_set_title (GTK_WINDOW (mProgressDialog), title);
+ gtk_label_set_text (GTK_LABEL (mTitleLabel), title);
+ g_free (converted);
+ g_free (title);
+ }
+ return NS_OK;
+}
+
+/* attribute wstring docURL; */
+NS_IMETHODIMP
+GeckoPrintSession::GetDocURL (PRUnichar * *aDocURL)
+{
+ g_return_val_if_reached (NS_ERROR_NOT_IMPLEMENTED);
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+GeckoPrintSession::SetDocURL (const PRUnichar * aDocURL)
+{
+#if 0
+ NS_ENSURE_STATE (mJob);
+
+ char *converted = EphyUtils::ConvertUTF16toUTF8 (aDocTitle, MAX_STRING_LENGTH);
+ if (converted) {
+ g_free (converted);
+ }
+#endif
+ return NS_OK;
+}
diff --git a/embed/mozilla/GeckoPrintSession.h b/embed/mozilla/GeckoPrintSession.h
new file mode 100644
index 000000000..4b06a9f04
--- /dev/null
+++ b/embed/mozilla/GeckoPrintSession.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2006 Christian Persch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef GECKO_PRINT_SESSION_H
+#define GECKO_PRINT_SESSION_H
+
+#include <nsCOMPtr.h>
+#include <nsIPrintSession.h>
+#include <nsIWebProgressListener.h>
+#include <nsIPrintProgress.h>
+#include <nsIPrintProgressParams.h>
+#include <nsWeakReference.h>
+
+#include <gtk/gtkwidget.h>
+#include <gtk/gtkprintjob.h>
+#include <gtk/gtkprinter.h>
+#include <gtk/gtkprintjob.h>
+
+class nsIPrintSettings;
+class nsIDOMWindow;
+
+/* 0940c973-97e7-476f-a612-4ed9473a0b36 */
+#define GECKO_PRINT_SESSION_IID \
+{ 0x0940c973, 0x97e7, 0x476f, \
+ { 0xa6, 0x12, 0x4e, 0xd9, 0x47, 0x3a, 0x0b, 0x36 } }
+
+#define GECKO_PRINT_SESSION_CLASSNAME "Gecko Print Session"
+
+class GeckoPrintSession : public nsIPrintSession,
+ public nsIPrintProgress,
+ public nsIPrintProgressParams,
+ public nsSupportsWeakReference
+{
+ public:
+ GeckoPrintSession();
+ virtual ~GeckoPrintSession();
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIPRINTSESSION
+ NS_DECL_NSIWEBPROGRESSLISTENER
+ NS_DECL_NSIPRINTPROGRESS
+ NS_DECL_NSIPRINTPROGRESSPARAMS
+
+ nsresult SetSettings (GtkPrintSettings*, GtkPageSetup*, GtkPrinter*);
+ void GetSourceFile (nsACString&);
+
+ static GeckoPrintSession *FromSettings (nsIPrintSettings *);
+
+ void Cancel ();
+ void StartPrinting ();
+ void JobStatusChanged ();
+ void JobDone ();
+ void JobError (const char *);
+
+ private:
+ GtkPrintSettings *mSettings;
+ GtkPageSetup *mPageSetup;
+ GtkPrinter *mPrinter;
+ GtkPrintJob *mJob;
+ GtkWidget *mProgressDialog;
+ GtkWidget *mTitleLabel;
+ GtkWidget *mProgressBar;
+ nsCString mSourceFile;
+ nsCString mTitle;
+ guint mStartPrintIdleID;
+ PRPackedBool mSourceFileIsTemp;
+ PRPackedBool mDone;
+ PRPackedBool mCancelled;
+
+ void SetProgress (PRInt32, PRInt32);
+ void SetProgressText (const char *); void LaunchJob ();
+ void LaunchJobOnIdle ();
+ void DestroyJob ();
+};
+
+#endif /* GECKO_PRINT_SESSION_H */
diff --git a/embed/mozilla/Makefile.am b/embed/mozilla/Makefile.am
index 2e25a2a27..a117955ff 100644
--- a/embed/mozilla/Makefile.am
+++ b/embed/mozilla/Makefile.am
@@ -33,6 +33,10 @@ libephymozillaembed_la_SOURCES = \
EphyUtils.h \
EventContext.cpp \
EventContext.h \
+ GeckoPrintService.cpp \
+ GeckoPrintService.h \
+ GeckoPrintSession.cpp \
+ GeckoPrintSession.has \
GlobalHistory.cpp \
GlobalHistory.h \
MozDownload.cpp \
@@ -41,8 +45,6 @@ libephymozillaembed_la_SOURCES = \
MozillaPrivate.h \
MozRegisterComponents.cpp \
MozRegisterComponents.h \
- PrintingPromptService.cpp \
- PrintingPromptService.h \
mozilla-download.cpp \
mozilla-download.h \
mozilla-embed.cpp \
diff --git a/embed/mozilla/MozRegisterComponents.cpp b/embed/mozilla/MozRegisterComponents.cpp
index b2fb94b02..0ec74ff17 100644
--- a/embed/mozilla/MozRegisterComponents.cpp
+++ b/embed/mozilla/MozRegisterComponents.cpp
@@ -29,12 +29,14 @@
#include <nsComponentManagerUtils.h>
#include <nsCOMPtr.h>
+#include <nsCURILoader.h>
#include <nsDocShellCID.h>
#include <nsICategoryManager.h>
#include <nsIComponentManager.h>
#include <nsIComponentRegistrar.h>
#include <nsIGenericFactory.h>
#include <nsILocalFile.h>
+#include <nsIScriptNameSpaceManager.h>
#include <nsIServiceManager.h>
#include <nsMemory.h>
#include <nsNetCID.h>
@@ -53,9 +55,10 @@
#include "EphyContentPolicy.h"
#include "EphyPromptService.h"
#include "EphySidebar.h"
+#include "GeckoPrintService.h"
+#include "GeckoPrintSession.h"
#include "GlobalHistory.h"
#include "MozDownload.h"
-#include "PrintingPromptService.h"
#ifdef ENABLE_FILEPICKER
#include "FilePicker.h"
@@ -77,7 +80,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(EphyContentPolicy)
NS_GENERIC_FACTORY_CONSTRUCTOR(EphyPromptService)
NS_GENERIC_FACTORY_CONSTRUCTOR(EphySidebar)
NS_GENERIC_FACTORY_CONSTRUCTOR(GContentHandler)
-NS_GENERIC_FACTORY_CONSTRUCTOR(GPrintingPromptService)
+NS_GENERIC_FACTORY_CONSTRUCTOR(GeckoPrintService)
+NS_GENERIC_FACTORY_CONSTRUCTOR(GeckoPrintSession)
NS_GENERIC_FACTORY_CONSTRUCTOR(MozDownload)
NS_GENERIC_FACTORY_CONSTRUCTOR(MozGlobalHistory)
@@ -96,41 +100,48 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(GtkNSSKeyPairDialogs)
NS_GENERIC_FACTORY_CONSTRUCTOR(GtkNSSSecurityWarningDialogs)
#endif
+#define XPINSTALL_CONTRACTID NS_CONTENT_HANDLER_CONTRACTID_PREFIX "application/x-xpinstall"
+
/* class information */
NS_DECL_CLASSINFO(EphySidebar)
-static NS_METHOD
-RegisterContentPolicy(nsIComponentManager *aCompMgr, nsIFile *aPath,
- const char *registryLocation, const char *componentType,
- const nsModuleComponentInfo *info)
+static nsresult
+RegisterCategories (void)
{
- nsCOMPtr<nsICategoryManager> cm =
- do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
- NS_ENSURE_TRUE (cm, NS_ERROR_FAILURE);
-
nsresult rv;
- char *oldval = nsnull;
- rv = cm->AddCategoryEntry ("content-policy",
- EPHY_CONTENT_POLICY_CONTRACTID,
- EPHY_CONTENT_POLICY_CONTRACTID,
- PR_TRUE, PR_TRUE, &oldval);
- if (oldval)
- nsMemory::Free (oldval);
- return rv;
-}
+ nsCOMPtr<nsICategoryManager> catMan =
+ do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
+ NS_ENSURE_SUCCESS (rv, rv);
-static NS_METHOD
-RegisterSidebar(nsIComponentManager *aCompMgr, nsIFile *aPath,
- const char *registryLocation, const char *componentType,
- const nsModuleComponentInfo *info)
-{
- nsCOMPtr<nsICategoryManager> cm =
- do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
- NS_ENSURE_TRUE (cm, NS_ERROR_FAILURE);
+ rv = catMan->AddCategoryEntry ("content-policy",
+ EPHY_CONTENT_POLICY_CONTRACTID,
+ EPHY_CONTENT_POLICY_CONTRACTID,
+ PR_FALSE /* don't persist */,
+ PR_TRUE /* replace */,
+ nsnull);
+
+ rv |= catMan->AddCategoryEntry (JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY,
+ "sidebar",
+ NS_SIDEBAR_CONTRACTID,
+ PR_FALSE /* don't persist */,
+ PR_TRUE /* replace */,
+ nsnull);
- return cm->AddCategoryEntry("JavaScript global property",
- "sidebar", NS_SIDEBAR_CONTRACTID,
- PR_FALSE, PR_TRUE, nsnull);
+#ifdef HAVE_GECKO_1_9
+ /* Unregister the XPI install trigger too
+ * Only do it on gecko 1.9 though, because it breaks in 1.8
+ * (because of https://bugzilla.mozilla.org/show_bug.cgi?id=329450)
+ */
+ rv |= catMan->DeleteCategoryEntry (JAVASCRIPT_GLOBAL_CONSTRUCTOR_CATEGORY,
+ "InstallVersion",
+ PR_FALSE /* don't persist */);
+ rv |= catMan->DeleteCategoryEntry (JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY,
+ "InstallTrigger",
+ PR_FALSE /* don't persist */);
+ NS_ENSURE_SUCCESS (rv, rv);
+#endif
+
+ return rv;
}
static const nsModuleComponentInfo sAppComps[] = {
@@ -197,24 +208,29 @@ static const nsModuleComponentInfo sAppComps[] = {
MozGlobalHistoryConstructor
},
{
- G_PRINTINGPROMPTSERVICE_CLASSNAME,
- G_PRINTINGPROMPTSERVICE_CID,
- G_PRINTINGPROMPTSERVICE_CONTRACTID,
- GPrintingPromptServiceConstructor
+ GECKO_PRINT_SERVICE_CLASSNAME,
+ GECKO_PRINT_SERVICE_IID,
+ "@mozilla.org/embedcomp/printingprompt-service;1",
+ GeckoPrintServiceConstructor
+ },
+ {
+ GECKO_PRINT_SESSION_CLASSNAME,
+ GECKO_PRINT_SESSION_IID,
+ "@mozilla.org/gfx/printsession;1",
+ GeckoPrintSessionConstructor
},
{
EPHY_CONTENT_POLICY_CLASSNAME,
EPHY_CONTENT_POLICY_CID,
EPHY_CONTENT_POLICY_CONTRACTID,
EphyContentPolicyConstructor,
- RegisterContentPolicy
},
{
EPHY_SIDEBAR_CLASSNAME,
EPHY_SIDEBAR_CID,
NS_SIDEBAR_CONTRACTID,
EphySidebarConstructor,
- RegisterSidebar,
+ nsnull /* no register func */,
nsnull /* no unregister func */,
nsnull /* no factory destructor */,
NS_CI_INTERFACE_GETTER_NAME(EphySidebar),
@@ -314,5 +330,28 @@ mozilla_register_components (void)
}
}
+ rv = RegisterCategories();
+ ret = NS_SUCCEEDED (rv);
+
+ /* Unregister xpinstall content handler */
+ nsCID *cidPtr = nsnull;
+ rv = cr->ContractIDToCID (XPINSTALL_CONTRACTID, &cidPtr);
+ if (NS_SUCCEEDED (rv) && cidPtr)
+ {
+ nsCOMPtr<nsIFactory> factory;
+ rv = cm->GetClassObject (*cidPtr, NS_GET_IID (nsIFactory),
+ getter_AddRefs (factory));
+ if (NS_SUCCEEDED (rv))
+ {
+ rv = cr->UnregisterFactory (*cidPtr, factory);
+ }
+
+ nsMemory::Free (cidPtr);
+ }
+ if (NS_FAILED (rv))
+ {
+ g_warning ("Failed to unregister xpinstall content handler!\n");
+ }
+
return ret;
}
diff --git a/embed/mozilla/PrintingPromptService.cpp b/embed/mozilla/PrintingPromptService.cpp
deleted file mode 100644
index 121425060..000000000
--- a/embed/mozilla/PrintingPromptService.cpp
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright (C) 2002 Philip Langdale
- * Copyright (C) 2003-2004 Christian Persch
- * Copyright (C) 2005 Juerg Billeter
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- */
-
-#include "mozilla-config.h"
-#include "config.h"
-
-#include <gtk/gtkdialog.h>
-
-#include <libgnomeprintui/gnome-print-dialog.h>
-
-#include "eel-gconf-extensions.h"
-#include "ephy-command-manager.h"
-#include "ephy-debug.h"
-#include "ephy-embed.h"
-#include "ephy-prefs.h"
-#include "print-dialog.h"
-
-#include <nsCOMPtr.h>
-#include <nsIPrintSettings.h>
-#include <nsIServiceManager.h>
-
-#include "EphyUtils.h"
-#include "AutoJSContextStack.h"
-
-#include "PrintingPromptService.h"
-
-/* Implementation file */
-NS_IMPL_ISUPPORTS3(GPrintingPromptService, nsIPrintingPromptService, nsIWebProgressListener, nsIPrintProgressParams)
-
-GPrintingPromptService::GPrintingPromptService()
-{
- LOG ("GPrintingPromptService ctor (%p)", this);
-
- mPrintInfo = NULL;
-}
-
-GPrintingPromptService::~GPrintingPromptService()
-{
- LOG ("GPrintingPromptService dtor (%p)", this);
-
- if (mPrintInfo != NULL)
- {
- ephy_print_info_free (mPrintInfo);
- }
-}
-
-/* void showPrintDialog (in nsIDOMWindow parent, in nsIWebBrowserPrint webBrowserPrint, in nsIPrintSettings printSettings); */
-NS_IMETHODIMP GPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrint *webBrowserPrint, nsIPrintSettings *printSettings)
-{
- EmbedPrintInfo *info;
- GtkWidget *dialog;
-
- if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_PRINTING))
- {
- return NS_ERROR_ABORT;
- }
-
- nsresult rv;
- AutoJSContextStack stack;
- rv = stack.Init ();
- if (NS_FAILED (rv)) return rv;
-
- EphyEmbed *embed = EPHY_EMBED (EphyUtils::FindEmbed (parent));
- NS_ENSURE_TRUE (embed, NS_ERROR_FAILURE);
-
- info = ephy_print_get_print_info ();
-
- if (!eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_PRINT_SETUP))
- {
- GtkWidget *gtkParent = EphyUtils::FindGtkParent(parent);
- NS_ENSURE_TRUE (gtkParent, NS_ERROR_FAILURE);
-
- dialog = ephy_print_dialog_new (gtkParent, info);
- gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
-
- int ret;
-
- while (TRUE)
- {
- ret = gtk_dialog_run (GTK_DIALOG (dialog));;
-
- if (ret != GNOME_PRINT_DIALOG_RESPONSE_PRINT)
- break;
-
- if (ephy_print_verify_postscript (GNOME_PRINT_DIALOG (dialog)))
- break;
- }
-
- gtk_widget_destroy (dialog);
-
- if (ret != GNOME_PRINT_DIALOG_RESPONSE_PRINT)
- {
- ephy_print_info_free (info);
-
- return NS_ERROR_ABORT;
- }
- }
-
- /* work around mozilla bug which borks when printing selection without having one */
- if (info->range == GNOME_PRINT_RANGE_SELECTION &&
- ephy_command_manager_can_do_command
- (EPHY_COMMAND_MANAGER (embed), "cmd_copy") == FALSE)
- {
- info->range = GNOME_PRINT_RANGE_ALL;
- }
-
- EphyUtils::CollatePrintSettings (info, printSettings, FALSE);
-
- mPrintInfo = info;
-
- return NS_OK;
-}
-
-/* void showProgress (in nsIDOMWindow parent, in nsIWebBrowserPrint webBrowserPrint, in nsIPrintSettings printSettings, in nsIObserver openDialogObserver, in boolean isForPrinting, out nsIWebProgressListener webProgressListener, out nsIPrintProgressParams printProgressParams, out boolean notifyOnOpen); */
-NS_IMETHODIMP GPrintingPromptService::ShowProgress(nsIDOMWindow *parent, nsIWebBrowserPrint *webBrowserPrint, nsIPrintSettings *printSettings, nsIObserver *openDialogObserver, PRBool isForPrinting, nsIWebProgressListener **webProgressListener, nsIPrintProgressParams **printProgressParams, PRBool *notifyOnOpen)
-{
- *printProgressParams = NS_STATIC_CAST(nsIPrintProgressParams*, this);
- NS_ADDREF(*printProgressParams);
-
- *webProgressListener = NS_STATIC_CAST(nsIWebProgressListener*, this);
- NS_ADDREF(*webProgressListener);
-
- return NS_OK;
-}
-
-/* void showPageSetup (in nsIDOMWindow parent, in nsIPrintSettings printSettings, in nsIObserver printObserver); */
-NS_IMETHODIMP GPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent,
- nsIPrintSettings *printSettings,
- nsIObserver *printObserver)
-{
- EphyDialog *dialog;
- nsresult rv = NS_ERROR_ABORT;
-
- if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_PRINTING) ||
- eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_PRINT_SETUP))
- {
- return rv;
- }
-
- AutoJSContextStack stack;
- rv = stack.Init ();
- if (NS_FAILED (rv)) return rv;
-
- dialog = ephy_print_setup_dialog_new ();
- ephy_dialog_set_modal (dialog, TRUE);
-
- int ret = ephy_dialog_run (dialog);
- if (ret == GTK_RESPONSE_OK)
- {
- rv = NS_OK;
- }
-
- g_object_unref (dialog);
-
- return rv;
-}
-
-/* void showPrinterProperties (in nsIDOMWindow parent, in wstring printerName, in nsIPrintSettings printSettings); */
-NS_IMETHODIMP GPrintingPromptService::ShowPrinterProperties(nsIDOMWindow *parent, const PRUnichar *printerName, nsIPrintSettings *printSettings)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-
-/* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long aStateFlags, in nsresult aStatus); */
-NS_IMETHODIMP GPrintingPromptService::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsresult aStatus)
-{
- if ((aStateFlags & STATE_STOP) && mPrintInfo)
- {
- if (NS_SUCCEEDED (aStatus))
- {
- ephy_print_do_print_and_free (mPrintInfo);
- }
- else
- {
- ephy_print_info_free (mPrintInfo);
- }
-
- mPrintInfo = NULL;
- }
- return NS_OK;
-}
-
-/* void onProgressChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aCurSelfProgress, in long aMaxSelfProgress, in long aCurTotalProgress, in long aMaxTotalProgress); */
-NS_IMETHODIMP GPrintingPromptService::OnProgressChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress, PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location); */
-NS_IMETHODIMP GPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void onStatusChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsresult aStatus, in wstring aMessage); */
-NS_IMETHODIMP GPrintingPromptService::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus, const PRUnichar *aMessage)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void onSecurityChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long state); */
-NS_IMETHODIMP GPrintingPromptService::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 state)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* attribute wstring docTitle; */
-NS_IMETHODIMP GPrintingPromptService::GetDocTitle(PRUnichar * *aDocTitle)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-NS_IMETHODIMP GPrintingPromptService::SetDocTitle(const PRUnichar * aDocTitle)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* attribute wstring docURL; */
-NS_IMETHODIMP GPrintingPromptService::GetDocURL(PRUnichar * *aDocURL)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-NS_IMETHODIMP GPrintingPromptService::SetDocURL(const PRUnichar * aDocURL)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
diff --git a/embed/mozilla/PrintingPromptService.h b/embed/mozilla/PrintingPromptService.h
deleted file mode 100644
index de0dfb353..000000000
--- a/embed/mozilla/PrintingPromptService.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2000 Marco Pesenti Gritti
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- */
-
-#ifndef __PrintingPromptService_h
-#define __PrintingPromptService_h
-
-#include "print-dialog.h"
-
-#include <nscore.h>
-#include <nsIPrintingPromptService.h>
-
-#define G_PRINTINGPROMPTSERVICE_CID \
-{ /* 5998a2d3-88ea-4c52-b4bb-4e7abd0d35e0 */ \
- 0x5998a2d3, \
- 0x88ea, \
- 0x4c52, \
- {0xb4, 0xbb, 0x4e, 0x7a, 0xbd, 0x0d, 0x35, 0xe0} \
-}
-
-#define G_PRINTINGPROMPTSERVICE_CLASSNAME "Epiphany's Printing Prompt Service"
-#define G_PRINTINGPROMPTSERVICE_CONTRACTID "@mozilla.org/embedcomp/printingprompt-service;1"
-
-class GPrintingPromptService : public nsIPrintingPromptService,
- nsIWebProgressListener,
- nsIPrintProgressParams
-{
-public:
- NS_DECL_ISUPPORTS
- NS_DECL_NSIPRINTINGPROMPTSERVICE
- NS_DECL_NSIWEBPROGRESSLISTENER
- NS_DECL_NSIPRINTPROGRESSPARAMS
-
- GPrintingPromptService();
- virtual ~GPrintingPromptService();
- /* additional members */
-
-protected:
- EmbedPrintInfo *mPrintInfo;
-};
-
-#endif
diff --git a/embed/print-dialog.c b/embed/print-dialog.c
deleted file mode 100755
index 18162c4c9..000000000
--- a/embed/print-dialog.c
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
- * Copyright (C) 2002 Jorn Baayen
- * Copyright (C) 2003, 2004 Christian Persch
- * Copyright (C) 2005 Juerg Billeter
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- */
-
-#include "config.h"
-
-#include "print-dialog.h"
-#include "ephy-embed-single.h"
-#include "ephy-embed-shell.h"
-#include "ephy-file-chooser.h"
-#include "ephy-file-helpers.h"
-#include "ephy-stock-icons.h"
-#include "eel-gconf-extensions.h"
-#include "ephy-debug.h"
-#include "ephy-gui.h"
-
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtkdialog.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkstock.h>
-#include <gtk/gtkcombobox.h>
-#include <gtk/gtkcellrenderertext.h>
-#include <gtk/gtkcelllayout.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <glib/gi18n.h>
-
-#include <libgnomeprintui/gnome-print-paper-selector.h>
-
-#define CONF_PRINT_PAGE_TITLE "/apps/epiphany/dialogs/print_page_title"
-#define CONF_PRINT_PAGE_URL "/apps/epiphany/dialogs/print_page_url"
-#define CONF_PRINT_DATE "/apps/epiphany/dialogs/print_date"
-#define CONF_PRINT_PAGE_NUMBERS "/apps/epiphany/dialogs/print_page_numbers"
-#define CONF_PRINT_COLOR "/apps/epiphany/dialogs/print_color"
-
-#define PRINT_CONFIG_FILENAME "ephy-print-config.xml"
-
-enum
-{
- SETUP_WINDOW_PROP,
- PAGE_TITLE_PROP,
- PAGE_URL_PROP,
- PAGE_NUMBERS_PROP,
- DATE_PROP,
- COLOR_PROP,
-};
-
-static const
-EphyDialogProperty setup_props [] =
-{
- { "print_setup_dialog", NULL, PT_NORMAL, 0 },
- { "print_page_title_checkbutton", CONF_PRINT_PAGE_TITLE, PT_AUTOAPPLY, 0 },
- { "print_page_url_checkbutton", CONF_PRINT_PAGE_URL, PT_AUTOAPPLY, 0 },
- { "print_page_numbers_checkbutton", CONF_PRINT_PAGE_NUMBERS, PT_AUTOAPPLY, 0 },
- { "print_date_checkbutton", CONF_PRINT_DATE, PT_AUTOAPPLY, 0 },
- { "print_color_radiobutton", CONF_PRINT_COLOR, PT_AUTOAPPLY, 0 },
-
- { NULL }
-};
-
-void
-ephy_print_info_free (EmbedPrintInfo *info)
-{
- g_return_if_fail (info != NULL);
-
- g_object_unref (info->config);
-
- g_free (info->tempfile);
-
- if (info->cancel_print_id != 0)
- g_signal_handler_disconnect (embed_shell, info->cancel_print_id);
-
- g_free (info->header_left_string);
- g_free (info->header_center_string);
- g_free (info->header_right_string);
- g_free (info->footer_left_string);
- g_free (info->footer_center_string);
- g_free (info->footer_right_string);
- g_free (info);
-}
-
-static GnomePrintConfig *
-ephy_print_load_config_from_file (void)
-{
- GnomePrintConfig *ephy_print_config = NULL;
- char *file_name, *contents = NULL;
-
- file_name = g_build_filename (ephy_dot_dir (),
- PRINT_CONFIG_FILENAME,
- NULL);
-
- if (g_file_get_contents (file_name, &contents, NULL, NULL))
- {
- ephy_print_config = gnome_print_config_from_string (contents, 0);
- g_free (contents);
- }
-
- if (ephy_print_config == NULL)
- {
- ephy_print_config = gnome_print_config_default ();
- }
-
- g_free (file_name);
-
- return ephy_print_config;
-}
-
-static void
-ephy_print_save_config_to_file (GnomePrintConfig *config)
-{
- char *file_name, *str;
-
- g_return_if_fail (config != NULL);
-
- str = gnome_print_config_to_string (config, 0);
- if (str == NULL) return;
-
- file_name = g_build_filename (ephy_dot_dir (), PRINT_CONFIG_FILENAME,
- NULL);
-
- g_file_set_contents (file_name, str, -1, NULL);
-
- g_free (file_name);
- g_free (str);
-}
-
-EmbedPrintInfo *
-ephy_print_get_print_info (void)
-{
- EmbedPrintInfo *info;
-
- info = g_new0 (EmbedPrintInfo, 1);
-
- info->config = ephy_print_load_config_from_file ();
-
- info->range = GNOME_PRINT_RANGE_ALL;
- info->from_page = 1;
- info->to_page = 1;
-
- info->print_color = ! eel_gconf_get_integer (setup_props[COLOR_PROP].pref);
-
- info->header_left_string = eel_gconf_get_boolean (setup_props[PAGE_TITLE_PROP].pref) ?
- g_strdup ("&T") : g_strdup ("");
- info->header_right_string = eel_gconf_get_boolean (setup_props[PAGE_URL_PROP].pref) ?
- g_strdup ("&U") : g_strdup ("");
- info->footer_left_string = eel_gconf_get_boolean (setup_props[PAGE_NUMBERS_PROP].pref) ?
- g_strdup ("&PT") : g_strdup ("");
- info->footer_right_string = eel_gconf_get_boolean (setup_props[DATE_PROP].pref) ?
- g_strdup ("&D") : g_strdup ("");
- info->header_center_string = g_strdup("");
- info->footer_center_string = g_strdup("");
-
- info->frame_type = 0;
-
- return info;
-}
-
-static void
-ephy_print_dialog_response_cb (GtkDialog *dialog,
- int response,
- EmbedPrintInfo *info)
-{
- if (response == GNOME_PRINT_DIALOG_RESPONSE_PRINT)
- {
- ephy_print_save_config_to_file (info->config);
-
- info->range = gnome_print_dialog_get_range_page (GNOME_PRINT_DIALOG (dialog),
- &info->from_page,
- &info->to_page);
- }
-}
-
-static gboolean
-using_pdf_printer (GnomePrintConfig *config)
-{
- const guchar *driver;
-
- driver = gnome_print_config_get (
- config, (const guchar *)"Settings.Engine.Backend.Driver");
-
- if (driver)
- {
- if (!strcmp ((const gchar *)driver, "gnome-print-pdf"))
- return TRUE;
- else
- return FALSE;
- }
-
- return FALSE;
-}
-
-static gboolean
-using_postscript_printer (GnomePrintConfig *config)
-{
- const guchar *driver;
- const guchar *transport;
-
- driver = gnome_print_config_get (
- config, (const guchar *)"Settings.Engine.Backend.Driver");
-
- transport = gnome_print_config_get (
- config, (const guchar *)"Settings.Transport.Backend");
-
- if (driver)
- {
- if (strcmp ((const gchar *)driver, "gnome-print-ps") == 0)
- return TRUE;
- else
- return FALSE;
- }
- else if (transport) /* these transports default to PostScript */
- {
- if (strcmp ((const gchar *)transport, "CUPS") == 0)
- return TRUE;
- else if (strcmp ((const gchar *)transport, "LPD") == 0)
- return TRUE;
- }
-
- return FALSE;
-}
-
-gboolean
-ephy_print_verify_postscript (GnomePrintDialog *print_dialog)
-{
- GnomePrintConfig *config;
- GtkWidget *dialog;
-
- config = gnome_print_dialog_get_config (print_dialog);
-
- if (using_postscript_printer (config))
- return TRUE;
-
- if (using_pdf_printer (config))
- {
- dialog = gtk_message_dialog_new (
- GTK_WINDOW (print_dialog), GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- _("Generating PDF is not supported"));
- }
- else
- {
- dialog = gtk_message_dialog_new (
- GTK_WINDOW (print_dialog), GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- _("Printing is not supported on this printer"));
- gtk_message_dialog_format_secondary_text (
- GTK_MESSAGE_DIALOG (dialog),
- _("You were trying to print to a printer using the ā€œ%sā€ driver. This program requires a PostScript printer driver."),
- gnome_print_config_get (
- config, (guchar *)"Settings.Engine.Backend.Driver"));
- }
-
- gtk_window_group_add_window (ephy_gui_ensure_window_group (GTK_WINDOW (print_dialog)),
- GTK_WINDOW (dialog));
-
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- return FALSE;
-}
-
-static void
-cancel_print_cb (EphyEmbedShell *shell, EmbedPrintInfo *info)
-{
- g_source_remove (info->print_idle_id);
-
- ephy_print_info_free (info);
-}
-
-static gboolean
-ephy_print_do_print_idle_cb (EmbedPrintInfo *info)
-{
- GnomePrintJob *job;
-
- /* Sometimes mozilla doesn't even create the temp file!? */
- if (g_file_test (info->tempfile, G_FILE_TEST_EXISTS) == FALSE) return FALSE;
-
- /* FIXME: is this actually necessary? libc docs say all streams
- * are flushed when reading from any stream.
- */
- fflush(NULL);
-
- job = gnome_print_job_new (info->config);
-
- gnome_print_job_set_file (job, info->tempfile);
- gnome_print_job_print (job);
- g_object_unref (job);
-
- unlink (info->tempfile);
-
- ephy_print_info_free (info);
-
- return FALSE;
-}
-
-void
-ephy_print_do_print_and_free (EmbedPrintInfo *info)
-{
- /* mozilla printing system hasn't really sent the data
- * to the printer when reporting that printing is done, it's
- * just ready to do it now
- */
- info->print_idle_id = g_idle_add ((GSourceFunc) ephy_print_do_print_idle_cb,
- info);
- info->cancel_print_id = g_signal_connect (embed_shell, "prepare-close",
- G_CALLBACK (cancel_print_cb),
- info);
-}
-
-static void
-ephy_print_setup_dialog_response_cb (GtkWidget *widget,
- int response,
- EphyDialog *dialog)
-{
- if (response == GTK_RESPONSE_HELP)
- {
- ephy_gui_help (GTK_WINDOW (widget), "epiphany", "using-print-setup");
- return;
- }
-
- g_object_unref (dialog);
-}
-
-/*
- * A variant of gnome_print_dialog_construct_range_page that can be used when
- * the total page count is unknown. It defaults to 1-1
- */
-static void
-ephy_print_dialog_construct_range_page (GnomePrintDialog *gpd, gint flags,
- const guchar *currentlabel, const guchar *rangelabel)
-{
- GtkWidget *hbox;
-
- hbox = NULL;
-
- if (flags & GNOME_PRINT_RANGE_RANGE) {
- GtkWidget *l, *sb;
- GtkObject *a;
- AtkObject *atko;
-
- hbox = gtk_hbox_new (FALSE, 3);
- gtk_widget_show (hbox);
-
- l = gtk_label_new_with_mnemonic (_("_From:"));
- gtk_widget_show (l);
- gtk_box_pack_start (GTK_BOX (hbox), l, FALSE, FALSE, 0);
-
- a = gtk_adjustment_new (1, 1, 9999, 1, 10, 10);
- g_object_set_data (G_OBJECT (hbox), "from", a);
- sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1, 0.0);
- gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (sb), TRUE);
- gtk_widget_show (sb);
- gtk_box_pack_start (GTK_BOX (hbox), sb, FALSE, FALSE, 0);
- gtk_label_set_mnemonic_widget ((GtkLabel *) l, sb);
-
- atko = gtk_widget_get_accessible (sb);
- atk_object_set_description (atko, _("Sets the start of the range of pages to be printed"));
-
- l = gtk_label_new_with_mnemonic (_("_To:"));
- gtk_widget_show (l);
- gtk_box_pack_start (GTK_BOX (hbox), l, FALSE, FALSE, 0);
-
- a = gtk_adjustment_new (1, 1, 9999, 1, 10, 10);
- g_object_set_data (G_OBJECT (hbox), "to", a);
- sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1, 0.0);
- gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (sb), TRUE);
- gtk_widget_show (sb);
- gtk_box_pack_start (GTK_BOX (hbox), sb, FALSE, FALSE, 0);
- gtk_label_set_mnemonic_widget ((GtkLabel *) l, sb);
-
- atko = gtk_widget_get_accessible (sb);
- atk_object_set_description (atko, _("Sets the end of the range of pages to be printed"));
- }
-
- gnome_print_dialog_construct_range_any (gpd, flags, hbox, currentlabel, rangelabel);
-}
-
-GtkWidget *
-ephy_print_dialog_new (GtkWidget *parent,
- EmbedPrintInfo *info)
-{
- GtkWidget *dialog;
-
- dialog = g_object_new (GNOME_TYPE_PRINT_DIALOG, "print_config",
- info->config, NULL);
-
- gnome_print_dialog_construct (GNOME_PRINT_DIALOG (dialog), (const guchar *) _("Print"),
- GNOME_PRINT_DIALOG_RANGE |
- GNOME_PRINT_DIALOG_COPIES);
-
- ephy_print_dialog_construct_range_page (GNOME_PRINT_DIALOG (dialog),
- GNOME_PRINT_RANGE_ALL |
- GNOME_PRINT_RANGE_RANGE |
- GNOME_PRINT_RANGE_SELECTION,
- NULL, (const guchar *) _("Pages"));
-
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
- GNOME_PRINT_DIALOG_RESPONSE_PREVIEW,
- FALSE);
-
- g_signal_connect (G_OBJECT (dialog), "response",
- G_CALLBACK (ephy_print_dialog_response_cb), info);
-
- gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
-
- gtk_window_group_add_window (ephy_gui_ensure_window_group (GTK_WINDOW (parent)),
- GTK_WINDOW (dialog));
-
- return dialog;
-}
-
-EphyDialog *
-ephy_print_setup_dialog_new (void)
-{
- EphyDialog *dialog;
- GtkWidget *window;
-
- dialog = EPHY_DIALOG (g_object_new (EPHY_TYPE_DIALOG, NULL));
-
- ephy_dialog_construct (dialog,
- setup_props,
- ephy_file ("print.glade"),
- "print_setup_dialog",
- NULL);
-
- window = ephy_dialog_get_control (dialog, setup_props[SETUP_WINDOW_PROP].id);
- g_signal_connect (window, "response",
- G_CALLBACK (ephy_print_setup_dialog_response_cb), dialog);
-
- return dialog;
-}
diff --git a/embed/print-dialog.h b/embed/print-dialog.h
deleted file mode 100644
index 34452581d..000000000
--- a/embed/print-dialog.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2002 Jorn Baayen
- * Copyright (C) 2003 Christian Persch
- * Copyright (C) 2005 Juerg Billeter
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- */
-
-#ifndef EPHY_PRINT_DIALOG_H
-#define EPHY_PRINT_DIALOG_H
-
-#include "ephy-dialog.h"
-#include "ephy-embed.h"
-
-#include <glib-object.h>
-#include <glib.h>
-#include <gtk/gtkwidget.h>
-
-/* for gnome_print_job_set_file */
-#define GNOME_PRINT_UNSTABLE_API
-#include <libgnomeprint/gnome-print-config.h>
-#include <libgnomeprintui/gnome-print-dialog.h>
-
-G_BEGIN_DECLS
-
-typedef struct _EmbedPrintInfo
-{
- GnomePrintConfig *config;
-
- char *tempfile;
- guint print_idle_id;
- gulong cancel_print_id;
-
- GnomePrintDialogRangeFlags range;
- int from_page;
- int to_page;
- int frame_type;
- gboolean print_color;
-
- /*
- * &T - title
- * &U - Document URL
- * &D - Date/Time
- * &P - Page Number
- * &PT - Page Number with total Number of Pages (example: 1 of 34)
- *
- * So, if headerLeftStr = "&T" the title and the document URL
- * will be printed out on the top left-hand side of each page.
- */
- char *header_left_string;
- char *header_center_string;
- char *header_right_string;
- char *footer_left_string;
- char *footer_center_string;
- char *footer_right_string;
-}
-EmbedPrintInfo;
-
-GtkWidget *ephy_print_dialog_new (GtkWidget *parent,
- EmbedPrintInfo *info);
-
-EphyDialog *ephy_print_setup_dialog_new (void);
-
-EmbedPrintInfo *ephy_print_get_print_info (void);
-
-void ephy_print_info_free (EmbedPrintInfo *info);
-
-void ephy_print_do_print_and_free (EmbedPrintInfo *info);
-
-gboolean ephy_print_verify_postscript (GnomePrintDialog *print_dialog);
-
-G_END_DECLS
-
-#endif
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 410da1756..81618503e 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -21,6 +21,12 @@
#include "config.h"
+#include <string.h>
+#include <glib/gi18n.h>
+#include <gtk/gtknotebook.h>
+#include <dirent.h>
+#include <unistd.h>
+
#include "ephy-shell.h"
#include "ephy-type-builtins.h"
#include "ephy-embed-shell.h"
@@ -44,16 +50,9 @@
#include "egg-toolbars-model.h"
#include "ephy-toolbars-model.h"
#include "ephy-toolbar.h"
-#include "print-dialog.h"
#include "ephy-prefs.h"
#include "ephy-gui.h"
-#include <string.h>
-#include <glib/gi18n.h>
-#include <gtk/gtknotebook.h>
-#include <dirent.h>
-#include <unistd.h>
-
#ifdef ENABLE_NETWORK_MANAGER
#include "ephy-net-monitor.h"
#endif
@@ -75,7 +74,6 @@ struct _EphyShellPrivate
GtkWidget *history_window;
GObject *pdm_dialog;
GObject *prefs_dialog;
- GObject *print_setup_dialog;
GList *del_on_exit;
guint embed_single_connected : 1;
@@ -354,13 +352,6 @@ ephy_shell_dispose (GObject *object)
priv->prefs_dialog = NULL;
}
- if (priv->print_setup_dialog != NULL)
- {
- LOG ("Unref print setup dialog");
- g_object_unref (priv->print_setup_dialog);
- priv->print_setup_dialog = NULL;
- }
-
if (priv->bookmarks != NULL)
{
LOG ("Unref bookmarks");
@@ -855,24 +846,6 @@ ephy_shell_get_prefs_dialog (EphyShell *shell)
return shell->priv->prefs_dialog;
}
-GObject *
-ephy_shell_get_print_setup_dialog (EphyShell *shell)
-{
- if (shell->priv->print_setup_dialog == NULL)
- {
- GObject **dialog;
-
- shell->priv->print_setup_dialog = G_OBJECT (ephy_print_setup_dialog_new ());
-
- dialog = &shell->priv->print_setup_dialog;
-
- g_object_add_weak_pointer (shell->priv->print_setup_dialog,
- (gpointer *) dialog);
- }
-
- return shell->priv->print_setup_dialog;
-}
-
void
_ephy_shell_create_instance (void)
{
diff --git a/src/ephy-shell.h b/src/ephy-shell.h
index 76e661c0f..8b400c2a4 100644
--- a/src/ephy-shell.h
+++ b/src/ephy-shell.h
@@ -117,8 +117,6 @@ GObject *ephy_shell_get_pdm_dialog (EphyShell *shell);
GObject *ephy_shell_get_prefs_dialog (EphyShell *shell);
-GObject *ephy_shell_get_print_setup_dialog (EphyShell *shell);
-
/* private API */
void _ephy_shell_create_instance (void);
diff --git a/src/epiphany.defs b/src/epiphany.defs
index 546212962..d811587c8 100644
--- a/src/epiphany.defs
+++ b/src/epiphany.defs
@@ -3144,12 +3144,6 @@
(return-type "GObject*")
)
-(define-method get_print_setup_dialog
- (of-object "EphyShell")
- (c-name "ephy_shell_get_print_setup_dialog")
- (return-type "GObject*")
-)
-
(define-method get_dbus_service
(of-object "EphyShell")
(c-name "ephy_shell_get_dbus_service")
diff --git a/src/window-commands.c b/src/window-commands.c
index ac845e637..051115db3 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -59,17 +59,32 @@
#include <gtk/gtkmain.h>
#include <gtk/gtkicontheme.h>
#include <gtk/gtktoggleaction.h>
+#include <gtk/gtkprintoperation.h>
#include <glib/gi18n.h>
+static void
+page_setup_done_cb (GtkPageSetup *setup,
+ EphyEmbedShell *shell)
+{
+ if (setup != NULL)
+ {
+ ephy_embed_shell_set_page_setup (shell, setup);
+ }
+}
+
void
window_cmd_file_print_setup (GtkAction *action,
EphyWindow *window)
{
- EphyDialog *dialog;
-
- dialog = EPHY_DIALOG (ephy_shell_get_print_setup_dialog (ephy_shell));
+ EphyEmbedShell *shell;
- ephy_dialog_show (dialog);
+ shell = ephy_embed_shell_get_default ();
+ gtk_print_run_page_setup_dialog_async
+ (GTK_WINDOW (window),
+ ephy_embed_shell_get_page_setup (shell),
+ ephy_embed_shell_get_print_settings (shell),
+ page_setup_done_cb,
+ shell);
}
void