Index: configure.in
===================================================================
RCS file: /cvs/gnome/epiphany/configure.in,v
retrieving revision 1.83
diff -u -p -r1.83 configure.in
--- configure.in	28 Aug 2003 00:06:00 -0000	1.83
+++ configure.in	28 Aug 2003 17:56:41 -0000
@@ -14,9 +14,17 @@ AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PAC
 dnl put the ACLOCAL flags in the Makefile
 ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
 
+LIBGLIB_REQUIRED=2.3.0
+LIBGTK_REQUIRED=2.3.0
 LIBBONOBOUI_REQUIRED=2.1.1
+LIBGNOMEPRINT_REQUIRED=2.3.1
+LIBGNOMEPRINTUI_REQUIRED=2.3.1
 
+AC_SUBST(LIBGLIB_REQUIRED)
+AC_SUBST(LIBGTK_REQUIRED)
 AC_SUBST(LIBBONOBOUI_REQUIRED)
+AC_SUBST(LIBGNOMEPRINT_REQUIRED)
+AC_SUBST(LIBGNOMEPRINTUI_REQUIRED)
 
 AC_ENABLE_SHARED(yes)
 AC_ENABLE_STATIC(no)
@@ -64,7 +72,7 @@ fi
 AC_MSG_RESULT($enable_nautilus_view)
 AM_CONDITIONAL(ENABLE_NAUTILUS_VIEW, test "x$enable_nautilus_view" = "xyes")
 
-PKG_CHECK_MODULES(EPIPHANY_DEPENDENCY, gtk+-2.0 libxml-2.0 libgnomeui-2.0 libglade-2.0 bonobo-activation-2.0 libbonoboui-2.0 >= $LIBBONOBOUI_REQUIRED ORBit-2.0 libglade-2.0 gnome-vfs-2.0 gnome-vfs-module-2.0 gconf-2.0 $nautilusview_pkgs)
+PKG_CHECK_MODULES(EPIPHANY_DEPENDENCY, glib-2.0 >= $LIBGLIB_REQUIRED gtk+-2.0 >= $LIBGTK_REQUIRED libxml-2.0 libgnomeui-2.0 libglade-2.0 bonobo-activation-2.0 libbonoboui-2.0 >= $LIBBONOBOUI_REQUIRED ORBit-2.0 libglade-2.0 gnome-vfs-2.0 gnome-vfs-module-2.0 gconf-2.0 $nautilusview_pkgs libgnomeprint-2.2 >= $LIBGNOMEPRINT_REQUIRED libgnomeprintui-2.2 >= $LIBGNOMEPRINTUI_REQUIRED)
 AC_SUBST(EPIPHANY_DEPENDENCY_CFLAGS)
 AC_SUBST(EPIPHANY_DEPENDENCY_LIBS)
 
@@ -194,6 +202,9 @@ AM_GLIB_GNU_GETTEXT
 
 dnl uninstalled share dir to search data
 AC_DEFINE_UNQUOTED(SHARE_UNINSTALLED_DIR,"`pwd`/data",[path to source data dir])
+
+dnl We need one func from libgnomeprint unstable api
+AC_DEFINE(GNOME_PRINT_UNSTABLE_API, 1, [Use unstable api of libgnomeprint(ui)])
 
 AC_OUTPUT([
 Makefile
? embed/gnome-print-dialog-private.h
Index: src/ephy-window.c
===================================================================
RCS file: /cvs/gnome/epiphany/src/ephy-window.c,v
retrieving revision 1.102
diff -u -p -r1.102 ephy-window.c
--- src/ephy-window.c	13 Aug 2003 19:17:03 -0000	1.102
+++ src/ephy-window.c	28 Aug 2003 17:55:52 -0000
@@ -280,7 +280,7 @@ struct EphyWindowPrivate
 	GtkNotebook *notebook;
 	EphyTab *active_tab;
 	EphyDialog *find_dialog;
-	EphyDialog *print_dialog;
+	PrintDialog *print_dialog;
 	EmbedChromeMask chrome_mask;
 	gboolean closing;
 	gboolean is_fullscreen;
@@ -1803,7 +1805,7 @@ update_embed_dialogs (EphyWindow *window
 {
 	EphyEmbed *embed;
 	EphyDialog *find_dialog = window->priv->find_dialog;
-	EphyDialog *print_dialog = window->priv->print_dialog;
+	PrintDialog *print_dialog = window->priv->print_dialog;
 
 	embed = ephy_tab_get_embed (tab);
 
@@ -1816,9 +1818,7 @@ update_embed_dialogs (EphyWindow *window
 
 	if (print_dialog)
 	{
-		ephy_embed_dialog_set_embed
-			(EPHY_EMBED_DIALOG(print_dialog),
-			 embed);
+		print_dialog_set_embed (print_dialog, embed);
 	}
 }
 
@@ -1868,7 +1868,7 @@ ephy_window_find (EphyWindow *window)
 }
 
 static void
-print_dialog_preview_cb (EphyDialog *dialog,
+print_dialog_preview_cb (PrintDialog *dialog,
 			 EphyWindow *window)
 {
 	ephy_window_set_chrome (window, EMBED_CHROME_PPVIEWTOOLBARON);
@@ -1878,14 +1878,14 @@ print_dialog_preview_cb (EphyDialog *dia
 void
 ephy_window_print (EphyWindow *window)
 {
-	EphyDialog *dialog;
+	PrintDialog *dialog;
 	EphyEmbed *embed;
 
 	if (window->priv->print_dialog == NULL)
 	{
 		embed = ephy_window_get_active_embed (window);
 		dialog = print_dialog_new_with_parent
-					(GTK_WIDGET(window), embed, NULL);
+				(GTK_WIDGET(window), embed);
 		g_signal_connect (G_OBJECT (dialog),
 				  "preview",
 				  G_CALLBACK (print_dialog_preview_cb),
@@ -1895,7 +1895,7 @@ ephy_window_print (EphyWindow *window)
 					  (gpointer *) &window->priv->print_dialog);
 	}
 
-	ephy_dialog_show (window->priv->print_dialog);
+	gtk_window_present (GTK_WINDOW (window->priv->print_dialog));
 }
 
 void
Index: src/ephy-nautilus-view.c
===================================================================
RCS file: /cvs/gnome/epiphany/src/ephy-nautilus-view.c,v
retrieving revision 1.17
diff -u -p -r1.17 ephy-nautilus-view.c
--- src/ephy-nautilus-view.c	29 Jun 2003 17:53:46 -0000	1.17
+++ src/ephy-nautilus-view.c	28 Aug 2003 17:55:54 -0000
@@ -526,14 +526,12 @@ gnv_cmd_file_print (BonoboUIComponent *u
 		    EphyNautilusView *view, 
 		    const char* verbname)
 {
-	EphyDialog *dialog;
-	EphyNautilusViewPrivate *p = view->priv;
+	EphyPrintDialog *dialog;
 	
-	dialog = print_dialog_new (p->embed, NULL);
-
-	ephy_dialog_set_modal (dialog, TRUE);
-	ephy_dialog_show (dialog);
+	dialog = print_dialog_new (view->priv->embed);
 
+	gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+	gtk_window_present (GTK_WINDOW (dialog));
 }
 
 static void
Index: src/window-commands.c
===================================================================
RCS file: /cvs/gnome/epiphany/src/window-commands.c,v
retrieving revision 1.76
diff -u -p -r1.76 window-commands.c
--- src/window-commands.c	18 Aug 2003 22:42:39 -0000	1.76
+++ src/window-commands.c	28 Aug 2003 17:55:55 -0000
@@ -23,7 +23,6 @@
 #include "ephy-shell.h"
 #include "ephy-debug.h"
 #include "window-commands.h"
-#include "print-dialog.h"
 #include "eel-gconf-extensions.h"
 #include "ephy-prefs.h"
 #include "ephy-embed-utils.h"
Index: embed/ephy-embed.c
===================================================================
RCS file: /cvs/gnome/epiphany/embed/ephy-embed.c,v
retrieving revision 1.12
diff -u -p -r1.12 ephy-embed.c
--- embed/ephy-embed.c	18 Aug 2003 22:42:27 -0000	1.12
+++ embed/ephy-embed.c	28 Aug 2003 17:55:56 -0000
@@ -574,10 +574,11 @@ ephy_embed_set_encoding (EphyEmbed *embe
 
 gresult
 ephy_embed_print (EphyEmbed *embed,
-                  EmbedPrintInfo *info)
+                  GObject *config,
+		  gboolean preview)
 {
 	EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed);
-        return klass->print (embed, info);
+        return klass->print (embed, config, preview);
 }
 
 gresult
Index: embed/ephy-embed.h
===================================================================
RCS file: /cvs/gnome/epiphany/embed/ephy-embed.h,v
retrieving revision 1.12
diff -u -p -r1.12 ephy-embed.h
--- embed/ephy-embed.h	18 Aug 2003 22:42:27 -0000	1.12
+++ embed/ephy-embed.h	28 Aug 2003 17:55:57 -0000
@@ -92,44 +92,6 @@ typedef enum
         DISPLAY_NORMAL = 2U
 } EmbedDisplayType;
 
-typedef struct
-{
-        gboolean print_to_file;
-        gchar *printer;
-        gchar *file;
-        gchar *paper;
-        gint top_margin;
-        gint bottom_margin;
-        gint left_margin;
-        gint right_margin;
-        gint pages;
-        gint from_page;
-        gint to_page;
-        gint frame_type;
-        gint orientation;
-        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.
-         */
-        gchar *header_left_string;
-        gchar *header_center_string;
-        gchar *header_right_string;
-        gchar *footer_left_string;
-        gchar *footer_center_string;
-        gchar *footer_right_string;
-
-	gboolean preview;
-}
-EmbedPrintInfo;
-
 typedef enum
 {
 	PRINTPREVIEW_GOTO_PAGENUM = 0,
@@ -262,7 +224,8 @@ struct EphyEmbedClass
 					    gboolean backwards);
 	gresult   (* activate)             (EphyEmbed *embed);
 	gresult   (* print)                (EphyEmbed *embed,
-				            EmbedPrintInfo *info);
+				            GObject *config,
+					    gboolean preview);
 	gresult	  (* print_preview_close)  (EphyEmbed *embed);
 	gresult   (* print_preview_num_pages)	(EphyEmbed *embed,
 						 gint *retNum);
@@ -396,7 +359,8 @@ gresult       ephy_embed_activate       
 /* Printing */
 
 gresult       ephy_embed_print                (EphyEmbed *embed,
-					       EmbedPrintInfo *info);
+					       GObject *config,
+					       gboolean preview);
 
 gresult	      ephy_embed_print_preview_close  (EphyEmbed *embed);
 
Index: embed/ephy-favicon-cache.c
===================================================================
RCS file: /cvs/gnome/epiphany/embed/ephy-favicon-cache.c,v
retrieving revision 1.20
diff -u -p -r1.20 ephy-favicon-cache.c
--- embed/ephy-favicon-cache.c	1 Jan 1997 09:21:16 -0000	1.20
+++ embed/ephy-favicon-cache.c	28 Aug 2003 17:55:58 -0000
@@ -229,6 +229,8 @@ ephy_favicon_cache_save (EphyFaviconCach
 	GPtrArray *children;
 	int i;
 
+	LOG ("EphyFaviconCache saving cache")
+
 	/* save nodes to xml */
 	xmlIndentTreeOutput = TRUE;
 	doc = xmlNewDoc ("1.0");
@@ -443,6 +445,7 @@ ephy_favicon_cache_get (EphyFaviconCache
 	GValue value = { 0, };
 	char *pix_file;
 	GdkPixbuf *pixbuf;
+	GError *err = NULL;
 
 	if (url == NULL) return NULL;
 
@@ -497,7 +500,16 @@ ephy_favicon_cache_get (EphyFaviconCache
 
 	LOG ("Create pixbuf for %s", pix_file)
 
-	pixbuf = gdk_pixbuf_new_from_file (pix_file, NULL);
+	pixbuf = gdk_pixbuf_new_from_file (pix_file, &err);
+
+	if (err != NULL)
+	{
+		g_warning ("Error creating pixbuf from file '%s': %s\n", pix_file, err->message);
+		g_error_free (err);
+		g_warning ("Returned pixbuf is %snull\n", pixbuf ? "NOT ": "");
+
+		return NULL;
+	}
 
 	if (pixbuf &&
 	    (gdk_pixbuf_get_width (pixbuf) > 16 ||
Index: embed/print-dialog.c
===================================================================
RCS file: /cvs/gnome/epiphany/embed/print-dialog.c,v
retrieving revision 1.9
diff -u -p -r1.9 print-dialog.c
--- embed/print-dialog.c	15 Aug 2003 10:03:27 -0000	1.9
+++ embed/print-dialog.c	28 Aug 2003 17:55:58 -0000
@@ -1,5 +1,7 @@
 /*
+ *  Copyright (C) 2000, 2001, 2002 Marco Pesenti Gritti
  *  Copyright (C) 2002 Jorn Baayen
+ *  Copyright (C) 2003 Christian Persch
  *
  *  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
@@ -15,74 +17,36 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *
- *  $Id: print-dialog.c,v 1.9 2003/08/15 10:03:27 chpe Exp $
+ *  $Id$
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "print-dialog.h"
-#include "ephy-prefs.h"
-#include <gtk/gtkdialog.h>
-#include <gtk/gtkstock.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
 
-#define CONF_PRINT_BOTTOM_MARGIN "/apps/epiphany/dialogs/print_bottom_margin"
-#define CONF_PRINT_TOP_MARGIN "/apps/epiphany/dialogs/print_top_margin"
-#define CONF_PRINT_LEFT_MARGIN "/apps/epiphany/dialogs/print_left_margin"
-#define CONF_PRINT_RIGHT_MARGIN "/apps/epiphany/dialogs/print_right_margin"
-#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_PRINTER "/apps/epiphany/dialogs/print_printer"
-#define CONF_PRINT_FILE "/apps/epiphany/dialogs/print_file"
-#define CONF_PRINT_PRINTON "/apps/epiphany/dialogs/print_on"
-#define CONF_PRINT_PAPER "/apps/epiphany/dialogs/print_paper"
-#define CONF_PRINT_ALL_PAGES "/apps/epiphany/dialogs/print_all_pages"
-#define CONF_PRINT_COLOR "/apps/epiphany/dialogs/print_color"
-#define CONF_PRINT_ORIENTATION "/apps/epiphany/dialogs/print_orientation"
-
-static void print_dialog_class_init (PrintDialogClass *klass);
-static void print_dialog_init (PrintDialog *dialog);
-static void print_dialog_finalize (GObject *object);
+#include "ephy-file-helpers.h"
+#include "ephy-debug.h"
 
-/* Glade callbacks */
-void
-print_cancel_button_cb (GtkWidget *widget,
-			EphyDialog *dialog);
-void
-print_ok_button_cb (GtkWidget *widget,
-		    EphyDialog *dialog);
-void
-print_preview_button_cb (GtkWidget *widget,
-	 	         EphyDialog *dialog);
+#include <bonobo/bonobo-i18n.h>
+#include <libgnomeprint/gnome-print-config.h>
+#include <libgnomeprint/gnome-print-job.h>
+#include <libgnomevfs/gnome-vfs-utils.h>
+#include <unistd.h>
+#include <string.h>
 
-static GObjectClass *parent_class = NULL;
+#define PRINT_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EPHY_TYPE_PRINT_DIALOG, PrintDialogPrivate))
 
 struct PrintDialogPrivate
 {
-	gpointer dummy;
-	GtkWidget *window;
+	EphyEmbed *embed;
 };
 
 enum
 {
-	WINDOW_PROP,
-	PRINTON_PROP,
-	PRINTER_PROP,
-	FILE_PROP,
-	PAPER_PROP,
-	TOP_PROP,
-	BOTTOM_PROP,
-	LEFT_PROP,
-	RIGHT_PROP,
-	PAGE_TITLE_PROP,
-	PAGE_URL_PROP,
-	PAGE_NUMBERS_PROP,
-	DATE_PROP,
-	ALL_PAGES_PROP,
-	TO_PROP,
-	FROM_PROP,
-	COLOR_PROP,
-	ORIENTATION_PROP
+	PROP_0,
+	PROP_EMBED
 };
 
 enum
@@ -91,39 +55,19 @@ enum
 	LAST_SIGNAL
 };
 
-static const
-EphyDialogProperty properties [] =
-{
-	{ WINDOW_PROP, "print_dialog", NULL, PT_NORMAL, NULL },
-	{ PRINTON_PROP, "printer_radiobutton", CONF_PRINT_PRINTON, PT_NORMAL, NULL },
-	{ PRINTER_PROP, "printer_entry", CONF_PRINT_PRINTER, PT_NORMAL, NULL },
-	{ FILE_PROP, "file_entry", CONF_PRINT_FILE, PT_NORMAL, NULL },
-	{ PAPER_PROP,"A4_radiobutton", CONF_PRINT_PAPER, PT_NORMAL, NULL },
-	{ TOP_PROP, "top_spinbutton", CONF_PRINT_TOP_MARGIN, PT_NORMAL, NULL },
-        { BOTTOM_PROP, "bottom_spinbutton", CONF_PRINT_BOTTOM_MARGIN, PT_NORMAL, NULL },
-	{ LEFT_PROP,"left_spinbutton", CONF_PRINT_LEFT_MARGIN, PT_NORMAL, NULL },
-	{ RIGHT_PROP, "right_spinbutton", CONF_PRINT_RIGHT_MARGIN, PT_NORMAL, NULL },
-	{ PAGE_TITLE_PROP, "print_page_title_checkbutton", CONF_PRINT_PAGE_TITLE, PT_NORMAL, NULL },
-	{ PAGE_URL_PROP, "print_page_url_checkbutton", CONF_PRINT_PAGE_URL, PT_NORMAL, NULL },
-	{ PAGE_NUMBERS_PROP, "print_page_numbers_checkbutton", CONF_PRINT_PAGE_NUMBERS, PT_NORMAL, NULL },
-	{ DATE_PROP, "print_date_checkbutton", CONF_PRINT_DATE, PT_NORMAL, NULL },
-	{ ALL_PAGES_PROP, "all_pages_radiobutton", CONF_PRINT_ALL_PAGES, PT_NORMAL, NULL },
-	{ TO_PROP, "to_spinbutton", NULL, PT_NORMAL, NULL },
-	{ FROM_PROP, "from_spinbutton", NULL, PT_NORMAL, NULL },
-	{ COLOR_PROP, "print_color_radiobutton", CONF_PRINT_COLOR, PT_NORMAL, NULL },
-	{ ORIENTATION_PROP, "orient_p_radiobutton", CONF_PRINT_ORIENTATION, PT_NORMAL, NULL },
+static guint signals[LAST_SIGNAL] = { 0 };
 
-	{ -1, NULL, NULL }
-};
+static GObjectClass *parent_class = NULL;
 
-static const
-char *paper_format_enum [] =
-{
-	"A4", "Letter", "Legal", "Executive"
-};
-static guint n_paper_format_enum = G_N_ELEMENTS (paper_format_enum);
+/* global config */
+static GnomePrintConfig *global_config = NULL;
+static char *config_file = NULL;
+
+static void print_dialog_class_init	(PrintDialogClass *klass);
+static void print_dialog_init		(PrintDialog *dialog);
+static void print_dialog_finalize		(GObject *object);
 
-static guint print_dialog_signals[LAST_SIGNAL] = { 0 };
+#define PRINT_CONFIG_FILENAME	"ephy-print-config.xml"
 
 GType
 print_dialog_get_type (void)
@@ -144,307 +88,392 @@ print_dialog_get_type (void)
                         0, /* n_preallocs */
                         (GInstanceInitFunc) print_dialog_init
                 };
-
-                print_dialog_type = g_type_register_static (EPHY_EMBED_DIALOG_TYPE,
-						            "PrintDialog",
-						            &our_info, 0);
+                print_dialog_type = g_type_register_static (GNOME_TYPE_PRINT_DIALOG,
+								 "PrintDialog",
+								 &our_info, 0);
         }
 
         return print_dialog_type;
-
 }
 
 static void
-print_dialog_class_init (PrintDialogClass *klass)
+print_dialog_set_property (GObject *object,
+				guint prop_id,
+				const GValue *value,
+				GParamSpec *pspec)
 {
-        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+        PrintDialog *dialog = PRINT_DIALOG (object);
 
-        parent_class = g_type_class_peek_parent (klass);
+        switch (prop_id)
+        {
+                case PROP_EMBED:
+                        print_dialog_set_embed (dialog, g_value_get_object (value));
+                        break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+			break;
+	}
+}
 
-        object_class->finalize = print_dialog_finalize;
+static void
+print_dialog_get_property (GObject *object,
+				guint prop_id,
+				GValue *value,
+				GParamSpec *pspec)
+{
+        PrintDialog *dialog = PRINT_DIALOG (object);
 
-	print_dialog_signals[PREVIEW] =
-                g_signal_new ("preview",
-                              G_OBJECT_CLASS_TYPE (object_class),
-                              G_SIGNAL_RUN_FIRST,
-                              G_STRUCT_OFFSET (PrintDialogClass, preview),
-                              NULL, NULL,
-                              g_cclosure_marshal_VOID__VOID,
-                              G_TYPE_NONE,
-                              0);
+        switch (prop_id)
+        {
+                case PROP_EMBED:
+                        g_value_set_object (value, dialog->priv->embed);
+                        break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+			break;
+        }
 }
 
-static void
-print_dialog_init (PrintDialog *dialog)
+#define SUCK	(const guchar*)
+
+static gboolean
+printing_done_and_idle_cb (GnomePrintConfig *config)
 {
-	GdkPixbuf *icon;
-	dialog->priv = g_new0 (PrintDialogPrivate, 1);
+	GnomePrintJob *job;
+	char *file, *str, *backend, *tempfile;
 
-	dialog->only_collect_info = FALSE;
+	LOG ("printing_done_and_idle_cb")
 
-	dialog->ret_info = NULL;
+	g_return_val_if_fail (GNOME_IS_PRINT_CONFIG (config), FALSE);
 
-	ephy_dialog_construct (EPHY_DIALOG(dialog),
-				 properties,
-				 "print.glade", "print_dialog");
+	/* FIXME: this was in xd2's gnomeprint patch for galeon,
+	 * what's it good for ?
+	 */
+	fflush(NULL);
 
-	dialog->priv->window = ephy_dialog_get_control (EPHY_DIALOG(dialog), WINDOW_PROP);
+	tempfile = (char *) g_object_get_data (G_OBJECT (config), "tempfile");
+	if (tempfile == NULL)
+	{
+		g_object_unref (config);
+		return FALSE;
+	}
 
-	ephy_dialog_add_enum (EPHY_DIALOG (dialog), PAPER_PROP,
-			      n_paper_format_enum, paper_format_enum);
-	
-	icon = gtk_widget_render_icon (dialog->priv->window, 
-						      GTK_STOCK_PRINT,
-						      GTK_ICON_SIZE_MENU,
-						      "print_dialog");
-	gtk_window_set_icon (GTK_WINDOW(dialog->priv->window), icon);
-	g_object_unref (icon);
+	job = gnome_print_job_new (config);
+	gnome_print_job_set_file (job, tempfile);
+
+	/* libgnomeprintui sucks!
+	 * you'd think this gets the filename, but it does NOT !
+	 *	filename = (char *) gnome_print_config_get
+	 *			(config, SUCK GNOME_PRINT_KEY_OUTPUT_FILENAME);
+	 */
+	backend = (char *) gnome_print_config_get (config, SUCK "Settings.Transport.Backend");
+	str = (char *) gnome_print_config_get (config, SUCK "Settings.Transport.Backend.FileName");
+	file = gnome_vfs_expand_initial_tilde (str);
+
+	LOG ("Backend %s", backend)
+
+	if (file && backend && strncmp (backend, "file", 4) == 0)
+	{
+		LOG ("Printing from tempfile %s to file %s", tempfile, file)
+
+		gnome_print_job_print_to_file (job, file);
+	}
+	else
+	{
+		LOG ("Printing from tempfile %s to printer", tempfile)
+
+		gnome_print_job_print (job);
+	}
+
+	g_free (backend);
+	g_free (file);
+	g_free (str);
+
+	/* cleanup */
+	unlink (tempfile);
+
+	g_object_unref (config);
+	g_object_unref (job);
+
+	return FALSE;
+}
+
+static gboolean
+printing_done_cb (GObject *data)
+{
+	g_object_ref (data);
+	g_idle_add ((GSourceFunc) printing_done_and_idle_cb, data);
+
+	return TRUE;
 }
 
 static void
-print_dialog_finalize (GObject *object)
+print_dialog_print (PrintDialog *dialog, gboolean preview)
 {
-	PrintDialog *dialog;
+	GnomePrintConfig *config;
+	char *tempfile, *path;
 
-        g_return_if_fail (object != NULL);
-        g_return_if_fail (IS_PRINT_DIALOG (object));
+	LOG ("print_dialog_print")
 
-	dialog = PRINT_DIALOG (object);
+	g_return_if_fail (dialog->priv->embed != NULL);
 
-        g_return_if_fail (dialog->priv != NULL);
+	/* FIXME: once we have custom nb pages for them,
+	 * translate the margin/header/footer/colour/... settings to the config */
 
-        g_free (dialog->priv);
+	config = gnome_print_config_dup (global_config);
 
-        G_OBJECT_CLASS (parent_class)->finalize (object);
-}
+	/* FIXME: use env var for temp file directory */
+	path = g_build_filename ("/tmp",
+				 "epiphany-print-XXXXXX",
+				 NULL);
+	tempfile = ephy_file_tmp_filename (path, "ps");
+	g_free (path);
 
-EphyDialog *
-print_dialog_new (EphyEmbed *embed,
-		  EmbedPrintInfo **ret_info)
-{
-	PrintDialog *dialog;
+	g_object_set_data_full (G_OBJECT (config), "tempfile", tempfile,
+				(GDestroyNotify) g_free);
+
+	g_object_set_data (G_OBJECT (config), "callback", (GSourceFunc) printing_done_cb);
 
-	dialog = PRINT_DIALOG (g_object_new (PRINT_DIALOG_TYPE,
-				     "embed", embed,
-				     NULL));
+	ephy_embed_print (dialog->priv->embed, G_OBJECT (config), preview);
 
-	if (!embed) dialog->only_collect_info = TRUE;
-	dialog->ret_info = ret_info;
+	g_object_unref (config);
 
-	return EPHY_DIALOG(dialog);
+	if (preview)
+	{
+	        g_signal_emit (G_OBJECT (dialog), signals[PREVIEW], 0);
+	}
 }
 
-EphyDialog *
-print_dialog_new_with_parent (GtkWidget *window,
-			      EphyEmbed *embed,
-			      EmbedPrintInfo **ret_info)
+static void
+print_dialog_save_config (PrintDialog *dialog)
 {
-	PrintDialog *dialog;
+	// char *string;
 
-	dialog = PRINT_DIALOG (g_object_new (PRINT_DIALOG_TYPE,
-				     "embed", embed,
-				     "ParentWindow", window,
-				     NULL));
+	// string = gnome_print_config_to_string (global_config, 0);
+	// how to write config to file?
+	// g_free (string);
+}
 
-	if (!embed) dialog->only_collect_info = TRUE;
-	dialog->ret_info = ret_info;
+static void
+response_cb (GtkWidget *widget, int response_id, PrintDialog *dialog)
+{
+	LOG ("response_cb")
+
+	switch (response_id)
+	{
+		case GNOME_PRINT_DIALOG_RESPONSE_PRINT:
+			print_dialog_print (dialog, FALSE);
+			print_dialog_save_config (dialog);
+			break;
+		case GNOME_PRINT_DIALOG_RESPONSE_PREVIEW:
+			print_dialog_print (dialog, TRUE);
+			print_dialog_save_config (dialog);
+			break;
+	}
 
-	return EPHY_DIALOG(dialog);
+	gtk_widget_destroy (widget);
 }
 
-void
-print_free_info (EmbedPrintInfo *info)
+static void
+impl_show (GtkWidget *widget)
 {
-	g_free (info->printer);
-	g_free (info->file);
-	g_free (info->paper);
-	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 EmbedPrintInfo *
-print_get_info (EphyDialog *dialog)
-{
-	EmbedPrintInfo *info;
-	GValue print_to_file = {0, };
-	GValue printer = {0, };
-	GValue file = {0, };
-	GValue top_margin = {0, };
-	GValue bottom_margin = {0, };
-	GValue left_margin = {0, };
-	GValue right_margin = {0, };
-	GValue from_page = {0, };
-	GValue to_page = {0, };
-	GValue paper = {0, };
-	GValue pages = {0, };
-	GValue print_color = {0, };
-	GValue orientation = {0, };
-	GValue page_title = {0, };
-	GValue page_url = {0, };
-	GValue date = {0, };
-	GValue page_numbers = {0, };
-
-	info = g_new0 (EmbedPrintInfo, 1);
-
-	ephy_dialog_get_value (dialog, PRINTON_PROP, &print_to_file);
-	info->print_to_file = g_value_get_int (&print_to_file);
-	g_value_unset (&print_to_file);
-
-	ephy_dialog_get_value (dialog, PRINTER_PROP, &printer);
-	info->printer = g_strdup (g_value_get_string (&printer));
-	g_value_unset (&printer);
-
-	ephy_dialog_get_value (dialog, FILE_PROP, &file);
-	info->file = gnome_vfs_expand_initial_tilde (g_value_get_string (&file));
-	g_value_unset (&file);
-
-	ephy_dialog_get_value (dialog, BOTTOM_PROP, &bottom_margin);
-	info->bottom_margin = g_value_get_float (&bottom_margin);
-	g_value_unset (&bottom_margin);
-
-	ephy_dialog_get_value (dialog, LEFT_PROP, &left_margin);
-	info->left_margin = g_value_get_float (&left_margin);
-	g_value_unset (&left_margin);
-
-	ephy_dialog_get_value (dialog, TOP_PROP, &top_margin);
-	info->top_margin = g_value_get_float (&top_margin);
-	g_value_unset (&top_margin);
-
-	ephy_dialog_get_value (dialog, RIGHT_PROP, &right_margin);
-	info->right_margin = g_value_get_float (&right_margin);
-	g_value_unset (&right_margin);
-
-	ephy_dialog_get_value (dialog, FROM_PROP, &from_page);
-	info->from_page = g_value_get_float (&from_page);
-	g_value_unset (&from_page);
-
-	ephy_dialog_get_value (dialog, TO_PROP, &to_page);
-	info->to_page = g_value_get_float (&to_page);
-	g_value_unset (&to_page);
-
-	ephy_dialog_get_value (dialog, PAPER_PROP, &paper);
-	info->paper = g_strdup (paper_format_enum[g_value_get_int (&paper)]);
-	g_value_unset (&paper);
-
-	ephy_dialog_get_value (dialog, ALL_PAGES_PROP, &pages);
-	info->pages = g_value_get_int (&pages);
-	g_value_unset (&pages);
-
-	ephy_dialog_get_value (dialog, COLOR_PROP, &print_color);
-	info->print_color = !g_value_get_int (&print_color);
-	g_value_unset (&print_color);
-
-	ephy_dialog_get_value (dialog, ORIENTATION_PROP, &orientation);
-	info->orientation = g_value_get_int (&orientation);
-	g_value_unset (&orientation);
-
-	info->frame_type = 0;
-
-	ephy_dialog_get_value (dialog, PAGE_TITLE_PROP, &page_title);
-	info->header_left_string = g_value_get_boolean (&page_title) ?
-				   g_strdup ("&T") : g_strdup ("");
-	g_value_unset (&page_title);
-
-	ephy_dialog_get_value (dialog, PAGE_URL_PROP, &page_url);
-	info->header_right_string = g_value_get_boolean (&page_url) ?
-				    g_strdup ("&U") : g_strdup ("");
-	g_value_unset (&page_url);
-
-	ephy_dialog_get_value (dialog, PAGE_NUMBERS_PROP, &page_numbers);
-	info->footer_left_string = g_value_get_boolean (&page_numbers) ?
-				   g_strdup ("&PT") : g_strdup ("");
-	g_value_unset (&page_numbers);
-
-	ephy_dialog_get_value (dialog, DATE_PROP, &date);
-	info->footer_right_string = g_value_get_boolean (&date) ?
-				    g_strdup ("&D") : g_strdup ("");
-	g_value_unset (&date);
-
-	info->header_center_string = g_strdup("");
-	info->footer_center_string = g_strdup("");
+	/* now construct the beast */
+
+	gnome_print_dialog_construct (GNOME_PRINT_DIALOG (widget),
+				      (const guchar *) _("Print"),
+				      GNOME_PRINT_DIALOG_RANGE |
+				      GNOME_PRINT_DIALOG_COPIES);
+
+	gnome_print_dialog_construct_range_page (GNOME_PRINT_DIALOG (widget),
+						 GNOME_PRINT_RANGE_ALL |
+						 GNOME_PRINT_RANGE_RANGE |
+						 GNOME_PRINT_RANGE_SELECTION,
+						 1,
+						 1,
+						 NULL,
+						 _("Pages"));
+
+	/* FIXME: append custom notebook page for
+	   margins, headers, footers, colour/grayscale, etc. */
 
-	return info;
+	g_signal_connect (G_OBJECT (widget), "response",
+			  G_CALLBACK (response_cb), widget);
+
+	GTK_WIDGET_CLASS (parent_class)->show (widget);
 }
 
 static void
-print_dialog_print (EphyDialog *dialog)
+print_init_config (void)
 {
-	EmbedPrintInfo *info;
-	EphyEmbed *embed;
-
-	info = print_get_info (dialog);
+	char *config_string;
+	gsize len;
+	
+	/* FIXME: we need to unref global_config and g_free confi_file
+	 * somewhere on exit...
+	 */
+
+	config_file = g_build_filename (ephy_dot_dir (),
+					PRINT_CONFIG_FILENAME,
+					NULL);
 
-	if(PRINT_DIALOG(dialog)->only_collect_info && PRINT_DIALOG(dialog)->ret_info)
+	if (g_file_get_contents (config_file, &config_string, &len, NULL))
 	{
-		*(PRINT_DIALOG(dialog)->ret_info) = info;
+		LOG ("loading from string")
+
+		global_config = gnome_print_config_from_string (config_string, 0);
+
+		g_free (config_string);
 	}
-	else
+
+	if (global_config == NULL)
 	{
-		embed = ephy_embed_dialog_get_embed
-			(EPHY_EMBED_DIALOG(dialog));
-		g_return_if_fail (embed != NULL);
+		LOG ("setting default config")
 
-		info->preview = FALSE;
-		ephy_embed_print (embed, info);
-		print_free_info (info);
+		global_config = gnome_print_config_default ();
 	}
 
-	g_object_unref (G_OBJECT(dialog));
+	g_assert (global_config != NULL);
 }
 
 static void
-print_dialog_preview (EphyDialog *dialog)
+print_dialog_class_init (PrintDialogClass *klass)
 {
-	EmbedPrintInfo *info;
-	EphyEmbed *embed;
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+        parent_class = g_type_class_peek_parent (klass);
 
-	info = print_get_info (dialog);
+        object_class->finalize = print_dialog_finalize;
+	object_class->set_property = print_dialog_set_property;
+	object_class->get_property = print_dialog_get_property;
 
-	if(PRINT_DIALOG(dialog)->only_collect_info && PRINT_DIALOG(dialog)->ret_info)
+	widget_class->show = impl_show;
+
+	signals[PREVIEW] =
+                g_signal_new ("preview",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_FIRST,
+                              G_STRUCT_OFFSET (PrintDialogClass, preview),
+                              NULL, NULL,
+                              g_cclosure_marshal_VOID__VOID,
+                              G_TYPE_NONE,
+                              0);
+
+	g_object_class_install_property (object_class,
+					 PROP_EMBED,
+                                         g_param_spec_object ("embed",
+                                                              "Embed",
+                                                              "The dialog's embed",
+                                                              G_TYPE_OBJECT,
+                                                              G_PARAM_READWRITE));
+
+	g_type_class_add_private (object_class, sizeof (PrintDialogPrivate));
+
+	print_init_config ();
+}
+
+static void
+sync_page_change (EphyEmbed *embed, PrintDialog *dialog)
+{
+	char *title, *embed_title;
+
+	ephy_embed_get_title (embed, &embed_title);
+	if (embed_title && embed_title[0] != '\0')
 	{
-		*(PRINT_DIALOG(dialog)->ret_info) = info;
+		title = g_strdup_printf ("Print \"%s\"", embed_title);
 	}
 	else
 	{
-		embed = ephy_embed_dialog_get_embed
-			(EPHY_EMBED_DIALOG(dialog));
-		g_return_if_fail (embed != NULL);
-
-		info->preview = TRUE;
-		ephy_embed_print (embed, info);
-		print_free_info (info);
+		title = g_strdup ("Print");
 	}
-	g_signal_emit (G_OBJECT (dialog), print_dialog_signals[PREVIEW], 0);
 
-	g_object_unref (G_OBJECT(dialog));
+	gtk_window_set_title (GTK_WINDOW (dialog), title);
+
+	g_free (title);
+	g_free (embed_title);
 }
 
-void
-print_cancel_button_cb (GtkWidget *widget,
-			EphyDialog *dialog)
+static void
+unset_embed (PrintDialog *dialog)
 {
-	g_object_unref (G_OBJECT(dialog));
+	if (dialog->priv->embed != NULL)
+	{
+		g_signal_handlers_disconnect_by_func (dialog->priv->embed,
+						      G_CALLBACK (sync_page_change),
+						      dialog);
+
+		g_object_remove_weak_pointer (G_OBJECT (dialog->priv->embed),
+					      (gpointer *)&dialog->priv->embed);
+
+		dialog->priv->embed = NULL;
+	}
 }
 
 void
-print_ok_button_cb (GtkWidget *widget,
-		    EphyDialog *dialog)
+print_dialog_set_embed (PrintDialog *dialog, EphyEmbed *embed)
 {
-	print_dialog_print (dialog);
+	g_return_if_fail (IS_EPHY_EMBED (embed));
+
+	unset_embed (dialog);
+	dialog->priv->embed = embed;
+
+	sync_page_change (embed, dialog);
+	g_signal_connect (G_OBJECT (embed), "ge_title",
+			  G_CALLBACK (sync_page_change), dialog);
+
+	g_object_add_weak_pointer (G_OBJECT (embed),
+				   (gpointer *)&dialog->priv->embed);
 }
 
-void
-print_preview_button_cb (GtkWidget *widget,
-		         EphyDialog *dialog)
+static void
+print_dialog_init (PrintDialog *dialog)
 {
-	//FIXME: Don't show preview button at all.
-	if(!(PRINT_DIALOG(dialog)->only_collect_info))
-		print_dialog_preview (dialog);
+	LOG ("PrintDialog initialising %p", dialog)
+
+	dialog->priv = PRINT_DIALOG_GET_PRIVATE (dialog);
+
+	dialog->priv->embed = NULL;
+
+	/* NOTE: we can't construct the dialogue here, because, you've
+	 * guessed it, libgnomeprintui sucks.
+	 */
 }
 
+static void
+print_dialog_finalize (GObject *object)
+{
+	PrintDialog *dialog = PRINT_DIALOG (object);
 
+	unset_embed (dialog);
+
+	LOG ("PrintDialog finalised %p", object)
+
+        G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+PrintDialog *
+print_dialog_new (EphyEmbed *embed)
+{
+	PrintDialog *dialog;
+
+	dialog = PRINT_DIALOG (g_object_new (EPHY_TYPE_PRINT_DIALOG,
+						  "embed", embed,
+						  NULL));
+
+	g_object_set (G_OBJECT (dialog), "print_config", global_config, NULL);
+
+	return dialog;
+}
+
+PrintDialog *
+print_dialog_new_with_parent (GtkWidget *parent, EphyEmbed *embed)
+{
+	PrintDialog *dialog;
+	
+	dialog = print_dialog_new (embed);
+
+	gtk_window_set_transient_for (GTK_WINDOW (dialog),
+				      GTK_WINDOW (parent));
+
+	return dialog;
+}
Index: embed/print-dialog.h
===================================================================
RCS file: /cvs/gnome/epiphany/embed/print-dialog.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 print-dialog.h
--- embed/print-dialog.h	30 Dec 2002 19:25:20 -0000	1.1.1.1
+++ embed/print-dialog.h	28 Aug 2003 17:55:59 -0000
@@ -1,5 +1,7 @@
 /*
+ *  Copyright (C) 2000, 2001, 2002 Marco Pesenti Gritti
  *  Copyright (C) 2002 Jorn Baayen
+ *  Copyright (C) 2003 Christian Persch
  *
  *  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
@@ -14,58 +16,58 @@
  *  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 PRINT_DIALOG_H
 #define PRINT_DIALOG_H
 
-#include "ephy-embed-dialog.h"
 #include "ephy-embed.h"
 
 #include <glib-object.h>
 #include <glib.h>
 
-G_BEGIN_DECLS
+#include <libgnomeprintui/gnome-print-dialog.h>
 
-typedef struct PrintDialog PrintDialog;
-typedef struct PrintDialogClass PrintDialogClass;
+// FIXME: SUCK SUCK! libgnomeprint[ui] sucks in so many different ways... :(
+#include "gnome-print-dialog-private.h"
 
-#define PRINT_DIALOG_TYPE             (print_dialog_get_type ())
-#define PRINT_DIALOG(obj)             (GTK_CHECK_CAST ((obj), PRINT_DIALOG_TYPE, PrintDialog))
-#define PRINT_DIALOG_CLASS(klass)     (GTK_CHECK_CLASS_CAST ((klass), PRINT_DIALOG, PrintDialogClass))
-#define IS_PRINT_DIALOG(obj)          (GTK_CHECK_TYPE ((obj), PRINT_DIALOG_TYPE))
-#define IS_PRINT_DIALOG_CLASS(klass)  (GTK_CHECK_CLASS_TYPE ((klass), PRINT_DIALOG))
+G_BEGIN_DECLS
 
-typedef struct PrintDialogPrivate PrintDialogPrivate;
+#define EPHY_TYPE_PRINT_DIALOG		  (print_dialog_get_type ())
+#define PRINT_DIALOG(obj)		  (G_TYPE_CHECK_INSTANCE_CAST ((obj), EPHY_TYPE_PRINT_DIALOG, PrintDialog))
+#define PRINT_DIALOG_CLASS(klass)	  (G_TYPE_CHECK_CLASS_CAST ((klass), PRINT_DIALOG, PrintDialogClass))
+#define EPHY_IS_PRINT_DIALOG(obj)	  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EPHY_TYPE_PRINT_DIALOG))
+#define EPHY_IS_PRINT_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PRINT_DIALOG))
+#define PRINT_DIALOG_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), EPHY_TYPE_PRINT_DIALOG, PrintDialogClass))
+
+typedef struct PrintDialog 		PrintDialog;
+typedef struct PrintDialogClass	PrintDialogClass;
+typedef struct PrintDialogPrivate	PrintDialogPrivate;
 
 struct PrintDialog
 {
-        EphyEmbedDialog parent;
+        GnomePrintDialog parent;
         PrintDialogPrivate *priv;
-        //FIXME: These should be gobject properties
-        gboolean only_collect_info;
-        EmbedPrintInfo **ret_info;
 };
 
 struct PrintDialogClass
 {
-        EphyEmbedDialogClass parent_class;
+        GnomePrintDialogClass parent;
 
-	void (* preview)    (PrintDialog *dialog);
+	void (* preview)	(PrintDialog *dialog);
 };
 
 GType		print_dialog_get_type		(void);
 
-EphyDialog     *print_dialog_new		(EphyEmbed *embed,
-						 EmbedPrintInfo **ret_info);
-
-EphyDialog     *print_dialog_new_with_parent	(GtkWidget *window,
-						 EphyEmbed *embed,
-						 EmbedPrintInfo **ret_info);
+PrintDialog *	print_dialog_new		(EphyEmbed *embed);
 
-gboolean	print_dialog_is_preview		(PrintDialog *dialog);
+PrintDialog *	print_dialog_new_with_parent	(GtkWidget *window,
+						 EphyEmbed *embed);
 
-void		print_free_info			(EmbedPrintInfo *info);
+void		print_dialog_set_embed		(PrintDialog *dialog,
+						 EphyEmbed *embed);
 
 G_END_DECLS
 
Index: embed/mozilla/EphyWrapper.cpp
===================================================================
RCS file: /cvs/gnome/epiphany/embed/mozilla/EphyWrapper.cpp,v
retrieving revision 1.17
diff -u -p -r1.17 EphyWrapper.cpp
--- embed/mozilla/EphyWrapper.cpp	23 Aug 2003 19:49:56 -0000	1.17
+++ embed/mozilla/EphyWrapper.cpp	28 Aug 2003 17:56:00 -0000
@@ -18,6 +18,7 @@
 
 #include "EphyWrapper.h"
 #include "GlobalHistory.h"
+#include "MozillaPrivate.h"
 #include "ProgressListener.h"
 #include "ephy-embed.h"
 #include "ephy-string.h"
@@ -68,6 +69,7 @@
 #include "nsIPresContext.h"
 #include "ContentHandler.h"
 #include "EphyEventListener.h"
+#include "PrintProgressListener.h"
 
 EphyWrapper::EphyWrapper ()
 {
@@ -179,10 +181,15 @@ nsresult EphyWrapper::GetDocShell (nsIDo
         
         return NS_OK;
 }
-nsresult EphyWrapper::Print (nsIPrintSettings *options, PRBool preview)
+
+nsresult EphyWrapper::Print (GObject *config, PRBool preview)
 {
 	nsresult result;
 
+	nsCOMPtr<nsIPrintSettings> options;
+	result = GetPrintSettings(getter_AddRefs(options));
+	if (NS_FAILED (result) || !options) return NS_ERROR_FAILURE;
+
 	nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(mWebBrowser, &result));
 	if (NS_FAILED(result) || !print) return NS_ERROR_FAILURE;
 
@@ -190,13 +197,20 @@ nsresult EphyWrapper::Print (nsIPrintSet
 	result = mWebBrowser->GetContentDOMWindow (getter_AddRefs(DOMWindow));
 	if (NS_FAILED(result) || !DOMWindow) return NS_ERROR_FAILURE;
 
-	if (!preview)
+	result = MozillaCollatePrintSettings (options, config, preview);
+	if (NS_FAILED (result)) return NS_ERROR_FAILURE;
+
+	GPrintListener *listener;
+	listener = new GPrintListener (config, preview);
+	if (!listener) return NS_ERROR_FAILURE;
+
+	if (preview)
 	{
-		result = print->Print (options, nsnull);
+		result = print->PrintPreview(options, nsnull, listener);
 	}
 	else
 	{
-		result = print->PrintPreview(options, nsnull, nsnull);
+		result = print->Print (options, listener);
 	}
 
 	return result;
Index: embed/mozilla/EphyWrapper.h
===================================================================
RCS file: /cvs/gnome/epiphany/embed/mozilla/EphyWrapper.h,v
retrieving revision 1.7
diff -u -p -r1.7 EphyWrapper.h
--- embed/mozilla/EphyWrapper.h	17 Aug 2003 15:29:53 -0000	1.7
+++ embed/mozilla/EphyWrapper.h	28 Aug 2003 17:56:00 -0000
@@ -48,7 +48,7 @@ public:
 	nsresult SetZoom (float aTextZoom, PRBool reflow);
 	nsresult GetZoom (float *aTextZoom);
 
-	nsresult Print (nsIPrintSettings *options, PRBool preview);
+	nsresult Print (GObject *config, PRBool preview);
 	nsresult GetPrintSettings (nsIPrintSettings * *options);
 	nsresult PrintPreviewClose (void);
 	nsresult PrintPreviewNumPages (int *numPages);
Index: embed/mozilla/EventContext.cpp
===================================================================
RCS file: /cvs/gnome/epiphany/embed/mozilla/EventContext.cpp,v
retrieving revision 1.10
diff -u -p -r1.10 EventContext.cpp
--- embed/mozilla/EventContext.cpp	5 Aug 2003 15:53:45 -0000	1.10
+++ embed/mozilla/EventContext.cpp	28 Aug 2003 17:56:01 -0000
@@ -609,7 +609,7 @@ nsresult EventContext::GetMouseEventInfo
 {
 	nsresult result;
 
-	/* casting 32-bit guint* to PRUint16* below will break on big-endian */
+	/* FIXME: casting 32-bit guint* to PRUint16* below will break on big-endian */
 	PRUint16 btn;
 	aMouseEvent->GetButton (&btn);
 
Index: embed/mozilla/Makefile.am
===================================================================
RCS file: /cvs/gnome/epiphany/embed/mozilla/Makefile.am,v
retrieving revision 1.19
diff -u -p -r1.19 Makefile.am
--- embed/mozilla/Makefile.am	23 Aug 2003 17:06:24 -0000	1.19
+++ embed/mozilla/Makefile.am	28 Aug 2003 17:56:02 -0000
@@ -73,6 +73,8 @@ libephymozillaembed_la_SOURCES = 	\
 	MozRegisterComponents.h         \
 	PrintingPromptService.cpp	\
 	PrintingPromptService.h		\
+	PrintProgressListener.cpp	\
+	PrintProgressListener.h		\
 	ProgressListener.cpp		\
 	ProgressListener.h		\
 	mozilla-embed.cpp	        \
Index: embed/mozilla/MozillaPrivate.cpp
===================================================================
RCS file: /cvs/gnome/epiphany/embed/mozilla/MozillaPrivate.cpp,v
retrieving revision 1.4
diff -u -p -r1.4 MozillaPrivate.cpp
--- embed/mozilla/MozillaPrivate.cpp	15 Aug 2003 10:11:27 -0000	1.4
+++ embed/mozilla/MozillaPrivate.cpp	28 Aug 2003 17:56:02 -0000
@@ -6,6 +6,10 @@
 #include <nsIWebBrowserChrome.h>
 #include <gtkmozembed.h>
 
+#include "ephy-debug.h"
+
+#include <libgnomeprint/gnome-print-config.h>
+
 GtkWidget *MozillaFindGtkParent (nsIDOMWindow *aDOMWindow)
 {
         nsresult result;
@@ -37,55 +41,122 @@ GtkWidget *MozillaFindGtkParent (nsIDOMW
 	return gtk_widget_get_toplevel (GTK_WIDGET(mozembed));
 }
 
-#define MM_TO_INCH(x)		(((double) x) / 25.4)
+#define SUCK (const guchar*)
 
-NS_METHOD MozillaCollatePrintSettings (const EmbedPrintInfo *info,
-				       nsIPrintSettings *options)
+NS_METHOD MozillaCollatePrintSettings (nsIPrintSettings *options,
+				       GObject *config_object,
+				       gboolean preview)
 {
-	const static int frame_types[] = {
-                nsIPrintSettings::kFramesAsIs,
-                nsIPrintSettings::kSelectedFrame,
-                nsIPrintSettings::kEachFrameSep
-        };
-
+	GnomePrintConfig *config;
+	nsresult result;
+	char *string, *tmp;
+	double value;
+	const GnomePrintUnit *unit, *inch, *mm;
 
-        switch (info->pages)
-        {
-        case 0:
-		options->SetPrintRange (nsIPrintSettings::kRangeAllPages);
-                break;
-        case 1:
-                options->SetPrintRange (nsIPrintSettings::kRangeSpecifiedPageRange);
-                options->SetStartPageRange (info->from_page);
-                options->SetEndPageRange (info->to_page);
-                break;
-        case 2:
-                options->SetPrintRange (nsIPrintSettings::kRangeSelection);
-                break;
-        }
+	g_return_val_if_fail (GNOME_IS_PRINT_CONFIG (config_object), NS_ERROR_FAILURE);
+	config = GNOME_PRINT_CONFIG (config_object);
 
-        options->SetMarginTop (MM_TO_INCH (info->top_margin));
-        options->SetMarginBottom (MM_TO_INCH (info->bottom_margin));
-        options->SetMarginLeft (MM_TO_INCH (info->left_margin));
-        options->SetMarginRight (MM_TO_INCH (info->right_margin));
-
-        options->SetPrinterName(NS_LITERAL_STRING("PostScript/default").get());
+	/**
+	 * translate the print settings from the GnomePrintConfig to mozilla.
+	 * For references see
+	 * http://lxr.mozilla.org/seamonkey/source/gfx/idl/nsIPrintSettings.idl
+	 */
 
-        options->SetHeaderStrLeft(NS_ConvertUTF8toUCS2(info->header_left_string).get());
+	mm = gnome_print_unit_get_by_abbreviation (SUCK "mm");
+	inch = gnome_print_unit_get_by_abbreviation (SUCK "in");
+	g_assert (mm != NULL && inch != NULL);
+
+	/* top margin */
+	if (gnome_print_config_get_length (config,
+					  SUCK GNOME_PRINT_KEY_PAGE_MARGIN_TOP,
+					  &value, &unit)
+	   && gnome_print_convert_distance (&value, unit, inch))
+	{
+		LOG ("Margin top=%f in", value)
+		options->SetMarginTop (value);	
+	}
 
-        options->SetHeaderStrCenter(NS_ConvertUTF8toUCS2(info->header_center_string).get());
+	/* bottom margin */
+	if (gnome_print_config_get_length (config,
+					  SUCK GNOME_PRINT_KEY_PAGE_MARGIN_BOTTOM,
+					  &value, &unit)
+	   && gnome_print_convert_distance (&value, unit, inch))
+	{
+		LOG ("Margin bottom=%f in", value)
+		options->SetMarginBottom (value);	
+	}
 
-        options->SetHeaderStrRight(NS_ConvertUTF8toUCS2(info->header_right_string).get());
+	/* left margin */
+	if (gnome_print_config_get_length (config,
+					  SUCK GNOME_PRINT_KEY_PAGE_MARGIN_LEFT,
+					  &value, &unit)
+	   && gnome_print_convert_distance (&value, unit, inch))
+	{
+		LOG ("Margin left=%f in", value)
+		options->SetMarginLeft (value);	
+	}
 
-        options->SetFooterStrLeft(NS_ConvertUTF8toUCS2(info->footer_left_string).get());
+	/* right margin */
+	if (gnome_print_config_get_length (config,
+					  SUCK GNOME_PRINT_KEY_PAGE_MARGIN_RIGHT,
+					  &value, &unit)
+	   && gnome_print_convert_distance (&value, unit, inch))
+	{
+		LOG ("Margin right=%f in", value)
+		options->SetMarginRight (value);	
+	}
 
-        options->SetFooterStrCenter(NS_ConvertUTF8toUCS2(info->footer_center_string).get());
+	/* paper size */
+	options->SetPaperSize (nsIPrintSettings::kPaperSizeDefined);
+	options->SetPaperSizeUnit (nsIPrintSettings::kPaperSizeMillimeters);
+
+	if (gnome_print_config_get_length (config,
+					  SUCK GNOME_PRINT_KEY_PAPER_WIDTH,
+					  &value, &unit)
+	   && gnome_print_convert_distance (&value, unit, mm))
+	{
+		LOG ("Paper width=%f mm", value)
+		options->SetPaperWidth(value);	
+	}
 
-        options->SetFooterStrRight(NS_ConvertUTF8toUCS2(info->footer_right_string).get());
+	if (gnome_print_config_get_length (config,
+					  SUCK GNOME_PRINT_KEY_PAPER_HEIGHT,
+					  &value, &unit)
+	   && gnome_print_convert_distance (&value, unit, mm))
+	{
+		LOG ("Paper height=%f mm", value)
+		options->SetPaperHeight(value);	
+	}
 
-        options->SetToFileName (NS_ConvertUTF8toUCS2(info->file).get());
+	/* paper name */
+	string = (char *) gnome_print_config_get (config, SUCK GNOME_PRINT_KEY_PAPER_SIZE);
+	LOG ("Paper name=%s", string)
+	options->SetPaperName (NS_ConvertUTF8toUCS2(string).get());
+	g_free (string);
+
+	/* paper orientation */
+	string = (char *) gnome_print_config_get (config, SUCK GNOME_PRINT_KEY_ORIENTATION);
+	if (string == NULL) string = g_strdup ("R0");
 
-	options->SetPrintCommand (NS_ConvertUTF8toUCS2(info->printer).get());
+	if (strncmp (string, "R90", 3) == 0 || strncmp (string, "R270", 4) == 0)
+	{
+		LOG ("Orientation landscape")
+		options->SetOrientation (nsIPrintSettings::kLandscapeOrientation);
+	}
+	else
+	{
+		LOG ("Orientation portrait")
+		options->SetOrientation (nsIPrintSettings::kPortraitOrientation);
+	}
+	g_free (string);
+	
+	/* misc options */
+	options->SetPrintSilent (PR_TRUE);
+	options->SetPrintFrameType (nsIPrintSettings::kFramesAsIs);
+
+	/* printer */
+	// FIXME how to use xprint backend if available
+        options->SetPrinterName (NS_LITERAL_STRING("PostScript/default").get());
 
 	/**
 	 * Work around a mozilla bug where paper size & orientation are ignored
@@ -93,22 +164,55 @@ NS_METHOD MozillaCollatePrintSettings (c
 	 * in print preview mode if we set "print to file" to true.
 	 * See epiphany bug #119818.
 	 */
-	if (info->preview)
+
+	if (preview)
 	{
 		options->SetPrintToFile (PR_FALSE);
 	}
 	else
 	{
-		options->SetPrintToFile (info->print_to_file);
+		const char *tempfile;
+
+	       	options->SetPrintToFile (PR_TRUE);
+
+		// FIXME can we get the tempfilename from a gnomeprintconfig key?
+		tempfile = (const char*) g_object_get_data (G_OBJECT (config), "tempfile");
+		g_return_val_if_fail (tempfile != NULL, NS_ERROR_FAILURE);
+
+		options->SetToFileName (NS_ConvertUTF8toUCS2(tempfile).get());
 	}
 
-	/* native paper size formats. Our dialog does not support custom yet */
-	options->SetPaperSize (nsIPrintSettings::kPaperSizeNativeData);
-	options->SetPaperName (NS_ConvertUTF8toUCS2(info->paper).get());
+	/* FIXME make this configurable again */
+	options->SetPrintInColor (PR_TRUE);
+	
+	/* FIXME: page range, copies, header, footer, background img/colour */
+	
+        //~ switch (info->pages)
+        //~ {
+        //~ case 0:
+		//~ options->SetPrintRange (nsIPrintSettings::kRangeAllPages);
+                //~ break;
+        //~ case 1:
+                //~ options->SetPrintRange (nsIPrintSettings::kRangeSpecifiedPageRange);
+                //~ options->SetStartPageRange (info->from_page);
+                //~ options->SetEndPageRange (info->to_page);
+                //~ break;
+        //~ case 2:
+                //~ options->SetPrintRange (nsIPrintSettings::kRangeSelection);
+                //~ break;
+        //~ }
+
+        //~ options->SetHeaderStrLeft(NS_ConvertUTF8toUCS2(info->header_left_string).get());
+
+        //~ options->SetHeaderStrCenter(NS_ConvertUTF8toUCS2(info->header_center_string).get());
+
+        //~ options->SetHeaderStrRight(NS_ConvertUTF8toUCS2(info->header_right_string).get());
+
+        //~ options->SetFooterStrLeft(NS_ConvertUTF8toUCS2(info->footer_left_string).get());
+
+        //~ options->SetFooterStrCenter(NS_ConvertUTF8toUCS2(info->footer_center_string).get());
 
-        options->SetPrintInColor (info->print_color);
-        options->SetOrientation (info->orientation);
-        options->SetPrintFrameType (frame_types[info->frame_type]);
+        //~ options->SetFooterStrRight(NS_ConvertUTF8toUCS2(info->footer_right_string).get());
 
 	return NS_OK;
 }
Index: embed/mozilla/MozillaPrivate.h
===================================================================
RCS file: /cvs/gnome/epiphany/embed/mozilla/MozillaPrivate.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 MozillaPrivate.h
--- embed/mozilla/MozillaPrivate.h	30 Dec 2002 19:26:21 -0000	1.1.1.1
+++ embed/mozilla/MozillaPrivate.h	28 Aug 2003 17:56:02 -0000
@@ -1,9 +1,12 @@
 #include <nsIPrintSettings.h>
 #include <nsIDOMWindow.h>
 
-#include "ephy-embed.h"
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtkwidget.h>
 
 GtkWidget *MozillaFindGtkParent (nsIDOMWindow *aDOMWindow);
 
-NS_METHOD MozillaCollatePrintSettings (const EmbedPrintInfo *info,
-				       nsIPrintSettings *settings);
+NS_METHOD MozillaCollatePrintSettings (nsIPrintSettings *options,
+				       GObject *config_object,
+				       gboolean preview);
Index: embed/mozilla/PrintProgressListener.cpp
===================================================================
RCS file: /cvs/gnome/epiphany/embed/mozilla/Attic/PrintProgressListener.cpp,v
retrieving revision 1.1
diff -u -p -r1.1 PrintProgressListener.cpp
--- embed/mozilla/PrintProgressListener.cpp	30 Dec 2002 19:26:11 -0000	1.1
+++ embed/mozilla/PrintProgressListener.cpp	28 Aug 2003 17:56:02 -0000
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2002 Philip Langdale
+ *  Copyright (C) 2003 Christian Persch
  *
  *  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
@@ -14,35 +15,47 @@
  *  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 "libgnomevfs/gnome-vfs-mime-handlers.h"
-
-/* see the FIXME below */
-#include <locale.h>
-
-#include <libgnome/gnome-exec.h>
-
 #include "PrintProgressListener.h"
 
+#include "ephy-debug.h"
 
 NS_IMPL_ISUPPORTS1(GPrintListener, nsIWebProgressListener)
 
 GPrintListener::GPrintListener()
 {
+	LOG ("GPrintListener")
+
 	NS_INIT_ISUPPORTS();
-	mFilename = NULL;
+	mConfig = nsnull;
+	mPreview = PR_TRUE;
 }
 
-GPrintListener::GPrintListener(char *filename)
+GPrintListener::GPrintListener(GObject *aConfig, PRBool aPreview)
 {
 	GPrintListener ();
-	mFilename = filename ? g_strdup (filename) : NULL;
+
+	if (aConfig)
+	{
+		g_object_ref (aConfig);
+		mConfig = aConfig;
+	}
+
+	mPreview = aPreview;
 }
 
 GPrintListener::~GPrintListener()
 {
-	g_free (mFilename);
+	LOG ("~GPrintListener")
+
+	if (mConfig)
+	{
+		g_object_unref (mConfig);
+		mConfig = nsnull;
+	}
 }
 
 /* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aStateFlags, in unsigned long aStatus); */
@@ -51,28 +64,26 @@ NS_IMETHODIMP GPrintListener::OnStateCha
 					    PRUint32 aStateFlags,
 					    PRUint32 aStatus)
 {
-	if (aStateFlags & nsIWebProgressListener::STATE_STOP)
+	LOG ("OnStateChange flags %d status %d", aStateFlags, aStatus)
+
+	if ((aStateFlags & nsIWebProgressListener::STATE_STOP) && !mPreview)
 	{
-		GnomeVFSMimeApplication *app;
-		gchar *command;
+		LOG ("STATE_STOP")
+
+		if (!mConfig) return NS_ERROR_FAILURE;
+
+		GSourceFunc callback;
+		callback = (GSourceFunc) g_object_get_data (mConfig, "callback");
 
-		/* FIXME(MOZILLA) ugly workaround for a mozilla problem with 
-		 * reseting the LC_* environment when printing */
-		setlocale(LC_ALL,"");
-		if (!mFilename) return NS_OK;
-
-		/* get the postscript handler */
-		app = gnome_vfs_mime_get_default_application
-						("application/postscript");
-		if (app)
+		if (callback)
 		{
-			command = g_strconcat (app->command, " ",
-					       mFilename, NULL);
-			gnome_execute_shell (g_get_home_dir(), command);
-			gnome_vfs_mime_application_free (app);
-			g_free (command);
+			LOG ("Calling back...")
+
+			gboolean result;
+			result = callback ((gpointer) mConfig);
+
+			return result ? NS_OK : NS_ERROR_FAILURE;
 		}
-		else return NS_ERROR_FAILURE;
 	}
 	return NS_OK;
 }
@@ -85,6 +96,10 @@ NS_IMETHODIMP GPrintListener::OnProgress
 					       PRInt32 aCurTotalProgress,
 					       PRInt32 aMaxTotalProgress)
 {
+	LOG ("OnProgressChange called: cur %d of %d, max %d of %d",
+	     aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress,
+	     aMaxTotalProgress);
+
 	return NS_OK;
 }
 
@@ -112,5 +127,3 @@ NS_IMETHODIMP GPrintListener::OnSecurity
 {
 	return NS_OK;
 }
-
-
Index: embed/mozilla/PrintProgressListener.h
===================================================================
RCS file: /cvs/gnome/epiphany/embed/mozilla/Attic/PrintProgressListener.h,v
retrieving revision 1.1
diff -u -p -r1.1 PrintProgressListener.h
--- embed/mozilla/PrintProgressListener.h	30 Dec 2002 19:26:22 -0000	1.1
+++ embed/mozilla/PrintProgressListener.h	28 Aug 2003 17:56:02 -0000
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2002 Philip Langdale
+ *  Copyright (C) 2003 Christian Persch
  *
  *  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
@@ -14,6 +15,8 @@
  *  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 __PrintProgressListener_h_
@@ -21,6 +24,8 @@
 
 #include "nsIWebProgressListener.h"
 
+#include <glib-object.h>
+
 class GPrintListener : public nsIWebProgressListener
 {
 public:
@@ -28,11 +33,12 @@ public:
 	NS_DECL_NSIWEBPROGRESSLISTENER
 
 	GPrintListener();
-	GPrintListener(char *filename);
+	GPrintListener(GObject *aConfig, PRBool aPreview);
         virtual ~GPrintListener();
 
 private:
-	char *mFilename;
+	GObject *mConfig;
+	PRBool mPreview;
 };
 
 #endif //__PrintProgressListener_h_
Index: embed/mozilla/PrintingPromptService.cpp
===================================================================
RCS file: /cvs/gnome/epiphany/embed/mozilla/PrintingPromptService.cpp,v
retrieving revision 1.3
diff -u -p -r1.3 PrintingPromptService.cpp
--- embed/mozilla/PrintingPromptService.cpp	12 Apr 2003 00:37:43 -0000	1.3
+++ embed/mozilla/PrintingPromptService.cpp	28 Aug 2003 17:56:03 -0000
@@ -22,8 +22,6 @@
 
 #include <gtk/gtkdialog.h>
 
-#include "print-dialog.h"
-#include "ephy-embed.h"
 #include "MozillaPrivate.h"
 #include "PrintingPromptService.h"
 
@@ -49,24 +47,8 @@ GPrintingPromptService::~GPrintingPrompt
 /* void showPrintDialog (in nsIDOMWindow parent, in nsIWebBrowserPrint webBrowserPrint, in nsIPrintSettings printSettings); */
 NS_IMETHODIMP GPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrint *webBrowserPrint, nsIPrintSettings *printSettings)
 {
-	EphyDialog *dialog;
-	EmbedPrintInfo *info;
-
-	GtkWidget *gtkParent = MozillaFindGtkParent(parent);
-
-	dialog = print_dialog_new_with_parent (gtkParent, NULL, &info);
-	ephy_dialog_set_modal (dialog, TRUE);
-
-	gint ret = ephy_dialog_run (dialog);
-	if(ret == GTK_RESPONSE_OK)
-	{
-		MozillaCollatePrintSettings(info, printSettings);
-		print_free_info(info);
-
-		return NS_OK;
-	}
-	else
-		return NS_ERROR_FAILURE;
+	g_warning ("ShowPrintDialog\n");
+	return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 /* 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); */
Index: embed/mozilla/mozilla-embed.cpp
===================================================================
RCS file: /cvs/gnome/epiphany/embed/mozilla/mozilla-embed.cpp,v
retrieving revision 1.29
diff -u -p -r1.29 mozilla-embed.cpp
--- embed/mozilla/mozilla-embed.cpp	18 Aug 2003 22:42:15 -0000	1.29
+++ embed/mozilla/mozilla-embed.cpp	28 Aug 2003 17:56:08 -0000
@@ -150,7 +150,8 @@ impl_set_encoding (EphyEmbed *embed,
 
 static gresult
 impl_print (EphyEmbed *embed, 
-            EmbedPrintInfo *info);
+            GObject *config,
+	    gboolean preview);
 
 static gresult
 impl_print_preview_close (EphyEmbed *embed);
@@ -1120,23 +1121,16 @@ impl_get_security_level (EphyEmbed *embe
 
 static gresult
 impl_print (EphyEmbed *embed,
-            EmbedPrintInfo *info)
+            GObject *config,
+	    gboolean preview)
 {
 	nsresult result = NS_OK;
 	EphyWrapper *wrapper;
-	
+
 	wrapper = MOZILLA_EMBED(embed)->priv->wrapper;
 	g_return_val_if_fail (wrapper != NULL, G_FAILED);
 
-        nsCOMPtr<nsIPrintSettings> options;
-        result = wrapper->GetPrintSettings(getter_AddRefs(options));
-        if (!NS_SUCCEEDED (result)) return G_FAILED;
-
-	MozillaCollatePrintSettings(info, options);
-
-        options->SetPrintSilent (PR_TRUE);
-
-	result = wrapper->Print(options, info->preview);
+	result = wrapper->Print(config, preview);
 
 	return NS_SUCCEEDED (result) ? G_OK : G_FAILED;
 }
@@ -1481,7 +1475,7 @@ mozilla_embed_dom_mouse_down_cb (GtkMozE
 	info = ephy_embed_event_new ();
 	
 	wrapper = MOZILLA_EMBED(membed)->priv->wrapper;
-	g_return_val_if_fail (wrapper != NULL, G_FAILED);
+	g_return_val_if_fail (wrapper != NULL, FALSE);
 
 	event_context.Init (wrapper);
         result = event_context.GetMouseEventInfo (static_cast<nsIDOMMouseEvent*>(dom_event), info);
