2011-11-05 [wwp] 3.7.10cvs72
[claws.git] / src / gtk / gtkaspell.c
index 1a2b2081455ca4ec59fbfda81be197f06bfb3673..18cd509a9b01b5e6a2544c5f509f6057d452f051 100644 (file)
@@ -390,6 +390,7 @@ GtkAspell *gtkaspell_new(const gchar *dictionary,
                if (!alt_gtkaspeller) {
                        gtkaspell_checkers_error_message(
                                g_strdup_printf(_("Couldn't initialize %s speller."), dictionary));
+                       gtkaspeller_delete(gtkaspeller);
                        g_free(gtkaspell);
                        return NULL;
                }
@@ -1187,6 +1188,38 @@ static void replace_word_cb(GtkWidget *w, gpointer data)
        set_point_continue(gtkaspell);
 }
 
+void gtkaspell_block_check(GtkAspell *gtkaspell)
+{
+       GtkTextView *gtktext;
+       
+       if (gtkaspell == NULL)
+               return;
+               
+       gtktext = gtkaspell->gtktext;
+       g_signal_handlers_block_by_func(G_OBJECT(gtktext),
+                                        G_CALLBACK(entry_insert_cb),
+                                        gtkaspell);
+       g_signal_handlers_block_by_func(G_OBJECT(gtktext),
+                                        G_CALLBACK(entry_delete_cb),
+                                        gtkaspell);
+}
+
+void gtkaspell_unblock_check(GtkAspell *gtkaspell)
+{
+       GtkTextView *gtktext;
+
+       if (gtkaspell == NULL)
+               return;
+               
+       gtktext = gtkaspell->gtktext;
+       g_signal_handlers_unblock_by_func(G_OBJECT(gtktext),
+                                        G_CALLBACK(entry_insert_cb),
+                                        gtkaspell);
+       g_signal_handlers_unblock_by_func(G_OBJECT(gtktext),
+                                        G_CALLBACK(entry_delete_cb),
+                                        gtkaspell);
+}
+
 static void replace_real_word(GtkAspell *gtkaspell, const gchar *newword)
 {
        int             oldlen, newlen, wordlen;
@@ -1348,10 +1381,10 @@ static gboolean replace_key_pressed(GtkWidget *widget,
                                   GdkEventKey *event,
                                   GtkAspell *gtkaspell)
 {
-       if (event && event->keyval == GDK_Escape) {
+       if (event && event->keyval == GDK_KEY_Escape) {
                gtk_widget_destroy(widget);
                return TRUE;
-       } else if (event && event->keyval == GDK_Return) {
+       } else if (event && event->keyval == GDK_KEY_Return) {
                replace_with_supplied_word_cb(widget, gtkaspell);
                return TRUE;
        }
@@ -1718,11 +1751,11 @@ static gboolean aspell_key_pressed(GtkWidget *widget,
                                   GdkEventKey *event,
                                   GtkAspell *gtkaspell)
 {
-       if (event && (isascii(event->keyval) || event->keyval == GDK_Return)) {
+       if (event && (isascii(event->keyval) || event->keyval == GDK_KEY_Return)) {
                gtk_accel_groups_activate(
                                G_OBJECT(gtkaspell->parent_window),
                                event->keyval, event->state);
-       } else if (event && event->keyval == GDK_Escape) {
+       } else if (event && event->keyval == GDK_KEY_Escape) {
                destroy_menu(NULL, gtkaspell);
        }
        return FALSE;
@@ -1774,7 +1807,7 @@ static GSList *make_sug_menu(GtkAspell *gtkaspell)
         g_signal_connect(G_OBJECT(item), "activate",
                         G_CALLBACK(add_word_to_session_cb), 
                         gtkaspell);
-       gtk_widget_add_accelerator(item, "activate", accel, GDK_space,
+       gtk_widget_add_accelerator(item, "activate", accel, GDK_KEY_space,
                                   GDK_CONTROL_MASK,
                                   GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
 
@@ -1784,7 +1817,7 @@ static GSList *make_sug_menu(GtkAspell *gtkaspell)
         g_signal_connect(G_OBJECT(item), "activate",
                         G_CALLBACK(add_word_to_personal_cb), 
                         gtkaspell);
-       gtk_widget_add_accelerator(item, "activate", accel, GDK_Return,
+       gtk_widget_add_accelerator(item, "activate", accel, GDK_KEY_Return,
                                   GDK_CONTROL_MASK,
                                   GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
 
@@ -1794,9 +1827,9 @@ static GSList *make_sug_menu(GtkAspell *gtkaspell)
         g_signal_connect(G_OBJECT(item), "activate",
                         G_CALLBACK(replace_with_create_dialog_cb), 
                         gtkaspell);
-       gtk_widget_add_accelerator(item, "activate", accel, GDK_R, 0,
+       gtk_widget_add_accelerator(item, "activate", accel, GDK_KEY_R, 0,
                                   GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
-       gtk_widget_add_accelerator(item, "activate", accel, GDK_R, 
+       gtk_widget_add_accelerator(item, "activate", accel, GDK_KEY_R, 
                                   GDK_CONTROL_MASK,
                                   GTK_ACCEL_LOCKED);
 
@@ -1810,9 +1843,9 @@ static GSList *make_sug_menu(GtkAspell *gtkaspell)
                g_signal_connect(G_OBJECT(item), "activate",
                                 G_CALLBACK(check_with_alternate_cb),
                                 gtkaspell);
-               gtk_widget_add_accelerator(item, "activate", accel, GDK_X, 0,
+               gtk_widget_add_accelerator(item, "activate", accel, GDK_KEY_X, 0,
                                           GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
-               gtk_widget_add_accelerator(item, "activate", accel, GDK_X, 
+               gtk_widget_add_accelerator(item, "activate", accel, GDK_KEY_X, 
                                           GDK_CONTROL_MASK,
                                           GTK_ACCEL_LOCKED);
        }
@@ -1863,12 +1896,12 @@ static GSList *make_sug_menu(GtkAspell *gtkaspell)
                        if (curmenu == NULL && count < MENUCOUNT) {
                                gtk_widget_add_accelerator(item, "activate",
                                                           accel,
-                                                          GDK_A + count, 0,
+                                                          GDK_KEY_A + count, 0,
                                                           GTK_ACCEL_LOCKED | 
                                                           GTK_ACCEL_VISIBLE);
                                gtk_widget_add_accelerator(item, "activate", 
                                                           accel,
-                                                          GDK_A + count, 
+                                                          GDK_KEY_A + count, 
                                                           GDK_CONTROL_MASK,
                                                           GTK_ACCEL_LOCKED);
                                }