#include <time.h>
#include <dirent.h>
+#include <glib.h>
+
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gtk/gtkoptionmenu.h>
}
+gint gtkaspell_set_dictionary_menu_active_item(GtkWidget *menu, const gchar *dictionary)
+{
+ GList *cur;
+ gint n;
+
+ g_return_val_if_fail(menu != NULL, 0);
+ g_return_val_if_fail(dictionary != NULL, 0);
+ g_return_val_if_fail(GTK_IS_OPTION_MENU(menu), 0);
+
+ n = 0;
+ for (cur = GTK_MENU_SHELL(gtk_option_menu_get_menu(GTK_OPTION_MENU(menu)))->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 ((dict_name != NULL) && !strcmp2(dict_name, dictionary)) {
+ gtk_option_menu_set_history(GTK_OPTION_MENU(menu), n);
+
+ return 1;
+ }
+ n++;
+ }
+
+ return 0;
+}
+
GtkWidget *gtkaspell_sugmode_option_menu_new(gint sugmode)
{
GtkWidget *menu;
}
-/* 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);
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,