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);
gtk_signal_connect(GTK_OBJECT(gtktext), "button-press-event",
GTK_SIGNAL_FUNC(button_press_intercept_cb), gtkpspell);
- debug_print("Pspell: created gtkpspell %0x\n", gtkpspell);
+ debug_print("Pspell: created gtkpspell %0x\n", (guint) gtkpspell);
return gtkpspell;
}
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)
if (gtkpspell->suggestions_list)
free_suggestions_list(gtkpspell);
- debug_print("Pspell: deleting gtkpspell %0x\n", gtkpspell);
+ debug_print("Pspell: deleting gtkpspell %0x\n", (guint) gtkpspell);
g_free(gtkpspell);
dictionary_delete(gtkpspeller->dictionary);
+ debug_print(_("Pspell: gtkpspeller %0x deleted.\n"),
+ (gint) gtkpspeller);
g_free(gtkpspeller);
return NULL;
g_return_val_if_fail(gtkpspell->gtkpspeller->config, FALSE);
debug_print("Pspell: setting sug mode of gtkpspeller %0x to %d\n",
- gtkpspell->gtkpspeller, themode);
+ (guint) gtkpspell->gtkpspeller, themode);
config = gtkpspell->gtkpspeller->config;
switch (themode) {
case PSPELL_FASTMODE:
{
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
set_point_continue(gtkpspell);
}
-static void deactivate_sug_menu_cb(GtkObject *w, gpointer data)
+static void check_with_alternate_cb(GtkWidget *w,
+ gpointer data)
{
- GtkMenuShell *menu_shell = GTK_MENU_SHELL(data);
- debug_print("Destroying %0x\n", w);
- gtk_menu_shell_deactivate(menu_shell);
-}
+ 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);
gtkpspell->popup_config_menu = gtk_menu_new();
debug_print("Pspell: creating/using popup_config_menu %0x\n",
- gtkpspell->popup_config_menu);
+ (guint) gtkpspell->popup_config_menu);
populate_submenu(gtkpspell, gtkpspell->popup_config_menu);
return GTK_MENU(gtkpspell->popup_config_menu);
menu = GTK_WIDGET(GTK_MENU_ITEM(menuitem)->submenu);
debug_print("Pspell: using config menu %0x\n",
- gtkpspell->popup_config_menu);
+ (guint) gtkpspell->popup_config_menu);
populate_submenu(gtkpspell, menu);
gtkpspell->config_menu = menu;
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 */