2006-12-27 [wwp] 2.6.1cvs81
authorTristan Chabredier <wwp@claws-mail.org>
Wed, 27 Dec 2006 11:19:49 +0000 (11:19 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Wed, 27 Dec 2006 11:19:49 +0000 (11:19 +0000)
* src/gtk/gtkaspell.c
* src/gtk/gtkaspell.h
* src/compose.c
Fix assignment of compose's default and alternate dictionary from
account or folder settings. Now gtkaspell_change_dict does rotate
dicts only when it's called from a menu cb.

ChangeLog
PATCHSETS
configure.ac
src/compose.c
src/gtk/gtkaspell.c
src/gtk/gtkaspell.h

index 59626f2..55169fe 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-12-27 [wwp]       2.6.1cvs81
+
+       * src/gtk/gtkaspell.c
+       * src/gtk/gtkaspell.h
+       * src/compose.c
+               Fix assignment of compose's default and alternate dictionary from
+               account or folder settings. Now gtkaspell_change_dict does rotate
+               dicts only when it's called from a menu cb.
+
 2006-12-27 [wwp]       2.6.1cvs80
 
        * src/folder_item_prefs.c
index e8b9787..f696923 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.179.2.143 -r 1.179.2.144 src/imap.c;  ) > 2.6.1cvs78.patchset
 ( cvs diff -u -r 1.1.2.33 -r 1.1.2.34 src/imap_gtk.c;  cvs diff -u -r 1.2.2.23 -r 1.2.2.24 src/mh_gtk.c;  ) > 2.6.1cvs79.patchset
 ( cvs diff -u -r 1.2.2.16 -r 1.2.2.17 src/folder_item_prefs.c;  ) > 2.6.1cvs80.patchset
+( cvs diff -u -r 1.9.2.47 -r 1.9.2.48 src/gtk/gtkaspell.c;  cvs diff -u -r 1.5.2.9 -r 1.5.2.10 src/gtk/gtkaspell.h;  cvs diff -u -r 1.382.2.346 -r 1.382.2.347 src/compose.c;  ) > 2.6.1cvs81.patchset
index b770c41..3f729c6 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=6
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=80
+EXTRA_VERSION=81
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index a0a18b6..bf2525c 100644 (file)
@@ -975,9 +975,9 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
        if (item && item->prefs && compose->gtkaspell) {
                if (item->prefs->enable_default_dictionary)
                        gtkaspell_change_dict(compose->gtkaspell, 
-                                   item->prefs->default_dictionary);
+                                   item->prefs->default_dictionary, FALSE);
                if (item->prefs->enable_default_alt_dictionary)
-                       gtkaspell_change_dict(compose->gtkaspell, 
+                       gtkaspell_change_alt_dict(compose->gtkaspell, 
                                    item->prefs->default_alt_dictionary);
                compose_spell_menu_changed(compose);
        }
@@ -1416,9 +1416,9 @@ static Compose *compose_generic_reply(MsgInfo *msginfo, gboolean quote,
            compose->gtkaspell) {
                if (msginfo->folder->prefs->enable_default_dictionary)
                        gtkaspell_change_dict(compose->gtkaspell, 
-                                   msginfo->folder->prefs->default_dictionary);
+                                   msginfo->folder->prefs->default_dictionary, FALSE);
                if (msginfo->folder->prefs->enable_default_alt_dictionary)
-                       gtkaspell_change_dict(compose->gtkaspell, 
+                       gtkaspell_change_alt_dict(compose->gtkaspell, 
                                    msginfo->folder->prefs->default_alt_dictionary);
                compose_spell_menu_changed(compose);
        }
index 1bbb15b..a8154f4 100644 (file)
@@ -2312,9 +2312,16 @@ static void set_menu_pos(GtkMenu *menu, gint *x, gint *y,
                                       gtkaspell->theword);
 }
 
-/* Menu call backs */
-
-gboolean gtkaspell_change_dict(GtkAspell *gtkaspell, const gchar *dictionary)
+/* change the current dictionary of gtkaspell
+   - if always_set_alt_dict is set, the alternate dict is unconditionally set to the former
+     current dictionary (common use: from menu callbacks)
+   - if always_set_alt_dict is NOT set, the alternate dict will be set to the former
+     current dictionary only if there is no alternate dictionary already set
+     (this is when we need to set the current dictionary then the alternate one
+     when creating a compose window, from the account and folder settings)
+*/
+gboolean gtkaspell_change_dict(GtkAspell *gtkaspell, const gchar *dictionary,
+                                                        gboolean always_set_alt_dict)
 {
        Dictionary      *dict;       
        GtkAspeller     *gtkaspeller;
@@ -2329,14 +2336,6 @@ gboolean gtkaspell_change_dict(GtkAspell *gtkaspell, const gchar *dictionary)
        dict->fullname = g_strdup(dictionary);
        dict->encoding = g_strdup(gtkaspell->gtkaspeller->dictionary->encoding);
 
-       if (gtkaspell->use_alternate && gtkaspell->alternate_speller &&
-           dict == gtkaspell->alternate_speller->dictionary) {
-               use_alternate_dict(gtkaspell);
-               dictionary_delete(dict);
-               gtkaspell->alternate_speller->dictionary = NULL;
-               return TRUE;
-       }
-       
        gtkaspeller = gtkaspeller_new(dict);
 
        if (!gtkaspeller) {
@@ -2348,9 +2347,16 @@ gboolean gtkaspell_change_dict(GtkAspell *gtkaspell, const gchar *dictionary)
                g_free(message);
        } else {
                if (gtkaspell->use_alternate) {
-                       if (gtkaspell->alternate_speller)
-                               gtkaspeller_delete(gtkaspell->alternate_speller);
-                       gtkaspell->alternate_speller = gtkaspell->gtkaspeller;
+                       if (gtkaspell->alternate_speller) {
+                               if (always_set_alt_dict) {
+                                       gtkaspeller_delete(gtkaspell->alternate_speller);
+                                       gtkaspell->alternate_speller = gtkaspell->gtkaspeller;
+                               } else
+                                       gtkaspeller_delete(gtkaspell->gtkaspeller);
+                       } else
+                               /* should never be reached as the dicts are always set
+                                  to a default value */
+                               gtkaspell->alternate_speller = gtkaspell->gtkaspeller;
                } else
                        gtkaspeller_delete(gtkaspell->gtkaspeller);
 
@@ -2363,6 +2369,41 @@ gboolean gtkaspell_change_dict(GtkAspell *gtkaspell, const gchar *dictionary)
        return TRUE;    
 }
 
+/* change the alternate dictionary of gtkaspell (doesn't affect the default dictionary) */
+gboolean gtkaspell_change_alt_dict(GtkAspell *gtkaspell, const gchar *alt_dictionary)
+{
+       Dictionary      *dict;       
+       GtkAspeller     *gtkaspeller;
+
+       g_return_val_if_fail(gtkaspell, FALSE);
+       g_return_val_if_fail(alt_dictionary, FALSE);
+  
+       dict = g_new0(Dictionary, 1);
+       dict->fullname = g_strdup(alt_dictionary);
+       dict->encoding = g_strdup(gtkaspell->gtkaspeller->dictionary->encoding);
+
+       gtkaspeller = gtkaspeller_new(dict);
+
+       if (!gtkaspeller) {
+               gchar *message;
+               message = g_strdup_printf(_("The spell checker could not change the alternate dictionary.\n%s"), 
+                                         gtkaspellcheckers->error_message);
+
+               alertpanel_warning(message); 
+               g_free(message);
+       } else {
+               if (gtkaspell->alternate_speller)
+                       gtkaspeller_delete(gtkaspell->alternate_speller);
+               gtkaspell->alternate_speller = gtkaspeller;
+       }
+       
+       dictionary_delete(dict);
+
+       return TRUE;    
+}
+
+/* Menu call backs */
+
 /* change_dict_cb() - Menu callback : change dict */
 static void change_dict_cb(GtkWidget *w, GtkAspell *gtkaspell)
 {
@@ -2373,7 +2414,7 @@ static void change_dict_cb(GtkWidget *w, GtkAspell *gtkaspell)
        if (!strcmp2(fullname, _("None")))
                return;
 
-       gtkaspell_change_dict(gtkaspell, fullname);
+       gtkaspell_change_dict(gtkaspell, fullname, TRUE);
        if (gtkaspell->recheck_when_changing_dict) {
                gtkaspell_highlight_all(gtkaspell);
        }
index cbcb244..4f7ce7f 100644 (file)
@@ -69,7 +69,11 @@ void                 gtkaspell_delete                (GtkAspell *gtkaspell);
 guchar*                gtkaspell_get_dict              (GtkAspell *gtkaspell);
 
 gboolean       gtkaspell_change_dict           (GtkAspell *gtkaspell,
-                                                const gchar* dictionary);
+                                                const gchar* dictionary,
+                                                        gboolean always_set_alt_dict);
+
+gboolean       gtkaspell_change_alt_dict       (GtkAspell *gtkaspell,
+                                                const gchar* alt_dictionary);
 
 guchar*                gtkaspell_get_path              (GtkAspell *gtkaspell);