diff options
author | Not Zed <NotZed@Ximian.com> | 2004-06-18 15:41:36 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-06-18 15:41:36 +0800 |
commit | 1a68102c00f473ff8892f901fa71f9cd2c5a6534 (patch) | |
tree | 7ee07ae8c9979fb2008e9abf91f7e43084634577 /mail/em-folder-view.c | |
parent | 01a1d4009633d920a823ed7085893082ac6b0187 (diff) | |
download | gsoc2013-evolution-1a68102c00f473ff8892f901fa71f9cd2c5a6534.tar.gz gsoc2013-evolution-1a68102c00f473ff8892f901fa71f9cd2c5a6534.tar.zst gsoc2013-evolution-1a68102c00f473ff8892f901fa71f9cd2c5a6534.zip |
** See #60214.
2004-06-18 Not Zed <NotZed@Ximian.com>
** See #60214.
* em-folder-view.c (em_folder_view_print): re-arrange code to make
the dialogue async. We also now load the message every time
before printing.
(emfv_print_response): handle response to print.
* em-format-html-print.c (em_format_html_print_message): new api
to print a specific uid on a specific folder.
svn path=/trunk/; revision=26413
Diffstat (limited to 'mail/em-folder-view.c')
-rw-r--r-- | mail/em-folder-view.c | 92 |
1 files changed, 60 insertions, 32 deletions
diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c index 4147a1d239..b5222f7b6c 100644 --- a/mail/em-folder-view.c +++ b/mail/em-folder-view.c @@ -1780,51 +1780,79 @@ emfv_activate(EMFolderView *emfv, BonoboUIComponent *uic, int act) } } -int em_folder_view_print(EMFolderView *emfv, int preview) +struct _print_data { + EMFolderView *emfv; + + int preview; + CamelFolder *folder; + char *uid; +}; + +static void +emfv_print_response(GtkWidget *w, int resp, struct _print_data *data) { - /*struct _EMFolderViewPrivate *p = emfv->priv;*/ EMFormatHTMLPrint *print; GnomePrintConfig *config = NULL; - int res; - struct _CamelMimeMessage *msg; - /* FIXME: need to load the message first */ - if (!emfv->preview_active) + switch (resp) { + case GNOME_PRINT_DIALOG_RESPONSE_PREVIEW: + data->preview = TRUE; + case GNOME_PRINT_DIALOG_RESPONSE_PRINT: + if (w) + config = gnome_print_dialog_get_config((GnomePrintDialog *)w); + print = em_format_html_print_new(); + em_format_set_session((EMFormat *)print, ((EMFormat *)data->emfv->preview)->session); + em_format_html_print_message(print, (EMFormatHTML *)data->emfv->preview, config, data->folder, data->uid, data->preview); + g_object_unref(print); + if (config) + g_object_unref(config); + break; + } + + if (w) + gtk_widget_destroy(w); + + g_object_unref(data->emfv); + camel_object_unref(data->folder); + g_free(data->uid); + g_free(data); +} + +int em_folder_view_print(EMFolderView *emfv, int preview) +{ + struct _print_data *data; + GPtrArray *uids; + + if (emfv->folder == NULL) return 0; - msg = emfv->preview->formathtml.format.message; - if (msg == NULL) + uids = message_list_get_selected(emfv->list); + if (uids->len != 1) { + message_list_free_uids(emfv->list, uids); return 0; - - if (!preview) { + } + + data = g_malloc0(sizeof(*data)); + data->emfv = emfv; + g_object_ref(emfv); + data->preview = preview; + data->folder = emfv->folder; + camel_object_ref(data->folder); + data->uid = g_strdup(uids->pdata[0]); + message_list_free_uids(emfv->list, uids); + + if (preview) { + emfv_print_response(NULL, GNOME_PRINT_DIALOG_RESPONSE_PREVIEW, data); + } else { GtkDialog *dialog = (GtkDialog *)gnome_print_dialog_new(NULL, _("Print Message"), GNOME_PRINT_DIALOG_COPIES); gtk_dialog_set_default_response(dialog, GNOME_PRINT_DIALOG_RESPONSE_PRINT); e_dialog_set_transient_for ((GtkWindow *) dialog, (GtkWidget *) emfv); - - switch (gtk_dialog_run(dialog)) { - case GNOME_PRINT_DIALOG_RESPONSE_PRINT: - break; - case GNOME_PRINT_DIALOG_RESPONSE_PREVIEW: - preview = TRUE; - break; - default: - gtk_widget_destroy((GtkWidget *)dialog); - return 0; - } - - config = gnome_print_dialog_get_config((GnomePrintDialog *)dialog); - gtk_widget_destroy((GtkWidget *)dialog); + g_signal_connect(dialog, "response", G_CALLBACK(emfv_print_response), data); + gtk_widget_show((GtkWidget *)dialog); } - print = em_format_html_print_new(); - em_format_set_session((EMFormat *)print, ((EMFormat *)emfv->preview)->session); - res = em_format_html_print_print(print, (EMFormatHTML *)emfv->preview, config, preview); - g_object_unref(print); - if (config) - g_object_unref(config); - - return res; + return 0; } EMPopupTarget * |