diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2004-07-11 02:45:23 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2004-07-11 02:45:23 +0800 |
commit | e3745955787160572f5bc2feb46f293c0f96894f (patch) | |
tree | 59614375b33eadad3f283fb31578d4360b788c6e | |
parent | b26c1e1243cb943f67fc42b646862919238501fc (diff) | |
download | gsoc2013-epiphany-e3745955787160572f5bc2feb46f293c0f96894f.tar.gz gsoc2013-epiphany-e3745955787160572f5bc2feb46f293c0f96894f.tar.zst gsoc2013-epiphany-e3745955787160572f5bc2feb46f293c0f96894f.zip |
Make print and print setup go trough nsIPrintingPromptService (backported
2004-07-10 Christian Persch <chpe@cvs.gnome.org>
* configure.in:
* data/glade/print.glade:
* embed/ephy-embed-single.c: (ephy_embed_single_print_setup):
* embed/ephy-embed-single.h:
* embed/ephy-embed.c: (ephy_embed_print),
(ephy_embed_set_print_preview_mode):
* embed/ephy-embed.h:
* embed/mozilla/EphyBrowser.cpp:
* embed/mozilla/EphyBrowser.h:
* embed/mozilla/MozillaPrivate.cpp:
* embed/mozilla/MozillaPrivate.h:
* embed/mozilla/PrintingPromptService.cpp:
* embed/mozilla/mozilla-embed-single.cpp:
* embed/mozilla/mozilla-embed.cpp:
* embed/print-dialog.c: (ephy_print_get_print_info),
(ephy_print_dialog_response_cb),
(ephy_print_setup_dialog_help_button_cb), (ephy_print_dialog_new):
* embed/print-dialog.h:
* src/ephy-shell.c: (ephy_shell_init), (ephy_shell_finalize),
(ephy_shell_get_prefs_dialog):
* src/ephy-shell.h:
* src/ephy-window.c: (ephy_window_delete_event_cb),
(ephy_window_finalize), (update_embed_dialogs), (ephy_window_find):
* src/ppview-toolbar.c: (toolbar_cmd_ppv_close):
* src/window-commands.c: (window_cmd_file_print_setup),
(window_cmd_file_print_preview), (window_cmd_file_print):
Make print and print setup go trough nsIPrintingPromptService
(backported from HEAD).
-rw-r--r-- | ChangeLog | 32 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | data/glade/print.glade | 1 | ||||
-rw-r--r-- | embed/ephy-embed-single.c | 7 | ||||
-rw-r--r-- | embed/ephy-embed-single.h | 3 | ||||
-rw-r--r-- | embed/ephy-embed.c | 10 | ||||
-rw-r--r-- | embed/ephy-embed.h | 49 | ||||
-rw-r--r-- | embed/mozilla/EphyBrowser.cpp | 56 | ||||
-rw-r--r-- | embed/mozilla/EphyBrowser.h | 5 | ||||
-rw-r--r-- | embed/mozilla/MozillaPrivate.cpp | 5 | ||||
-rw-r--r-- | embed/mozilla/MozillaPrivate.h | 5 | ||||
-rw-r--r-- | embed/mozilla/PrintingPromptService.cpp | 11 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed-single.cpp | 22 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed.cpp | 32 | ||||
-rwxr-xr-x | embed/print-dialog.c | 45 | ||||
-rw-r--r-- | embed/print-dialog.h | 39 | ||||
-rw-r--r-- | src/ephy-shell.c | 22 | ||||
-rw-r--r-- | src/ephy-shell.h | 2 | ||||
-rw-r--r-- | src/ephy-window.c | 58 | ||||
-rwxr-xr-x | src/ppview-toolbar.c | 2 | ||||
-rw-r--r-- | src/window-commands.c | 26 |
21 files changed, 180 insertions, 254 deletions
@@ -1,3 +1,35 @@ +2004-07-10 Christian Persch <chpe@cvs.gnome.org> + + * configure.in: + * data/glade/print.glade: + * embed/ephy-embed-single.c: (ephy_embed_single_print_setup): + * embed/ephy-embed-single.h: + * embed/ephy-embed.c: (ephy_embed_print), + (ephy_embed_set_print_preview_mode): + * embed/ephy-embed.h: + * embed/mozilla/EphyBrowser.cpp: + * embed/mozilla/EphyBrowser.h: + * embed/mozilla/MozillaPrivate.cpp: + * embed/mozilla/MozillaPrivate.h: + * embed/mozilla/PrintingPromptService.cpp: + * embed/mozilla/mozilla-embed-single.cpp: + * embed/mozilla/mozilla-embed.cpp: + * embed/print-dialog.c: (ephy_print_get_print_info), + (ephy_print_dialog_response_cb), + (ephy_print_setup_dialog_help_button_cb), (ephy_print_dialog_new): + * embed/print-dialog.h: + * src/ephy-shell.c: (ephy_shell_init), (ephy_shell_finalize), + (ephy_shell_get_prefs_dialog): + * src/ephy-shell.h: + * src/ephy-window.c: (ephy_window_delete_event_cb), + (ephy_window_finalize), (update_embed_dialogs), (ephy_window_find): + * src/ppview-toolbar.c: (toolbar_cmd_ppv_close): + * src/window-commands.c: (window_cmd_file_print_setup), + (window_cmd_file_print_preview), (window_cmd_file_print): + + Make print and print setup go trough nsIPrintingPromptService + (backported from HEAD). + 2004-07-09 Christian Persch <chpe@cvs.gnome.org> * configure.in: diff --git a/configure.in b/configure.in index 474d4c7d9..7f7d042a9 100644 --- a/configure.in +++ b/configure.in @@ -204,6 +204,8 @@ case "$MOZILLA_VERSION" in 1.7rc2) MOZILLA_SNAPSHOT=16 ;; 1.7rc3) MOZILLA_SNAPSHOT=17 ;; 1.7) MOZILLA_SNAPSHOT=17 ;; +1.7.1) MOZILLA_SNAPSHOT=17 ;; +1.7.2) MOZILLA_SNAPSHOT=17 ;; branch1.7) MOZILLA_SNAPSHOT=17 ;; 1.8a) MOZILLA_SNAPSHOT=18 ;; 1.8a1) MOZILLA_SNAPSHOT=18 ;; diff --git a/data/glade/print.glade b/data/glade/print.glade index 781242f6b..3138bcd72 100644 --- a/data/glade/print.glade +++ b/data/glade/print.glade @@ -41,7 +41,6 @@ <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> <property name="response_id">-7</property> - <signal name="clicked" handler="ephy_print_setup_dialog_close_button_cb" last_modification_time="Sat, 06 Dec 2003 10:22:18 GMT"/> </widget> </child> diff --git a/embed/ephy-embed-single.c b/embed/ephy-embed-single.c index c0303af7c..39349db85 100644 --- a/embed/ephy-embed-single.c +++ b/embed/ephy-embed-single.c @@ -156,3 +156,10 @@ ephy_embed_single_get_font_list (EphyEmbedSingle *single, EphyEmbedSingleIface *iface = EPHY_EMBED_SINGLE_GET_IFACE (single); return iface->get_font_list (single, langGroup); } + +void +ephy_embed_single_print_setup (EphyEmbedSingle *single) +{ + EphyEmbedSingleIface *iface = EPHY_EMBED_SINGLE_GET_IFACE (single); + iface->print_setup (single); +} diff --git a/embed/ephy-embed-single.h b/embed/ephy-embed-single.h index f9db7cfb9..4089f85cd 100644 --- a/embed/ephy-embed-single.h +++ b/embed/ephy-embed-single.h @@ -56,6 +56,7 @@ struct EphyEmbedSingleIface const char* url); GList * (* get_font_list) (EphyEmbedSingle *shell, const char *langGroup); + void (* print_setup) (EphyEmbedSingle *single); }; GType ephy_embed_single_get_type (void); @@ -73,6 +74,8 @@ void ephy_embed_single_load_proxy_autoconf (EphyEmbedSingle *shell, GList *ephy_embed_single_get_font_list (EphyEmbedSingle *shell, const char *langGroup); +void ephy_embed_single_print_setup (EphyEmbedSingle *single); + G_END_DECLS #endif diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c index ce7c74013..aa5acc242 100644 --- a/embed/ephy-embed.c +++ b/embed/ephy-embed.c @@ -379,18 +379,18 @@ ephy_embed_get_encoding_info (EphyEmbed *embed) } void -ephy_embed_print (EphyEmbed *embed, - EmbedPrintInfo *info) +ephy_embed_print (EphyEmbed *embed) { EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - iface->print (embed, info); + iface->print (embed); } void -ephy_embed_print_preview_close (EphyEmbed *embed) +ephy_embed_set_print_preview_mode (EphyEmbed *embed, + gboolean preview_mode) { EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - iface->print_preview_close (embed); + iface->set_print_preview_mode (embed, preview_mode); } int diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h index 0099385dd..4cfbd8922 100644 --- a/embed/ephy-embed.h +++ b/embed/ephy-embed.h @@ -76,43 +76,6 @@ typedef enum EMBED_RELOAD_FORCE = 1 << 1 } EmbedReloadFlags; -typedef struct -{ - gboolean print_to_file; - char *printer; - char *file; - char *paper; - int top_margin; - int bottom_margin; - int left_margin; - int right_margin; - int pages; - int from_page; - int to_page; - int frame_type; - int orientation; - gboolean print_color; - gboolean preview; - - /* - * &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; - typedef enum { PRINTPREVIEW_GOTO_PAGENUM = 0, @@ -216,9 +179,9 @@ struct EphyEmbedIface void (* set_encoding) (EphyEmbed *embed, const char *encoding); EphyEncodingInfo * (* get_encoding_info) (EphyEmbed *embed); - void (* print) (EphyEmbed *embed, - EmbedPrintInfo *info); - void (* print_preview_close) (EphyEmbed *embed); + void (* print) (EphyEmbed *embed); + void (* set_print_preview_mode) (EphyEmbed *embed, + gboolean mode); int (* print_preview_n_pages) (EphyEmbed *embed); void (* print_preview_navigate) (EphyEmbed *embed, EmbedPrintPreviewNavType type, @@ -304,10 +267,10 @@ void ephy_embed_set_encoding (EphyEmbed *embed, EphyEncodingInfo *ephy_embed_get_encoding_info (EphyEmbed *embed); /* Print */ -void ephy_embed_print (EphyEmbed *embed, - EmbedPrintInfo *info); +void ephy_embed_print (EphyEmbed *embed); -void ephy_embed_print_preview_close (EphyEmbed *embed); +void ephy_embed_set_print_preview_mode (EphyEmbed *embed, + gboolean preview_mode); int ephy_embed_print_preview_n_pages (EphyEmbed *embed); diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp index 9101ea31f..ee7e84412 100644 --- a/embed/mozilla/EphyBrowser.cpp +++ b/embed/mozilla/EphyBrowser.cpp @@ -83,6 +83,8 @@ #include "nsPromiseFlatString.h" #include "nsString.h" #include "ContentHandler.h" +#include "MozillaPrivate.h" +#include "print-dialog.h" EphyEventListener::EphyEventListener(void) : mOwner(nsnull) @@ -301,43 +303,49 @@ EphyBrowser::DetachListeners(void) return NS_OK; } -nsresult EphyBrowser::Print (nsIPrintSettings *options, PRBool preview) +nsresult EphyBrowser::Print () { - nsresult result; - NS_ENSURE_TRUE (mWebBrowser, NS_ERROR_FAILURE); nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(mWebBrowser)); NS_ENSURE_TRUE (print, NS_ERROR_FAILURE); - if (!preview) - { - result = print->Print (options, nsnull); - } - else - { - result = print->PrintPreview(options, nsnull, nsnull); - } - - return result; + return print->Print (nsnull, nsnull); } -nsresult EphyBrowser::PrintPreviewClose (void) +nsresult EphyBrowser::SetPrintPreviewMode (PRBool previewMode) { nsresult rv; - PRBool isPreview = PR_FALSE; NS_ENSURE_TRUE (mWebBrowser, NS_ERROR_FAILURE); nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(mWebBrowser)); NS_ENSURE_TRUE (print, NS_ERROR_FAILURE); - rv = print->GetDoingPrintPreview(&isPreview); - NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE); + if (previewMode) + { + EmbedPrintInfo *info; - if (isPreview == PR_TRUE) + nsCOMPtr<nsIPrintSettings> settings; + print->GetGlobalPrintSettings (getter_AddRefs(settings)); + + info = ephy_print_get_print_info (); + MozillaCollatePrintSettings (info, settings, TRUE); + ephy_print_info_free (info); + + rv = print->PrintPreview (nsnull, mDOMWindow, nsnull); + } + else { - rv = print->ExitPrintPreview(); + PRBool isPreview = PR_FALSE; + + rv = print->GetDoingPrintPreview(&isPreview); + NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE); + + if (isPreview == PR_TRUE) + { + rv = print->ExitPrintPreview(); + } } return rv; @@ -363,16 +371,6 @@ nsresult EphyBrowser::PrintPreviewNavigate(PRInt16 navType, PRInt32 pageNum) return print->PrintPreviewNavigate(navType, pageNum); } -nsresult EphyBrowser::GetPrintSettings (nsIPrintSettings **options) -{ - NS_ENSURE_TRUE (mWebBrowser, NS_ERROR_FAILURE); - - nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(mWebBrowser)); - NS_ENSURE_TRUE (print, NS_ERROR_FAILURE); - - return print->GetGlobalPrintSettings(options); -} - nsresult EphyBrowser::GetSHistory (nsISHistory **aSHistory) { nsresult result; diff --git a/embed/mozilla/EphyBrowser.h b/embed/mozilla/EphyBrowser.h index 27a1e399c..f6e3fe260 100644 --- a/embed/mozilla/EphyBrowser.h +++ b/embed/mozilla/EphyBrowser.h @@ -88,9 +88,8 @@ public: nsresult SetZoom (float aTextZoom, PRBool reflow); nsresult GetZoom (float *aTextZoom); - nsresult Print (nsIPrintSettings *options, PRBool preview); - nsresult GetPrintSettings (nsIPrintSettings * *options); - nsresult PrintPreviewClose (void); + nsresult Print (); + nsresult SetPrintPreviewMode (PRBool previewMode); nsresult PrintPreviewNumPages (int *numPages); nsresult PrintPreviewNavigate(PRInt16 navType, PRInt32 pageNum); diff --git a/embed/mozilla/MozillaPrivate.cpp b/embed/mozilla/MozillaPrivate.cpp index 41b144969..46bd005c9 100644 --- a/embed/mozilla/MozillaPrivate.cpp +++ b/embed/mozilla/MozillaPrivate.cpp @@ -76,7 +76,8 @@ GtkWidget *MozillaFindGtkParent (nsIDOMWindow *aDOMWindow) #define MM_TO_INCH(x) (((double) x) / 25.4) NS_METHOD MozillaCollatePrintSettings (const EmbedPrintInfo *info, - nsIPrintSettings *options) + nsIPrintSettings *options, + gboolean preview) { const static int frame_types[] = { nsIPrintSettings::kFramesAsIs, @@ -129,7 +130,7 @@ NS_METHOD MozillaCollatePrintSettings (const EmbedPrintInfo *info, * 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); } diff --git a/embed/mozilla/MozillaPrivate.h b/embed/mozilla/MozillaPrivate.h index c2f9a4b42..0fa96021d 100644 --- a/embed/mozilla/MozillaPrivate.h +++ b/embed/mozilla/MozillaPrivate.h @@ -1,11 +1,12 @@ #include <nsIPrintSettings.h> #include <nsIDOMWindow.h> -#include "ephy-embed.h" +#include "print-dialog.h" GtkWidget *MozillaFindEmbed (nsIDOMWindow *aDOMWindow); GtkWidget *MozillaFindGtkParent (nsIDOMWindow *aDOMWindow); NS_METHOD MozillaCollatePrintSettings (const EmbedPrintInfo *info, - nsIPrintSettings *settings); + nsIPrintSettings *settings, + gboolean preview); diff --git a/embed/mozilla/PrintingPromptService.cpp b/embed/mozilla/PrintingPromptService.cpp index 16dc3c2e9..cf8645ffa 100644 --- a/embed/mozilla/PrintingPromptService.cpp +++ b/embed/mozilla/PrintingPromptService.cpp @@ -71,7 +71,7 @@ NS_IMETHODIMP GPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIW GtkWidget *gtkParent = MozillaFindGtkParent(parent); NS_ENSURE_TRUE (gtkParent, NS_ERROR_FAILURE); - dialog = ephy_print_dialog_new (gtkParent, embed, TRUE); + dialog = ephy_print_dialog_new (gtkParent, embed); ephy_dialog_set_modal (dialog, TRUE); int ret = ephy_dialog_run (dialog); @@ -95,7 +95,7 @@ NS_IMETHODIMP GPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIW info->pages = 0; } - MozillaCollatePrintSettings (info, printSettings); + MozillaCollatePrintSettings (info, printSettings, FALSE); ephy_print_info_free (info); @@ -125,7 +125,12 @@ NS_IMETHODIMP GPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent, nsIPri dialog = ephy_print_setup_dialog_new (); ephy_dialog_set_modal (dialog, TRUE); - int ret = ephy_dialog_run (dialog); + int ret; + do + { + ret = ephy_dialog_run (dialog); + } while (ret == GTK_RESPONSE_HELP); + if (ret == GTK_RESPONSE_OK) { rv = NS_OK; diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp index 01564d034..ffab10d8f 100644 --- a/embed/mozilla/mozilla-embed-single.cpp +++ b/embed/mozilla/mozilla-embed-single.cpp @@ -76,6 +76,9 @@ #include <nsIURI.h> #include <nsNetUtil.h> #include <nsIHttpAuthManager.h> +#include <nsIPrintSettings.h> +#include <nsIPrintSettingsService.h> +#include <nsIPrintingPromptService.h> // FIXME: For setting the locale. hopefully gtkmozembed will do itself soon #include <nsIChromeRegistry.h> @@ -591,6 +594,24 @@ impl_get_font_list (EphyEmbedSingle *shell, return g_list_reverse (l); } +static void +impl_print_setup (EphyEmbedSingle *single) +{ + nsCOMPtr<nsIPrintSettingsService> pss + (do_GetService ("@mozilla.org/gfx/printsettings-service;1")); + if (!pss) return; + + nsCOMPtr<nsIPrintSettings> settings; + pss->GetGlobalPrintSettings (getter_AddRefs (settings)); + if (!settings) return; + + nsCOMPtr<nsIPrintingPromptService> prompt + (do_GetService ("@mozilla.org/embedcomp/printingprompt-service;1")); + if (!prompt) return; + + prompt->ShowPageSetup (nsnull, settings, nsnull); +} + static GList * impl_list_cookies (EphyCookieManager *manager) { @@ -873,6 +894,7 @@ ephy_embed_single_iface_init (EphyEmbedSingleIface *iface) iface->set_offline_mode = impl_set_offline_mode; iface->load_proxy_autoconf = impl_load_proxy_autoconf; iface->get_font_list = impl_get_font_list; + iface->print_setup = impl_print_setup; } static void diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp index f52e25ca1..ee67049d1 100644 --- a/embed/mozilla/mozilla-embed.cpp +++ b/embed/mozilla/mozilla-embed.cpp @@ -686,39 +686,19 @@ impl_get_security_level (EphyEmbed *embed, } static void -impl_print (EphyEmbed *embed, - EmbedPrintInfo *info) +impl_print (EphyEmbed *embed) { MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; - nsresult result; - - nsCOMPtr<nsIPrintSettings> options; - result = mpriv->browser->GetPrintSettings(getter_AddRefs(options)); - if (NS_FAILED (result) || !options) return; - - /* work around mozilla bug which borks when printing selection without having one */ - if (info->pages == 2 && ephy_command_manager_can_do_command - (EPHY_COMMAND_MANAGER (embed), "cmd_copy") == FALSE) - { - info->pages = 0; - } - - MozillaCollatePrintSettings(info, options); - - options->SetPrintSilent (PR_TRUE); - - result = mpriv->browser->Print(options, info->preview); - - /* Workaround for bug 125984 */ - options->SetPrintSilent (PR_FALSE); + + mpriv->browser->Print (); } static void -impl_print_preview_close (EphyEmbed *embed) +impl_set_print_preview_mode (EphyEmbed *embed, gboolean preview_mode) { MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; - mpriv->browser->PrintPreviewClose(); + mpriv->browser->SetPrintPreviewMode (preview_mode); } static int @@ -1140,7 +1120,7 @@ ephy_embed_iface_init (EphyEmbedIface *iface) iface->set_encoding = impl_set_encoding; iface->get_encoding_info = impl_get_encoding_info; iface->print = impl_print; - iface->print_preview_close = impl_print_preview_close; + iface->set_print_preview_mode = impl_set_print_preview_mode; iface->print_preview_n_pages = impl_print_preview_n_pages; iface->print_preview_navigate = impl_print_preview_navigate; iface->has_modified_forms = impl_has_modified_forms; diff --git a/embed/print-dialog.c b/embed/print-dialog.c index a18728faa..b9de37e7b 100755 --- a/embed/print-dialog.c +++ b/embed/print-dialog.c @@ -131,8 +131,6 @@ void ephy_print_dialog_response_cb (GtkWidget *widget, EphyDialog *dialog); void ephy_print_dialog_browse_button_cb (GtkWidget *widget, EphyDialog *dialog); -void ephy_print_setup_dialog_close_button_cb (GtkWidget *widget, - EphyDialog *dialog); void ephy_print_setup_dialog_help_button_cb (GtkWidget *widget, EphyDialog *dialog); @@ -200,7 +198,6 @@ ephy_print_get_print_info (void) info->footer_center_string = g_strdup(""); info->frame_type = 0; - info->preview = FALSE; return info; } @@ -210,39 +207,14 @@ ephy_print_dialog_response_cb (GtkWidget *widget, int response, EphyDialog *dialog) { - EphyEmbed *embed; - EmbedPrintInfo *info; - gboolean only_collect_info; - - only_collect_info = GPOINTER_TO_INT - (g_object_get_data (G_OBJECT (dialog), "only-collect-info")); - - if (only_collect_info) - { - return; - } - switch (response) { - case GTK_RESPONSE_OK: - info = ephy_print_get_print_info (); - - embed = ephy_embed_dialog_get_embed (EPHY_EMBED_DIALOG (dialog)); - g_return_if_fail (EPHY_IS_EMBED (embed)); - - ephy_embed_print (embed, info); - - ephy_print_info_free (info); - - break; case GTK_RESPONSE_HELP: ephy_gui_help (GTK_WINDOW (widget), "epiphany", "to-print-page"); return; default: break; } - - g_object_unref (dialog); } static void @@ -295,23 +267,15 @@ ephy_print_dialog_browse_button_cb (GtkWidget *widget, } void -ephy_print_setup_dialog_close_button_cb (GtkWidget *widget, - EphyDialog *dialog) -{ - g_object_unref (dialog); -} - -void ephy_print_setup_dialog_help_button_cb (GtkWidget *widget, - EphyDialog *dialog) + EphyDialog *dialog) { - ephy_gui_help (GTK_WINDOW (dialog), "epiphany", "using-print-setup"); + ephy_gui_help (GTK_WINDOW (widget), "epiphany", "using-print-setup"); } EphyDialog * ephy_print_dialog_new (GtkWidget *parent, - EphyEmbed *embed, - gboolean only_collect_info) + EphyEmbed *embed) { EphyDialog *dialog; GtkWidget *window, *button; @@ -343,9 +307,6 @@ ephy_print_dialog_new (GtkWidget *parent, button = ephy_dialog_get_control (dialog, print_props[BROWSE_PROP].id); gtk_widget_set_sensitive (button, eel_gconf_key_is_writable (CONF_PRINT_FILE)); - g_object_set_data (G_OBJECT (dialog), "only-collect-info", - GINT_TO_POINTER (only_collect_info)); - return dialog; } diff --git a/embed/print-dialog.h b/embed/print-dialog.h index f7801d8f5..81a5d5f24 100644 --- a/embed/print-dialog.h +++ b/embed/print-dialog.h @@ -31,9 +31,44 @@ G_BEGIN_DECLS +typedef struct +{ + gboolean print_to_file; + char *printer; + char *file; + char *paper; + int top_margin; + int bottom_margin; + int left_margin; + int right_margin; + int pages; + int from_page; + int to_page; + int frame_type; + int 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. + */ + 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; + EphyDialog *ephy_print_dialog_new (GtkWidget *parent, - EphyEmbed *embed, - gboolean only_collect_info); + EphyEmbed *embed); EphyDialog *ephy_print_setup_dialog_new (void); diff --git a/src/ephy-shell.c b/src/ephy-shell.c index 7bd229531..5ec1442a5 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -76,7 +76,6 @@ struct EphyShellPrivate GtkWidget *history_window; GObject *pdm_dialog; GObject *prefs_dialog; - GObject *print_setup_dialog; GList *del_on_exit; guint server_timeout; }; @@ -192,7 +191,6 @@ ephy_shell_init (EphyShell *shell) shell->priv->bme = NULL; shell->priv->history_window = NULL; shell->priv->pdm_dialog = NULL; - shell->priv->print_setup_dialog = NULL; shell->priv->toolbars_model = NULL; shell->priv->fs_toolbars_model = NULL; shell->priv->extensions_manager = NULL; @@ -483,12 +481,6 @@ ephy_shell_finalize (GObject *object) g_object_unref (shell->priv->prefs_dialog); } - LOG ("Unref print setup dialog") - if (shell->priv->print_setup_dialog) - { - g_object_unref (shell->priv->print_setup_dialog); - } - LOG ("Unref bookmarks") if (shell->priv->bookmarks) { @@ -814,17 +806,3 @@ 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) - { - shell->priv->print_setup_dialog = G_OBJECT (ephy_print_setup_dialog_new ()); - - g_object_add_weak_pointer (shell->priv->print_setup_dialog, - (gpointer *) &shell->priv->print_setup_dialog); - } - - return shell->priv->print_setup_dialog; -} diff --git a/src/ephy-shell.h b/src/ephy-shell.h index 1c5e07a05..08a0b7411 100644 --- a/src/ephy-shell.h +++ b/src/ephy-shell.h @@ -134,8 +134,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); - G_END_DECLS #endif diff --git a/src/ephy-window.c b/src/ephy-window.c index 127b0d9b6..3be64d27b 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -334,7 +334,6 @@ struct EphyWindowPrivate GtkNotebook *notebook; EphyTab *active_tab; EphyDialog *find_dialog; - EphyDialog *print_dialog; gboolean closing; gboolean has_size; guint num_tabs; @@ -675,7 +674,7 @@ ephy_window_delete_event_cb (GtkWidget *widget, GdkEvent *event, EphyWindow *win EphyEmbed *embed; embed = ephy_window_get_active_embed (window); - ephy_embed_print_preview_close (embed); + ephy_embed_set_print_preview_mode (embed, FALSE); ephy_window_set_print_preview (window, FALSE); } @@ -2047,11 +2046,6 @@ ephy_window_finalize (GObject *object) g_object_unref (G_OBJECT (window->priv->find_dialog)); } - if (window->priv->print_dialog) - { - g_object_unref (G_OBJECT (window->priv->print_dialog)); - } - g_object_unref (window->priv->fav_menu); g_object_unref (window->priv->enc_menu); g_object_unref (window->priv->tabs_menu); @@ -2322,7 +2316,6 @@ update_embed_dialogs (EphyWindow *window, { EphyEmbed *embed; EphyDialog *find_dialog = window->priv->find_dialog; - EphyDialog *print_dialog = window->priv->print_dialog; embed = ephy_tab_get_embed (tab); @@ -2332,13 +2325,6 @@ update_embed_dialogs (EphyWindow *window, (EPHY_EMBED_DIALOG(find_dialog), embed); } - - if (print_dialog) - { - ephy_embed_dialog_set_embed - (EPHY_EMBED_DIALOG(print_dialog), - embed); - } } static void @@ -2387,48 +2373,6 @@ ephy_window_find (EphyWindow *window) } void -ephy_window_print (EphyWindow *window) -{ - if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_PRINTING)) - { - return; - } - - if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_PRINT_SETUP) || - eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_COMMAND_LINE)) - { - EphyEmbed *embed; - EmbedPrintInfo *info; - - info = ephy_print_get_print_info (); - - embed = ephy_window_get_active_embed (window); - g_return_if_fail (EPHY_IS_EMBED (embed)); - - ephy_embed_print (embed, info); - - ephy_print_info_free (info); - - return; - } - - if (window->priv->print_dialog == NULL) - { - EphyDialog *dialog; - EphyEmbed *embed; - - embed = ephy_window_get_active_embed (window); - dialog = ephy_print_dialog_new (GTK_WIDGET (window), embed, FALSE); - - window->priv->print_dialog = dialog; - g_object_add_weak_pointer(G_OBJECT (dialog), - (gpointer *) &window->priv->print_dialog); - } - - ephy_dialog_show (window->priv->print_dialog); -} - -void ephy_window_set_zoom (EphyWindow *window, float zoom) { diff --git a/src/ppview-toolbar.c b/src/ppview-toolbar.c index bdf70f322..8604448f1 100755 --- a/src/ppview-toolbar.c +++ b/src/ppview-toolbar.c @@ -392,6 +392,6 @@ toolbar_cmd_ppv_close (GtkUIManager *merge, ephy_window_set_print_preview (window, FALSE); - ephy_embed_print_preview_close (embed); + ephy_embed_set_print_preview_mode (embed, FALSE); } diff --git a/src/window-commands.c b/src/window-commands.c index 59ab51d2d..8c5985519 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -22,6 +22,8 @@ #include "config.h" #endif +#include "ephy-embed-shell.h" +#include "ephy-embed-single.h" #include "ephy-shell.h" #include "ephy-embed-factory.h" #include "ephy-embed-persist.h" @@ -73,12 +75,10 @@ void window_cmd_file_print_setup (GtkAction *action, EphyWindow *window) { - EphyDialog *dialog; - - dialog = EPHY_DIALOG (ephy_shell_get_print_setup_dialog (ephy_shell)); - ephy_dialog_set_parent (dialog, GTK_WIDGET (window)); + EphyEmbedSingle *single; - ephy_dialog_show (dialog); + single = EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (embed_shell)); + ephy_embed_single_print_setup (single); } void @@ -86,18 +86,11 @@ window_cmd_file_print_preview (GtkAction *action, EphyWindow *window) { EphyEmbed *embed; - EmbedPrintInfo *info; embed = ephy_window_get_active_embed (window); g_return_if_fail (EPHY_IS_EMBED (embed)); - info = ephy_print_get_print_info (); - info->preview = TRUE; - - ephy_embed_print (embed, info); - - ephy_print_info_free (info); - + ephy_embed_set_print_preview_mode (embed, TRUE); ephy_window_set_print_preview (window, TRUE); } @@ -105,7 +98,12 @@ void window_cmd_file_print (GtkAction *action, EphyWindow *window) { - ephy_window_print (window); + EphyEmbed *embed; + + embed = ephy_window_get_active_embed (window); + g_return_if_fail (EPHY_IS_EMBED (embed)); + + ephy_embed_print (embed); } void |