From 831692cf871c3d6bf8fd3b8422adf9dc79fdb88d Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Fri, 29 Sep 2000 23:45:49 +0000 Subject: Add print preview verb here. 2000-09-29 Miguel de Icaza * folder-browser-factory.c: Add print preview verb here. * mail-callbacks.c (do_mail_print): Handle printing here, the complete engine. (mail_print_preview_msg): new. does print previewing. (mail_print_msg): does printing of the message. svn path=/trunk/; revision=5641 --- mail/mail-callbacks.c | 113 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 93 insertions(+), 20 deletions(-) (limited to 'mail/mail-callbacks.c') diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index 118dc5d4bb..f4f1ffcb20 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -41,6 +41,7 @@ #include "filter/filter-editor.h" #include "filter/filter-driver.h" #include +#include /* FIXME: is there another way to do this? */ #include "Evolution.h" @@ -723,42 +724,114 @@ providers_config (BonoboUIHandler *uih, void *user_data, const char *path) mail_config ((FOLDER_BROWSER (user_data))->shell); } -void -manage_subscriptions (BonoboUIHandler *uih, void *user_data, const char *path) +/* + * FIXME: This routine could be made generic, by having a closure + * function plus data, and having the whole process be taken care + * of for you + */ +static void +do_mail_print (MailDisplay *md, gboolean preview) { - /* XXX pass in the selected storage */ - GtkWidget *subscribe = subscribe_control_new (); + GnomePrintContext *print_context; + GnomePrintMaster *print_master; + GnomePrintDialog *gpd; + GnomePrinter *printer = NULL; + int copies = 1; + int collate = FALSE; - gtk_widget_show (subscribe); -} + if (!preview){ + + gpd = GNOME_PRINT_DIALOG ( + gnome_print_dialog_new (_("Print Message"), GNOME_PRINT_DIALOG_COPIES)); + gnome_dialog_set_default (GNOME_DIALOG (gpd), GNOME_PRINT_PRINT); + + switch (gnome_dialog_run (GNOME_DIALOG (gpd))){ + case GNOME_PRINT_PRINT: + break; + + case GNOME_PRINT_PREVIEW: + preview = TRUE; + break; + + case -1: + return; + + default: + gnome_dialog_close (GNOME_DIALOG (gpd)); + return; + } + + gnome_print_dialog_get_copies (gpd, &copies, &collate); + printer = gnome_print_dialog_get_printer (gpd); + gnome_dialog_close (GNOME_DIALOG (gpd)); + } -void -mail_print_msg (MailDisplay *md) -{ - GnomePrintMaster *print_master; - GnomePrintContext *print_context; - GtkWidget *preview; - print_master = gnome_print_master_new (); - + +/* FIXME: set paper size gnome_print_master_set_paper (print_master, */ + + if (printer) + gnome_print_master_set_printer (print_master, printer); + gnome_print_master_set_copies (print_master, copies, collate); print_context = gnome_print_master_get_context (print_master); gtk_html_print (md->html, print_context); - - preview = GTK_WIDGET (gnome_print_master_preview_new ( - print_master, "Mail Print Preview")); - gtk_widget_show (preview); - + gnome_print_master_close (print_master); + + if (preview){ + gboolean landscape = FALSE; + GnomePrintMasterPreview *preview; + + preview = gnome_print_master_preview_new_with_orientation ( + print_master, _("Print Preview"), landscape); + gtk_widget_show (GTK_WIDGET (preview)); + } else { + int result = gnome_print_master_print (print_master); + + if (result == -1){ + e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, + _("Printing of message failed")); + } + } gtk_object_unref (GTK_OBJECT (print_master)); } +void +mail_print_preview_msg (MailDisplay *md) +{ + do_mail_print (md, TRUE); +} + +void +mail_print_msg (MailDisplay *md) +{ + do_mail_print (md, FALSE); +} + void print_msg (GtkWidget *button, gpointer user_data) { FolderBrowser *fb = user_data; - + mail_print_msg (fb->mail_display); } +void +print_preview_msg (GtkWidget *button, gpointer user_data) +{ + FolderBrowser *fb = user_data; + + mail_print_preview_msg (fb->mail_display); +} + +void +manage_subscriptions (BonoboUIHandler *uih, void *user_data, const char *path) +{ + /* XXX pass in the selected storage */ + GtkWidget *subscribe = subscribe_control_new (); + + gtk_widget_show (subscribe); +} + void configure_folder(BonoboUIHandler *uih, void *user_data, const char *path) { -- cgit v1.2.3