2007-01-11 [wwp] 2.7.0cvs7
authorTristan Chabredier <wwp@claws-mail.org>
Thu, 11 Jan 2007 11:16:38 +0000 (11:16 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Thu, 11 Jan 2007 11:16:38 +0000 (11:16 +0000)
* src/compose.c
* src/prefs_account.c
* src/prefs_account.h
Add per-account spellcheck default dictionaries settings.

ChangeLog
PATCHSETS
configure.ac
src/compose.c
src/prefs_account.c
src/prefs_account.h

index 7ed1754..a3f4d89 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-01-11 [wwp]       2.7.0cvs7
+
+       * src/compose.c
+       * src/prefs_account.c
+       * src/prefs_account.h
+               Add per-account spellcheck default dictionaries settings.
+
 2007-01-10 [colin]     2.7.0cvs6
 
        * src/prefs_folder_item.c
index 4edc6b4..36eb446 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.5.2.40 -r 1.5.2.41 src/gtk/pluginwindow.c;  ) > 2.7.0cvs4.patchset
 ( cvs diff -u -r 1.274.2.161 -r 1.274.2.162 src/mainwindow.c;  ) > 2.7.0cvs5.patchset
 ( cvs diff -u -r 1.52.2.34 -r 1.52.2.35 src/prefs_folder_item.c;  ) > 2.7.0cvs6.patchset
+( cvs diff -u -r 1.382.2.349 -r 1.382.2.350 src/compose.c;  cvs diff -u -r 1.105.2.76 -r 1.105.2.77 src/prefs_account.c;  cvs diff -u -r 1.49.2.23 -r 1.49.2.24 src/prefs_account.h;  ) > 2.7.0cvs7.patchset
index 207cd96..f8a108f 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=7
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=6
+EXTRA_VERSION=7
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 8608782..917a2dd 100644 (file)
@@ -517,6 +517,11 @@ static PrefsAccount *compose_guess_forward_account_from_msginfo    (MsgInfo *msginf
 
 static MsgInfo *compose_msginfo_new_from_compose(Compose *compose);
 
+#ifdef USE_ASPELL
+static void compose_set_dictionaries_from_folder_prefs(Compose *compose,
+                                               FolderItem *folder_item);
+#endif
+
 static GtkItemFactoryEntry compose_popup_entries[] =
 {
        {N_("/_Add..."),        NULL, compose_attach_cb, 0, NULL},
@@ -972,15 +977,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
 
        undo_block(compose->undostruct);
 #ifdef USE_ASPELL
-       if (item && item->prefs && compose->gtkaspell) {
-               if (item->prefs->enable_default_dictionary)
-                       gtkaspell_change_dict(compose->gtkaspell, 
-                                   item->prefs->default_dictionary, FALSE);
-               if (item->prefs->enable_default_alt_dictionary)
-                       gtkaspell_change_alt_dict(compose->gtkaspell, 
-                                   item->prefs->default_alt_dictionary);
-               compose_spell_menu_changed(compose);
-       }
+       compose_set_dictionaries_from_folder_prefs(compose, item);
 #endif
 
        if (account->auto_sig)
@@ -1411,17 +1408,7 @@ static Compose *compose_generic_reply(MsgInfo *msginfo, gboolean quote,
 
        undo_block(compose->undostruct);
 #ifdef USE_ASPELL
-       if (msginfo->folder && msginfo->folder->prefs && 
-           msginfo->folder->prefs && 
-           compose->gtkaspell) {
-               if (msginfo->folder->prefs->enable_default_dictionary)
-                       gtkaspell_change_dict(compose->gtkaspell, 
-                                   msginfo->folder->prefs->default_dictionary, FALSE);
-               if (msginfo->folder->prefs->enable_default_alt_dictionary)
-                       gtkaspell_change_alt_dict(compose->gtkaspell, 
-                                   msginfo->folder->prefs->default_alt_dictionary);
-               compose_spell_menu_changed(compose);
-       }
+               compose_set_dictionaries_from_folder_prefs(compose, msginfo->folder);
 #endif
 
        if (quote) {
@@ -4120,6 +4107,21 @@ static void compose_select_account(Compose *compose, PrefsAccount *account,
                compose_insert_sig(compose, TRUE);
                undo_unblock(compose->undostruct);
        }
+
+#ifdef USE_ASPELL
+       /* use account's dict info if set */
+       if (compose->gtkaspell) {
+               if (account->enable_default_dictionary)
+                       gtkaspell_change_dict(compose->gtkaspell,
+                                       account->default_dictionary, FALSE);
+               if (account->enable_default_alt_dictionary)
+                       gtkaspell_change_alt_dict(compose->gtkaspell,
+                                       account->default_alt_dictionary);
+               if (account->enable_default_dictionary
+                       || account->enable_default_alt_dictionary)
+                       compose_spell_menu_changed(compose);
+       }
+#endif
 }
 
 gboolean compose_check_for_valid_recipient(Compose *compose) {
@@ -9491,6 +9493,29 @@ static MsgInfo *compose_msginfo_new_from_compose(Compose *compose)
        return newmsginfo;
 }
 
+#ifdef USE_ASPELL
+/* update compose's dictionaries from folder dict settings */
+static void compose_set_dictionaries_from_folder_prefs(Compose *compose,
+                                               FolderItem *folder_item)
+{
+       g_return_if_fail(compose != NULL);
+
+       if (compose->gtkaspell && folder_item && folder_item->prefs) {
+               FolderItemPrefs *prefs = folder_item->prefs;
+
+               if (prefs->enable_default_dictionary)
+                       gtkaspell_change_dict(compose->gtkaspell,
+                                       prefs->default_dictionary, FALSE);
+               if (folder_item->prefs->enable_default_alt_dictionary)
+                       gtkaspell_change_alt_dict(compose->gtkaspell,
+                                       prefs->default_alt_dictionary);
+               if (prefs->enable_default_dictionary
+                       || prefs->enable_default_alt_dictionary)
+                       compose_spell_menu_changed(compose);
+       }
+}
+#endif
+
 /*
  * End of Source.
  */
index 9610c24..d21ce95 100644 (file)
@@ -163,6 +163,12 @@ static struct Compose {
        GtkWidget *autobcc_entry;
        GtkWidget *autoreplyto_chkbtn;
        GtkWidget *autoreplyto_entry;
+#ifdef USE_ASPELL
+       GtkWidget *checkbtn_enable_default_dictionary;
+       GtkWidget *optmenu_default_dictionary;
+       GtkWidget *checkbtn_enable_default_alt_dictionary;
+       GtkWidget *optmenu_default_alt_dictionary;
+#endif
 } compose;
 
 static struct Privacy {
@@ -265,6 +271,13 @@ static void prefs_account_nntpauth_toggled(GtkToggleButton *button,
 static void prefs_account_mailcmd_toggled(GtkToggleButton *button,
                                          gpointer user_data);
 
+#if USE_ASPELL
+static void prefs_account_compose_default_dictionary_set_string_from_optmenu
+                                                       (PrefParam *pparam);
+static void prefs_account_compose_default_dictionary_set_optmenu_from_string
+                                                       (PrefParam *pparam);
+#endif
+
 static gchar *privacy_prefs;
 
 static PrefParam param[] = {
@@ -441,6 +454,26 @@ static PrefParam param[] = {
         &compose.autoreplyto_entry,
         prefs_set_data_from_entry, prefs_set_entry},
 
+#if USE_ASPELL
+       {"enable_default_dictionary", "", &tmp_ac_prefs.enable_default_dictionary, P_BOOL,
+        &compose.checkbtn_enable_default_dictionary,
+        prefs_set_data_from_toggle, prefs_set_toggle},
+
+       {"default_dictionary", NULL, &tmp_ac_prefs.default_dictionary, P_STRING,
+        &compose.optmenu_default_dictionary,
+        prefs_account_compose_default_dictionary_set_string_from_optmenu,
+        prefs_account_compose_default_dictionary_set_optmenu_from_string},
+
+       {"enable_default_alt_dictionary", "", &tmp_ac_prefs.enable_default_alt_dictionary, P_BOOL,
+        &compose.checkbtn_enable_default_alt_dictionary,
+        prefs_set_data_from_toggle, prefs_set_toggle},
+
+       {"default_alt_dictionary", NULL, &tmp_ac_prefs.default_alt_dictionary, P_STRING,
+        &compose.optmenu_default_alt_dictionary,
+        prefs_account_compose_default_dictionary_set_string_from_optmenu,
+        prefs_account_compose_default_dictionary_set_optmenu_from_string},
+#endif  
+
        /* Privacy */
        {"default_privacy_system", "", &tmp_ac_prefs.default_privacy_system, P_STRING,
         &privacy.default_privacy_system,
@@ -710,6 +743,17 @@ static void create_widget_func(PrefsPage * _page,
 
        if (notebook == NULL)
                prefs_account_create();
+       else {
+               /* reset gtkaspell menus */
+               gtk_option_menu_remove_menu(GTK_OPTION_MENU(compose.optmenu_default_dictionary));
+               gtk_option_menu_set_menu(GTK_OPTION_MENU(compose.optmenu_default_dictionary), 
+                               gtkaspell_dictionary_option_menu_new(
+                               prefs_common.aspell_path));
+               gtk_option_menu_remove_menu(GTK_OPTION_MENU(compose.optmenu_default_alt_dictionary));
+               gtk_option_menu_set_menu(GTK_OPTION_MENU(compose.optmenu_default_alt_dictionary), 
+                               gtkaspell_dictionary_option_menu_new_with_refresh(
+                               prefs_common.aspell_path, FALSE));
+       }
        gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0);
        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
 
@@ -1881,6 +1925,14 @@ static void prefs_account_compose_create(void)
        GtkWidget *autobcc_entry;
        GtkWidget *autoreplyto_chkbtn;
        GtkWidget *autoreplyto_entry;
+#if USE_ASPELL
+       GtkWidget *frame_dict;
+       GtkWidget *table_dict;
+       GtkWidget *checkbtn_enable_default_dictionary = NULL;
+       GtkWidget *optmenu_default_dictionary = NULL;
+       GtkWidget *checkbtn_enable_default_alt_dictionary = NULL;
+       GtkWidget *optmenu_default_alt_dictionary = NULL;
+#endif
 
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
        gtk_widget_show (vbox1);
@@ -2006,6 +2058,53 @@ static void prefs_account_compose_create(void)
 
        SET_TOGGLE_SENSITIVITY (autoreplyto_chkbtn, autoreplyto_entry);
 
+#if USE_ASPELL
+       PACK_FRAME (vbox1, frame_dict, _("Spell check dictionaries"));
+
+       table_dict =  gtk_table_new (2, 2, FALSE);
+       gtk_widget_show (table_dict);
+       gtk_container_add (GTK_CONTAINER (frame_dict), table_dict);
+       gtk_container_set_border_width (GTK_CONTAINER (table_dict), 8);
+       gtk_table_set_row_spacings (GTK_TABLE (table_dict), VSPACING_NARROW_2);
+       gtk_table_set_col_spacings (GTK_TABLE (table_dict), 8);
+
+       /* Default dictionary */
+       checkbtn_enable_default_dictionary = gtk_check_button_new_with_label(_("Default dictionary: "));
+       gtk_table_attach(GTK_TABLE(table_dict), checkbtn_enable_default_dictionary, 0, 1,
+                       0, 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_dictionary),
+                       tmp_ac_prefs.enable_default_dictionary);
+
+       optmenu_default_dictionary = gtk_option_menu_new();
+       gtk_table_attach(GTK_TABLE(table_dict), optmenu_default_dictionary, 1, 2,
+                       0, 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+
+       gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_default_dictionary), 
+                       gtkaspell_dictionary_option_menu_new(
+                       prefs_common.aspell_path));
+
+       SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_dictionary, optmenu_default_dictionary);
+
+       /* Default dictionary */
+       checkbtn_enable_default_alt_dictionary = gtk_check_button_new_with_label(_("Default alternate dictionary: "));
+       gtk_table_attach(GTK_TABLE(table_dict), checkbtn_enable_default_alt_dictionary, 0, 1,
+                       1, 2, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_alt_dictionary),
+                       tmp_ac_prefs.enable_default_alt_dictionary);
+
+       optmenu_default_alt_dictionary = gtk_option_menu_new();
+       gtk_table_attach(GTK_TABLE(table_dict), optmenu_default_alt_dictionary, 1, 2,
+                       1, 2, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+
+       gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_default_alt_dictionary), 
+                       gtkaspell_dictionary_option_menu_new_with_refresh(
+                       prefs_common.aspell_path, FALSE));
+
+       SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_alt_dictionary, optmenu_default_alt_dictionary);
+
+       gtk_widget_show_all(table_dict);
+#endif
+
        compose.sigfile_radiobtn = sigfile_radiobtn;
        compose.entry_sigpath      = entry_sigpath;
        compose.checkbtn_autosig   = checkbtn_autosig;
@@ -2017,6 +2116,12 @@ static void prefs_account_compose_create(void)
        compose.autobcc_entry      = autobcc_entry;
        compose.autoreplyto_chkbtn = autoreplyto_chkbtn;
        compose.autoreplyto_entry  = autoreplyto_entry;
+#ifdef USE_ASPELL
+       compose.checkbtn_enable_default_dictionary = checkbtn_enable_default_dictionary;
+       compose.optmenu_default_dictionary = optmenu_default_dictionary;
+       compose.checkbtn_enable_default_alt_dictionary = checkbtn_enable_default_alt_dictionary;
+       compose.optmenu_default_alt_dictionary = optmenu_default_alt_dictionary;
+#endif
 }
 
 static void prefs_account_privacy_create(void)
@@ -3361,6 +3466,49 @@ static void prefs_account_mailcmd_toggled(GtkToggleButton *button,
        gtk_widget_set_sensitive(basic.pass_entry, !use_mailcmd);
 }
 
+#if USE_ASPELL
+static void prefs_account_compose_default_dictionary_set_string_from_optmenu
+                                                       (PrefParam *pparam)
+{
+       GtkWidget *menu;
+       GtkWidget *menuitem;
+       gchar **str;
+
+       g_return_if_fail(*pparam->widget != NULL);
+
+       menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
+       menuitem = gtk_menu_get_active(GTK_MENU(menu));
+       if (menuitem == NULL)
+               return;
+
+       str = (gchar **) pparam->data;
+       g_free(*str);
+       *str = gtkaspell_get_dictionary_menu_active_item(menu);
+}
+
+static void prefs_account_compose_default_dictionary_set_optmenu_from_string
+                                                       (PrefParam *pparam)
+{
+       GtkWidget *optionmenu;
+       GtkWidget *menu;
+       GtkWidget *menuitem;
+       gchar *dictionary;
+
+       g_return_if_fail(*pparam->widget != NULL);
+
+       dictionary = *((gchar **) pparam->data);
+       if (dictionary == NULL)
+               return;
+
+       optionmenu = *pparam->widget;
+       menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optionmenu));
+       if (dictionary)
+               gtkaspell_set_dictionary_menu_active_item(optionmenu, dictionary);
+       menuitem = gtk_menu_get_active(GTK_MENU(menu));
+       gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
+}
+#endif
+
 void prefs_account_register_page(PrefsPage *page)
 {
        prefs_pages = g_slist_append(prefs_pages, page);
index 005daa9..34c49c5 100644 (file)
@@ -126,6 +126,12 @@ struct _PrefsAccount
        gchar    *auto_bcc;
        gboolean  set_autoreplyto;
        gchar    *auto_replyto;
+#ifdef USE_ASPELL
+       gboolean  enable_default_dictionary;
+       gchar    *default_dictionary;
+       gboolean  enable_default_alt_dictionary;
+       gchar    *default_alt_dictionary;
+#endif
 
        /* Privacy */
        gchar    *default_privacy_system;