diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | embed/mozilla/PrintingPromptService.cpp | 56 | ||||
-rw-r--r-- | lib/ephy-prefs.h | 3 | ||||
-rw-r--r-- | src/ephy-main.c | 3 | ||||
-rw-r--r-- | src/ephy-window.c | 52 |
5 files changed, 105 insertions, 19 deletions
@@ -1,3 +1,13 @@ +2004-01-10 Christopher James Lahey <clahey@ximian.com> + + * 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. + 2004-01-10 Christian Persch <chpe@cvs.gnome.org> * configure.in: 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 <nsIPrintSettings.h> #include <nsCOMPtr.h> @@ -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); diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h index d1cc998f7..91ec12e51 100644 --- a/lib/ephy-prefs.h +++ b/lib/ephy-prefs.h @@ -50,6 +50,9 @@ G_BEGIN_DECLS #define CONF_LOCKDOWN_DISABLE_HISTORY "/apps/epiphany/lockdown/disable_history" #define CONF_LOCKDOWN_DISABLE_SAVE_TO_DISK "/desktop/gnome/lockdown/disable_save_to_disk" #define CONF_LOCKDOWN_DISABLE_HISTORY "/apps/epiphany/lockdown/disable_history" +#define CONF_LOCKDOWN_DISABLE_PRINTING "/desktop/gnome/lockdown/disable_printing" +#define CONF_LOCKDOWN_DISABLE_PRINT_SETUP "/desktop/gnome/lockdown/disable_print_setup" +#define CONF_LOCKDOWN_DISABLE_COMMAND_LINE "/desktop/gnome/lockdown/disable_command_line" /* System prefs */ #define CONF_DESKTOP_FTP_HANDLER "/desktop/gnome/url-handlers/ftp/command" diff --git a/src/ephy-main.c b/src/ephy-main.c index ccb349ee3..f2240e76b 100644 --- a/src/ephy-main.c +++ b/src/ephy-main.c @@ -156,6 +156,8 @@ main (int argc, char *argv[]) ephy_stock_icons_init (); eel_gconf_monitor_add ("/apps/epiphany/general"); eel_gconf_monitor_add ("/apps/epiphany/lockdown"); + eel_gconf_monitor_add ("/desktop/gnome/lockdown"); + bonobo_activate (); ephy_shell = ephy_shell_new (); @@ -182,6 +184,7 @@ main (int argc, char *argv[]) eel_gconf_monitor_remove ("/apps/epiphany/general"); eel_gconf_monitor_remove ("/apps/epiphany/lockdown"); + eel_gconf_monitor_remove ("/desktop/gnome/lockdown"); ephy_state_save (); ephy_file_helpers_shutdown (); gnome_vfs_shutdown (); diff --git a/src/ephy-window.c b/src/ephy-window.c index 8e3c0c91b..2e24e68e0 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -338,7 +338,10 @@ struct EphyWindowPrivate guint disable_bookmark_editing_notifier_id; guint disable_toolbar_editing_notifier_id; guint disable_history_notifier_id; + guint disable_printing_notifier_id; + guint disable_print_setup_notifier_id; guint disable_save_to_disk_notifier_id; + guint disable_command_line_notifier_id; guint browse_with_caret_notifier_id; }; @@ -1710,6 +1713,7 @@ update_actions (EphyWindow *window) GtkActionGroup *popups_action_group = GTK_ACTION_GROUP (window->priv->popups_action_group); GtkAction *action; gboolean bookmarks_editable, save_to_disk; + gboolean printing, print_setup; action = gtk_action_group_get_action (action_group, "ViewToolbar"); gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), @@ -1752,6 +1756,16 @@ update_actions (EphyWindow *window) action = gtk_action_group_get_action (popups_action_group, "SaveImageAs"); g_object_set (action, "sensitive", save_to_disk, NULL); + printing = !eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_PRINTING); + print_setup = !eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_PRINT_SETUP) && + !eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_COMMAND_LINE); + action = gtk_action_group_get_action (action_group, "FilePrintSetup"); + g_object_set (action, "sensitive", printing && print_setup, NULL); + action = gtk_action_group_get_action (action_group, "FilePrintPreview"); + g_object_set (action, "sensitive", printing && print_setup, NULL); + action = gtk_action_group_get_action (action_group, "FilePrint"); + g_object_set (action, "sensitive", printing, NULL); + action = gtk_action_group_get_action (popups_action_group, "SetImageAsBackground"); g_object_set (action, "sensitive", eel_gconf_key_is_writable (CONF_DESKTOP_BG_PICTURE), NULL); @@ -1919,10 +1933,22 @@ ephy_window_init (EphyWindow *window) (CONF_LOCKDOWN_DISABLE_HISTORY, (GConfClientNotifyFunc)navigation_notifier, window); + window->priv->disable_printing_notifier_id = eel_gconf_notification_add + (CONF_LOCKDOWN_DISABLE_PRINTING, + (GConfClientNotifyFunc)actions_notifier, window); + + window->priv->disable_print_setup_notifier_id = eel_gconf_notification_add + (CONF_LOCKDOWN_DISABLE_PRINT_SETUP, + (GConfClientNotifyFunc)actions_notifier, window); + window->priv->disable_save_to_disk_notifier_id = eel_gconf_notification_add (CONF_LOCKDOWN_DISABLE_SAVE_TO_DISK, (GConfClientNotifyFunc)actions_notifier, window); + window->priv->disable_command_line_notifier_id = eel_gconf_notification_add + (CONF_LOCKDOWN_DISABLE_COMMAND_LINE, + (GConfClientNotifyFunc)actions_notifier, window); + /* other notifiers */ browse_with_caret_notifier (NULL, 0, NULL, window); window->priv->browse_with_caret_notifier_id = eel_gconf_notification_add @@ -1949,7 +1975,10 @@ ephy_window_finalize (GObject *object) eel_gconf_notification_remove (window->priv->disable_bookmark_editing_notifier_id); eel_gconf_notification_remove (window->priv->disable_toolbar_editing_notifier_id); eel_gconf_notification_remove (window->priv->disable_history_notifier_id); + eel_gconf_notification_remove (window->priv->disable_printing_notifier_id); + eel_gconf_notification_remove (window->priv->disable_print_setup_notifier_id); eel_gconf_notification_remove (window->priv->disable_save_to_disk_notifier_id); + eel_gconf_notification_remove (window->priv->disable_command_line_notifier_id); eel_gconf_notification_remove (window->priv->browse_with_caret_notifier_id); if (window->priv->find_dialog) @@ -2296,6 +2325,29 @@ 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; |