0.9.4claws47
authorChristoph Hohmann <reboot@gmx.ch>
Sat, 30 Aug 2003 19:35:12 +0000 (19:35 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Sat, 30 Aug 2003 19:35:12 +0000 (19:35 +0000)
* src/compose.c
* src/folder_item_prefs.[ch]
* src/prefs_folder_item.c
* src/gtk/gtkaspell.[ch]
        commit per folder dictionary patch by
        Paul Evans <nerd@freeuk.com>

ChangeLog.claws
configure.ac
src/compose.c
src/folder_item_prefs.c
src/folder_item_prefs.h
src/gtk/gtkaspell.c
src/gtk/gtkaspell.h
src/prefs_folder_item.c

index 872de65..9bd6940 100644 (file)
@@ -1,3 +1,12 @@
+2003-08-30 [christoph] 0.9.4claws47
+
+       * src/compose.c
+       * src/folder_item_prefs.[ch]
+       * src/prefs_folder_item.c
+       * src/gtk/gtkaspell.[ch]
+               commit per folder dictionary patch by
+               Paul Evans <nerd@freeuk.com>
+
 2003-08-30 [christoph] 0.9.4claws46
 
        * src/plugins/spamassassin/spamassassin_gtk.c
index d1e3c81..3c0a173 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=4
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=46
+EXTRA_VERSION=47
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index 19f62a9..8f02f46 100644 (file)
@@ -709,6 +709,13 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
        text = GTK_STEXT(compose->text);
        gtk_stext_freeze(text);
 
+#ifdef USE_ASPELL
+       if (item && item->prefs && item->prefs->enable_default_dictionary &&
+           compose->gtkaspell) 
+               gtkaspell_change_dict(compose->gtkaspell, 
+                   item->prefs->default_dictionary);
+#endif
+
        if (account->auto_sig)
                compose_insert_sig(compose, FALSE);
        gtk_editable_set_position(GTK_EDITABLE(text), 0);
@@ -959,6 +966,15 @@ static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
        text = GTK_STEXT(compose->text);
        gtk_stext_freeze(text);
 
+#ifdef USE_ASPELL
+       if (msginfo->folder && msginfo->folder->prefs && 
+           msginfo->folder->prefs && 
+           msginfo->folder->prefs->enable_default_dictionary &&
+           compose->gtkaspell)
+               gtkaspell_change_dict(compose->gtkaspell, 
+                   msginfo->folder->prefs->default_dictionary);
+#endif
+
        if (quote) {
                gchar *qmark;
 
index d60d0e9..595887f 100644 (file)
@@ -80,6 +80,12 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"default_account", NULL, &tmp_prefs.default_account, P_INT,
         NULL, NULL, NULL},
+#if USE_ASPELL
+       {"enable_default_dictionary", "", &tmp_prefs.enable_default_dictionary, P_BOOL,
+        NULL, NULL, NULL},
+       {"default_dictionary", NULL, &tmp_prefs.default_dictionary, P_STRING,
+        NULL, NULL, NULL},
+#endif  
        {"save_copy_to_folder", NULL, &tmp_prefs.save_copy_to_folder, P_BOOL,
         NULL, NULL, NULL},
        {"folder_color", "", &tmp_prefs.color, P_INT,
@@ -170,6 +176,10 @@ static FolderItemPrefs *folder_item_prefs_clear(FolderItemPrefs *prefs)
        prefs->folder_chmod = 0;
        prefs->enable_default_account = FALSE;
        prefs->default_account = 0;
+#if USE_ASPELL
+       prefs->enable_default_dictionary = FALSE;
+       prefs->default_dictionary = NULL;
+#endif
        prefs->save_copy_to_folder = FALSE;
        prefs->color = 0;
 
@@ -262,6 +272,10 @@ void folder_item_prefs_copy_prefs(FolderItem * src, FolderItem * dest)
        tmp_prefs.folder_chmod                  = src->prefs->folder_chmod;
        tmp_prefs.enable_default_account        = src->prefs->enable_default_account;
        tmp_prefs.default_account               = src->prefs->default_account;
+#if USE_ASPELL
+       tmp_prefs.enable_default_dictionary     = src->prefs->enable_default_dictionary;
+       tmp_prefs.default_dictionary            = g_strdup(src->prefs->default_dictionary);
+#endif
        tmp_prefs.save_copy_to_folder           = src->prefs->save_copy_to_folder;
        tmp_prefs.color                         = src->prefs->color;
 
index 44a6c64..76ff911 100644 (file)
@@ -58,6 +58,10 @@ struct _FolderItemPrefs {
        gint folder_chmod;
        gboolean enable_default_account;
        gint default_account;
+#if USE_ASPELL
+       gboolean enable_default_dictionary;
+       gchar *default_dictionary;
+#endif
        gboolean save_copy_to_folder;
        guint color;
 };
index f1ff505..c9eaae8 100644 (file)
@@ -2112,30 +2112,26 @@ static gboolean cancel_menu_cb(GtkMenuShell *w, gpointer data)
        
 }
 
-/* change_dict_cb() - Menu callback : change dict */
-static void change_dict_cb(GtkWidget *w, GtkAspell *gtkaspell)
+gboolean gtkaspell_change_dict(GtkAspell *gtkaspell, guchar *dictionary)
 {
        Dictionary      *dict;       
-       gchar           *fullname;
        GtkAspeller     *gtkaspeller;
        gint             sug_mode;
-  
-        fullname = (gchar *) gtk_object_get_data(GTK_OBJECT(w), "dict_name");
-       
-       if (!strcmp2(fullname, _("None")))
-               return;
 
+       g_return_val_if_fail(gtkaspell, FALSE);
+       g_return_val_if_fail(dictionary, FALSE);
+  
        sug_mode  = gtkaspell->default_sug_mode;
 
        dict = g_new0(Dictionary, 1);
-       dict->fullname = g_strdup(fullname);
+       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);
-               return;
+               return TRUE;
        }
        
        gtkaspeller = gtkaspeller_new(dict);
@@ -2163,6 +2159,21 @@ static void change_dict_cb(GtkWidget *w, GtkAspell *gtkaspell)
 
        if (gtkaspell->config_menu)
                populate_submenu(gtkaspell, gtkaspell->config_menu);
+
+       return TRUE;    
+}
+
+/* change_dict_cb() - Menu callback : change dict */
+static void change_dict_cb(GtkWidget *w, GtkAspell *gtkaspell)
+{
+       gchar           *fullname;
+  
+        fullname = (gchar *) gtk_object_get_data(GTK_OBJECT(w), "dict_name");
+       
+       if (!strcmp2(fullname, _("None")))
+               return;
+
+       gtkaspell_change_dict(gtkaspell, fullname);
 }
 
 static void switch_to_alternate_cb(GtkWidget *w,
index 92e348f..412f6d7 100644 (file)
@@ -64,6 +64,9 @@ void          gtkaspell_delete                (GtkAspell *gtkaspell);
 
 guchar*                gtkaspell_get_dict              (GtkAspell *gtkaspell);
 
+gboolean       gtkaspell_change_dict           (GtkAspell *gtkaspell,
+                                                guchar* dictionary);
+
 guchar*                gtkaspell_get_path              (GtkAspell *gtkaspell);
 
 gboolean       gtkaspell_set_sug_mode          (GtkAspell *gtkaspell, 
index 7d21058..de3de4c 100644 (file)
 #include "manage_window.h"
 #include "utils.h"
 #include "addr_compl.h"
+#include "prefs_common.h"
 #include "prefs_scoring.h"
 #include "gtkutils.h"
 #include "filtering.h"
 #include "folder_item_prefs.h"
 #include "gtk/colorsel.h"
 
+#if USE_ASPELL
+#include "gtkaspell.h"
+#endif
+
 #define ASSIGN_STRING(string, value) \
        { \
                g_free(string); \
@@ -81,6 +86,10 @@ struct FolderItemComposePage
        GtkWidget *entry_default_reply_to;
        GtkWidget *checkbtn_enable_default_account;
        GtkWidget *optmenu_default_account;
+#if USE_ASPELL
+       GtkWidget *checkbtn_enable_default_dictionary;
+       GtkWidget *optmenu_default_dictionary;
+#endif
 };
 
 
@@ -259,8 +268,17 @@ void prefs_folder_item_compose_create_widget_func(PrefsPage * _page,
        GtkWidget *optmenu_default_account;
        GtkWidget *optmenu_default_account_menu;
        GtkWidget *optmenu_default_account_menuitem;
+#if USE_ASPELL
+       GtkWidget *checkbtn_enable_default_dictionary;
+       GtkWidget *optmenu_default_dictionary;
+       GtkWidget *optmenu_default_dictionary_menu;
+       GtkWidget *opemenu_default_dictionary_menuitem;
+#endif
        GList *cur_ac;
        GList *account_list;
+#if USE_ASPELL
+       gchar *dictionary;
+#endif
        PrefsAccount *ac_prefs;
        GtkOptionMenu *optmenu;
        GtkWidget *menu;
@@ -270,7 +288,12 @@ void prefs_folder_item_compose_create_widget_func(PrefsPage * _page,
        page->item         = item;
 
        /* Table */
-       table = gtk_table_new(5, 2, FALSE);
+#if USE_ASPELL
+# define TABLEHEIGHT 6
+#else
+# define TABLEHEIGHT 5
+#endif
+       table = gtk_table_new(TABLEHEIGHT, 2, FALSE);
        gtk_widget_show(table);
        gtk_table_set_row_spacings(GTK_TABLE(table), -1);
        rowcount = 0;
@@ -373,6 +396,39 @@ void prefs_folder_item_compose_create_widget_func(PrefsPage * _page,
 
        rowcount++;
 
+#if USE_ASPELL
+       /* Default dictionary */
+       checkbtn_enable_default_dictionary = gtk_check_button_new_with_label(_("Default dictionary: "));
+       gtk_widget_show(checkbtn_enable_default_dictionary);
+       gtk_table_attach(GTK_TABLE(table), checkbtn_enable_default_dictionary, 0, 1,
+                        rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_dictionary),
+                                    item->prefs->enable_default_dictionary);
+
+       optmenu_default_dictionary = gtk_option_menu_new();
+       gtk_widget_show(optmenu_default_dictionary);
+       gtk_table_attach_defaults(GTK_TABLE(table), optmenu_default_dictionary, 1, 2,
+                               rowcount, rowcount + 1);
+
+       gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_default_dictionary), 
+                                gtkaspell_dictionary_option_menu_new(
+                                        prefs_common.aspell_path));
+
+       dictionary = item->prefs->default_dictionary;
+
+       optmenu = GTK_OPTION_MENU(optmenu_default_dictionary);
+
+       menu = gtk_option_menu_get_menu(optmenu);
+       if (dictionary)
+               gtkaspell_set_dictionary_menu_active_item(optmenu_default_dictionary, dictionary);
+       menuitem = gtk_menu_get_active(GTK_MENU(menu));
+       gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
+
+       SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_dictionary, optmenu_default_dictionary);
+
+       rowcount++;
+#endif
+
        page->window = GTK_WIDGET(window);
        page->table = table;
        page->checkbtn_request_return_receipt = checkbtn_request_return_receipt;
@@ -383,6 +439,10 @@ void prefs_folder_item_compose_create_widget_func(PrefsPage * _page,
        page->entry_default_reply_to = entry_default_reply_to;
        page->checkbtn_enable_default_account = checkbtn_enable_default_account;
        page->optmenu_default_account = optmenu_default_account;
+#ifdef USE_ASPELL
+       page->checkbtn_enable_default_dictionary = checkbtn_enable_default_dictionary;
+       page->optmenu_default_dictionary = optmenu_default_dictionary;
+#endif
 
        address_completion_start(page->window);
 
@@ -431,6 +491,14 @@ void prefs_folder_item_compose_save_func(PrefsPage *_page)
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
        prefs->default_account = GPOINTER_TO_INT(gtk_object_get_user_data(GTK_OBJECT(menuitem)));
 
+#if USE_ASPELL
+       prefs->enable_default_dictionary =
+           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_enable_default_dictionary));
+       menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(page->optmenu_default_dictionary));
+       ASSIGN_STRING(prefs->default_dictionary,
+           gtkaspell_get_dictionary_menu_active_item(menu));
+#endif
+
        folder_item_prefs_save_config(page->item);
 }