diff options
-rw-r--r-- | mail/ChangeLog | 25 | ||||
-rw-r--r-- | mail/em-folder-view.c | 14 | ||||
-rw-r--r-- | mail/em-format-html.c | 17 | ||||
-rw-r--r-- | mail/em-format-html.h | 1 | ||||
-rw-r--r-- | mail/em-format.c | 61 | ||||
-rw-r--r-- | mail/em-format.h | 2 | ||||
-rw-r--r-- | mail/evolution-mail.schemas | 28 | ||||
-rw-r--r-- | mail/mail-preferences.c | 4 |
8 files changed, 91 insertions, 61 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index fa60a8087f..5ebbbe6b17 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,28 @@ +2003-09-30 Not Zed <NotZed@Ximian.com> + + * em-format-html.c (efh_init): remove gconf stuff. + (em_format_html_set_xmailer_mask): new method to set the xmailer mask. + + * em-folder-view.c (emfv_display_keys[]): Added charset key to + monitor/retrieve, and xmailer_mask. + (emfv_setting_notify): Monitor charset setting, pass onto the + formatter, as well as xmailer_mask. + + * mail-preferences.c (mail_preferences_construct): use the new + charset key. + (mail_preferences_apply): use the new charset key. + + * evolution-mail.schemas: Moved the mail/format/charset to + mail/display/charset. 1. it makes more sense, and 2. it makes + notification update easier in em-folder-view.c + + * em-format.c (emf_init): remove the gconf charset stuff, for bug + #48791, and also actually fixes the fixme that jeff thought he + fixed. + (em_format_format_text): use default charset as fallback. + (em_format_set_default_charset): New method to set the default charset. + (gconf_charset_changed): removed. + 2003-09-29 Jeffrey Stedfast <fejj@ximian.com> * em-format.c (emf_init): Oops, put the arguments in the right order. diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c index be3af1c284..cbe1fc913a 100644 --- a/mail/em-folder-view.c +++ b/mail/em-folder-view.c @@ -1844,6 +1844,7 @@ emfv_folder_changed(CamelFolder *folder, CamelFolderChangeInfo *changes, EMFolde /* keep these two tables in sync */ enum { EMFV_ANIMATE_IMAGES = 1, + EMFV_CHARSET, EMFV_CITATION_COLOUR, EMFV_CITATION_MARK, EMFV_CARET_MODE, @@ -1851,19 +1852,22 @@ enum { EMFV_MARK_SEEN, EMFV_MARK_SEEN_TIMEOUT, EMFV_LOAD_HTTP, + EMFV_XMAILER_MASK, EMFV_SETTINGS /* last, for loop count */ }; /* IF these get too long, update key field */ static const char * const emfv_display_keys[] = { "animate_images", + "charset", "citation_colour", "mark_citations", "caret_mode", "message_style", "mark_seen", "mark_seen_timeout", - "load_http_images" + "load_http_images", + "xmailer_mask", }; static GHashTable *emfv_setting_key; @@ -1878,11 +1882,14 @@ emfv_setting_notify(GConfClient *gconf, guint cnxn_id, GConfEntry *entry, EMFold tkey = strrchr(entry->key, '/'); g_return_if_fail (tkey != NULL); - + switch(GPOINTER_TO_INT(g_hash_table_lookup(emfv_setting_key, tkey+1))) { case EMFV_ANIMATE_IMAGES: em_format_html_display_set_animate(emfv->preview, gconf_value_get_bool(gconf_entry_get_value(entry))); break; + case EMFV_CHARSET: + em_format_set_default_charset((EMFormat *)emfv->preview, gconf_value_get_string(gconf_entry_get_value(entry))); + break; case EMFV_CITATION_COLOUR: { const char *s; GdkColor colour; @@ -1921,6 +1928,9 @@ emfv_setting_notify(GConfClient *gconf, guint cnxn_id, GConfEntry *entry, EMFold /* FIXME: this doesn't handle the 'sometimes' case, only the always case */ em_format_html_set_load_http((EMFormatHTML *)emfv->preview, style == 2); break; } + case EMFV_XMAILER_MASK: + em_format_html_set_xmailer_mask((EMFormatHTML *)emfv->preview, gconf_value_get_int(gconf_entry_get_value(entry))); + break; } } diff --git a/mail/em-format-html.c b/mail/em-format-html.c index a8cf6c85c3..32f763311d 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -40,8 +40,6 @@ #include <gtkhtml/gtkhtml-stream.h> #include <gtkhtml/htmlengine.h> -#include <gconf/gconf-client.h> - #include <libgnomevfs/gnome-vfs-utils.h> #include <libgnomevfs/gnome-vfs-mime-utils.h> #include <libgnomevfs/gnome-vfs-mime-handlers.h> @@ -111,7 +109,6 @@ static void efh_init(GObject *o) { EMFormatHTML *efh = (EMFormatHTML *)o; - GConfClient *gconf; efh->priv = g_malloc0(sizeof(*efh->priv)); @@ -137,11 +134,6 @@ efh_init(GObject *o) efh->text_colour = 0; efh->text_html_flags = CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES | CAMEL_MIME_FILTER_TOHTML_MARK_CITATION; - - /* TODO: should this be here? wont track changes ... */ - gconf = gconf_client_get_default(); - efh->xmailer_mask = gconf_client_get_int(gconf, "/apps/evolution/mail/display/xmailer_mask", NULL); - g_object_unref(gconf); } static void @@ -279,6 +271,15 @@ em_format_html_set_mark_citations(EMFormatHTML *emfh, int state, guint32 citatio } } +void +em_format_html_set_xmailer_mask(EMFormatHTML *emfh, unsigned int xmailer_mask) +{ + if (emfh->xmailer_mask ^ xmailer_mask) { + emfh->xmailer_mask = xmailer_mask; + em_format_format_clone((EMFormat *)emfh, emfh->format.message, (EMFormat *)emfh); + } +} + CamelMimePart * em_format_html_file_part(EMFormatHTML *efh, const char *mime_type, const char *path, const char *name) { diff --git a/mail/em-format-html.h b/mail/em-format-html.h index c9b4705a96..31675f62fd 100644 --- a/mail/em-format-html.h +++ b/mail/em-format-html.h @@ -130,6 +130,7 @@ void em_format_html_load_http(EMFormatHTML *emf); void em_format_html_set_load_http(EMFormatHTML *emf, int state); void em_format_html_set_mark_citations(EMFormatHTML *emf, int state, guint32 citation_colour); +void em_format_html_set_xmailer_mask(EMFormatHTML *emf, unsigned int xmailer_mask); /* output headers */ void em_format_html_format_headers(EMFormatHTML *efh, struct _CamelStream *stream, struct _CamelMedium *part); diff --git a/mail/em-format.c b/mail/em-format.c index 5cac389dc9..2b8b70b14e 100644 --- a/mail/em-format.c +++ b/mail/em-format.c @@ -33,8 +33,6 @@ #include <libgnomevfs/gnome-vfs-mime-utils.h> #include <libgnomevfs/gnome-vfs-mime-handlers.h> -#include <gconf/gconf-client.h> - #include <e-util/e-msgport.h> #include <camel/camel-url.h> #include <camel/camel-stream.h> @@ -55,12 +53,6 @@ #define d(x) -struct _EMFormatPrivate { - GConfClient *gconf; - guint charset_id; - char *gconf_charset; -}; - static void emf_builtin_init(EMFormatClass *); static const char *emf_snoop_part(CamelMimePart *part); @@ -76,29 +68,10 @@ static guint emf_signals[EMF_LAST_SIGNAL]; static GObjectClass *emf_parent; static void -gconf_charset_changed (GConfClient *client, guint cnxn_id, - GConfEntry *entry, gpointer user_data) -{ - struct _EMFormatPrivate *priv = ((EMFormat *) user_data)->priv; - - g_free (priv->gconf_charset); - priv->gconf_charset = gconf_client_get_string (priv->gconf, "/apps/evolution/mail/format/charset", NULL); -} - -static void emf_init(GObject *o) { - struct _EMFormatPrivate *priv; EMFormat *emf = (EMFormat *)o; - priv = emf->priv = g_new (struct _EMFormatPrivate, 1); - priv->gconf = gconf_client_get_default (); - gconf_client_add_dir (priv->gconf, "/apps/evolution/mail/format/charset", - GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - priv->charset_id = gconf_client_notify_add (priv->gconf, "/apps/evolution/mail/format/charset", - gconf_charset_changed, emf, NULL, NULL); - priv->gconf_charset = gconf_client_get_string (priv->gconf, "/apps/evolution/mail/format/charset", NULL); - emf->inline_table = g_hash_table_new(NULL, NULL); e_dlist_init(&emf->header_list); em_format_default_headers(emf); @@ -107,15 +80,8 @@ emf_init(GObject *o) static void emf_finalise(GObject *o) { - struct _EMFormatPrivate *priv = ((EMFormat *) o)->priv; EMFormat *emf = (EMFormat *)o; - gconf_client_notify_remove (priv->gconf, priv->charset_id); - priv->charset_id = 0; - g_object_unref (priv->gconf); - g_free (priv->gconf_charset); - g_free (priv); - if (emf->session) camel_object_unref(emf->session); @@ -658,6 +624,31 @@ em_format_set_charset(EMFormat *emf, const char *charset) em_format_format_clone(emf, emf->message, emf); } + +/** + * em_format_set_default_charset: + * @emf: + * @charset: + * + * Set the fallback, default system charset to use when no other charsets + * are present. Message will be redisplayed if required (and sometimes redisplayed + * when it isn't). + **/ +void +em_format_set_default_charset(EMFormat *emf, const char *charset) +{ + if ((emf->default_charset && charset && g_ascii_strcasecmp(emf->default_charset, charset) == 0) + || (emf->default_charset == NULL && charset == NULL) + || (emf->default_charset == charset)) + return; + + g_free(emf->default_charset); + emf->default_charset = g_strdup(charset); + + if (emf->message && emf->charset == NULL) + em_format_format_clone(emf, emf->message, emf); +} + /** * em_format_clear_headers: * @emf: @@ -858,7 +849,7 @@ em_format_format_text(EMFormat *emf, CamelStream *stream, CamelDataWrapper *dw) charset = camel_mime_filter_windows_real_charset (windows); camel_object_unref(windows); } else if (charset == NULL) { - charset = emf->priv->gconf_charset; + charset = emf->default_charset; } filter_stream = camel_stream_filter_new_with_stream(stream); diff --git a/mail/em-format.h b/mail/em-format.h index 14bdab1cdc..cc0f6bdd75 100644 --- a/mail/em-format.h +++ b/mail/em-format.h @@ -118,6 +118,7 @@ struct _EMFormat { em_format_mode_t mode; /* source/headers/etc */ char *charset; /* charset override */ + char *default_charset; /* charset fallback */ }; struct _EMFormatClass { @@ -150,6 +151,7 @@ void em_format_set_session(EMFormat *emf, struct _CamelSession *s); void em_format_set_mode(EMFormat *emf, em_format_mode_t type); void em_format_set_charset(EMFormat *emf, const char *charset); +void em_format_set_default_charset(EMFormat *emf, const char *charset); void em_format_clear_headers(EMFormat *emf); /* also indicates to show all headers */ void em_format_default_headers(EMFormat *emf); diff --git a/mail/evolution-mail.schemas b/mail/evolution-mail.schemas index a5a761d8b3..013af3f96a 100644 --- a/mail/evolution-mail.schemas +++ b/mail/evolution-mail.schemas @@ -188,6 +188,20 @@ </schema> <schema> + <key>/schemas/apps/evolution/mail/display/charset</key> + <applyto>/apps/evolution/mail/display/charset</applyto> + <owner>evolution-mail</owner> + <type>string</type> + <default></default> + <locale name="C"> + <short>Default charset in which to display messages</short> + <long> + Default charset in which to display messages. + </long> + </locale> + </schema> + + <schema> <key>/schemas/apps/evolution/mail/display/load_http_images</key> <applyto>/apps/evolution/mail/display/load_http_images</applyto> <owner>evolution-mail</owner> @@ -423,20 +437,6 @@ <!-- Format settings --> <schema> - <key>/schemas/apps/evolution/mail/format/charset</key> - <applyto>/apps/evolution/mail/format/charset</applyto> - <owner>evolution-mail</owner> - <type>string</type> - <default></default> - <locale name="C"> - <short>Default charset in which to display messages</short> - <long> - Default charset in which to display messages. - </long> - </locale> - </schema> - - <schema> <key>/schemas/apps/evolution/mail/format/forward_style</key> <applyto>/apps/evolution/mail/format/forward_style</applyto> <owner>evolution-mail</owner> diff --git a/mail/mail-preferences.c b/mail/mail-preferences.c index 19b786fb6d..43f3a438f7 100644 --- a/mail/mail-preferences.c +++ b/mail/mail-preferences.c @@ -239,7 +239,7 @@ mail_preferences_construct (MailPreferences *prefs) g_signal_connect (prefs->timeout, "value-changed", G_CALLBACK (settings_changed), prefs); prefs->charset = GTK_OPTION_MENU (glade_xml_get_widget (gui, "omenuCharset")); - buf = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/format/charset", NULL); + buf = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/display/charset", NULL); menu = e_charset_picker_new (buf && *buf ? buf : e_iconv_locale_charset ()); gtk_option_menu_set_menu (prefs->charset, GTK_WIDGET (menu)); option_menu_connect (prefs->charset, prefs); @@ -398,7 +398,7 @@ mail_preferences_apply (MailPreferences *prefs) if (!(string = e_charset_picker_get_charset (menu))) string = g_strdup (e_iconv_locale_charset ()); - gconf_client_set_string (prefs->gconf, "/apps/evolution/mail/format/charset", string, NULL); + gconf_client_set_string (prefs->gconf, "/apps/evolution/mail/display/charset", string, NULL); g_free (string); gconf_client_set_bool (prefs->gconf, "/apps/evolution/mail/display/mark_citations", |