diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-12-15 03:11:05 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-12-15 03:11:05 +0800 |
commit | 900078b3119c8061c5e416d6ef3441a7700c7fdb (patch) | |
tree | 3b3c7f9787e625bd4e7158dcb6e23c740dc03f5b /mail | |
parent | 3abfba882b264e33315a8f1e9f3e91e676085d04 (diff) | |
download | gsoc2013-evolution-900078b3119c8061c5e416d6ef3441a7700c7fdb.tar gsoc2013-evolution-900078b3119c8061c5e416d6ef3441a7700c7fdb.tar.gz gsoc2013-evolution-900078b3119c8061c5e416d6ef3441a7700c7fdb.tar.bz2 gsoc2013-evolution-900078b3119c8061c5e416d6ef3441a7700c7fdb.tar.lz gsoc2013-evolution-900078b3119c8061c5e416d6ef3441a7700c7fdb.tar.xz gsoc2013-evolution-900078b3119c8061c5e416d6ef3441a7700c7fdb.tar.zst gsoc2013-evolution-900078b3119c8061c5e416d6ef3441a7700c7fdb.zip |
Connect to the save-draft signal. (send_to_url): Here too. (mail_reply):
2001-12-14 Jeffrey Stedfast <fejj@ximian.com>
* mail-callbacks.c (compose_msg): Connect to the save-draft signal.
(send_to_url): Here too.
(mail_reply): And here...
(forward_get_composer): Same.
(do_edit_messages): And finally here.
svn path=/trunk/; revision=15081
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 6 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 101 | ||||
-rw-r--r-- | mail/mail-callbacks.h | 1 |
3 files changed, 107 insertions, 1 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 46fc4f8027..f1b5cb329c 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,5 +1,11 @@ 2001-12-14 Jeffrey Stedfast <fejj@ximian.com> + * mail-callbacks.c (compose_msg): Connect to the save-draft signal. + (send_to_url): Here too. + (mail_reply): And here... + (forward_get_composer): Same. + (do_edit_messages): And finally here. + * mail-format.c (try_inline_pgp): (try_inline_pgp_sig): Start reiplementing The Right Way and not danw's fucking half-assed kludge that doesn't work. diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index 637c01c17f..3f1baa452f 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -651,6 +651,92 @@ composer_postpone_cb (EMsgComposer *composer, gpointer data) gtk_widget_destroy (GTK_WIDGET (composer)); } +struct _save_draft_info { + EMsgComposer *composer; + int quit; +}; + +static void +save_draft_done (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, int ok, void *data) +{ + struct _save_draft_info *sdi = data; + + if (ok && sdi->quit) + gtk_widget_destroy (GTK_WIDGET (sdi->composer)); + else + gtk_object_unref (GTK_OBJECT (sdi->composer)); + + g_free (info); + g_free (sdi); +} + +static void +use_default_drafts_cb (int reply, gpointer data) +{ + extern CamelFolder *drafts_folder; + CamelFolder **folder = data; + + if (reply == 0) + *folder = drafts_folder; +} + +static void +save_draft_folder (char *uri, CamelFolder *folder, gpointer data) +{ + CamelFolder **save = data; + + if (folder) { + *save = folder; + camel_object_ref (CAMEL_OBJECT (folder)); + } +} + +void +composer_save_draft_cb (EMsgComposer *composer, int quit, gpointer data) +{ + extern char *default_drafts_folder_uri; + extern CamelFolder *drafts_folder; + CamelMimeMessage *msg; + CamelMessageInfo *info; + const MailConfigAccount *account; + struct _save_draft_info *sdi; + CamelFolder *folder = NULL; + + account = e_msg_composer_get_preferred_account (composer); + if (account && account->drafts_folder_uri && + strcmp (account->drafts_folder_uri, default_drafts_folder_uri) != 0) { + int id; + + id = mail_get_folder (account->drafts_folder_uri, 0, save_draft_folder, &folder, mail_thread_new); + mail_msg_wait (id); + + if (!folder) { + GtkWidget *dialog; + + dialog = gnome_ok_cancel_dialog_parented (_("Unable to open the drafts folder for this account.\n" + "Would you like to use the default drafts folder?"), + use_default_drafts_cb, &folder, GTK_WINDOW (composer)); + gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); + if (!folder) + return; + } + } else + folder = drafts_folder; + + msg = e_msg_composer_get_message_draft (composer); + + info = g_new0 (CamelMessageInfo, 1); + info->flags = CAMEL_MESSAGE_DRAFT | CAMEL_MESSAGE_SEEN; + + sdi = g_malloc (sizeof (struct _save_draft_info)); + sdi->composer = composer; + gtk_object_ref (GTK_OBJECT (composer)); + sdi->quit = quit; + + mail_append_mail (folder, msg, info, save_draft_done, sdi); + camel_object_unref (CAMEL_OBJECT (msg)); +} + static GtkWidget * create_msg_composer (const char *url) { @@ -689,6 +775,8 @@ compose_msg (GtkWidget *widget, gpointer user_data) GTK_SIGNAL_FUNC (composer_send_cb), NULL); gtk_signal_connect (GTK_OBJECT (composer), "postpone", GTK_SIGNAL_FUNC (composer_postpone_cb), NULL); + gtk_signal_connect (GTK_OBJECT (composer), "save-draft", + GTK_SIGNAL_FUNC (composer_save_draft_cb), NULL); gtk_widget_show (composer); } @@ -712,7 +800,9 @@ send_to_url (const char *url) GTK_SIGNAL_FUNC (composer_send_cb), NULL); gtk_signal_connect (GTK_OBJECT (composer), "postpone", GTK_SIGNAL_FUNC (composer_postpone_cb), NULL); - + gtk_signal_connect (GTK_OBJECT (composer), "save-draft", + GTK_SIGNAL_FUNC (composer_save_draft_cb), NULL); + gtk_widget_show (composer); } @@ -1035,6 +1125,8 @@ mail_reply (CamelFolder *folder, CamelMimeMessage *msg, const char *uid, int mod GTK_SIGNAL_FUNC (composer_send_cb), psd); gtk_signal_connect (GTK_OBJECT (composer), "postpone", GTK_SIGNAL_FUNC (composer_postpone_cb), psd); + gtk_signal_connect (GTK_OBJECT (composer), "save-draft", + GTK_SIGNAL_FUNC (composer_save_draft_cb), NULL); gtk_signal_connect (GTK_OBJECT (composer), "destroy", GTK_SIGNAL_FUNC (free_psd), psd); @@ -1126,6 +1218,8 @@ forward_get_composer (CamelMimeMessage *message, const char *subject) GTK_SIGNAL_FUNC (composer_send_cb), NULL); gtk_signal_connect (GTK_OBJECT (composer), "postpone", GTK_SIGNAL_FUNC (composer_postpone_cb), NULL); + gtk_signal_connect (GTK_OBJECT (composer), "save-draft", + GTK_SIGNAL_FUNC (composer_save_draft_cb), NULL); e_msg_composer_set_headers (composer, account->name, NULL, NULL, NULL, subject); } else { g_warning ("Could not create composer"); @@ -1741,6 +1835,11 @@ do_edit_messages (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, voi gtk_signal_connect (GTK_OBJECT (composer), "postpone", composer_postpone_cb, NULL); + /* FIXME: we want to pass data to this callback so + we can remove the old draft when they save again */ + gtk_signal_connect (GTK_OBJECT (composer), "save-draft", + composer_save_draft_cb, NULL); + gtk_widget_show (GTK_WIDGET (composer)); } } diff --git a/mail/mail-callbacks.h b/mail/mail-callbacks.h index 5859411727..9a82884640 100644 --- a/mail/mail-callbacks.h +++ b/mail/mail-callbacks.h @@ -119,6 +119,7 @@ void mail_reply (CamelFolder *folder, CamelMimeMessage *msg, const ch void composer_send_cb (EMsgComposer *composer, gpointer data); void composer_postpone_cb (EMsgComposer *composer, gpointer data); +void composer_save_draft_cb (EMsgComposer *composer, int quit, gpointer data); void forward_messages (CamelFolder *folder, GPtrArray *uids, gboolean inline); |