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 | |
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
-rw-r--r-- | mail/ChangeLog | 12 | ||||
-rw-r--r-- | mail/em-folder-view.c | 92 | ||||
-rw-r--r-- | mail/em-format-html-print.c | 35 | ||||
-rw-r--r-- | mail/em-format-html-print.h | 4 |
4 files changed, 110 insertions, 33 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 92c16e2aad..f0d6f83a4c 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,5 +1,17 @@ 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. + +2004-06-18 Not Zed <NotZed@Ximian.com> + * em-vfolder-rule.c (get_widget): use mail dialogs.glade. * mail-dialogs.glade: move the vfolder-source window here from 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 * diff --git a/mail/em-format-html-print.c b/mail/em-format-html-print.c index 69fc9f19a2..6b252064a0 100644 --- a/mail/em-format-html-print.c +++ b/mail/em-format-html-print.c @@ -34,6 +34,8 @@ #include <gtk/gtkwindow.h> #include <camel/camel-i18n.h> +#include "mail-ops.h" +#include "mail-mt.h" #include "em-format-html-print.h" static void efhp_builtin_init(EMFormatHTMLPrintClass *efhc); @@ -65,6 +67,8 @@ efhp_finalise(GObject *o) gtk_widget_destroy(efhp->window); if (efhp->config) g_object_unref(efhp->config); + if (efhp->source) + g_object_unref(efhp->source); ((GObjectClass *)efhp_parent)->finalize(o); } @@ -198,6 +202,37 @@ int em_format_html_print_print(EMFormatHTMLPrint *efhp, EMFormatHTML *source, st return 0; /* damn async ... */ } +static void +emfhp_got_message(struct _CamelFolder *folder, const char *uid, struct _CamelMimeMessage *msg, void *data) +{ + EMFormatHTMLPrint *efhp = data; + + if (msg) { + if (efhp->source) + ((EMFormatHTML *)efhp)->load_http = efhp->source->load_http_now; + g_signal_connect(efhp, "complete", G_CALLBACK(emfhp_complete), efhp); + em_format_format_clone((EMFormat *)efhp, folder, uid, msg, (EMFormat *)efhp->source); + } else { + g_object_unref(efhp); + } +} + +int em_format_html_print_message(EMFormatHTMLPrint *efhp, EMFormatHTML *source, struct _GnomePrintConfig *print_config, struct _CamelFolder *folder, const char *uid, int preview) +{ + efhp->config = print_config; + if (print_config) + g_object_ref(print_config); + efhp->preview = preview; + efhp->source = source; + if (source) + g_object_ref(source); + g_object_ref(efhp); + + mail_get_message(folder, uid, emfhp_got_message, efhp, mail_thread_new); + + return 0; /* damn async ... */ +} + /* ********************************************************************** */ /* if only ... but i doubt this is possible with gnome print/gtkhtml */ diff --git a/mail/em-format-html-print.h b/mail/em-format-html-print.h index 5c8731ef12..0153d405e6 100644 --- a/mail/em-format-html-print.h +++ b/mail/em-format-html-print.h @@ -13,13 +13,14 @@ struct _GnomePrintConfig; typedef struct _EMFormatHTMLPrint EMFormatHTMLPrint; typedef struct _EMFormatHTMLPrintClass EMFormatHTMLPrintClass; -struct _CamelMimePart; +struct _CamelFolder; struct _EMFormatHTMLPrint { EMFormatHTML formathtml; struct _GtkWidget *window; /* used to realise the gtkhtml in a toplevel, i dont know why */ struct _GnomePrintConfig *config; + struct _EMFormatHTML *source; /* used for print_message */ int preview:1; }; @@ -33,5 +34,6 @@ GType em_format_html_print_get_type(void); EMFormatHTMLPrint *em_format_html_print_new(void); int em_format_html_print_print(EMFormatHTMLPrint *efhp, EMFormatHTML *source, struct _GnomePrintConfig *print_config, int preview); +int em_format_html_print_message(EMFormatHTMLPrint *efhp, EMFormatHTML *source, struct _GnomePrintConfig *print_config, struct _CamelFolder *folder, const char *uid, int preview); #endif /* ! _EM_FORMAT_HTML_PRINT_H */ |