gpointer data);
static void replace_real_word (GtkPspell *gtkpspell,
gchar *newword);
+static void check_with_alternate_cb (GtkWidget *w,
+ gpointer data);
+static void use_alternate_dict (GtkPspell *gtkpspell);
static void toggle_check_while_typing_cb (GtkWidget *w,
gpointer data);
gpointer data);
static void change_dict_cb (GtkWidget *w,
GtkPspell *gtkpspell);
+static void switch_to_alternate_cb (GtkWidget *w,
+ gpointer data);
/* Misc. helper functions */
static void set_point_continue (GtkPspell *gtkpspell);
const gchar *encoding,
gint misspelled_color,
gboolean check_while_typing,
+ gboolean use_alternate,
GtkSText *gtktext)
{
Dictionary *dict = g_new0(Dictionary, 1);
gtkpspell = g_new(GtkPspell, 1);
gtkpspell->gtkpspeller = gtkpspeller;
+ gtkpspell->alternate_speller = NULL;
gtkpspell->theword[0] = 0x00;
gtkpspell->start_pos = 0;
gtkpspell->end_pos = 0;
gtkpspell->default_sug_mode = PSPELL_FASTMODE;
gtkpspell->max_sug = -1;
gtkpspell->suggestions_list = NULL;
+ gtkpspell->use_alternate = use_alternate;
allocate_color(gtkpspell, misspelled_color);
gtkpspeller_delete(gtkpspell->gtkpspeller);
+ if (gtkpspell->use_alternate && gtkpspell->alternate_speller)
+ gtkpspeller_delete(gtkpspell->alternate_speller);
+
if (gtkpspell->sug_menu)
gtk_widget_destroy(gtkpspell->sug_menu);
if (gtkpspell->popup_config_menu)
dictionary_delete(gtkpspeller->dictionary);
+ debug_print(_("Pspell: gtkpspeller %0x deleted.\n"),
+ (gint) gtkpspeller);
g_free(gtkpspeller);
return NULL;
{
GtkPspell *gtkpspell = (GtkPspell *) data;
gint pos = gtk_editable_get_position(GTK_EDITABLE(gtkpspell->gtktext));
-
if (pos < gtkpspell->end_check_pos && gtkpspell->misspelled)
gtkpspell->misspelled = check_next_prev(gtkpspell, TRUE);
else
gtk_menu_shell_deactivate(menu_shell);
}
+static void check_with_alternate_cb(GtkWidget *w,
+ gpointer data)
+{
+ GtkPspell *gtkpspell = (GtkPspell *) data;
+ gint misspelled;
+ gtk_menu_shell_deactivate(GTK_MENU_SHELL(GTK_WIDGET(w)->parent));
+
+ use_alternate_dict(gtkpspell);
+ misspelled = check_at(gtkpspell, gtkpspell->start_pos);
+
+ if (!gtkpspell->continue_check) {
+ gtkpspell->misspelled = misspelled;
+ if (gtkpspell->misspelled) {
+ misspelled_suggest(gtkpspell, gtkpspell->theword);
+ gtk_stext_set_point(GTK_STEXT(gtkpspell->gtktext),
+ gtkpspell->end_pos);
+ gtk_editable_set_position(GTK_EDITABLE(gtkpspell->gtktext),
+ gtkpspell->end_pos);
+ gtk_menu_popup(make_sug_menu(gtkpspell), NULL, NULL,
+ set_menu_pos, gtkpspell, 0,
+ GDK_CURRENT_TIME);
+ return;
+ }
+ } else
+ gtkpspell->orig_pos = gtkpspell->start_pos;
+
+ set_point_continue(gtkpspell);
+}
+
static void replace_with_create_dialog_cb(GtkWidget *w, gpointer data)
{
GtkWidget *dialog;
return sugmode;
}
+
+static void use_alternate_dict(GtkPspell *gtkpspell)
+{
+ GtkPspeller *tmp;
+
+ tmp = gtkpspell->gtkpspeller;
+ gtkpspell->gtkpspeller = gtkpspell->alternate_speller;
+ gtkpspell->alternate_speller = tmp;
+
+ if (gtkpspell->config_menu)
+ populate_submenu(gtkpspell, gtkpspell->config_menu);
+}
+
+
#if 0 /* Experimenal */
void gtkpspell_set_primary_dict(GtkPspell *gtkpspell, gchar *dict, gchar *encoding)
{
gtk_signal_connect(GTK_OBJECT(menu), "cancel",
GTK_SIGNAL_FUNC(cancel_menu_cb), gtkpspell);
- caption = g_strdup_printf(_("Unknown word: \"%s\""),
- (unsigned char*) l->data);
+ caption = g_strdup_printf(_("\"%s\" unknown in %s"),
+ (unsigned char*) l->data,
+ gtkpspell->gtkpspeller->dictionary->dictname);
item = gtk_menu_item_new_with_label(caption);
gtk_widget_show(item);
gtk_menu_append(GTK_MENU(menu), item);
gtk_widget_add_accelerator(item, "activate", accel, GDK_R, 0,
GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
+ if (gtkpspell->use_alternate && gtkpspell->alternate_speller) {
+ caption = g_strdup_printf(_("Check with %s"),
+ gtkpspell->alternate_speller->dictionary->dictname);
+ item = gtk_menu_item_new_with_label(caption);
+ g_free(caption);
+ gtk_widget_show(item);
+ gtk_menu_append(GTK_MENU(menu), item);
+ gtk_signal_connect(GTK_OBJECT(item), "activate",
+ GTK_SIGNAL_FUNC(check_with_alternate_cb),
+ gtkpspell);
+ gtk_widget_add_accelerator(item, "activate", accel, GDK_X, 0,
+ GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
+ }
item = gtk_menu_item_new();
gtk_widget_show(item);
gtk_menu_append(GTK_MENU(menu), item);
item = gtk_menu_item_new();
gtk_widget_show(item);
gtk_menu_append(GTK_MENU(menu), item);
-
+
+ if (gtkpspell->use_alternate && gtkpspell->alternate_speller) {
+ dictname = g_strdup_printf(_("Use alternate (%s)"),
+ gtkpspell->alternate_speller->dictionary->dictname);
+ item = gtk_menu_item_new_with_label(dictname);
+ g_free(dictname);
+ gtk_signal_connect(GTK_OBJECT(item), "activate",
+ GTK_SIGNAL_FUNC(switch_to_alternate_cb),
+ gtkpspell);
+ gtk_widget_show(item);
+ gtk_menu_append(GTK_MENU(menu), item);
+ }
+
item = gtk_check_menu_item_new_with_label(_("Fast Mode"));
if (ispell || gtkpspell->gtkpspeller->sug_mode == PSPELL_FASTMODE)
gtk_widget_set_sensitive(GTK_WIDGET(item),FALSE);
dict = g_new0(Dictionary, 1);
dict->fullname = g_strdup(fullname);
dict->encoding = g_strdup(gtkpspell->gtkpspeller->dictionary->encoding);
+
+ if (gtkpspell->use_alternate && gtkpspell->alternate_speller &&
+ dict == gtkpspell->alternate_speller->dictionary) {
+ use_alternate_dict(gtkpspell);
+ dictionary_delete(dict);
+ return;
+ }
gtkpspeller = gtkpspeller_new(dict);
gtkpspell_alert_dialog(message);
g_free(message);
} else {
- gtkpspeller_delete(gtkpspell->gtkpspeller);
+ if (gtkpspell->use_alternate) {
+ if (gtkpspell->alternate_speller)
+ gtkpspeller_delete(gtkpspell->alternate_speller);
+ gtkpspell->alternate_speller = gtkpspell->gtkpspeller;
+ } else
+ gtkpspeller_delete(gtkpspell->gtkpspeller);
+
gtkpspell->gtkpspeller = gtkpspeller;
gtkpspell_set_sug_mode(gtkpspell, sug_mode);
}
}
+static void switch_to_alternate_cb(GtkWidget *w,
+ gpointer data)
+{
+ GtkPspell *gtkpspell = (GtkPspell *) data;
+ use_alternate_dict(gtkpspell);
+}
+
/******************************************************************************/
/* Misc. helper functions */
GtkWidget *optmenu_dictionary;
GtkWidget *optmenu_sugmode;
GtkWidget *misspelled_btn;
+ GtkWidget *checkbtn_use_alternate;
GtkWidget *checkbtn_check_while_typing;
} spelling;
#endif
{"pspell_sugmode", "1", &prefs_common.pspell_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},
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");
+ 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;
gtk_widget_set_sensitive(spelling.optmenu_dictionary, toggled);
gtk_widget_set_sensitive(spelling.optmenu_sugmode, toggled);
gtk_widget_set_sensitive(spelling.btn_pspell_path, toggled);
- gtk_widget_set_sensitive(spelling.misspelled_btn, toggled);
- gtk_widget_set_sensitive(spelling.checkbtn_check_while_typing, 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_pspell_path_clicked_cb(GtkWidget *widget,
if (prefs_common.pspell_path)
g_free(prefs_common.pspell_path);
- prefs_common.pspell_path = g_strdup_printf("%s%s",tmp,G_DIR_SEPARATOR_S);
+ prefs_common.pspell_path = g_strdup_printf("%s%s",tmp,
+ G_DIR_SEPARATOR_S);
new_menu = gtkpspell_dictionary_option_menu_new(prefs_common.pspell_path);
gtk_option_menu_set_menu(GTK_OPTION_MENU(spelling.optmenu_dictionary),
new_menu);
- gtk_entry_set_text(GTK_ENTRY(spelling.entry_pspell_path), prefs_common.pspell_path);
+ gtk_entry_set_text(GTK_ENTRY(spelling.entry_pspell_path),
+ prefs_common.pspell_path);
/* select first one */
- gtk_option_menu_set_history(GTK_OPTION_MENU(spelling.optmenu_dictionary), 0);
+ gtk_option_menu_set_history(GTK_OPTION_MENU(
+ spelling.optmenu_dictionary), 0);
if (prefs_common.dictionary)
g_free(prefs_common.dictionary);
- prefs_common.dictionary = gtkpspell_get_dictionary_menu_active_item(
- gtk_option_menu_get_menu(GTK_OPTION_MENU(spelling.optmenu_dictionary)));
+ prefs_common.dictionary =
+ gtkpspell_get_dictionary_menu_active_item(
+ gtk_option_menu_get_menu(
+ GTK_OPTION_MENU(
+ spelling.optmenu_dictionary)));
g_free(tmp);
-
}
}
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 *hbox_col;
GtkWidget *col_align;
+ GtkWidget *hline;
vbox1 = gtk_vbox_new (FALSE, VSPACING);
PACK_CHECK_BUTTON(vbox_spell, checkbtn_check_while_typing,
_("Check while typing"));
- gtk_signal_connect(GTK_OBJECT(checkbtn_enable_pspell), "toggled",
- GTK_SIGNAL_FUNC(prefs_spelling_checkbtn_enable_pspell_toggle_cb),
- NULL);
+ PACK_CHECK_BUTTON(vbox_spell, checkbtn_use_alternate,
+ _("Enable alternate dictionary"));
+ help_label = gtk_label_new(_("Enabling alternate dictionary makes switching\nwith the last used dictionary faster."));
+ 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), 0);
+ 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_pspell_path = gtk_label_new (_("Dictionaries path:"));
gtk_misc_set_alignment(GTK_MISC(label_pspell_path), 1.0, 0.5);
gtk_widget_show(label_pspell_path);
- gtk_table_attach (GTK_TABLE (spell_table), label_pspell_path, 0, 1, 0, 1,
- GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
+ gtk_table_attach (GTK_TABLE (spell_table), label_pspell_path, 0, 1, 0,
+ 1, GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
hbox_pspell_path = gtk_hbox_new (FALSE, 8);
- gtk_table_attach (GTK_TABLE (spell_table), hbox_pspell_path, 1, 2, 0, 1,
- GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
+ gtk_table_attach (GTK_TABLE (spell_table), hbox_pspell_path, 1, 2, 0,
+ 1, GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
gtk_widget_show(hbox_pspell_path);
entry_pspell_path = gtk_entry_new();
gtk_widget_show(entry_pspell_path);
- gtk_box_pack_start(GTK_BOX(hbox_pspell_path), entry_pspell_path, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox_pspell_path), entry_pspell_path, TRUE,
+ TRUE, 0);
gtk_widget_set_sensitive(entry_pspell_path, prefs_common.enable_pspell);
optmenu_dictionary = gtk_option_menu_new();
gtk_widget_show(optmenu_dictionary);
gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_dictionary),
- gtkpspell_dictionary_option_menu_new(prefs_common.pspell_path));
- gtk_table_attach (GTK_TABLE (spell_table), optmenu_dictionary, 1, 2, 1, 2,
- GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
+ gtkpspell_dictionary_option_menu_new(
+ prefs_common.pspell_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_pspell);
/* Suggestion mode */
spelling.btn_pspell_path = btn_pspell_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;
}