aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--composer/ChangeLog13
-rw-r--r--composer/e-msg-composer-attachment-bar.c13
-rw-r--r--composer/e-msg-composer-attachment-bar.h3
-rw-r--r--composer/e-msg-composer.c50
-rw-r--r--composer/e-msg-composer.h2
5 files changed, 68 insertions, 13 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 8a58e343d3..4421e39866 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,7 +1,20 @@
2001-07-02 Jeffrey Stedfast <fejj@ximian.com>
+ * e-msg-composer-attachment-bar.c (attach_to_multipart): Set the
+ user-chosen charset.
+
+ * e-msg-composer.c (menu_change_charset_cb): New callback function
+ to get the user-set charset.
+ (init): Set the charset to NULL.
+ (best_charset): Take a default_charset param that holds the value
+ the user set for this particular message using the menu.
+ (destroy): Free the charset.
+
+2001-07-02 Jeffrey Stedfast <fejj@ximian.com>
+
* e-msg-composer.c (setup_ui): Construct an e-charset-picker
bonobo-ui menu.
+ (menu_change_charset_cb):
2001-06-30 Jon Trowbridge <trow@ximian.com>
diff --git a/composer/e-msg-composer-attachment-bar.c b/composer/e-msg-composer-attachment-bar.c
index 27d017e787..3e454cd8b8 100644
--- a/composer/e-msg-composer-attachment-bar.c
+++ b/composer/e-msg-composer-attachment-bar.c
@@ -729,7 +729,8 @@ best_encoding (const guchar *text)
static void
attach_to_multipart (CamelMultipart *multipart,
- EMsgComposerAttachment *attachment)
+ EMsgComposerAttachment *attachment,
+ const char *default_charset)
{
CamelContentType *content_type;
@@ -747,9 +748,10 @@ attach_to_multipart (CamelMultipart *multipart,
g_byte_array_append (array, "", 1);
text = array->data;
- if (is_8bit (text))
+ if (is_8bit (text)) {
camel_mime_part_set_encoding (attachment->body, best_encoding (text));
- else
+ header_content_type_set_param (content_type, "charset", default_charset);
+ } else
camel_mime_part_set_encoding (attachment->body, CAMEL_MIME_PART_ENCODING_7BIT);
camel_object_unref (CAMEL_OBJECT (stream));
@@ -764,7 +766,8 @@ attach_to_multipart (CamelMultipart *multipart,
void
e_msg_composer_attachment_bar_to_multipart (EMsgComposerAttachmentBar *bar,
- CamelMultipart *multipart)
+ CamelMultipart *multipart,
+ const char *default_charset)
{
EMsgComposerAttachmentBarPrivate *priv;
GList *p;
@@ -780,7 +783,7 @@ e_msg_composer_attachment_bar_to_multipart (EMsgComposerAttachmentBar *bar,
EMsgComposerAttachment *attachment;
attachment = E_MSG_COMPOSER_ATTACHMENT (p->data);
- attach_to_multipart (multipart, attachment);
+ attach_to_multipart (multipart, attachment, default_charset);
}
}
diff --git a/composer/e-msg-composer-attachment-bar.h b/composer/e-msg-composer-attachment-bar.h
index 118f245a88..15774bb2fe 100644
--- a/composer/e-msg-composer-attachment-bar.h
+++ b/composer/e-msg-composer-attachment-bar.h
@@ -63,7 +63,8 @@ typedef struct _EMsgComposerAttachmentBarClass EMsgComposerAttachmentBarClass;
GtkType e_msg_composer_attachment_bar_get_type (void);
GtkWidget *e_msg_composer_attachment_bar_new (GtkAdjustment *adj);
-void e_msg_composer_attachment_bar_to_multipart (EMsgComposerAttachmentBar *bar, CamelMultipart *multipart);
+void e_msg_composer_attachment_bar_to_multipart (EMsgComposerAttachmentBar *bar, CamelMultipart *multipart,
+ const char *default_charset);
guint e_msg_composer_attachment_bar_get_num_attachments (EMsgComposerAttachmentBar *bar);
void e_msg_composer_attachment_bar_attach (EMsgComposerAttachmentBar *bar, const gchar *file_name);
void e_msg_composer_attachment_bar_attach_mime_part (EMsgComposerAttachmentBar *bar, CamelMimePart *part);
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index b48e85b691..4e72852fd2 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -189,19 +189,28 @@ best_encoding (GByteArray *buf, const char *charset)
}
static const char *
-best_charset (GByteArray *buf, CamelMimePartEncodingType *encoding)
+best_charset (GByteArray *buf, const char *default_charset, CamelMimePartEncodingType *encoding)
{
const char *charset;
-
+
+ /* First try US-ASCII */
*encoding = best_encoding (buf, "US-ASCII");
if (*encoding == CAMEL_MIME_PART_ENCODING_7BIT)
return NULL;
-
+
+ /* Next try the user-specified charset for this message */
+ charset = default_charset;
+ *encoding = best_encoding (buf, charset);
+ if (*encoding != -1)
+ return charset;
+
+ /* Now try the user's default charset from the mail config */
charset = mail_config_get_default_charset ();
*encoding = best_encoding (buf, charset);
if (*encoding != -1)
return charset;
-
+
+ /* Try to find something that will work */
charset = camel_charset_best (buf->data, buf->len);
if (!charset)
*encoding = CAMEL_MIME_PART_ENCODING_7BIT;
@@ -309,10 +318,13 @@ build_message (EMsgComposer *composer)
camel_object_unref (CAMEL_OBJECT (new));
return NULL;
}
- charset = best_charset (data, &plain_encoding);
+
+ /* FIXME: we may want to do better than this... */
+ charset = best_charset (data, composer->charset, &plain_encoding);
type = header_content_type_new ("text", "plain");
if (charset)
header_content_type_set_param (type, "charset", charset);
+
plain = camel_data_wrapper_new ();
stream = camel_stream_mem_new_with_byte_array (data);
camel_data_wrapper_construct_from_stream (plain, stream);
@@ -393,7 +405,7 @@ build_message (EMsgComposer *composer)
camel_multipart_add_part (multipart, part);
camel_object_unref (CAMEL_OBJECT (part));
- e_msg_composer_attachment_bar_to_multipart (attachment_bar, multipart);
+ e_msg_composer_attachment_bar_to_multipart (attachment_bar, multipart, composer->charset);
current = CAMEL_DATA_WRAPPER (multipart);
}
@@ -1349,6 +1361,24 @@ menu_view_cc_cb (BonoboUIComponent *component,
e_msg_composer_set_view_cc (E_MSG_COMPOSER (user_data), atoi (state));
}
+static void
+menu_changed_charset_cb (BonoboUIComponent *component,
+ const char *path,
+ Bonobo_UIComponent_EventType type,
+ const char *state,
+ gpointer user_data)
+{
+ if (type != Bonobo_UIComponent_STATE_CHANGED)
+ return;
+
+ if (atoi (state)) {
+ /* Charset menu names are "Charset-%s" where %s is the charset name */
+ g_free (E_MSG_COMPOSER (user_data)->charset);
+ E_MSG_COMPOSER (user_data)->charset = g_strdup (path + strlen ("Charset-"));
+ g_warning ("Set charset to %s", E_MSG_COMPOSER (user_data)->charset);
+ }
+}
+
static BonoboUIVerb verbs [] = {
@@ -1399,7 +1429,9 @@ setup_ui (EMsgComposer *composer)
e_pixmaps_update (composer->uic, pixcache);
- e_charset_picker_bonobo_ui_populate (composer->uic, NULL);
+ e_charset_picker_bonobo_ui_populate (composer->uic, NULL,
+ menu_changed_charset_cb,
+ composer);
if (!camel_session_is_online (session)) {
/* Move the accelerator from Send to Send Later */
@@ -1606,6 +1638,8 @@ destroy (GtkObject *object)
e_msg_composer_clear_inlined_table (composer);
g_hash_table_destroy (composer->inline_images);
+ g_free (composer->charset);
+
CORBA_exception_init (&ev);
if (composer->persist_stream_interface != CORBA_OBJECT_NIL) {
@@ -1790,6 +1824,8 @@ init (EMsgComposer *composer)
composer->smime_encrypt = FALSE;
composer->has_changed = FALSE;
+
+ composer->charset = NULL;
}
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index 2c3aca359c..ba587e28c2 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -73,6 +73,8 @@ struct _EMsgComposer {
Bonobo_PropertyBag property_bag;
+ char *charset;
+
gboolean attachment_bar_visible : 1;
gboolean send_html : 1;
gboolean pgp_sign : 1;