0.9.4claws11
authorChristoph Hohmann <reboot@gmx.ch>
Sat, 9 Aug 2003 01:11:53 +0000 (01:11 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Sat, 9 Aug 2003 01:11:53 +0000 (01:11 +0000)
* src/gtk/Makefile.am
* src/gtk/colorsel.[ch]                 ** NEW **
        create a color selection dialog that can be used as a simple
        function call with it's own gtk main loop like filesel.[ch]

* src/Makefile.am
* src/main.c
* src/prefs_common.c
* src/prefs_spelling.[ch]               ** NEW **
* src/prefs_spelling.glade              ** NEW **
* src/gtk/gtkutils.[ch]
        move "Spell Checker" prefs to new prefs dialog

* src/prefs_folder_item.c
        use new colorsel dialog

14 files changed:
ChangeLog.claws
configure.ac
src/Makefile.am
src/gtk/Makefile.am
src/gtk/colorsel.c [new file with mode: 0644]
src/gtk/colorsel.h [new file with mode: 0644]
src/gtk/gtkutils.c
src/gtk/gtkutils.h
src/main.c
src/prefs_common.c
src/prefs_folder_item.c
src/prefs_spelling.c [new file with mode: 0644]
src/prefs_spelling.glade [new file with mode: 0644]
src/prefs_spelling.h [new file with mode: 0644]

index 46e235f..38801c9 100644 (file)
@@ -1,3 +1,21 @@
+2003-08-09 [christoph] 0.9.4claws11
+
+       * src/gtk/Makefile.am
+       * src/gtk/colorsel.[ch]                 ** NEW **
+               create a color selection dialog that can be used as a simple
+               function call with it's own gtk main loop like filesel.[ch]
+
+       * src/Makefile.am
+       * src/main.c
+       * src/prefs_common.c
+       * src/prefs_spelling.[ch]               ** NEW **
+       * src/prefs_spelling.glade              ** NEW **
+       * src/gtk/gtkutils.[ch]
+               move "Spell Checker" prefs to new prefs dialog
+
+       * src/prefs_folder_item.c
+               use new colorsel dialog
+
 2003-08-08 [paul]      0.9.4claws10
 
        * src/inc.c
index 893fd87..e080061 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=4
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=10
+EXTRA_VERSION=11
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index 25c6e6b..b487f22 100644 (file)
@@ -87,6 +87,7 @@ sylpheed_SOURCES = \
        prefs_gtk.c \
        prefs_matcher.c \
        prefs_scoring.c \
+       prefs_spelling.c \
        prefs_summary_column.c \
        prefs_template.c \
        prefs_toolbar.c \
@@ -206,6 +207,7 @@ sylpheedinclude_HEADERS = \
        prefs_gtk.h \
        prefs_matcher.h \
        prefs_scoring.h \
+       prefs_spelling.h \
        prefs_summary_column.h \
        prefs_template.h \
        prefs_toolbar.h \
index c8643e3..a4978cd 100644 (file)
@@ -3,6 +3,7 @@ noinst_LTLIBRARIES = libsylpheedgtk.la
 libsylpheedgtk_la_SOURCES = \
        about.c \
        colorlabel.c \
+       colorsel.c \
        description_window.c \
        filesel.c \
        gtkaspell.c \
@@ -21,6 +22,7 @@ sylpheedgtkincludedir = $(pkgincludedir)/gtk
 sylpheedgtkinclude_HEADERS = \
        about.h \
        colorlabel.h \
+       colorsel.h \
        description_window.h \
        filesel.h \
        gtkaspell.h \
diff --git a/src/gtk/colorsel.c b/src/gtk/colorsel.c
new file mode 100644 (file)
index 0000000..a0c6882
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2003 Hiroyuki Yamamoto & The Sylpheed Claws Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <gtk/gtk.h>
+
+#include "colorsel.h"
+#include "manage_window.h"
+
+static void quote_colors_set_dialog_ok(GtkWidget *widget, gpointer data)
+{
+       *((gint *) data) = 0;
+       gtk_main_quit();
+}
+
+static void quote_colors_set_dialog_cancel(GtkWidget *widget, gpointer data)
+{
+       *((gint *) data) = 1;
+       gtk_main_quit();
+}
+
+static void quote_colors_set_dialog_key_pressed(GtkWidget *widget,
+                                               GdkEventKey *event,
+                                               gpointer data)
+{
+       *((gint *) data) = 1;
+       gtk_main_quit();
+}
+
+gint colorsel_select_color_rgb(gchar *title, gint rgbvalue)
+{
+       gdouble color[4] = {0.0, 0.0, 0.0, 0.0};
+       GtkColorSelectionDialog *color_dialog;
+       gint result;
+
+       color_dialog = GTK_COLOR_SELECTION_DIALOG(gtk_color_selection_dialog_new(title));
+       gtk_window_set_position(GTK_WINDOW(color_dialog), GTK_WIN_POS_CENTER);
+       gtk_window_set_modal(GTK_WINDOW(color_dialog), TRUE);
+       gtk_window_set_policy(GTK_WINDOW(color_dialog), FALSE, FALSE, FALSE);
+       manage_window_set_transient(GTK_WINDOW(color_dialog));
+
+       gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->ok_button),
+                          "clicked", GTK_SIGNAL_FUNC(quote_colors_set_dialog_ok), &result);
+       gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->cancel_button),
+                          "clicked", GTK_SIGNAL_FUNC(quote_colors_set_dialog_cancel), &result);
+       gtk_signal_connect(GTK_OBJECT(color_dialog), "key_press_event",
+                          GTK_SIGNAL_FUNC(quote_colors_set_dialog_key_pressed),
+                          &result);
+
+       /* preselect the previous color in the color selection dialog */
+       color[0] = (gdouble) ((rgbvalue & 0xff0000) >> 16) / 255.0;
+       color[1] = (gdouble) ((rgbvalue & 0x00ff00) >>  8) / 255.0;
+       color[2] = (gdouble)  (rgbvalue & 0x0000ff)        / 255.0;
+       gtk_color_selection_set_color
+               (GTK_COLOR_SELECTION(color_dialog->colorsel), color);
+
+       gtk_widget_show(GTK_WIDGET(color_dialog));
+       gtk_main();
+
+       if (result == 0) {
+               gint red, green, blue, rgbvalue_new;
+
+               gtk_color_selection_get_color(GTK_COLOR_SELECTION(color_dialog->colorsel), color);
+
+               red          = (gint) (color[0] * 255.0);
+               green        = (gint) (color[1] * 255.0);
+               blue         = (gint) (color[2] * 255.0);
+               rgbvalue_new = (gint) ((red * 0x10000) | (green * 0x100) | blue);
+               
+#if 0
+               fprintf(stderr, "redc = %f, greenc = %f, bluec = %f\n", color[0], color[1], color[2]);
+               fprintf(stderr, "red = %d, green = %d, blue = %d\n", red, green, blue);
+               fprintf(stderr, "Color is %x\n", rgbvalue);
+#endif
+
+               rgbvalue = rgbvalue_new;
+       }
+
+       gtk_widget_destroy(GTK_WIDGET(color_dialog));
+
+       return rgbvalue;
+}
+
diff --git a/src/gtk/colorsel.h b/src/gtk/colorsel.h
new file mode 100644 (file)
index 0000000..828460b
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2003 Hiroyuki Yamamoto & The Sylpheed Claws Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef COLORSEL_H
+#define COLORSEL_H
+
+gint colorsel_select_color_rgb(gchar *title, gint rgbvalue);
+
+#endif /* COLORSEL_H */
index 090f272..6430db9 100644 (file)
@@ -574,3 +574,17 @@ GtkWidget *gtkut_account_menu_new(GList                    *ac_list,
        }
        return menu;
 }
+
+void gtkut_set_widget_bgcolor_rgb(GtkWidget *widget, guint rgbvalue)
+{
+       GtkStyle *newstyle;
+       GdkColor gdk_color;
+
+       gtkut_convert_int_to_gdk_color(rgbvalue, &gdk_color);
+       newstyle = gtk_style_copy(gtk_widget_get_default_style());
+       newstyle->bg[GTK_STATE_NORMAL]   = gdk_color;
+       newstyle->bg[GTK_STATE_PRELIGHT] = gdk_color;
+       newstyle->bg[GTK_STATE_ACTIVE]   = gdk_color;
+       gtk_widget_set_style(widget, newstyle);
+}
+
index 3c97a57..527733a 100644 (file)
@@ -142,4 +142,7 @@ void gtkut_widget_set_composer_icon (GtkWidget      *widget);
 GtkWidget *gtkut_account_menu_new      (GList                  *ac_list,
                                         GtkSignalFunc           callback,
                                         gpointer                data);
+
+void gtkut_set_widget_bgcolor_rgb      (GtkWidget      *widget,
+                                        guint           rgbvalue);
 #endif /* __GTKUTILS_H__ */
index ea62599..6969836 100644 (file)
@@ -51,6 +51,7 @@
 #include "prefs_common.h"
 #include "prefs_account.h"
 #include "prefs_actions.h"
+#include "prefs_spelling.h"
 #include "scoring.h"
 #include "prefs_display_header.h"
 #include "account.h"
@@ -273,6 +274,7 @@ int main(int argc, char *argv[])
 
 #ifdef USE_ASPELL
        gtkaspell_checkers_init();
+       prefs_spelling_init();
 #endif
        
        sock_set_io_timeout(prefs_common.io_timeout_secs);
@@ -375,6 +377,7 @@ int main(int argc, char *argv[])
        addressbook_destroy();
 
 #ifdef USE_ASPELL       
+       prefs_spelling_done();
        gtkaspell_checkers_quit();
 #endif
        sylpheed_done();
index aad3b5c..efed6bf 100644 (file)
 #include "stock_pixmap.h"
 #include "quote_fmt.h"
 
-#if USE_ASPELL
-#include "gtkaspell.h"
-#endif
-
 PrefsCommon prefs_common;
 
 static PrefsDialog dialog;
@@ -132,20 +128,6 @@ static struct Compose {
        GtkWidget *entry_autosave_length;
 } compose;
 
-       /* spelling */
-#if USE_ASPELL
-static struct Spelling {
-       GtkWidget *checkbtn_enable_aspell;
-       GtkWidget *entry_aspell_path;
-       GtkWidget *btn_aspell_path;
-       GtkWidget *optmenu_dictionary;
-       GtkWidget *optmenu_sugmode;
-       GtkWidget *misspelled_btn;
-       GtkWidget *checkbtn_use_alternate;
-       GtkWidget *checkbtn_check_while_typing;
-} spelling;
-#endif
-
 static struct Quote {
        GtkWidget *entry_quotemark;
        GtkWidget *text_quotefmt;
@@ -277,14 +259,6 @@ static void prefs_common_send_dialog_set_optmenu(PrefParam *pparam);
 static void prefs_nextunreadmsgdialog_set_data_from_optmenu(PrefParam *pparam);
 static void prefs_nextunreadmsgdialog_set_optmenu(PrefParam *pparam);
 
-#if USE_ASPELL
-static void prefs_dictionary_set_data_from_optmenu     (PrefParam *param);
-static void prefs_dictionary_set_optmenu               (PrefParam *pparam);
-static void prefs_speller_sugmode_set_data_from_optmenu        (PrefParam *pparam);
-static void prefs_speller_sugmode_set_optmenu          (PrefParam *pparam);
-#endif
-
-
 /*
    parameter name, default value, pointer to the prefs variable, data type,
    pointer to the widget pointer,
@@ -411,24 +385,18 @@ static PrefParam param[] = {
         P_INT, &compose.entry_autosave_length,
         prefs_set_data_from_entry, prefs_set_entry},
 #if USE_ASPELL
-       {"enable_aspell", "TRUE", &prefs_common.enable_aspell,
-        P_BOOL, &spelling.checkbtn_enable_aspell,
-        prefs_set_data_from_toggle, prefs_set_toggle},
-       {"aspell_path", ASPELL_PATH, &prefs_common.aspell_path, 
-        P_STRING, &spelling.entry_aspell_path, 
-        prefs_set_data_from_entry, prefs_set_entry},
-       {"dictionary",  "", &prefs_common.dictionary,
-        P_STRING, &spelling.optmenu_dictionary, 
-        prefs_dictionary_set_data_from_optmenu, prefs_dictionary_set_optmenu },
-       {"aspell_sugmode",  "1", &prefs_common.aspell_sugmode,
-        P_INT, &spelling.optmenu_sugmode, 
-        prefs_speller_sugmode_set_data_from_optmenu, prefs_speller_sugmode_set_optmenu },
-       {"use_alternate_dict", "FALSE", &prefs_common.use_alternate,
-        P_BOOL, &spelling.checkbtn_use_alternate,
-        prefs_set_data_from_toggle, prefs_set_toggle},
-       {"check_while_typing", "TRUE", &prefs_common.check_while_typing,
-        P_BOOL, &spelling.checkbtn_check_while_typing,
-        prefs_set_data_from_toggle, prefs_set_toggle},
+       {"enable_aspell", "TRUE", &prefs_common.enable_aspell, P_BOOL,
+        NULL, NULL, NULL},
+       {"aspell_path", ASPELL_PATH, &prefs_common.aspell_path, P_STRING,
+        NULL, NULL, NULL},
+       {"dictionary",  "", &prefs_common.dictionary, P_STRING,
+        NULL, NULL, NULL},
+       {"aspell_sugmode", "1", &prefs_common.aspell_sugmode, P_INT,
+        NULL, NULL, NULL},
+       {"use_alternate_dict", "FALSE", &prefs_common.use_alternate, P_BOOL,
+        NULL, NULL, NULL},
+       {"check_while_typing", "TRUE", &prefs_common.check_while_typing, P_BOOL,
+        NULL, NULL, NULL},
        {"misspelled_color", "16711680", &prefs_common.misspelled_col, P_COLOR,
         NULL, NULL, NULL},
 #endif
@@ -847,9 +815,6 @@ static PrefParam param[] = {
 static void prefs_common_create                (void);
 static void prefs_receive_create       (void);
 static void prefs_send_create          (void);
-#ifdef USE_ASPELL
-static void prefs_spelling_create      (void);
-#endif
 static void prefs_compose_create       (void);
 static void prefs_quote_create         (void);
 static void prefs_display_create       (void);
@@ -1040,10 +1005,6 @@ static void prefs_common_create(void)
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Send"),      page++);
        prefs_compose_create();
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Compose"),   page++);
-#if USE_ASPELL
-       prefs_spelling_create();
-       SET_NOTEBOOK_LABEL(dialog.notebook, _("Spell Checker"),   page++);
-#endif 
        prefs_quote_create();
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Quote"),   page++);
        prefs_display_create();
@@ -1518,292 +1479,6 @@ static void prefs_common_recv_dialog_newmail_notify_toggle_cb(GtkWidget *w, gpoi
        gtk_widget_set_sensitive(receive.hbox_newmail_notify, toggled);
 }
 
-#if USE_ASPELL
-static void prefs_dictionary_set_data_from_optmenu(PrefParam *param)
-{
-       gchar *str;
-       gchar *dict_fullname;
-       
-       g_return_if_fail(param);
-       g_return_if_fail(param->data);
-       g_return_if_fail(param->widget);
-       g_return_if_fail(*(param->widget));
-
-       dict_fullname = gtkaspell_get_dictionary_menu_active_item
-               (gtk_option_menu_get_menu(GTK_OPTION_MENU(*(param->widget))));
-       str = *((gchar **) param->data);
-       if (str)
-               g_free(str);
-       *((gchar **) param->data) = dict_fullname;
-}
-
-static void prefs_dictionary_set_optmenu(PrefParam *pparam)
-{
-       GList *cur;
-       GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
-       GtkWidget *menu;
-       GtkWidget *menuitem;
-       gchar *dict_name;
-       gint n = 0;
-
-       g_return_if_fail(optmenu != NULL);
-       g_return_if_fail(pparam->data != NULL);
-
-       if (*(gchar **) pparam->data) {
-               menu = gtk_option_menu_get_menu(optmenu);
-               for (cur = GTK_MENU_SHELL(menu)->children;
-                    cur != NULL; cur = cur->next) {
-                       menuitem = GTK_WIDGET(cur->data);
-                       dict_name = gtk_object_get_data(GTK_OBJECT(menuitem), 
-                                                       "dict_name");
-                       if (!strcmp2(dict_name, *((gchar **)pparam->data))) {
-                               gtk_option_menu_set_history(optmenu, n);
-                               return;
-                       }
-                       n++;
-               }
-       }               
-
-       gtk_option_menu_set_history(optmenu, 0);
-       prefs_dictionary_set_data_from_optmenu(pparam);
-}
-
-static void prefs_speller_sugmode_set_data_from_optmenu(PrefParam *param)
-{
-       gint sugmode;
-       g_return_if_fail(param);
-       g_return_if_fail(param->data);
-       g_return_if_fail(param->widget);
-       g_return_if_fail(*(param->widget));
-
-       sugmode = gtkaspell_get_sugmode_from_option_menu
-               (GTK_OPTION_MENU(*(param->widget)));
-       *((gint *) param->data) = sugmode;
-}
-
-static void prefs_speller_sugmode_set_optmenu(PrefParam *pparam)
-{
-       GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
-       gint sugmode;
-
-       g_return_if_fail(optmenu != NULL);
-       g_return_if_fail(pparam->data != NULL);
-
-       sugmode = *(gint *) pparam->data;
-       gtkaspell_sugmode_option_menu_set(optmenu, sugmode);
-}
-       
-       
-static void prefs_spelling_checkbtn_enable_aspell_toggle_cb
-       (GtkWidget *widget,
-        gpointer data)
-{
-       gboolean toggled;
-
-       toggled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
-
-       gtk_widget_set_sensitive(spelling.entry_aspell_path,   toggled);
-       gtk_widget_set_sensitive(spelling.optmenu_dictionary,  toggled);
-       gtk_widget_set_sensitive(spelling.optmenu_sugmode,     toggled);
-       gtk_widget_set_sensitive(spelling.btn_aspell_path,     toggled);
-       gtk_widget_set_sensitive(spelling.misspelled_btn,      toggled);
-       gtk_widget_set_sensitive(spelling.checkbtn_use_alternate,      toggled);
-       gtk_widget_set_sensitive(spelling.checkbtn_check_while_typing, toggled);
-}
-
-static void prefs_spelling_btn_aspell_path_clicked_cb(GtkWidget *widget,
-                                                    gpointer data)
-{
-       gchar *file_path, *tmp;
-       GtkWidget *new_menu;
-
-       file_path = filesel_select_file(_("Select dictionaries location"),
-                                       prefs_common.aspell_path);
-       if (file_path == NULL) {
-               /* don't change */      
-       }
-       else {
-         tmp=g_dirname(file_path);
-         
-               if (prefs_common.aspell_path)
-                       g_free(prefs_common.aspell_path);
-               prefs_common.aspell_path = g_strdup_printf("%s%s",tmp,
-                                                          G_DIR_SEPARATOR_S);
-
-               new_menu = gtkaspell_dictionary_option_menu_new(prefs_common.aspell_path);
-               gtk_option_menu_set_menu(GTK_OPTION_MENU(spelling.optmenu_dictionary),
-                                        new_menu);
-
-               gtk_entry_set_text(GTK_ENTRY(spelling.entry_aspell_path), 
-                                  prefs_common.aspell_path);                                    
-               /* select first one */
-               gtk_option_menu_set_history(GTK_OPTION_MENU(
-                                       spelling.optmenu_dictionary), 0);
-       
-               if (prefs_common.dictionary)
-                       g_free(prefs_common.dictionary);
-
-               prefs_common.dictionary = 
-                       gtkaspell_get_dictionary_menu_active_item(
-                               gtk_option_menu_get_menu(
-                                       GTK_OPTION_MENU(
-                                               spelling.optmenu_dictionary)));
-               g_free(tmp);
-
-       }
-}
-
-static void prefs_spelling_create()
-{
-       GtkWidget *vbox1;
-       GtkWidget *frame_spell;
-       GtkWidget *vbox_spell;
-       GtkWidget *hbox_aspell_path;
-       GtkWidget *checkbtn_enable_aspell;
-       GtkWidget *label_aspell_path;
-       GtkWidget *entry_aspell_path;
-       GtkWidget *btn_aspell_path;
-       GtkWidget *spell_table;
-       GtkWidget *label_dictionary;
-       GtkWidget *optmenu_dictionary;
-       GtkWidget *sugmode_label;
-       GtkWidget *sugmode_optmenu;
-       GtkWidget *checkbtn_use_alternate;
-       GtkWidget *help_label;
-       GtkWidget *checkbtn_check_while_typing;
-       GtkWidget *color_label;
-       GtkWidget *col_align;
-
-       vbox1 = gtk_vbox_new (FALSE, VSPACING);
-       gtk_widget_show (vbox1);
-       gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
-       gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
-
-       /* spell checker defaults */                       
-       PACK_FRAME(vbox1, frame_spell, _("Global spelling checker settings"));
-       vbox_spell = gtk_vbox_new(FALSE, VSPACING_NARROW);
-       gtk_widget_show (vbox_spell);
-       gtk_container_add(GTK_CONTAINER(frame_spell), vbox_spell);
-       gtk_container_set_border_width(GTK_CONTAINER(vbox_spell), 8);
-
-       PACK_CHECK_BUTTON(vbox_spell, checkbtn_enable_aspell, 
-                         _("Enable spell checker"));
-
-       gtk_signal_connect(GTK_OBJECT(checkbtn_enable_aspell), "toggled",
-                          GTK_SIGNAL_FUNC(prefs_spelling_checkbtn_enable_aspell_toggle_cb),
-                          NULL);
-
-       /* Check while typing */
-       PACK_CHECK_BUTTON(vbox_spell, checkbtn_check_while_typing, 
-                         _("Check while typing"));
-
-       PACK_CHECK_BUTTON(vbox_spell, checkbtn_use_alternate, 
-                         _("Enable alternate dictionary"));
-
-       help_label = gtk_label_new(_("Enabling an alternate dictionary makes switching\n"
-                                    "with the last used dictionary faster."));
-       gtk_misc_set_alignment (GTK_MISC (help_label), 0, 0);
-       gtk_widget_show(help_label);
-       gtk_box_pack_start(GTK_BOX(vbox_spell), help_label, FALSE, TRUE, 0);
-       
-       spell_table = gtk_table_new(4, 3, FALSE);
-       gtk_container_set_border_width (GTK_CONTAINER (spell_table), VSPACING);
-       gtk_table_set_row_spacings(GTK_TABLE(spell_table), 8);
-       gtk_table_set_col_spacings(GTK_TABLE(spell_table), 8);
-
-       gtk_box_pack_start(GTK_BOX(vbox_spell), spell_table, TRUE, TRUE, 0);
-
-       label_aspell_path = gtk_label_new (_("Dictionaries path:"));
-       gtk_misc_set_alignment(GTK_MISC(label_aspell_path), 1.0, 0.5);
-       gtk_widget_show(label_aspell_path);
-       gtk_table_attach (GTK_TABLE (spell_table), label_aspell_path, 0, 1, 0,
-                         1, GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
-       
-       hbox_aspell_path = gtk_hbox_new (FALSE, 8);
-       gtk_table_attach (GTK_TABLE (spell_table), hbox_aspell_path, 1, 2, 0,
-                         1, GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
-       gtk_widget_show(hbox_aspell_path);
-
-       entry_aspell_path = gtk_entry_new();
-       gtk_widget_show(entry_aspell_path);
-       gtk_box_pack_start(GTK_BOX(hbox_aspell_path), entry_aspell_path, TRUE,
-                          TRUE, 0);    
-       
-       gtk_widget_set_sensitive(entry_aspell_path, prefs_common.enable_aspell);
-
-       btn_aspell_path = gtk_button_new_with_label(" ... ");
-       gtk_widget_show(btn_aspell_path);
-       gtk_box_pack_start(GTK_BOX(hbox_aspell_path), btn_aspell_path, FALSE, FALSE, 0);
-       gtk_widget_set_sensitive(btn_aspell_path, prefs_common.enable_aspell);
-
-       gtk_signal_connect(GTK_OBJECT(btn_aspell_path), "clicked", 
-                          GTK_SIGNAL_FUNC(prefs_spelling_btn_aspell_path_clicked_cb),
-                          NULL);
-
-       label_dictionary = gtk_label_new(_("Default dictionary:"));
-       gtk_misc_set_alignment(GTK_MISC(label_dictionary), 1.0, 0.5);
-       gtk_widget_show(label_dictionary);
-       gtk_table_attach (GTK_TABLE (spell_table), label_dictionary, 0, 1, 1, 2,
-                         GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
-
-       optmenu_dictionary = gtk_option_menu_new();
-       gtk_widget_show(optmenu_dictionary);
-       gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_dictionary), 
-                                gtkaspell_dictionary_option_menu_new(
-                                        prefs_common.aspell_path));
-       gtk_table_attach (GTK_TABLE (spell_table), optmenu_dictionary, 1, 2, 1,
-                         2, GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
-       gtk_widget_set_sensitive(optmenu_dictionary, prefs_common.enable_aspell);
-
-       /* Suggestion mode */
-       sugmode_label = gtk_label_new(_("Default suggestion mode"));
-       gtk_misc_set_alignment(GTK_MISC(sugmode_label), 1.0, 0.5);
-       gtk_widget_show(sugmode_label);
-       gtk_table_attach(GTK_TABLE (spell_table), sugmode_label, 0, 1, 2, 3,
-                        GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
-
-       sugmode_optmenu = gtk_option_menu_new();
-       gtk_widget_show(sugmode_optmenu);
-       gtk_option_menu_set_menu(GTK_OPTION_MENU(sugmode_optmenu),
-                           gtkaspell_sugmode_option_menu_new(prefs_common.aspell_sugmode));
-       gtk_table_attach(GTK_TABLE(spell_table), sugmode_optmenu, 1, 2, 2, 3,
-                        GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
-       gtk_widget_set_sensitive(sugmode_optmenu, prefs_common.enable_aspell);
-
-       /* Color */
-       color_label = gtk_label_new(_("Misspelled word color:"));
-       gtk_misc_set_alignment(GTK_MISC(color_label), 1.0, 0.5);
-       gtk_table_attach (GTK_TABLE (spell_table), color_label, 0, 1, 3, 4,
-                         GTK_FILL, GTK_SHRINK, 0, 0);
-       gtk_widget_show(color_label);
-       
-       col_align = gtk_alignment_new(0.0, 0.5, 0, 0);
-       gtk_widget_show(col_align);
-       gtk_table_attach (GTK_TABLE (spell_table), col_align, 1, 2, 3, 4,
-                         GTK_FILL, GTK_SHRINK, 0, 0);
-
-       spelling.misspelled_btn = gtk_button_new_with_label ("");
-       set_button_bg_color(spelling.misspelled_btn,
-                           prefs_common.misspelled_col);
-       gtk_widget_set_usize (spelling.misspelled_btn, 30, 20);
-       gtk_widget_set_sensitive(spelling.misspelled_btn, prefs_common.enable_aspell);
-       gtk_signal_connect (GTK_OBJECT (spelling.misspelled_btn), "clicked",
-                           GTK_SIGNAL_FUNC(quote_color_set_dialog), "Misspelled word");
-       gtk_container_add(GTK_CONTAINER(col_align), spelling.misspelled_btn);
-
-
-       spelling.checkbtn_enable_aspell = checkbtn_enable_aspell;
-       spelling.entry_aspell_path      = entry_aspell_path;
-       spelling.btn_aspell_path        = btn_aspell_path;
-       spelling.optmenu_dictionary     = optmenu_dictionary;
-       spelling.optmenu_sugmode        = sugmode_optmenu;
-       spelling.checkbtn_use_alternate = checkbtn_use_alternate;
-       spelling.checkbtn_check_while_typing = checkbtn_check_while_typing;
-}
-
-#endif
-
-
 static void prefs_compose_create(void)
 {
        GtkWidget *vbox1;
@@ -3545,11 +3220,6 @@ static void quote_color_set_dialog(GtkWidget *widget, gpointer data)
        } else if(g_strcasecmp(type, "SIGNATURE") == 0) {
                title = _("Pick color for signatures");
                rgbvalue = prefs_common.signature_col;
-#if USE_ASPELL         
-       } else if(g_strcasecmp(type, "Misspelled word") == 0) {
-               title = _("Pick color for misspelled word");
-               rgbvalue = prefs_common.misspelled_col;
-#endif         
        } else {   /* Should never be called */
                g_warning("Unrecognized datatype '%s' in quote_color_set_dialog\n", type);
                return;
@@ -3620,11 +3290,6 @@ static void quote_colors_set_dialog_ok(GtkWidget *widget, gpointer data)
        } else if (g_strcasecmp(type, "SIGNATURE") == 0) {
                prefs_common.signature_col = rgbvalue;
                set_button_bg_color(color_buttons.signature_btn, rgbvalue);
-#if USE_ASPELL         
-       } else if (g_strcasecmp(type, "Misspelled word") == 0) {
-               prefs_common.misspelled_col = rgbvalue;
-               set_button_bg_color(spelling.misspelled_btn, rgbvalue);
-#endif         
        } else
                fprintf( stderr, "Unrecognized datatype '%s' in quote_color_set_dialog_ok\n", type );
 
index 39ce107..821b4a9 100644 (file)
@@ -41,6 +41,7 @@
 #include "gtkutils.h"
 #include "filtering.h"
 #include "folder_item_prefs.h"
+#include "gtk/colorsel.h"
 
 struct FolderItemGeneralPage
 {
@@ -53,10 +54,9 @@ struct FolderItemGeneralPage
        GtkWidget *entry_simplify_subject;
        GtkWidget *checkbtn_folder_chmod;
        GtkWidget *entry_folder_chmod;
-       GtkWidget *folder_color;
        GtkWidget *folder_color_btn;
 
-       GtkWidget *color_dialog;
+       gint       folder_color;
 };
 
 struct FolderItemComposePage
@@ -80,13 +80,7 @@ struct FolderItemComposePage
 
 gint prefs_folder_item_chmod_mode              (gchar *folder_chmod);
 
-static void set_button_color(guint rgbvalue, GtkWidget *button);
 static void folder_color_set_dialog(GtkWidget *widget, gpointer data);
-static void folder_color_set_dialog_ok(GtkWidget *widget, gpointer data);
-static void folder_color_set_dialog_cancel(GtkWidget *widget, gpointer data);
-static void folder_color_set_dialog_key_pressed(GtkWidget *widget,
-                                               GdkEventKey *event,
-                                               gpointer data);
 
 #define SAFE_STRING(str) \
        (str) ? (str) : ""
@@ -108,9 +102,6 @@ void prefs_folder_item_general_create_widget_func(PrefsPage * _page,
        GtkWidget *entry_folder_chmod;
        GtkWidget *folder_color;
        GtkWidget *folder_color_btn;
-       GtkWidget *menu;
-       GtkWidget *menuitem;
-       gint account_index, index;
 
        page->item         = item;
 
@@ -178,13 +169,13 @@ void prefs_folder_item_general_create_widget_func(PrefsPage * _page,
        gtk_widget_set_usize(folder_color_btn, 36, 26);
        gtk_box_pack_start (GTK_BOX(hbox), folder_color_btn, FALSE, FALSE, 0);
 
-       page->item->prefs->color = item->prefs->color;
+       page->folder_color = item->prefs->color;
 
        gtk_signal_connect(GTK_OBJECT(folder_color_btn), "clicked",
                           GTK_SIGNAL_FUNC(folder_color_set_dialog),
                           page);
 
-       set_button_color(item->prefs->color, folder_color_btn);
+       gtkut_set_widget_bgcolor_rgb(folder_color_btn, item->prefs->color);
 
        rowcount++;
 
@@ -193,7 +184,6 @@ void prefs_folder_item_general_create_widget_func(PrefsPage * _page,
        page->entry_simplify_subject = entry_simplify_subject;
        page->checkbtn_folder_chmod = checkbtn_folder_chmod;
        page->entry_folder_chmod = entry_folder_chmod;
-       page->folder_color = folder_color;
        page->folder_color_btn = folder_color_btn;
 
        page->page.widget = table;
@@ -201,7 +191,7 @@ void prefs_folder_item_general_create_widget_func(PrefsPage * _page,
 
 void prefs_folder_item_general_destroy_widget_func(PrefsPage *_page) 
 {
-       struct FolderItemGeneralPage *page = (struct FolderItemGeneralPage *) _page;
+       /* struct FolderItemGeneralPage *page = (struct FolderItemGeneralPage *) _page; */
 }
 
 void prefs_folder_item_general_save_func(PrefsPage *_page) 
@@ -209,8 +199,6 @@ void prefs_folder_item_general_save_func(PrefsPage *_page)
        gchar *buf;
        struct FolderItemGeneralPage *page = (struct FolderItemGeneralPage *) _page;
        FolderItemPrefs *prefs = page->item->prefs;
-       GtkWidget *menu;
-       GtkWidget *menuitem;
        gboolean   old_simplify_val;
        gchar     *old_simplify_str;
 
@@ -242,7 +230,7 @@ void prefs_folder_item_general_save_func(PrefsPage *_page)
        prefs->folder_chmod = prefs_folder_item_chmod_mode(buf);
        g_free(buf);
 
-       prefs->color = page->item->prefs->color;
+       prefs->color = page->folder_color;
        /* update folder view */
        if (prefs->color > 0)
                folder_item_update(page->item, F_ITEM_UPDATE_MSGCNT);
@@ -413,7 +401,6 @@ void prefs_folder_item_compose_destroy_widget_func(PrefsPage *_page)
 
 void prefs_folder_item_compose_save_func(PrefsPage *_page) 
 {
-       gchar *buf;
        struct FolderItemComposePage *page = (struct FolderItemComposePage *) _page;
        FolderItemPrefs *prefs = page->item->prefs;
        GtkWidget *menu;
@@ -464,84 +451,15 @@ gint prefs_folder_item_chmod_mode(gchar *folder_chmod)
        return newmode;
 }
 
-static void set_button_color(guint rgbvalue, GtkWidget *button)
-{
-       GtkStyle *newstyle;
-       GdkColor gdk_color;
-
-       gtkut_convert_int_to_gdk_color(rgbvalue, &gdk_color);
-       newstyle = gtk_style_copy(gtk_widget_get_default_style());
-       newstyle->bg[GTK_STATE_NORMAL]   = gdk_color;
-       newstyle->bg[GTK_STATE_PRELIGHT] = gdk_color;
-       newstyle->bg[GTK_STATE_ACTIVE]   = gdk_color;
-       gtk_widget_set_style(GTK_WIDGET(button), newstyle);
-}
-
 static void folder_color_set_dialog(GtkWidget *widget, gpointer data)
 {
        struct FolderItemGeneralPage *page = (struct FolderItemGeneralPage *) data;
-       GtkColorSelectionDialog *dialog;
-       gdouble color[4] = {0.0, 0.0, 0.0, 0.0};
-       guint rgbcolor;
-
-       page->color_dialog = gtk_color_selection_dialog_new(_("Pick color for folder"));
-       gtk_window_set_position(GTK_WINDOW(page->color_dialog), GTK_WIN_POS_CENTER);
-       gtk_window_set_modal(GTK_WINDOW(page->color_dialog), TRUE);
-       gtk_window_set_policy(GTK_WINDOW(page->color_dialog), FALSE, FALSE, FALSE);
-       manage_window_set_transient(GTK_WINDOW(page->color_dialog));
-
-       gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(page->color_dialog)->ok_button),
-                          "clicked", GTK_SIGNAL_FUNC(folder_color_set_dialog_ok), data);
-       gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(page->color_dialog)->cancel_button),
-                          "clicked", GTK_SIGNAL_FUNC(folder_color_set_dialog_cancel), data);
-       gtk_signal_connect(GTK_OBJECT(page->color_dialog), "key_press_event",
-                          GTK_SIGNAL_FUNC(folder_color_set_dialog_key_pressed),
-                          data);
-
-       rgbcolor = page->item->prefs->color;
-       color[0] = (gdouble) ((rgbcolor & 0xff0000) >> 16) / 255.0;
-       color[1] = (gdouble) ((rgbcolor & 0x00ff00) >>  8) / 255.0;
-       color[2] = (gdouble)  (rgbcolor & 0x0000ff)        / 255.0;
-
-       dialog = GTK_COLOR_SELECTION_DIALOG(page->color_dialog);
-       gtk_color_selection_set_color(GTK_COLOR_SELECTION(dialog->colorsel), color);
-
-       gtk_widget_show(page->color_dialog);
-}
-
-static void folder_color_set_dialog_ok(GtkWidget *widget, gpointer data)
-{
-       struct FolderItemGeneralPage *page = (struct FolderItemGeneralPage *) data;
-       GtkColorSelection *colorsel = (GtkColorSelection *)
-                               ((GtkColorSelectionDialog *) page->color_dialog)->colorsel;
-       gdouble color[4];
-       guint red, green, blue, rgbvalue;
-
-       gtk_color_selection_get_color(colorsel, color);
-
-       red      = (guint) (color[0] * 255.0);
-       green    = (guint) (color[1] * 255.0);
-       blue     = (guint) (color[2] * 255.0);
-       rgbvalue = (guint) ((red * 0x10000) | (green * 0x100) | blue);
-
-       page->item->prefs->color = rgbvalue;
-       set_button_color(rgbvalue, page->folder_color_btn);
-
-       gtk_widget_destroy(page->color_dialog);
-}
+       gint rgbcolor;
 
-static void folder_color_set_dialog_cancel(GtkWidget *widget, gpointer data)
-{
-       struct FolderItemGeneralPage *page = (struct FolderItemGeneralPage *) data;
-       gtk_widget_destroy(page->color_dialog);
-}
-
-static void folder_color_set_dialog_key_pressed(GtkWidget *widget,
-                                               GdkEventKey *event,
-                                               gpointer data)
-{
-       struct FolderItemGeneralPage *page = (struct FolderItemGeneralPage *) data;
-       gtk_widget_destroy(page->color_dialog);
+       rgbcolor = colorsel_select_color_rgb(_("Pick color for folder"), 
+                                            page->folder_color);
+       gtkut_set_widget_bgcolor_rgb(page->folder_color_btn, rgbcolor);
+       page->folder_color = rgbcolor;
 }
 
 struct FolderItemGeneralPage folder_item_general_page;
diff --git a/src/prefs_spelling.c b/src/prefs_spelling.c
new file mode 100644 (file)
index 0000000..d518705
--- /dev/null
@@ -0,0 +1,391 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2002 Hiroyuki Yamamoto & the Sylpheed-Claws team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * General functions for accessing address book files.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "defs.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "intl.h"
+#include "utils.h"
+#include "prefs_common.h"
+#include "prefs_gtk.h"
+
+#include "gtk/gtkutils.h"
+#include "gtk/prefswindow.h"
+#include "gtk/filesel.h"
+#include "gtk/colorsel.h"
+
+typedef struct _SpellingPage
+{
+       PrefsPage page;
+
+       GtkWidget *window;              /* do not modify */
+
+       GtkWidget *checkbtn_enable_aspell;
+       GtkWidget *entry_aspell_path;
+       GtkWidget *btn_aspell_path;
+       GtkWidget *optmenu_dictionary;
+       GtkWidget *optmenu_sugmode;
+       GtkWidget *misspelled_btn;
+       GtkWidget *checkbtn_use_alternate;
+       GtkWidget *checkbtn_check_while_typing;
+
+       gint       misspell_col;
+} SpellingPage;
+
+static void prefs_spelling_enable(SpellingPage *spelling, gboolean enable)
+{
+       gtk_widget_set_sensitive(spelling->entry_aspell_path,           enable);
+       gtk_widget_set_sensitive(spelling->optmenu_dictionary,          enable);
+       gtk_widget_set_sensitive(spelling->optmenu_sugmode,             enable);
+       gtk_widget_set_sensitive(spelling->btn_aspell_path,             enable);
+       gtk_widget_set_sensitive(spelling->misspelled_btn,              enable);
+       gtk_widget_set_sensitive(spelling->checkbtn_use_alternate,      enable);
+       gtk_widget_set_sensitive(spelling->checkbtn_check_while_typing, enable);
+}
+
+static void prefs_spelling_checkbtn_enable_aspell_toggle_cb
+       (GtkWidget *widget,
+        gpointer data)
+{
+       SpellingPage *spelling = (SpellingPage *) data;
+       gboolean toggled;
+
+       toggled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+       prefs_spelling_enable(spelling, toggled);
+}
+
+static void prefs_spelling_btn_aspell_path_clicked_cb(GtkWidget *widget,
+                                                    gpointer data)
+{
+       SpellingPage *spelling = (SpellingPage *) data;
+       gchar *file_path;
+       GtkWidget *new_menu;
+
+       file_path = filesel_select_file(_("Select dictionaries location"),
+                                       prefs_common.aspell_path);
+       if (file_path != NULL) {
+               gchar *tmp_path, *tmp;
+
+               tmp_path = g_dirname(file_path);
+               tmp = g_strdup_printf("%s%s", tmp_path, G_DIR_SEPARATOR_S);
+               g_free(tmp_path);
+
+               new_menu = gtkaspell_dictionary_option_menu_new(tmp);
+               gtk_option_menu_set_menu(GTK_OPTION_MENU(spelling->optmenu_dictionary),
+                                        new_menu);
+
+               gtk_entry_set_text(GTK_ENTRY(spelling->entry_aspell_path), tmp);
+               /* select first one */
+               gtk_option_menu_set_history(GTK_OPTION_MENU(
+                                       spelling->optmenu_dictionary), 0);
+       
+               g_free(tmp);
+
+       }
+}
+
+static void prefs_spelling_colorsel(GtkWidget *widget,
+                                   gpointer data)
+{
+       SpellingPage *spelling = (SpellingPage *) data;
+       gint rgbcolor;
+
+       rgbcolor = colorsel_select_color_rgb(_("Pick color for misspelled word"), 
+                                            spelling->misspell_col);
+       gtkut_set_widget_bgcolor_rgb(spelling->misspelled_btn, rgbcolor);
+       spelling->misspell_col = rgbcolor;
+}
+
+#define SAFE_STRING(str) \
+       (str) ? (str) : ""
+
+void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gpointer data)
+{
+       SpellingPage *prefs_spelling = (SpellingPage *) _page;
+       GList *cur;
+       gint n;
+
+       /* START GLADE CODE */
+       GtkWidget *table;
+       GtkWidget *checkbtn_enable_aspell;
+       GtkWidget *checkbtn_check_while_typing;
+       GtkWidget *checkbtn_use_alternate;
+       GtkWidget *label1;
+       GtkWidget *label2;
+       GtkWidget *entry_aspell_path;
+       GtkWidget *label3;
+       GtkWidget *optmenu_dictionary;
+       GtkWidget *optmenu_dictionary_menu;
+       GtkWidget *label4;
+       GtkWidget *optmenu_sugmode;
+       GtkWidget *optmenu_sugmode_menu;
+       GtkWidget *label5;
+       GtkWidget *btn_aspell_path;
+       GtkWidget *hbox1;
+       GtkWidget *misspelled_btn;
+
+       table = gtk_table_new(8, 3, FALSE);
+       gtk_widget_show(table);
+       gtk_container_set_border_width(GTK_CONTAINER(table), 8);
+       gtk_table_set_row_spacings(GTK_TABLE(table), 4);
+       gtk_table_set_col_spacings(GTK_TABLE(table), 8);
+
+       checkbtn_enable_aspell =
+           gtk_check_button_new_with_label(_("Enable spell checker"));
+       gtk_widget_show(checkbtn_enable_aspell);
+       gtk_table_attach(GTK_TABLE(table), checkbtn_enable_aspell, 0, 3, 0,
+                        1, (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+
+       checkbtn_check_while_typing =
+           gtk_check_button_new_with_label(_("Check while typing"));
+       gtk_widget_show(checkbtn_check_while_typing);
+       gtk_table_attach(GTK_TABLE(table), checkbtn_check_while_typing, 0,
+                        3, 1, 2, (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+
+       checkbtn_use_alternate =
+           gtk_check_button_new_with_label(_
+                                           ("Enable alternate dictionary"));
+       gtk_widget_show(checkbtn_use_alternate);
+       gtk_table_attach(GTK_TABLE(table), checkbtn_use_alternate, 0, 3, 2,
+                        3, (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+
+       label1 =
+           gtk_label_new(_
+                         ("Enabling an alternate dictionary makes switching\nwith the last used dictionary faster"));
+       gtk_widget_show(label1);
+       gtk_table_attach(GTK_TABLE(table), label1, 0, 3, 3, 4,
+                        (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+       gtk_misc_set_alignment(GTK_MISC(label1), 7.45058e-09, 0.5);
+
+       label2 = gtk_label_new(_("Dictionaries path:"));
+       gtk_widget_show(label2);
+       gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 4, 5,
+                        (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+       gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_RIGHT);
+       gtk_misc_set_alignment(GTK_MISC(label2), 1, 0.5);
+
+       entry_aspell_path = gtk_entry_new();
+       gtk_widget_show(entry_aspell_path);
+       gtk_table_attach(GTK_TABLE(table), entry_aspell_path, 1, 2, 4, 5,
+                        (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+
+       label3 = gtk_label_new(_("Default dictionary:"));
+       gtk_widget_show(label3);
+       gtk_table_attach(GTK_TABLE(table), label3, 0, 1, 5, 6,
+                        (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+       gtk_label_set_justify(GTK_LABEL(label3), GTK_JUSTIFY_RIGHT);
+       gtk_misc_set_alignment(GTK_MISC(label3), 1, 0.5);
+
+       optmenu_dictionary = gtk_option_menu_new();
+       gtk_widget_show(optmenu_dictionary);
+       gtk_table_attach(GTK_TABLE(table), optmenu_dictionary, 1, 3, 5, 6,
+                        (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+       optmenu_dictionary_menu = gtk_menu_new();
+       gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_dictionary),
+                                optmenu_dictionary_menu);
+
+       label4 = gtk_label_new(_("Default suggestion mode:"));
+       gtk_widget_show(label4);
+       gtk_table_attach(GTK_TABLE(table), label4, 0, 1, 6, 7,
+                        (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+       gtk_label_set_justify(GTK_LABEL(label4), GTK_JUSTIFY_RIGHT);
+       gtk_misc_set_alignment(GTK_MISC(label4), 1, 0.5);
+
+       optmenu_sugmode = gtk_option_menu_new();
+       gtk_widget_show(optmenu_sugmode);
+       gtk_table_attach(GTK_TABLE(table), optmenu_sugmode, 1, 3, 6, 7,
+                        (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+       optmenu_sugmode_menu = gtk_menu_new();
+       gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_sugmode),
+                                optmenu_sugmode_menu);
+
+       label5 = gtk_label_new(_("Misspelled word color:"));
+       gtk_widget_show(label5);
+       gtk_table_attach(GTK_TABLE(table), label5, 0, 1, 7, 8,
+                        (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+       gtk_label_set_justify(GTK_LABEL(label5), GTK_JUSTIFY_RIGHT);
+       gtk_misc_set_alignment(GTK_MISC(label5), 1, 0.5);
+
+       btn_aspell_path = gtk_button_new_with_label(_(" ... "));
+       gtk_widget_show(btn_aspell_path);
+       gtk_table_attach(GTK_TABLE(table), btn_aspell_path, 2, 3, 4, 5,
+                        (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+
+       hbox1 = gtk_hbox_new(FALSE, 0);
+       gtk_widget_show(hbox1);
+       gtk_table_attach(GTK_TABLE(table), hbox1, 1, 2, 7, 8,
+                        (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (GTK_FILL), 0, 0);
+
+       misspelled_btn = gtk_button_new_with_label("");
+       gtk_widget_show(misspelled_btn);
+       gtk_box_pack_start(GTK_BOX(hbox1), misspelled_btn, FALSE, FALSE,
+                          0);
+       gtk_widget_set_usize(misspelled_btn, 30, 20);
+       /* END GLADE CODE */
+
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_aspell),
+                                    prefs_common.enable_aspell);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_check_while_typing),
+                                    prefs_common.check_while_typing);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_use_alternate),
+                                    prefs_common.use_alternate);
+       gtk_entry_set_text(GTK_ENTRY(entry_aspell_path), 
+                          SAFE_STRING(prefs_common.aspell_path));
+
+       gtk_signal_connect(GTK_OBJECT(checkbtn_enable_aspell), "toggled",
+                          GTK_SIGNAL_FUNC(prefs_spelling_checkbtn_enable_aspell_toggle_cb),
+                          prefs_spelling);
+       gtk_signal_connect(GTK_OBJECT(btn_aspell_path), "clicked", 
+                          GTK_SIGNAL_FUNC(prefs_spelling_btn_aspell_path_clicked_cb),
+                          prefs_spelling);
+       gtk_signal_connect(GTK_OBJECT(misspelled_btn), "clicked",
+                          GTK_SIGNAL_FUNC(prefs_spelling_colorsel), prefs_spelling);
+
+       gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_dictionary),
+                                gtkaspell_dictionary_option_menu_new(prefs_common.aspell_path));
+       n = 0;
+       for (cur = GTK_MENU_SHELL(gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu_dictionary)))->children;
+            cur != NULL; cur = cur->next) {
+               GtkWidget *menuitem;
+               gchar *dict_name;
+
+               menuitem = GTK_WIDGET(cur->data);
+               dict_name = gtk_object_get_data(GTK_OBJECT(menuitem), 
+                                               "dict_name");
+               if (!strcmp2(dict_name, prefs_common.dictionary)) {
+                       gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu_dictionary), n);
+               }
+               n++;
+       }
+
+       gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_sugmode),
+                                gtkaspell_sugmode_option_menu_new(prefs_common.aspell_sugmode));
+       gtkaspell_sugmode_option_menu_set(GTK_OPTION_MENU(optmenu_sugmode),
+                                         prefs_common.aspell_sugmode);
+
+       prefs_spelling->misspell_col = prefs_common.misspelled_col;
+       gtkut_set_widget_bgcolor_rgb(misspelled_btn, prefs_spelling->misspell_col);
+
+       prefs_spelling->window
+               = GTK_WIDGET(window);
+       prefs_spelling->checkbtn_enable_aspell 
+               = checkbtn_enable_aspell;
+       prefs_spelling->entry_aspell_path
+               = entry_aspell_path;
+       prefs_spelling->btn_aspell_path
+               = btn_aspell_path;
+       prefs_spelling->optmenu_dictionary
+               = optmenu_dictionary;
+       prefs_spelling->optmenu_sugmode
+               = optmenu_sugmode;
+       prefs_spelling->checkbtn_use_alternate
+               = checkbtn_use_alternate;
+       prefs_spelling->checkbtn_check_while_typing
+               = checkbtn_check_while_typing;
+       prefs_spelling->misspelled_btn
+               = misspelled_btn;
+
+       prefs_spelling->page.widget = table;
+
+       prefs_spelling_enable(prefs_spelling, prefs_common.enable_aspell);
+}
+
+void prefs_spelling_save(PrefsPage *_page)
+{
+       SpellingPage *spelling = (SpellingPage *) _page;
+
+       prefs_common.enable_aspell =
+               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(spelling->checkbtn_enable_aspell));
+       prefs_common.check_while_typing =
+               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(spelling->checkbtn_check_while_typing));
+       prefs_common.use_alternate =
+               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(spelling->checkbtn_use_alternate));
+
+       if (prefs_common.aspell_path)
+               g_free(prefs_common.aspell_path);
+       prefs_common.aspell_path =
+               gtk_editable_get_chars(GTK_EDITABLE(spelling->entry_aspell_path), 0, -1);
+
+       if (prefs_common.dictionary != NULL)
+               g_free(prefs_common.dictionary);
+       prefs_common.dictionary = 
+               gtkaspell_get_dictionary_menu_active_item(
+                       gtk_option_menu_get_menu(
+                               GTK_OPTION_MENU(
+                                       spelling->optmenu_dictionary)));
+
+       prefs_common.aspell_sugmode =
+               gtkaspell_get_sugmode_from_option_menu(
+                       GTK_OPTION_MENU(spelling->optmenu_sugmode));
+
+       prefs_common.misspelled_col = spelling->misspell_col;
+}
+
+static void prefs_spelling_destroy_widget(PrefsPage *_page)
+{
+       /* SpellingPage *spelling = (SpellingPage *) _page; */
+
+}
+
+SpellingPage *prefs_spelling;
+
+void prefs_spelling_init(void)
+{
+       SpellingPage *page;
+
+       page = g_new0(SpellingPage, 1);
+       page->page.path = _("Compose/Spell Checker");
+       page->page.create_widget = prefs_spelling_create_widget;
+       page->page.destroy_widget = prefs_spelling_destroy_widget;
+       page->page.save_page = prefs_spelling_save;
+       prefs_gtk_register_page((PrefsPage *) page);
+       prefs_spelling = page;
+}
+
+void prefs_spelling_done(void)
+{
+       prefs_gtk_unregister_page((PrefsPage *) prefs_spelling);
+       g_free(prefs_spelling);
+}
diff --git a/src/prefs_spelling.glade b/src/prefs_spelling.glade
new file mode 100644 (file)
index 0000000..e018f4c
--- /dev/null
@@ -0,0 +1,367 @@
+<?xml version="1.0"?>
+<GTK-Interface>
+
+<project>
+  <name>Sylpheed-Claws</name>
+  <program_name>sylpheed-claws</program_name>
+  <directory></directory>
+  <source_directory>src</source_directory>
+  <pixmaps_directory>pixmaps</pixmaps_directory>
+  <language>C</language>
+  <gnome_support>False</gnome_support>
+  <gettext_support>True</gettext_support>
+  <output_main_file>False</output_main_file>
+  <output_build_files>False</output_build_files>
+  <backup_source_files>False</backup_source_files>
+</project>
+
+<widget>
+  <class>GtkWindow</class>
+  <name>prefs_spelling</name>
+  <title>Prefs Spelling</title>
+  <type>GTK_WINDOW_TOPLEVEL</type>
+  <position>GTK_WIN_POS_NONE</position>
+  <modal>False</modal>
+  <allow_shrink>False</allow_shrink>
+  <allow_grow>True</allow_grow>
+  <auto_shrink>False</auto_shrink>
+
+  <widget>
+    <class>GtkTable</class>
+    <name>table</name>
+    <border_width>8</border_width>
+    <rows>8</rows>
+    <columns>3</columns>
+    <homogeneous>False</homogeneous>
+    <row_spacing>4</row_spacing>
+    <column_spacing>8</column_spacing>
+
+    <widget>
+      <class>GtkCheckButton</class>
+      <name>checkbtn_enable_aspell</name>
+      <can_focus>True</can_focus>
+      <label>Enable spell checker</label>
+      <active>False</active>
+      <draw_indicator>True</draw_indicator>
+      <child>
+       <left_attach>0</left_attach>
+       <right_attach>3</right_attach>
+       <top_attach>0</top_attach>
+       <bottom_attach>1</bottom_attach>
+       <xpad>0</xpad>
+       <ypad>0</ypad>
+       <xexpand>False</xexpand>
+       <yexpand>False</yexpand>
+       <xshrink>False</xshrink>
+       <yshrink>False</yshrink>
+       <xfill>True</xfill>
+       <yfill>False</yfill>
+      </child>
+    </widget>
+
+    <widget>
+      <class>GtkCheckButton</class>
+      <name>checkbtn_check_while_typing</name>
+      <can_focus>True</can_focus>
+      <label>Check while typing</label>
+      <active>False</active>
+      <draw_indicator>True</draw_indicator>
+      <child>
+       <left_attach>0</left_attach>
+       <right_attach>3</right_attach>
+       <top_attach>1</top_attach>
+       <bottom_attach>2</bottom_attach>
+       <xpad>0</xpad>
+       <ypad>0</ypad>
+       <xexpand>False</xexpand>
+       <yexpand>False</yexpand>
+       <xshrink>False</xshrink>
+       <yshrink>False</yshrink>
+       <xfill>True</xfill>
+       <yfill>False</yfill>
+      </child>
+    </widget>
+
+    <widget>
+      <class>GtkCheckButton</class>
+      <name>checkbtn_use_alternate</name>
+      <can_focus>True</can_focus>
+      <label>Enable alternate dictionary</label>
+      <active>False</active>
+      <draw_indicator>True</draw_indicator>
+      <child>
+       <left_attach>0</left_attach>
+       <right_attach>3</right_attach>
+       <top_attach>2</top_attach>
+       <bottom_attach>3</bottom_attach>
+       <xpad>0</xpad>
+       <ypad>0</ypad>
+       <xexpand>False</xexpand>
+       <yexpand>False</yexpand>
+       <xshrink>False</xshrink>
+       <yshrink>False</yshrink>
+       <xfill>True</xfill>
+       <yfill>False</yfill>
+      </child>
+    </widget>
+
+    <widget>
+      <class>GtkLabel</class>
+      <name>label1</name>
+      <label>Enabling an alternate dictionary makes switching
+with the last used dictionary faster</label>
+      <justify>GTK_JUSTIFY_CENTER</justify>
+      <wrap>False</wrap>
+      <xalign>7.45058e-09</xalign>
+      <yalign>0.5</yalign>
+      <xpad>0</xpad>
+      <ypad>0</ypad>
+      <child>
+       <left_attach>0</left_attach>
+       <right_attach>3</right_attach>
+       <top_attach>3</top_attach>
+       <bottom_attach>4</bottom_attach>
+       <xpad>0</xpad>
+       <ypad>0</ypad>
+       <xexpand>False</xexpand>
+       <yexpand>False</yexpand>
+       <xshrink>False</xshrink>
+       <yshrink>False</yshrink>
+       <xfill>True</xfill>
+       <yfill>False</yfill>
+      </child>
+    </widget>
+
+    <widget>
+      <class>GtkLabel</class>
+      <name>label2</name>
+      <label>Dictionaries path:</label>
+      <justify>GTK_JUSTIFY_RIGHT</justify>
+      <wrap>False</wrap>
+      <xalign>1</xalign>
+      <yalign>0.5</yalign>
+      <xpad>0</xpad>
+      <ypad>0</ypad>
+      <child>
+       <left_attach>0</left_attach>
+       <right_attach>1</right_attach>
+       <top_attach>4</top_attach>
+       <bottom_attach>5</bottom_attach>
+       <xpad>0</xpad>
+       <ypad>0</ypad>
+       <xexpand>False</xexpand>
+       <yexpand>False</yexpand>
+       <xshrink>False</xshrink>
+       <yshrink>False</yshrink>
+       <xfill>True</xfill>
+       <yfill>False</yfill>
+      </child>
+    </widget>
+
+    <widget>
+      <class>GtkEntry</class>
+      <name>entry_aspell_path</name>
+      <can_focus>True</can_focus>
+      <editable>True</editable>
+      <text_visible>True</text_visible>
+      <text_max_length>0</text_max_length>
+      <text></text>
+      <child>
+       <left_attach>1</left_attach>
+       <right_attach>2</right_attach>
+       <top_attach>4</top_attach>
+       <bottom_attach>5</bottom_attach>
+       <xpad>0</xpad>
+       <ypad>0</ypad>
+       <xexpand>True</xexpand>
+       <yexpand>False</yexpand>
+       <xshrink>False</xshrink>
+       <yshrink>False</yshrink>
+       <xfill>True</xfill>
+       <yfill>False</yfill>
+      </child>
+    </widget>
+
+    <widget>
+      <class>GtkLabel</class>
+      <name>label3</name>
+      <label>Default dictionary:</label>
+      <justify>GTK_JUSTIFY_RIGHT</justify>
+      <wrap>False</wrap>
+      <xalign>1</xalign>
+      <yalign>0.5</yalign>
+      <xpad>0</xpad>
+      <ypad>0</ypad>
+      <child>
+       <left_attach>0</left_attach>
+       <right_attach>1</right_attach>
+       <top_attach>5</top_attach>
+       <bottom_attach>6</bottom_attach>
+       <xpad>0</xpad>
+       <ypad>0</ypad>
+       <xexpand>False</xexpand>
+       <yexpand>False</yexpand>
+       <xshrink>False</xshrink>
+       <yshrink>False</yshrink>
+       <xfill>True</xfill>
+       <yfill>False</yfill>
+      </child>
+    </widget>
+
+    <widget>
+      <class>GtkOptionMenu</class>
+      <name>optmenu_dictionary</name>
+      <can_focus>True</can_focus>
+      <items></items>
+      <initial_choice>0</initial_choice>
+      <child>
+       <left_attach>1</left_attach>
+       <right_attach>3</right_attach>
+       <top_attach>5</top_attach>
+       <bottom_attach>6</bottom_attach>
+       <xpad>0</xpad>
+       <ypad>0</ypad>
+       <xexpand>False</xexpand>
+       <yexpand>False</yexpand>
+       <xshrink>False</xshrink>
+       <yshrink>False</yshrink>
+       <xfill>True</xfill>
+       <yfill>False</yfill>
+      </child>
+    </widget>
+
+    <widget>
+      <class>GtkLabel</class>
+      <name>label4</name>
+      <label>Default suggestion mode:</label>
+      <justify>GTK_JUSTIFY_RIGHT</justify>
+      <wrap>False</wrap>
+      <xalign>1</xalign>
+      <yalign>0.5</yalign>
+      <xpad>0</xpad>
+      <ypad>0</ypad>
+      <child>
+       <left_attach>0</left_attach>
+       <right_attach>1</right_attach>
+       <top_attach>6</top_attach>
+       <bottom_attach>7</bottom_attach>
+       <xpad>0</xpad>
+       <ypad>0</ypad>
+       <xexpand>False</xexpand>
+       <yexpand>False</yexpand>
+       <xshrink>False</xshrink>
+       <yshrink>False</yshrink>
+       <xfill>True</xfill>
+       <yfill>False</yfill>
+      </child>
+    </widget>
+
+    <widget>
+      <class>GtkOptionMenu</class>
+      <name>optmenu_sugmode</name>
+      <can_focus>True</can_focus>
+      <items></items>
+      <initial_choice>0</initial_choice>
+      <child>
+       <left_attach>1</left_attach>
+       <right_attach>3</right_attach>
+       <top_attach>6</top_attach>
+       <bottom_attach>7</bottom_attach>
+       <xpad>0</xpad>
+       <ypad>0</ypad>
+       <xexpand>False</xexpand>
+       <yexpand>False</yexpand>
+       <xshrink>False</xshrink>
+       <yshrink>False</yshrink>
+       <xfill>True</xfill>
+       <yfill>False</yfill>
+      </child>
+    </widget>
+
+    <widget>
+      <class>GtkLabel</class>
+      <name>label5</name>
+      <label>Misspelled word color:</label>
+      <justify>GTK_JUSTIFY_RIGHT</justify>
+      <wrap>False</wrap>
+      <xalign>1</xalign>
+      <yalign>0.5</yalign>
+      <xpad>0</xpad>
+      <ypad>0</ypad>
+      <child>
+       <left_attach>0</left_attach>
+       <right_attach>1</right_attach>
+       <top_attach>7</top_attach>
+       <bottom_attach>8</bottom_attach>
+       <xpad>0</xpad>
+       <ypad>0</ypad>
+       <xexpand>False</xexpand>
+       <yexpand>False</yexpand>
+       <xshrink>False</xshrink>
+       <yshrink>False</yshrink>
+       <xfill>True</xfill>
+       <yfill>False</yfill>
+      </child>
+    </widget>
+
+    <widget>
+      <class>GtkButton</class>
+      <name>btn_aspell_path</name>
+      <can_focus>True</can_focus>
+      <label> ... </label>
+      <relief>GTK_RELIEF_NORMAL</relief>
+      <child>
+       <left_attach>2</left_attach>
+       <right_attach>3</right_attach>
+       <top_attach>4</top_attach>
+       <bottom_attach>5</bottom_attach>
+       <xpad>0</xpad>
+       <ypad>0</ypad>
+       <xexpand>False</xexpand>
+       <yexpand>False</yexpand>
+       <xshrink>False</xshrink>
+       <yshrink>False</yshrink>
+       <xfill>True</xfill>
+       <yfill>False</yfill>
+      </child>
+    </widget>
+
+    <widget>
+      <class>GtkHBox</class>
+      <name>hbox1</name>
+      <homogeneous>False</homogeneous>
+      <spacing>0</spacing>
+      <child>
+       <left_attach>1</left_attach>
+       <right_attach>2</right_attach>
+       <top_attach>7</top_attach>
+       <bottom_attach>8</bottom_attach>
+       <xpad>0</xpad>
+       <ypad>0</ypad>
+       <xexpand>False</xexpand>
+       <yexpand>False</yexpand>
+       <xshrink>False</xshrink>
+       <yshrink>False</yshrink>
+       <xfill>True</xfill>
+       <yfill>True</yfill>
+      </child>
+
+      <widget>
+       <class>GtkButton</class>
+       <name>misspelled_btn</name>
+       <width>30</width>
+       <height>20</height>
+       <can_focus>True</can_focus>
+       <label></label>
+       <relief>GTK_RELIEF_NORMAL</relief>
+       <child>
+         <padding>0</padding>
+         <expand>False</expand>
+         <fill>False</fill>
+       </child>
+      </widget>
+    </widget>
+  </widget>
+</widget>
+
+</GTK-Interface>
diff --git a/src/prefs_spelling.h b/src/prefs_spelling.h
new file mode 100644 (file)
index 0000000..c3f9840
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2001 Hiroyuki Yamamoto
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef PREFS_SPELLING_H
+#define PREFS_SPELLING_H
+
+void prefs_spelling_init       (void);
+void prefs_spelling_done       (void);
+
+#endif /* PREFS_SPELLING_H */