From 2bb495b6eb8e1e7e2c22691a5b3891879baa5f76 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Wed, 30 May 2001 21:41:42 +0000 Subject: Rename the "PGP" page back to "Other" and add a "default charset" option * mail-config.glade: Rename the "PGP" page back to "Other" and add a "default charset" option menu. * mail-config.c (config_read, mail_config_write_on_exit, mail_config_get_default_charset, mail_config_set_default_charset): Handle "default charset". * mail-accounts.c (construct): Fill in the "default_charset" menu with an e_charset_picker menu. (charset_menu_deactivate): Update the default charset. svn path=/trunk/; revision=10057 --- mail/ChangeLog | 13 +++++++++++++ mail/mail-accounts.c | 22 +++++++++++++++++++++- mail/mail-accounts.h | 1 + mail/mail-config.c | 33 ++++++++++++++++++++++++++++++++ mail/mail-config.glade | 51 ++++++++++++++++++++++++++++++++++++++++++++++---- mail/mail-config.h | 3 +++ 6 files changed, 118 insertions(+), 5 deletions(-) diff --git a/mail/ChangeLog b/mail/ChangeLog index 49090864c9..60a41502c2 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,16 @@ +2001-05-30 Dan Winship + + * mail-config.glade: Rename the "PGP" page back to "Other" and add + a "default charset" option menu. + + * mail-config.c (config_read, mail_config_write_on_exit, + mail_config_get_default_charset, mail_config_set_default_charset): + Handle "default charset". + + * mail-accounts.c (construct): Fill in the "default_charset" menu + with an e_charset_picker menu. + (charset_menu_deactivate): Update the default charset. + 2001-05-29 Jeffrey Stedfast * mail-callbacks.c (list_add_addresses): Take another argument to diff --git a/mail/mail-accounts.c b/mail/mail-accounts.c index b98a426eb9..78317336cd 100644 --- a/mail/mail-accounts.c +++ b/mail/mail-accounts.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "mail-accounts.h" #include "mail-config.h" @@ -548,11 +549,23 @@ attach_forward_style_signal (GtkWidget *item, gpointer data) (*num)++; } +static void +charset_menu_deactivate (GtkWidget *menu, gpointer data) +{ + char *charset; + + charset = e_charset_picker_get_charset (menu); + if (charset) { + mail_config_set_default_charset (charset); + g_free (charset); + } +} + static void construct (MailAccountsDialog *dialog) { GladeXML *gui; - GtkWidget *notebook; + GtkWidget *notebook, *menu; int num; gui = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", NULL); @@ -654,6 +667,7 @@ construct (MailAccountsDialog *dialog) gtk_container_foreach (GTK_CONTAINER (gtk_option_menu_get_menu (dialog->forward_style)), attach_forward_style_signal, &num); + /* Other page */ dialog->pgp_path = GNOME_FILE_ENTRY (glade_xml_get_widget (gui, "filePgpPath")); gtk_entry_set_text (GTK_ENTRY (gnome_file_entry_gtk_entry (dialog->pgp_path)), mail_config_get_pgp_path ()); @@ -661,6 +675,12 @@ construct (MailAccountsDialog *dialog) gtk_signal_connect (GTK_OBJECT (gnome_file_entry_gtk_entry (dialog->pgp_path)), "changed", GTK_SIGNAL_FUNC (pgp_path_changed), dialog); + dialog->charset = GTK_OPTION_MENU (glade_xml_get_widget (gui, "omenuCharset")); + menu = e_charset_picker_new (mail_config_get_default_charset ()); + gtk_option_menu_set_menu (dialog->charset, menu); + gtk_signal_connect (GTK_OBJECT (menu), "deactivate", + GTK_SIGNAL_FUNC (charset_menu_deactivate), NULL); + /* now to fill in the clists */ dialog->accounts_row = -1; dialog->accounts = mail_config_get_accounts (); diff --git a/mail/mail-accounts.h b/mail/mail-accounts.h index 91de24e6d1..be7898ad8c 100644 --- a/mail/mail-accounts.h +++ b/mail/mail-accounts.h @@ -81,6 +81,7 @@ struct _MailAccountsDialog { /* Composer page */ GtkToggleButton *send_html; GtkOptionMenu *forward_style; + GtkOptionMenu *charset; /* PGP page */ GnomeFileEntry *pgp_path; diff --git a/mail/mail-config.c b/mail/mail-config.c index aba9a56220..af1667200f 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -68,6 +68,7 @@ typedef struct { MailConfigHTTPMode http_mode; MailConfigForwardStyle default_forward_style; MailConfigDisplayStyle message_display_style; + char *default_charset; } MailConfig; static const char GCONFPATH[] = "/apps/Evolution/Mail"; @@ -477,6 +478,19 @@ config_read (void) config->message_display_style = MAIL_CONFIG_DISPLAY_NORMAL; g_free (str); + /* Default charset */ + str = g_strdup_printf ("=%s/config/Mail=/Format/charset", evolution_dir); + config->default_charset = gnome_config_get_string (str); + g_free (str); + if (!config->default_charset) { + config->default_charset = g_get_charset (); + if (!config->default_charset || + !g_strcasecmp (config->default_charset, "US-ASCII")) + config->default_charset = g_strdup ("ISO-8859-1"); + else + config->default_charset = g_strdup (config->default_charset); + } + gnome_config_sync (); } @@ -671,6 +685,11 @@ mail_config_write_on_exit (void) gnome_config_set_int (str, config->message_display_style); g_free (str); + /* Default charset */ + str = g_strdup_printf ("=%s/config/Mail=/Format/default_charset", evolution_dir); + gnome_config_set_string (str, config->default_charset); + g_free (str); + /* Passwords */ gnome_config_private_clean_section ("/Evolution/Passwords"); sources = mail_config_get_sources (); @@ -927,6 +946,20 @@ mail_config_set_message_display_style (MailConfigDisplayStyle style) config->message_display_style = style; } +const char * +mail_config_get_default_charset (void) +{ + return config->default_charset; +} + +void +mail_config_set_default_charset (const char *charset) +{ + g_free (config->default_charset); + config->default_charset = g_strdup (charset); +} + + const MailConfigAccount * mail_config_get_default_account (void) { diff --git a/mail/mail-config.glade b/mail/mail-config.glade index f6fcfc9464..f4c5519882 100644 --- a/mail/mail-config.glade +++ b/mail/mail-config.glade @@ -2182,7 +2182,7 @@ Quoted vbox64 4 False - 4 + 8 GtkHBox @@ -2203,7 +2203,7 @@ Quoted False 0.5 0.5 - 4 + 0 0 0 @@ -2237,13 +2237,56 @@ Quoted + + + GtkHBox + hbox56 + False + 0 + + 0 + False + True + + + + GtkLabel + lblCharset + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GtkOptionMenu + omenuCharset + True + placeholder + + 0 + + 0 + False + False + + + GtkLabel Notebook:tab - pgp_config_label - + other_config_label + GTK_JUSTIFY_CENTER False 0.5 diff --git a/mail/mail-config.h b/mail/mail-config.h index d242d032d1..bb4fb8fbce 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -137,6 +137,9 @@ void mail_config_set_default_forward_style (MailConfigForwardS MailConfigDisplayStyle mail_config_get_message_display_style (void); void mail_config_set_message_display_style (MailConfigDisplayStyle style); +const char *mail_config_get_default_charset (void); +void mail_config_set_default_charset (const char *charset); + const MailConfigAccount *mail_config_get_default_account (void); const MailConfigAccount *mail_config_get_account_by_name (const char *account_name); const MailConfigAccount *mail_config_get_account_by_source_url (const char *url); -- cgit