From 09136af43c1074fb979578be2987cd0ae3a8852d Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Sat, 10 Jan 2004 21:59:25 +0000 Subject: Implement print and print setup disabling for lockdown mode. 2004-01-10 Christopher James Lahey * embed/mozilla/PrintingPromptService.cpp: * lib/ephy-prefs.h: * src/ephy-main.c: (main): * src/ephy-window.c: (update_actions), (ephy_window_init), (ephy_window_finalize), (ephy_window_print): Implement print and print setup disabling for lockdown mode. --- embed/mozilla/PrintingPromptService.cpp | 56 ++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 19 deletions(-) (limited to 'embed/mozilla/PrintingPromptService.cpp') diff --git a/embed/mozilla/PrintingPromptService.cpp b/embed/mozilla/PrintingPromptService.cpp index 60eb3b1db..85c885592 100644 --- a/embed/mozilla/PrintingPromptService.cpp +++ b/embed/mozilla/PrintingPromptService.cpp @@ -30,6 +30,8 @@ #include "ephy-command-manager.h" #include "MozillaPrivate.h" #include "PrintingPromptService.h" +#include "eel-gconf-extensions.h" +#include "ephy-prefs.h" #include #include @@ -51,41 +53,50 @@ GPrintingPromptService::~GPrintingPromptService() NS_IMETHODIMP GPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrint *webBrowserPrint, nsIPrintSettings *printSettings) { EphyDialog *dialog; - nsresult rv = NS_ERROR_ABORT; - GtkWidget *gtkParent = MozillaFindGtkParent(parent); - NS_ENSURE_TRUE (gtkParent, NS_ERROR_FAILURE); + if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_PRINTING)) + { + return NS_ERROR_ABORT; + } EphyEmbed *embed = EPHY_EMBED (MozillaFindEmbed (parent)); NS_ENSURE_TRUE (embed, NS_ERROR_FAILURE); - dialog = ephy_print_dialog_new (gtkParent, embed, TRUE); - ephy_dialog_set_modal (dialog, TRUE); - - int ret = ephy_dialog_run (dialog); - if (ret == GTK_RESPONSE_OK) + if (!(eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_PRINT_SETUP) || + eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_COMMAND_LINE))) { - EmbedPrintInfo *info; + GtkWidget *gtkParent = MozillaFindGtkParent(parent); + NS_ENSURE_TRUE (gtkParent, NS_ERROR_FAILURE); + + dialog = ephy_print_dialog_new (gtkParent, embed, TRUE); + ephy_dialog_set_modal (dialog, TRUE); + + int ret = ephy_dialog_run (dialog); - info = ephy_print_get_print_info (); + g_object_unref (dialog); - /* 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) + if (ret != GTK_RESPONSE_OK) { - info->pages = 0; + return NS_ERROR_ABORT; } + } - MozillaCollatePrintSettings (info, printSettings); + EmbedPrintInfo *info; - ephy_print_info_free (info); + info = ephy_print_get_print_info (); - rv = NS_OK; + /* 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; } - g_object_unref (dialog); + MozillaCollatePrintSettings (info, printSettings); - return rv; + ephy_print_info_free (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); */ @@ -101,6 +112,13 @@ NS_IMETHODIMP GPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent, nsIPri 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) || + eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_COMMAND_LINE)) + { + return rv; + } + dialog = ephy_print_setup_dialog_new (); ephy_dialog_set_modal (dialog, TRUE); -- cgit v1.2.3