diff options
author | Dan Winship <danw@src.gnome.org> | 2001-10-30 09:36:48 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2001-10-30 09:36:48 +0800 |
commit | 46dee516710185ab5fb881a02580c66f3e82181c (patch) | |
tree | 726f24567c51d27580c4f444ee7d7b33b5f5671e | |
parent | e6e77f1fc333b12693989ccbbd9a432465c6ffd6 (diff) | |
download | gsoc2013-evolution-46dee516710185ab5fb881a02580c66f3e82181c.tar.gz gsoc2013-evolution-46dee516710185ab5fb881a02580c66f3e82181c.tar.zst gsoc2013-evolution-46dee516710185ab5fb881a02580c66f3e82181c.zip |
Set the (new) "no_body" flag on the composer.
* evolution-composer.c (init): Set the (new) "no_body" flag on the
composer.
(impl_Composer_set_body_text): And unset it here.
(unset_no_body): And here (called if/when the composer is
realized).
* e-msg-composer.c (build_message): If the composer has the
"no_body" flag set, and a single attachment, promote that
attachment to be the message body.
svn path=/trunk/; revision=14393
-rw-r--r-- | composer/ChangeLog | 12 | ||||
-rw-r--r-- | composer/e-msg-composer.c | 31 | ||||
-rw-r--r-- | composer/e-msg-composer.h | 1 | ||||
-rw-r--r-- | composer/evolution-composer.c | 13 |
4 files changed, 52 insertions, 5 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog index 33ff23ef08..2e4e572644 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,15 @@ +2001-10-29 Dan Winship <danw@ximian.com> + + * evolution-composer.c (init): Set the (new) "no_body" flag on the + composer. + (impl_Composer_set_body_text): And unset it here. + (unset_no_body): And here (called if/when the composer is + realized). + + * e-msg-composer.c (build_message): If the composer has the + "no_body" flag set, and a single attachment, promote that + attachment to be the message body. + 2001-10-30 Radek Doulik <rodo@ximian.com> * listener.c (reply_indent): simplified, requires new gtkhtml diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 50c4e608c8..b68d0e871f 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -280,6 +280,21 @@ add_inlined_images (EMsgComposer *composer, CamelMultipart *multipart) } } +static void +copy_headers (CamelMedium *dest, CamelMedium *src) +{ + CamelMediumHeader header; + GArray *headers; + int i; + + headers = camel_medium_get_headers (src); + for (i = 0; i < headers->len; i++) { + header = g_array_index (headers, CamelMediumHeader, i); + camel_medium_set_header (dest, header.name, header.value); + } + camel_medium_free_headers (src, headers); +} + /* This functions builds a CamelMimeMessage for the message that the user has * composed in `composer'. */ @@ -299,7 +314,7 @@ build_message (EMsgComposer *composer) CamelMultipart *body = NULL; CamelMimePart *part; CamelException ex; - int i; + int i, num_attachments; if (composer->persist_stream_interface == CORBA_OBJECT_NIL) return NULL; @@ -395,7 +410,8 @@ build_message (EMsgComposer *composer) } else current = plain; - if (e_msg_composer_attachment_bar_get_num_attachments (attachment_bar)) { + num_attachments = e_msg_composer_attachment_bar_get_num_attachments (attachment_bar); + if (num_attachments) { CamelMultipart *multipart = camel_multipart_new (); /* Generate a random boundary. */ @@ -410,8 +426,15 @@ build_message (EMsgComposer *composer) camel_object_unref (CAMEL_OBJECT (part)); e_msg_composer_attachment_bar_to_multipart (attachment_bar, multipart, composer->charset); - - current = CAMEL_DATA_WRAPPER (multipart); + + if (composer->no_body && num_attachments == 1) { + part = camel_multipart_get_part (multipart, 1); + current = camel_medium_get_content_object (CAMEL_MEDIUM (part)); + copy_headers (CAMEL_MEDIUM (new), CAMEL_MEDIUM (part)); + camel_object_ref (CAMEL_OBJECT (current)); + camel_object_unref (CAMEL_OBJECT (multipart)); + } else + current = CAMEL_DATA_WRAPPER (multipart); } if (composer->pgp_sign || composer->pgp_encrypt) { diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h index 941834d120..4e73509207 100644 --- a/composer/e-msg-composer.h +++ b/composer/e-msg-composer.h @@ -92,6 +92,7 @@ struct _EMsgComposer { gboolean view_cc : 1; gboolean view_subject : 1; gboolean has_changed : 1; + gboolean no_body : 1; gboolean in_signature_insert : 1; }; diff --git a/composer/evolution-composer.c b/composer/evolution-composer.c index c19f286a66..289a8a3765 100644 --- a/composer/evolution-composer.c +++ b/composer/evolution-composer.c @@ -109,6 +109,7 @@ impl_Composer_set_body_text (PortableServer_Servant servant, composer = EVOLUTION_COMPOSER (bonobo_object); e_msg_composer_set_body_text (composer->composer, text); + composer->composer->no_body = FALSE; } static void @@ -244,13 +245,23 @@ class_init (EvolutionComposerClass *klass) } static void +unset_no_body (EMsgComposer *composer, gpointer user_data) +{ + composer->no_body = FALSE; +} + +static void init (EvolutionComposer *composer) { const MailConfigAccount *account; account = mail_config_get_default_account (); composer->composer = e_msg_composer_new (); - + composer->composer->no_body = TRUE; + + gtk_signal_connect (GTK_OBJECT (composer->composer), "realize", + GTK_SIGNAL_FUNC (unset_no_body), NULL); + gtk_signal_connect (GTK_OBJECT (composer->composer), "send", GTK_SIGNAL_FUNC (send_cb), NULL); gtk_signal_connect (GTK_OBJECT (composer->composer), "postpone", |