untwist file selection logic - be explicit
[claws.git] / src / prefs_spelling.c
index d51870563f9977b6b422ddc98754d7aa9685373a..23560f9a821bb83e2d28b96b82f7020dcc6e2e38 100644 (file)
@@ -25,6 +25,8 @@
 #  include "config.h"
 #endif
 
+#if USE_ASPELL
+
 #include "defs.h"
 
 #include <stdio.h>
@@ -90,7 +92,7 @@ static void prefs_spelling_btn_aspell_path_clicked_cb(GtkWidget *widget,
        gchar *file_path;
        GtkWidget *new_menu;
 
-       file_path = filesel_select_file(_("Select dictionaries location"),
+       file_path = filesel_select_file_open(_("Select dictionaries location"),
                                        prefs_common.aspell_path);
        if (file_path != NULL) {
                gchar *tmp_path, *tmp;
@@ -131,15 +133,12 @@ static void prefs_spelling_colorsel(GtkWidget *widget,
 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;
@@ -152,6 +151,9 @@ void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gpointer
        GtkWidget *btn_aspell_path;
        GtkWidget *hbox1;
        GtkWidget *misspelled_btn;
+       GtkTooltips *tooltips;
+
+       tooltips = gtk_tooltips_new ();
 
        table = gtk_table_new(8, 3, FALSE);
        gtk_widget_show(table);
@@ -180,15 +182,8 @@ void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gpointer
        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);
+       gtk_tooltips_set_tip (tooltips, checkbtn_use_alternate, 
+                       _("Faster switching with last used dictionary"), NULL);
 
        label2 = gtk_label_new(_("Dictionaries path:"));
        gtk_widget_show(label2);
@@ -274,31 +269,18 @@ void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gpointer
        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);
+       g_signal_connect(G_OBJECT(checkbtn_enable_aspell), "toggled",
+                        G_CALLBACK(prefs_spelling_checkbtn_enable_aspell_toggle_cb),
+                        prefs_spelling);
+       g_signal_connect(G_OBJECT(btn_aspell_path), "clicked", 
+                        G_CALLBACK(prefs_spelling_btn_aspell_path_clicked_cb),
+                        prefs_spelling);
+       g_signal_connect(G_OBJECT(misspelled_btn), "clicked",
+                        G_CALLBACK(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++;
-       }
+       gtkaspell_set_dictionary_menu_active_item(optmenu_dictionary, prefs_common.dictionary);
 
        gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_sugmode),
                                 gtkaspell_sugmode_option_menu_new(prefs_common.aspell_sugmode));
@@ -380,6 +362,7 @@ void prefs_spelling_init(void)
        page->page.create_widget = prefs_spelling_create_widget;
        page->page.destroy_widget = prefs_spelling_destroy_widget;
        page->page.save_page = prefs_spelling_save;
+       page->page.weight = 50.0;
        prefs_gtk_register_page((PrefsPage *) page);
        prefs_spelling = page;
 }
@@ -389,3 +372,5 @@ void prefs_spelling_done(void)
        prefs_gtk_unregister_page((PrefsPage *) prefs_spelling);
        g_free(prefs_spelling);
 }
+
+#endif /* USE_ASPELL */