Fix speller accelerator (requires hack)
authorColin Leroy <colin@colino.net>
Sat, 24 Jul 2004 15:42:11 +0000 (15:42 +0000)
committerColin Leroy <colin@colino.net>
Sat, 24 Jul 2004 15:42:11 +0000 (15:42 +0000)
ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/compose.c
src/gtk/gtkaspell.c
src/gtk/gtkaspell.h

index 19afca735d8c369a10b8fff8d2d525136311c033..48ca11845580338fc579a824813093b7690755fd 100644 (file)
@@ -1,3 +1,10 @@
+2004-07-24 [colin]     0.9.12cvs33.21
+
+       * src/compose.c
+       * src/gtk/gtkaspell.c
+       * src/gtk/gtkaspell.h
+               Fix speller accelerators (require hack)
+
 2004-07-24 [colin]     0.9.12cvs33.20
 
        * src/gtk/gtkaspell.c
index 51718db658a535fe8b25fa46518921deaa1e3c75..922c7da0ff562d43bd7a62569b4ee075be7e2a32 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
@@ -74,3 +74,4 @@
 ( cvs diff -u -r 1.1.2.1 -r 1.1.2.2 src/prefs_msg_colors.c; ) > 0.9.12cvs33.18.patchset
 ( cvs diff -u -r 1.2.4.2 -r 1.2.4.3 src/browseldap.c; cvs diff -u -r 1.2.2.1 -r 1.2.2.2 src/ldapctrl.c; cvs diff -u -r 1.1.4.1 -r 1.1.4.2 src/ldapctrl.h; cvs diff -u -r 1.2.2.1 -r 1.2.2.2 src/ldapserver.h; ) > 0.9.12cvs33.19.patchset
 ( cvs diff -u -r 1.9.2.5 -r 1.9.2.6 src/gtk/gtkaspell.c; ) > 0.9.12cvs33.20.patchset
+( cvs diff -u -r 1.382.2.33 -r 1.382.2.34 src/compose.c; cvs diff -u -r 1.9.2.6 -r 1.9.2.7 src/gtk/gtkaspell.c; cvs diff -u -r 1.5.2.1 -r 1.5.2.2 src/gtk/gtkaspell.h; ) > 0.9.12cvs33.21.patchset
index 5850b66287ce42f46c002426e8b3952cfac758c7..f577d34a823ceefbfcdb30fbbc39fc7a87139aee 100644 (file)
@@ -13,7 +13,7 @@ INTERFACE_AGE=0
 BINARY_AGE=0
 EXTRA_VERSION=33
 EXTRA_RELEASE=
-EXTRA_GTK2_VERSION=.20
+EXTRA_GTK2_VERSION=.21
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}${EXTRA_RELEASE}${EXTRA_GTK2_VERSION}
index b1431679b2d4126361e11e6af35cf5efe74039ed..a170a4945dd7392ac5a75f081254fd851b83c939 100644 (file)
@@ -5417,7 +5417,8 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode)
                                                  prefs_common.misspelled_col,
                                                  prefs_common.check_while_typing,
                                                  prefs_common.use_alternate,
-                                                 GTK_TEXT_VIEW(text));
+                                                 GTK_TEXT_VIEW(text),
+                                                 GTK_WINDOW(compose->window));
                        if (!gtkaspell) {
                                alertpanel_error(_("Spell checker could not "
                                                "be started.\n%s"),
index 2d1092fc69e30bc1dc9d595e046f6bd7154734c6..7886506f96fac13d54288e9c2ef1b506ff87f10c 100644 (file)
@@ -128,6 +128,7 @@ struct _GtkAspell
        GtkWidget       *popup_config_menu;
        GtkWidget       *sug_menu;
        GtkWidget       *replace_entry;
+       GtkWidget       *parent_window;
 
        gint             default_sug_mode;
        gint             max_sug;
@@ -373,7 +374,8 @@ GtkAspell *gtkaspell_new(const gchar *dictionary_path,
                         gint  misspelled_color,
                         gboolean check_while_typing,
                         gboolean use_alternate,
-                        GtkTextView *gtktext)
+                        GtkTextView *gtktext,
+                        GtkWindow *parent_win)
 {
        Dictionary      *dict;
        GtkAspell       *gtkaspell;
@@ -416,7 +418,8 @@ GtkAspell *gtkaspell_new(const gchar *dictionary_path,
        gtkaspell->max_sug            = -1;
        gtkaspell->suggestions_list   = NULL;
        gtkaspell->use_alternate      = use_alternate;
-
+       gtkaspell->parent_window      = GTK_WIDGET(parent_win);
+       
        allocate_color(gtkaspell, misspelled_color);
 
        g_signal_connect_after(G_OBJECT(buffer), "insert-text",
@@ -1221,7 +1224,7 @@ static void replace_with_supplied_word_cb(GtkWidget *w, GtkAspell *gtkaspell)
                replace_real_word(gtkaspell, newword);
 
                if ((e->type == GDK_KEY_PRESS &&
-                   ((GdkEventKey *) e)->state & GDK_MOD1_MASK)) {
+                   ((GdkEventKey *) e)->state & GDK_CONTROL_MASK)) {
                        aspell_speller_store_replacement(
                                        gtkaspell->gtkaspeller->checker,
                                         gtkaspell->theword, -1,
@@ -1247,9 +1250,9 @@ static void replace_word_cb(GtkWidget *w, gpointer data)
        replace_real_word(gtkaspell, newword);
 
        if ((e->type == GDK_KEY_PRESS && 
-           ((GdkEventKey *) e)->state & GDK_MOD1_MASK) ||
+           ((GdkEventKey *) e)->state & GDK_CONTROL_MASK) ||
            (e->type == GDK_BUTTON_RELEASE && 
-            ((GdkEventButton *) e)->state & GDK_MOD1_MASK)) {
+            ((GdkEventButton *) e)->state & GDK_CONTROL_MASK)) {
                aspell_speller_store_replacement(
                                gtkaspell->gtkaspeller->checker,
                                                 gtkaspell->theword, -1, 
@@ -1454,7 +1457,7 @@ static void replace_with_create_dialog_cb(GtkWidget *w, gpointer data)
 
        gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, TRUE, 
                           TRUE, 0);
-       label = gtk_label_new(_("Holding down MOD1 key while pressing "
+       label = gtk_label_new(_("Holding down Control key while pressing "
                                "Enter\nwill learn from mistake.\n"));
        gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
        gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
@@ -1791,6 +1794,17 @@ static void popup_menu(GtkAspell *gtkaspell, GdkEventButton *eb)
                       eb->button, GDK_CURRENT_TIME);
 }
 
+static gboolean aspell_key_pressed(GtkWidget *widget,
+                                  GdkEventKey *event,
+                                  GtkAspell *gtkaspell)
+{
+       if (event && isascii(event->keyval)) {
+               gtk_accel_groups_activate(gtkaspell->parent_window, 
+                               event->keyval, event->state);
+       }
+       return FALSE;
+}
+
 /* make_sug_menu() - Add menus to accept this word for this session 
  * and to add it to personal dictionary 
  */
@@ -1836,7 +1850,7 @@ static GtkMenu *make_sug_menu(GtkAspell *gtkaspell)
                         G_CALLBACK(add_word_to_session_cb), 
                         gtkaspell);
        gtk_widget_add_accelerator(item, "activate", accel, GDK_space,
-                                  GDK_MOD1_MASK,
+                                  GDK_CONTROL_MASK,
                                   GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
 
        item = gtk_menu_item_new_with_label(_("Add to personal dictionary"));
@@ -1846,7 +1860,7 @@ static GtkMenu *make_sug_menu(GtkAspell *gtkaspell)
                         G_CALLBACK(add_word_to_personal_cb), 
                         gtkaspell);
        gtk_widget_add_accelerator(item, "activate", accel, GDK_Return,
-                                  GDK_MOD1_MASK,
+                                  GDK_CONTROL_MASK,
                                   GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
 
         item = gtk_menu_item_new_with_label(_("Replace with..."));
@@ -1917,7 +1931,7 @@ static GtkMenu *make_sug_menu(GtkAspell *gtkaspell)
                                gtk_widget_add_accelerator(item, "activate", 
                                                           accel,
                                                           GDK_A + count, 
-                                                          GDK_MOD1_MASK,
+                                                          GDK_CONTROL_MASK,
                                                           GTK_ACCEL_LOCKED);
                                }
 
@@ -1926,14 +1940,12 @@ static GtkMenu *make_sug_menu(GtkAspell *gtkaspell)
                } while ((l = l->next) != NULL);
        }
 
-#ifndef _MSC_VER
-#warning GTK2 set accelerators for speller popup
-#endif
-/* XXX:GTK2 */
-#if 0
-       gtk_accel_group_attach(accel, G_OBJECT(menu));
-       gtk_accel_group_unref(accel);
-#endif
+       gtk_window_add_accel_group
+               (GTK_WINDOW(gtkaspell->parent_window),
+                accel);
+       g_signal_connect(G_OBJECT(menu),
+                       "key_press_event",
+                       G_CALLBACK(aspell_key_pressed), gtkaspell);
        
        return GTK_MENU(menu);
 }
index 6652694baaae1b68192119ac12df66c3aeaa41b9..f56535a74d76c07addaeee78f3ea2f4aa8d75b01 100644 (file)
@@ -58,7 +58,8 @@ GtkAspell*    gtkaspell_new                   (const gchar *dictionary_path,
                                                 gint  misspelled_color,
                                                 gboolean check_while_typing,  
                                                 gboolean use_alternate,  
-                                                GtkTextView *gtktext);
+                                                GtkTextView *gtktext,
+                                                GtkWindow *parent_win);
 
 void           gtkaspell_delete                (GtkAspell *gtkaspell);