aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-10-10 06:01:49 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-10-10 06:01:49 +0800
commitcd28010b326d9f212759a4f4de6cd9b67ac4f0db (patch)
tree4bfd81b9b33e3c38f7ee6f1cc4ea2a291e89c9a2
parenta7282ea415c41d561245abfb988460a7a53c4cfb (diff)
downloadgsoc2013-evolution-cd28010b326d9f212759a4f4de6cd9b67ac4f0db.tar.gz
gsoc2013-evolution-cd28010b326d9f212759a4f4de6cd9b67ac4f0db.tar.zst
gsoc2013-evolution-cd28010b326d9f212759a4f4de6cd9b67ac4f0db.zip
Create a chaqrset picker submenu in the View menu.
2001-10-09 Jeffrey Stedfast <fejj@ximian.com> * folder-browser-ui.c (folder_browser_ui_add_message): Create a chaqrset picker submenu in the View menu. * mail-format.c (mail_format_raw_message): Pass the mail-display to get_data_wrapper_text. (get_data_wrapper_text): Use the user's override charset if one is provided, otherwise user the user's default charset. (handle_text_plain): Pass along the mail-display to get_data_wrapper_text. (handle_application_pgp): Same. (handle_text_enriched): Here too. (mail_get_message_body): Pass NULL as the mail-display to get_data_wrapper_text since we don't have access to a mail-display. * mail-display.c (mail_display_set_charset): New function to set a charset on the maildisplay. Once set, the message is redisplayed using the new charset. (mail_display_destroy): Free the charset. * folder-browser.c (folder_browser_charset_changed): New callback for when a user overrides the message charset. svn path=/trunk/; revision=13530
-rw-r--r--mail/ChangeLog25
-rw-r--r--mail/folder-browser-ui.c27
-rw-r--r--mail/folder-browser.c25
-rw-r--r--mail/folder-browser.h14
-rw-r--r--mail/mail-callbacks.c2
-rw-r--r--mail/mail-display.c18
-rw-r--r--mail/mail-display.h13
-rw-r--r--mail/mail-format.c22
8 files changed, 116 insertions, 30 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index d5a1f97ada..44e9ff183d 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,28 @@
+2001-10-09 Jeffrey Stedfast <fejj@ximian.com>
+
+ * folder-browser-ui.c (folder_browser_ui_add_message): Create a
+ chaqrset picker submenu in the View menu.
+
+ * mail-format.c (mail_format_raw_message): Pass the mail-display
+ to get_data_wrapper_text.
+ (get_data_wrapper_text): Use the user's override charset if one is
+ provided, otherwise user the user's default charset.
+ (handle_text_plain): Pass along the mail-display to
+ get_data_wrapper_text.
+ (handle_application_pgp): Same.
+ (handle_text_enriched): Here too.
+ (mail_get_message_body): Pass NULL as the mail-display to
+ get_data_wrapper_text since we don't have access to a
+ mail-display.
+
+ * mail-display.c (mail_display_set_charset): New function to set a
+ charset on the maildisplay. Once set, the message is redisplayed
+ using the new charset.
+ (mail_display_destroy): Free the charset.
+
+ * folder-browser.c (folder_browser_charset_changed): New callback
+ for when a user overrides the message charset.
+
2001-10-09 Dan Winship <danw@ximian.com>
* mail-callbacks.c (e_gnome_dialog_set_parent): Use
diff --git a/mail/folder-browser-ui.c b/mail/folder-browser-ui.c
index 48cfc2169a..6e691c51f9 100644
--- a/mail/folder-browser-ui.c
+++ b/mail/folder-browser-ui.c
@@ -18,6 +18,7 @@
#include <bonobo/bonobo-ui-component.h>
#include <bonobo/bonobo-ui-util.h>
+#include "widgets/misc/e-charset-picker.h"
#include "widgets/menus/gal-view-menus.h" /* GalView stuff */
#include <gal/menus/gal-view-factory-etable.h>
#include <gal/menus/gal-view-etable.h>
@@ -169,16 +170,16 @@ static void ui_add (FolderBrowser *fb,
EPixmap pixcache[])
{
BonoboUIComponent *uic = fb->uicomp;
- gchar *file;
-
+ char *file;
+
bonobo_ui_component_add_verb_list_with_data (uic, verb, fb);
-
+
bonobo_ui_component_freeze (uic, NULL);
-
+
file = g_strconcat ("evolution-mail-", name, ".xml", NULL);
bonobo_ui_util_set_ui (uic, EVOLUTION_DATADIR, file, "evolution-mail");
g_free (file);
-
+
e_pixmaps_update (uic, pixcache);
bonobo_ui_component_thaw (uic, NULL);
@@ -299,11 +300,10 @@ folder_browser_ui_add_message (FolderBrowser *fb)
int state;
BonoboUIComponent *uic = fb->uicomp;
FolderBrowserSelectionState prev_state;
-
+
ui_add (fb, "message", message_verbs, message_pixcache);
-
+
/* Display Style */
-
state = fb->mail_display->display_style;
bonobo_ui_component_set_prop (uic, message_display_styles[state],
"state", "1", NULL);
@@ -313,17 +313,20 @@ folder_browser_ui_add_message (FolderBrowser *fb)
/* FIXME: this kind of bypasses bonobo but seems the only way when we change components */
folder_browser_set_message_display_style (uic, strrchr (message_display_styles[state], '/') + 1,
Bonobo_UIComponent_STATE_CHANGED, "1", fb);
-
+
/* Resend Message */
-
if (fb->folder && !folder_browser_is_sent (fb))
bonobo_ui_component_set_prop (uic, "/commands/MessageResend", "sensitive", "0", NULL);
-
+
/* sensitivity of message-specific commands */
-
prev_state = fb->selection_state;
fb->selection_state = FB_SELSTATE_UNDEFINED;
folder_browser_ui_set_selection_state (fb, prev_state);
+
+ /* Charset picker */
+ e_charset_picker_bonobo_ui_populate (uic, "/menu/View", FB_DEFAULT_CHARSET,
+ folder_browser_charset_changed,
+ fb);
}
/*
diff --git a/mail/folder-browser.c b/mail/folder-browser.c
index c435b3c281..126ec20a01 100644
--- a/mail/folder-browser.c
+++ b/mail/folder-browser.c
@@ -138,7 +138,7 @@ folder_browser_finalise (GtkObject *object)
g_free (folder_browser->uri);
folder_browser->uri = NULL;
-
+
if (folder_browser->folder) {
camel_object_unhook_event(CAMEL_OBJECT(folder_browser->folder), "folder_changed",
folder_changed, folder_browser);
@@ -1172,6 +1172,29 @@ folder_browser_set_message_display_style (BonoboUIComponent *component
}
void
+folder_browser_charset_changed (BonoboUIComponent *component,
+ const char *path,
+ Bonobo_UIComponent_EventType type,
+ const char *state,
+ gpointer user_data)
+{
+ FolderBrowser *fb = FOLDER_BROWSER (user_data);
+ const char *charset;
+
+ if (type != Bonobo_UIComponent_STATE_CHANGED)
+ return;
+
+ if (atoi (state)) {
+ /* Charset menu names are "Charset-%s" where %s is the charset name */
+ charset = path + strlen ("Charset-");
+ if (!strcmp (charset, FB_DEFAULT_CHARSET))
+ charset = NULL;
+
+ mail_display_set_charset (fb->mail_display, charset);
+ }
+}
+
+void
vfolder_subject (GtkWidget *w, FolderBrowser *fb)
{
vfolder_gui_add_from_message (fb->mail_display->current_message, AUTO_SUBJECT, fb->uri);
diff --git a/mail/folder-browser.h b/mail/folder-browser.h
index 1e10b907a9..85a6d6bbaf 100644
--- a/mail/folder-browser.h
+++ b/mail/folder-browser.h
@@ -24,6 +24,8 @@
#define IS_FOLDER_BROWSER(o) (GTK_CHECK_TYPE ((o), FOLDER_BROWSER_TYPE))
#define IS_FOLDER_BROWSER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), FOLDER_BROWSER_TYPE))
+#define FB_DEFAULT_CHARSET _("Default")
+
typedef enum _FolderBrowserSelectionState {
FB_SELSTATE_NONE,
FB_SELSTATE_SINGLE,
@@ -38,7 +40,7 @@ struct _FolderBrowser {
GNOME_Evolution_Shell shell;
GNOME_Evolution_ShellView shell_view;
-
+
BonoboUIComponent *uicomp;
/*
@@ -68,11 +70,11 @@ struct _FolderBrowser {
gboolean preview_shown;
gboolean threaded;
gboolean pref_master;
-
+
FolderBrowserSelectionState selection_state;
GSList *sensitize_changes;
int sensitize_timeout_id;
-
+
/* View collection and the menu handler object */
GalViewCollection *view_collection;
GalViewMenus *view_menus;
@@ -153,6 +155,12 @@ void folder_browser_set_message_display_style (BonoboUIComponent *comp
const char *state,
gpointer user_data);
+void folder_browser_charset_changed (BonoboUIComponent *component,
+ const char *path,
+ Bonobo_UIComponent_EventType type,
+ const char *state,
+ gpointer user_data);
+
gboolean folder_browser_is_drafts (FolderBrowser *fb);
gboolean folder_browser_is_sent (FolderBrowser *fb);
gboolean folder_browser_is_outbox (FolderBrowser *fb);
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c
index fb2729af59..0efbae40a5 100644
--- a/mail/mail-callbacks.c
+++ b/mail/mail-callbacks.c
@@ -87,7 +87,7 @@ e_gnome_dialog_set_parent (GnomeDialog *dialog, GtkWindow *parent)
gnome_dialog_set_parent (dialog, parent);
gtk_signal_connect_while_alive (GTK_OBJECT (parent), "destroy",
e_gnome_dialog_parent_destroyed,
- dialog, dialog);
+ dialog, GTK_OBJECT (dialog));
}
static GtkWidget *
diff --git a/mail/mail-display.c b/mail/mail-display.c
index a950bace5d..005159f981 100644
--- a/mail/mail-display.c
+++ b/mail/mail-display.c
@@ -1353,6 +1353,23 @@ mail_display_set_message (MailDisplay *md, CamelMedium *medium)
}
/**
+ * mail_display_set_message:
+ * @mail_display: the mail display object
+ * @medium: the input camel medium, or %NULL
+ *
+ * Makes the mail_display object show the contents of the medium
+ * param.
+ **/
+void
+mail_display_set_charset (MailDisplay *mail_display, const char *charset)
+{
+ g_free (mail_display->charset);
+ mail_display->charset = g_strdup (charset);
+
+ mail_display_queue_redisplay (mail_display);
+}
+
+/**
* mail_display_load_images:
* @md: the mail display object
*
@@ -1395,6 +1412,7 @@ mail_display_destroy (GtkObject *object)
{
MailDisplay *mail_display = MAIL_DISPLAY (object);
+ g_free (mail_display->charset);
g_free (mail_display->selection);
g_datalist_clear (mail_display->data);
diff --git a/mail/mail-display.h b/mail/mail-display.h
index 5a6b76c257..61dd4f0579 100644
--- a/mail/mail-display.h
+++ b/mail/mail-display.h
@@ -23,23 +23,25 @@
struct _MailDisplay {
GtkVBox parent;
-
+
EScrollFrame *scroll;
GtkHTML *html;
GtkHTMLStream *stream;
gint redisplay_counter;
gpointer last_active;
guint idle_id;
-
+
+ char *charset;
+
char *selection;
CamelMimeMessage *current_message;
GData **data;
-
+
/* Sigh. This shouldn't be needed. I haven't figured out why it is
though. */
GtkWidget *invisible;
-
+
MailConfigDisplayStyle display_style;
};
@@ -66,6 +68,9 @@ void mail_display_stream_write_when_loaded (MailDisplay *md,
void mail_display_set_message (MailDisplay *mail_display,
CamelMedium *medium);
+void mail_display_set_charset (MailDisplay *mail_display,
+ const char *charset);
+
void mail_display_load_images (MailDisplay *mail_display);
diff --git a/mail/mail-format.c b/mail/mail-format.c
index 03bff9a765..c86a603253 100644
--- a/mail/mail-format.c
+++ b/mail/mail-format.c
@@ -48,7 +48,7 @@
#include "mail-mt.h"
#include "mail-crypto.h"
-static char *get_data_wrapper_text (CamelDataWrapper *data);
+static char *get_data_wrapper_text (CamelDataWrapper *data, MailDisplay *mail_display);
static char *try_inline_pgp (char *start, CamelMimePart *part, MailDisplay *md);
static char *try_inline_pgp_sig (char *start, CamelMimePart *part, MailDisplay *md);
@@ -209,8 +209,8 @@ mail_format_raw_message (CamelMimeMessage *mime_message, MailDisplay *md)
return;
mail_html_write (md->html, md->stream, "<table cellspacing=0 cellpadding=10 width=\"100%%\"><tr><td><tt>\n");
-
- text = get_data_wrapper_text (CAMEL_DATA_WRAPPER (mime_message));
+
+ text = get_data_wrapper_text (CAMEL_DATA_WRAPPER (mime_message), md);
html = e_text_to_html (text, E_TEXT_TO_HTML_CONVERT_NL | E_TEXT_TO_HTML_CONVERT_SPACES | E_TEXT_TO_HTML_ESCAPE_8BIT);
g_free (text);
gtk_html_write (md->html, md->stream, html, strlen (html));
@@ -1050,7 +1050,7 @@ mail_content_loaded (CamelDataWrapper *wrapper, MailDisplay *md, gboolean redisp
* whitespace.
*/
static char *
-get_data_wrapper_text (CamelDataWrapper *wrapper)
+get_data_wrapper_text (CamelDataWrapper *wrapper, MailDisplay *mail_display)
{
CamelStream *memstream;
CamelStreamFilter *filtered_stream;
@@ -1068,7 +1068,11 @@ get_data_wrapper_text (CamelDataWrapper *wrapper)
CamelMimeFilterCharset *filter;
const char *charset;
- charset = mail_config_get_default_charset ();
+ if (mail_display && mail_display->charset)
+ charset = mail_display->charset;
+ else
+ charset = mail_config_get_default_charset ();
+
filter = camel_mime_filter_charset_new_convert (charset, "utf-8");
if (filter) {
camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (filter));
@@ -1124,7 +1128,7 @@ handle_text_plain (CamelMimePart *part, const char *mime_type,
const char *format;
int i;
- text = get_data_wrapper_text (wrapper);
+ text = get_data_wrapper_text (wrapper, md);
if (!text)
return FALSE;
@@ -1206,7 +1210,7 @@ handle_application_pgp (CamelMimePart *part, const char *mime_type,
if (g_strcasecmp (format, "text") != 0)
return FALSE;
- text = get_data_wrapper_text (wrapper);
+ text = get_data_wrapper_text (wrapper, md);
if (!text)
return FALSE;
@@ -1684,7 +1688,7 @@ handle_text_enriched (CamelMimePart *part, const char *mime_type,
g_hash_table_insert (translations, "np", "<hr>");
}
- text = get_data_wrapper_text (wrapper);
+ text = get_data_wrapper_text (wrapper, md);
if (!text)
return FALSE;
@@ -2351,7 +2355,7 @@ mail_get_message_body (CamelDataWrapper *data, gboolean want_plain, gboolean cit
/* Get the body data for other text/ or message/ types */
if (header_content_type_is (mime_type, "text", "*") ||
header_content_type_is (mime_type, "message", "*")) {
- text = get_data_wrapper_text (data);
+ text = get_data_wrapper_text (data, NULL);
if (text && !header_content_type_is (mime_type, "text", "html")) {
char *html = e_text_to_html (text, E_TEXT_TO_HTML_PRE | (cite ? E_TEXT_TO_HTML_CITE : 0));
g_free (text);