? spell.patch Index: src/wp/ap/Makefile =================================================================== RCS file: /cvsroot/abi/src/wp/ap/Makefile,v retrieving revision 1.74 diff -u -r1.74 Makefile --- src/wp/ap/Makefile 2000/10/11 04:51:22 1.74 +++ src/wp/ap/Makefile 2000/10/11 15:34:33 @@ -75,6 +75,7 @@ $(OBJDIR)/ap_$(ABI_FE)$(ABI_GNOME_PREFIX)Dialog_WordCount.$(OBJ_SUFFIX) \ $(OBJDIR)/ap_$(ABI_FE)$(ABI_GNOME_PREFIX)Dialog_Paragraph.$(OBJ_SUFFIX) \ $(OBJDIR)/ap_$(ABI_FE)$(ABI_GNOME_PREFIX)Dialog_Lists.$(OBJ_SUFFIX) \ + $(OBJDIR)/ap_$(ABI_FE)$(ABI_GNOME_PREFIX)Dialog_Spell.$(OBJ_SUFFIX) \ $(OBJDIR)/ap_$(ABI_FE)$(ABI_GNOME_PREFIX)Dialog_Tab.$(OBJ_SUFFIX) \ $(OBJDIR)/ap_$(ABI_FE)$(ABI_GNOME_PREFIX)Dialog_Options.$(OBJ_SUFFIX) endif Index: src/wp/ap/unix/ap_UnixDialog_All.h =================================================================== RCS file: /cvsroot/abi/src/wp/ap/unix/ap_UnixDialog_All.h,v retrieving revision 1.46 diff -u -r1.46 ap_UnixDialog_All.h --- src/wp/ap/unix/ap_UnixDialog_All.h 2000/10/11 04:51:22 1.46 +++ src/wp/ap/unix/ap_UnixDialog_All.h 2000/10/11 15:34:33 @@ -75,6 +75,7 @@ # include "ap_UnixGnomeDialog_Field.h" # include "ap_UnixGnomeDialog_Lists.h" # include "ap_UnixGnomeDialog_Columns.h" +# include "ap_UnixGnomeDialog_Spell.h" # include "ap_UnixGnomeDialog_Tab.h" #endif @@ -100,7 +101,7 @@ DeclareDialog(AP_DIALOG_ID_FIND, AP_UnixGnomeDialog_Replace) DeclareDialog(AP_DIALOG_ID_GOTO, AP_UnixGnomeDialog_Goto) DeclareDialog(AP_DIALOG_ID_BREAK, AP_UnixGnomeDialog_Break) - DeclareDialog(AP_DIALOG_ID_SPELL, AP_UnixDialog_Spell) + DeclareDialog(AP_DIALOG_ID_SPELL, AP_UnixGnomeDialog_Spell) DeclareDialog(AP_DIALOG_ID_TAB, AP_UnixGnomeDialog_Tab) DeclareDialog(AP_DIALOG_ID_PARAGRAPH, AP_UnixGnomeDialog_Paragraph) DeclareDialog(AP_DIALOG_ID_OPTIONS, AP_UnixGnomeDialog_Options) Index: src/wp/ap/unix/ap_UnixDialog_Spell.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/ap/unix/ap_UnixDialog_Spell.cpp,v retrieving revision 1.12 diff -u -r1.12 ap_UnixDialog_Spell.cpp --- src/wp/ap/unix/ap_UnixDialog_Spell.cpp 2000/06/20 22:24:18 1.12 +++ src/wp/ap/unix/ap_UnixDialog_Spell.cpp 2000/10/11 15:34:33 @@ -69,7 +69,7 @@ GtkWidget * mainWindow = _constructWindow(); UT_ASSERT(mainWindow); - connectFocus(GTK_WIDGET(mainWindow),pFrame); + connectFocus(GTK_WIDGET(mainWindow),pFrame); // Populate the window's data items _populateWindowData(); @@ -84,10 +84,9 @@ // Center our new dialog in its parent and make it a transient // soo it won't get lost underneath centerDialog(parentWindow, mainWindow); - gtk_window_set_transient_for(GTK_WINDOW(mainWindow), GTK_WINDOW(parentWindow)); // Show the top level dialog - gtk_widget_show(mainWindow); + gtk_widget_show_all(mainWindow); // Make it modal, and stick it up top gtk_grab_add(mainWindow); @@ -185,267 +184,203 @@ GtkWidget * AP_UnixDialog_Spell::_constructWindow(void) { GtkWidget *windowSpell; + GtkWidget *vbox; + + const XAP_StringSet * pSS = m_pApp->getStringSet(); + + windowSpell = gtk_window_new (GTK_WINDOW_DIALOG); + gtk_window_set_title (GTK_WINDOW (windowSpell), pSS->getValue(AP_STRING_ID_DLG_Spell_SpellTitle)); + gtk_window_set_policy (GTK_WINDOW (windowSpell), TRUE, TRUE, FALSE); + + // *very* important to add the vbox + // to the window so that it gets a + // gdkwindow associated with it + // + m_windowMain = windowSpell; + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(windowSpell), vbox); + + _constructWindowContents(vbox); + _connectSignals(); + + gtk_widget_show_all(windowSpell); + return windowSpell; +} + +void AP_UnixDialog_Spell::_constructWindowContents(GtkWidget *box) +{ GtkWidget *tableMain; GtkWidget *label1; GtkWidget *scroll2; - GtkWidget *textWord; GtkWidget *label2; - GtkWidget *entryChange; GtkWidget *scroll1; - GtkWidget *clistSuggestions; - GtkWidget *buttonChange; - GtkWidget *buttonChangeAll; - GtkWidget *buttonIgnore; - GtkWidget *buttonIgnoreAll; - GtkWidget *buttonAddToDict; - GtkWidget *buttonCancel; const XAP_StringSet * pSS = m_pApp->getStringSet(); XML_Char * unixstr = NULL; // used for conversions - - windowSpell = gtk_window_new (GTK_WINDOW_DIALOG); - gtk_object_set_data (GTK_OBJECT (windowSpell), "windowSpell", windowSpell); - gtk_window_set_title (GTK_WINDOW (windowSpell), pSS->getValue(AP_STRING_ID_DLG_Spell_SpellTitle)); - gtk_window_set_policy (GTK_WINDOW (windowSpell), TRUE, TRUE, FALSE); + // create the buttons right away + _createButtons(); + tableMain = gtk_table_new (10, 3, FALSE); - gtk_widget_ref (tableMain); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "tableMain", tableMain, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (tableMain); - gtk_container_add (GTK_CONTAINER (windowSpell), tableMain); + gtk_container_add (GTK_CONTAINER (box), tableMain); gtk_container_set_border_width (GTK_CONTAINER(tableMain), 5); gtk_table_set_row_spacings (GTK_TABLE(tableMain), 2); gtk_table_set_row_spacing (GTK_TABLE(tableMain), 4, 7); gtk_table_set_row_spacing (GTK_TABLE(tableMain), 8, 7); gtk_table_set_col_spacings (GTK_TABLE(tableMain), 2); - + GtkWidget * alignmentLabel = gtk_alignment_new (0, 1, 0, 0); - gtk_widget_ref (alignmentLabel); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "alignmentLabel", alignmentLabel, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (alignmentLabel); gtk_table_attach (GTK_TABLE(tableMain), alignmentLabel, 0, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0); UT_XML_cloneNoAmpersands(unixstr, pSS->getValue(AP_STRING_ID_DLG_Spell_UnknownWord)); label1 = gtk_label_new (unixstr); FREEP(unixstr); - gtk_widget_ref (label1); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "label1", label1, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (label1); gtk_label_set_justify (GTK_LABEL(label1), GTK_JUSTIFY_LEFT); gtk_container_add (GTK_CONTAINER(alignmentLabel), label1); - + scroll2 = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_ref (scroll2); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll2), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "scroll2", scroll2, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (scroll2); - gtk_table_attach_defaults (GTK_TABLE(tableMain), scroll2, 0, 2, 1, 4); - - textWord = gtk_text_new (NULL, NULL); - gtk_widget_ref (textWord); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "textWord", textWord, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (textWord); - gtk_container_add (GTK_CONTAINER (scroll2), textWord); - gtk_text_set_word_wrap(GTK_TEXT(textWord), TRUE); - gtk_widget_set_usize (textWord, 350, 80); + gtk_table_attach_defaults (GTK_TABLE(tableMain), scroll2, 0, 2, 1, 4); - gtk_widget_realize (textWord); + m_textWord = gtk_text_new (NULL, NULL); + gtk_widget_ref (m_textWord); + gtk_container_add (GTK_CONTAINER (scroll2), m_textWord); + gtk_text_set_word_wrap(GTK_TEXT(m_textWord), TRUE); + gtk_widget_set_usize (m_textWord, 350, 80); + gtk_widget_realize (m_textWord); // ignore button set GtkWidget * vboxIgnoreButtons = gtk_vbox_new(FALSE, 5); - gtk_widget_ref (vboxIgnoreButtons); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "vboxIgnoreButtons", vboxIgnoreButtons, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (vboxIgnoreButtons); gtk_table_attach_defaults (GTK_TABLE(tableMain), vboxIgnoreButtons, 2, 3, 1, 4); - - UT_XML_cloneNoAmpersands(unixstr, pSS->getValue(AP_STRING_ID_DLG_Spell_Ignore)); - buttonIgnore = gtk_button_new_with_label (unixstr); - FREEP(unixstr); - gtk_widget_ref (buttonIgnore); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "buttonIgnore", buttonIgnore, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (buttonIgnore); - gtk_box_pack_start (GTK_BOX(vboxIgnoreButtons), buttonIgnore, FALSE, FALSE, 5); -// gtk_table_attach (GTK_TABLE(tableMain), buttonIgnore, 2, 3, 1, 2, GTK_FILL, GTK_EXPAND, 2, 0); - UT_XML_cloneNoAmpersands(unixstr, pSS->getValue(AP_STRING_ID_DLG_Spell_IgnoreAll)); - buttonIgnoreAll = gtk_button_new_with_label (unixstr); - FREEP(unixstr); - gtk_widget_ref (buttonIgnoreAll); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "buttonIgnoreAll", buttonIgnoreAll, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (buttonIgnoreAll); - gtk_box_pack_start (GTK_BOX(vboxIgnoreButtons), buttonIgnoreAll, FALSE, FALSE, 5); -// gtk_table_attach (GTK_TABLE(tableMain), buttonIgnoreAll, 2, 3, 2, 3, GTK_FILL, GTK_EXPAND, 2, 5); - - UT_XML_cloneNoAmpersands(unixstr, pSS->getValue(AP_STRING_ID_DLG_Spell_AddToDict)); - buttonAddToDict = gtk_button_new_with_label (unixstr); - FREEP(unixstr); - gtk_widget_ref (buttonAddToDict); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "buttonAddToDict", buttonAddToDict, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (buttonAddToDict); - gtk_box_pack_start (GTK_BOX(vboxIgnoreButtons), buttonAddToDict, FALSE, FALSE, 5); -// gtk_table_attach (GTK_TABLE(tableMain), buttonAddToDict, 2, 3, 3, 4, GTK_FILL, GTK_EXPAND, 2, 0); - + gtk_box_pack_start (GTK_BOX(vboxIgnoreButtons), m_buttonIgnore, FALSE, FALSE, 5); + gtk_box_pack_start (GTK_BOX(vboxIgnoreButtons), m_buttonIgnoreAll, FALSE, FALSE, 5); + gtk_box_pack_start (GTK_BOX(vboxIgnoreButtons), m_buttonAddToDict, FALSE, FALSE, 5); // suggestion half GtkWidget * hboxChangeTo = gtk_hbox_new(FALSE, 5); - gtk_widget_ref (hboxChangeTo); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "hboxChangeTo", hboxChangeTo, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (hboxChangeTo); gtk_table_attach_defaults (GTK_TABLE(tableMain), hboxChangeTo, 0, 2, 5, 6); UT_XML_cloneNoAmpersands(unixstr, pSS->getValue(AP_STRING_ID_DLG_Spell_ChangeTo)); label2 = gtk_label_new (unixstr); FREEP(unixstr); - gtk_widget_ref (label2); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "label2", label2, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (label2); gtk_box_pack_start (GTK_BOX(hboxChangeTo), label2, FALSE, FALSE, 5); -// gtk_table_attach (GTK_TABLE(tableMain), label2, 0, 1, 5, 6, GTK_SHRINK, GTK_SHRINK, 0, 0); gtk_label_set_justify( GTK_LABEL(label2), GTK_JUSTIFY_LEFT); -// gtk_misc_set_padding (GTK_MISC (label2), 5, 0); - entryChange = gtk_entry_new (); - gtk_widget_ref (entryChange); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "entryChange", entryChange, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (entryChange); - gtk_box_pack_start (GTK_BOX(hboxChangeTo), entryChange, TRUE, TRUE, 0); -// gtk_table_attach_defaults (GTK_TABLE(tableMain), entryChange, 1, 2, 5, 6); + m_entryChange = gtk_entry_new (); + gtk_box_pack_start (GTK_BOX(hboxChangeTo), m_entryChange, TRUE, TRUE, 0); scroll1 = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_ref (scroll1); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll1), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "scroll1", scroll1, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (scroll1); + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_table_attach_defaults (GTK_TABLE(tableMain), scroll1, 0, 2, 6, 9); - - clistSuggestions = gtk_clist_new (1); - gtk_widget_ref (clistSuggestions); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "clistSuggestions", - clistSuggestions, (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (clistSuggestions); - gtk_container_add (GTK_CONTAINER (scroll1), clistSuggestions); - gtk_widget_set_usize (clistSuggestions, -2, 100); - gtk_clist_set_column_width (GTK_CLIST (clistSuggestions), 0, 80); - gtk_clist_column_titles_hide (GTK_CLIST (clistSuggestions)); + m_clistSuggestions = gtk_clist_new (1); + gtk_container_add (GTK_CONTAINER (scroll1), m_clistSuggestions); + gtk_widget_set_usize (m_clistSuggestions, -2, 100); + gtk_clist_set_column_width (GTK_CLIST (m_clistSuggestions), 0, 80); + gtk_clist_column_titles_hide (GTK_CLIST (m_clistSuggestions)); - // change buttons + // change button set GtkWidget * vboxChangeButtons = gtk_vbox_new(FALSE, 5); - gtk_widget_ref (vboxChangeButtons); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "vboxChangeButtons", vboxChangeButtons, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (vboxChangeButtons); gtk_table_attach_defaults (GTK_TABLE(tableMain), vboxChangeButtons, 2, 3, 6, 9); - UT_XML_cloneNoAmpersands(unixstr, pSS->getValue(AP_STRING_ID_DLG_Spell_Change)); - buttonChange = gtk_button_new_with_label (unixstr); - FREEP(unixstr); - gtk_widget_ref (buttonChange); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "buttonChange", buttonChange, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (buttonChange); - gtk_box_pack_start (GTK_BOX(vboxChangeButtons), buttonChange, FALSE, FALSE, 5); -// gtk_table_attach (GTK_TABLE(tableMain), buttonChange, 2, 3, 6, 7, GTK_FILL, GTK_EXPAND, 2, 0); - - UT_XML_cloneNoAmpersands(unixstr, pSS->getValue(AP_STRING_ID_DLG_Spell_ChangeAll)); - buttonChangeAll = gtk_button_new_with_label (unixstr); - FREEP(unixstr); - gtk_widget_ref (buttonChangeAll); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "buttonChangeAll", buttonChangeAll, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (buttonChangeAll); - gtk_box_pack_start (GTK_BOX(vboxChangeButtons), buttonChangeAll, FALSE, FALSE, 5); -// gtk_table_attach (GTK_TABLE(tableMain), buttonChangeAll, 2, 3, 7, 8, GTK_FILL, GTK_EXPAND, 2, 5); - - - - buttonCancel = gtk_button_new_with_label (pSS->getValue(XAP_STRING_ID_DLG_Cancel)); - gtk_widget_ref (buttonCancel); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "buttonCancel", buttonCancel, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (buttonCancel); - gtk_table_attach (GTK_TABLE(tableMain), buttonCancel, 2, 3, 9, 10, GTK_FILL, GTK_EXPAND, 2, 5); + gtk_box_pack_start (GTK_BOX(vboxChangeButtons), m_buttonChange, FALSE, FALSE, 5); + gtk_box_pack_start (GTK_BOX(vboxChangeButtons), m_buttonChangeAll, FALSE, FALSE, 5); + gtk_box_pack_start (GTK_BOX(vboxChangeButtons), m_buttonCancel, FALSE, FALSE, 5); + // gtk_table_attach (GTK_TABLE(tableMain), buttonCancel, 2, 3, 9, 10, GTK_FILL, GTK_EXPAND, 2, 5); + + // highlight our misspelled word in red + GdkColormap * cm = gdk_colormap_get_system(); + m_highlight.red = 0xffff; + m_highlight.green = 0x0000; + m_highlight.blue = 0x0000; + gdk_colormap_alloc_color(cm, &m_highlight, FALSE, TRUE); + gtk_widget_show_all(tableMain); +} + +// create normal gtk buttons +// override for gnome buttons +void AP_UnixDialog_Spell::_createButtons(void) +{ + const XAP_StringSet * pSS = m_pApp->getStringSet(); + XML_Char * unixstr = NULL; // used for conversions + + UT_XML_cloneNoAmpersands(unixstr, + pSS->getValue(AP_STRING_ID_DLG_Spell_Change)); + m_buttonChange = gtk_button_new_with_label (unixstr); + FREEP(unixstr); + + UT_XML_cloneNoAmpersands(unixstr, + pSS->getValue(AP_STRING_ID_DLG_Spell_ChangeAll)); + m_buttonChangeAll = gtk_button_new_with_label (unixstr); + FREEP(unixstr); + + UT_XML_cloneNoAmpersands(unixstr, + pSS->getValue(AP_STRING_ID_DLG_Spell_Ignore)); + m_buttonIgnore = gtk_button_new_with_label (unixstr); + FREEP(unixstr); + + UT_XML_cloneNoAmpersands(unixstr, + pSS->getValue(AP_STRING_ID_DLG_Spell_IgnoreAll)); + m_buttonIgnoreAll = gtk_button_new_with_label (unixstr); + FREEP(unixstr); + + UT_XML_cloneNoAmpersands(unixstr, + pSS->getValue(AP_STRING_ID_DLG_Spell_AddToDict)); + m_buttonAddToDict = gtk_button_new_with_label (unixstr); + FREEP(unixstr); + + m_buttonCancel = gtk_button_new_with_label (pSS->getValue(XAP_STRING_ID_DLG_Cancel)); +} + +void AP_UnixDialog_Spell::_connectSignals(void) +{ // connect signals to handlers // buttons - gtk_signal_connect(GTK_OBJECT(buttonChange), "clicked", + gtk_signal_connect(GTK_OBJECT(m_buttonChange), "clicked", GTK_SIGNAL_FUNC(s_change_clicked), (gpointer) this); - gtk_signal_connect(GTK_OBJECT(buttonChangeAll), "clicked", + gtk_signal_connect(GTK_OBJECT(m_buttonChangeAll), "clicked", GTK_SIGNAL_FUNC(s_change_all_clicked), (gpointer) this); - gtk_signal_connect(GTK_OBJECT(buttonIgnore), "clicked", + gtk_signal_connect(GTK_OBJECT(m_buttonIgnore), "clicked", GTK_SIGNAL_FUNC(s_ignore_clicked), (gpointer) this); - gtk_signal_connect(GTK_OBJECT(buttonIgnoreAll), "clicked", + gtk_signal_connect(GTK_OBJECT(m_buttonIgnoreAll), "clicked", GTK_SIGNAL_FUNC(s_ignore_all_clicked), (gpointer) this); - gtk_signal_connect(GTK_OBJECT(buttonAddToDict), "clicked", + gtk_signal_connect(GTK_OBJECT(m_buttonAddToDict), "clicked", GTK_SIGNAL_FUNC(s_add_to_dict_clicked), (gpointer) this); - gtk_signal_connect(GTK_OBJECT(buttonCancel), "clicked", + gtk_signal_connect(GTK_OBJECT(m_buttonCancel), "clicked", GTK_SIGNAL_FUNC(s_cancel_clicked), (gpointer) this); // suggestion list - m_listHandlerID = gtk_signal_connect(GTK_OBJECT(clistSuggestions), "select-row", - GTK_SIGNAL_FUNC(s_suggestion_selected), - (gpointer) this); + m_listHandlerID = gtk_signal_connect(GTK_OBJECT(m_clistSuggestions), "select-row", + GTK_SIGNAL_FUNC(s_suggestion_selected), + (gpointer) this); // replacement edited - m_replaceHandlerID = gtk_signal_connect(GTK_OBJECT(entryChange), "changed", - GTK_SIGNAL_FUNC(s_replacement_changed), - (gpointer) this); + m_replaceHandlerID = gtk_signal_connect(GTK_OBJECT(m_entryChange), "changed", + GTK_SIGNAL_FUNC(s_replacement_changed), + (gpointer) this); // the catch-alls - gtk_signal_connect_after(GTK_OBJECT(windowSpell), + gtk_signal_connect_after(GTK_OBJECT(m_windowMain), "delete_event", GTK_SIGNAL_FUNC(s_delete_clicked), (gpointer) this); - gtk_signal_connect_after(GTK_OBJECT(windowSpell), + gtk_signal_connect_after(GTK_OBJECT(m_windowMain), "destroy", NULL, NULL); - - // update member variables with the important widgets - // that we'll interact with later - - m_buttonChange = buttonChange; - m_buttonChangeAll = buttonChangeAll; - m_buttonIgnore = buttonIgnore; - m_buttonIgnoreAll = buttonIgnoreAll; - m_buttonAddToDict = buttonAddToDict; - m_buttonCancel = buttonCancel; - - m_textWord = textWord; - m_entryChange = entryChange; - m_clistSuggestions = clistSuggestions; - - GdkColormap * cm = gdk_colormap_get_system(); - m_highlight.red = 0xffff; - m_highlight.green = 0x0000; - m_highlight.blue = 0x0000; - gdk_colormap_alloc_color(cm, &m_highlight, FALSE, TRUE); - - return windowSpell; } void AP_UnixDialog_Spell::_showMisspelledWord(void) @@ -464,10 +399,12 @@ FREEP(p); gtk_text_insert(GTK_TEXT(m_textWord), NULL, NULL, NULL, preword, strlen(preword)); + // insert misspelled word (in highlight color) p = _getCurrentWord(); gchar * word = (gchar*) _convertToMB(p); FREEP(p); + gtk_text_insert(GTK_TEXT(m_textWord) , NULL, &m_highlight, NULL, word, strlen(word)); @@ -477,13 +414,11 @@ FREEP(p); gtk_text_insert(GTK_TEXT(m_textWord), NULL, NULL, NULL, postword, strlen(postword)); - + // TODO: set scroll position so misspelled word is centered - gtk_text_thaw( GTK_TEXT(m_textWord) ); - - gtk_clist_freeze( GTK_CLIST(m_clistSuggestions) ); - + gtk_text_thaw( GTK_TEXT(m_textWord) ); + gtk_clist_freeze( GTK_CLIST(m_clistSuggestions) ); gtk_clist_clear(GTK_CLIST(m_clistSuggestions)); gchar *suggest[2] = {NULL, NULL}; @@ -499,7 +434,7 @@ UT_XML_cloneNoAmpersands(suggest[0], pSS->getValue(AP_STRING_ID_DLG_Spell_NoSuggestions)); gtk_clist_append( GTK_CLIST(m_clistSuggestions), suggest); FREEP(suggest[0]); - gtk_clist_set_selectable( GTK_CLIST(m_clistSuggestions), 0, FALSE); + gtk_clist_set_selectable(GTK_CLIST(m_clistSuggestions), 0, FALSE); gtk_signal_handler_block(GTK_OBJECT(m_entryChange), m_replaceHandlerID); gtk_entry_set_text(GTK_ENTRY(m_entryChange), ""); @@ -510,11 +445,11 @@ } else { // select first on the list; signal handler should update our entry box - gtk_clist_select_row( GTK_CLIST(m_clistSuggestions), 0, 0); + gtk_clist_select_row(GTK_CLIST(m_clistSuggestions), 0, 0); } - gtk_clist_thaw( GTK_CLIST(m_clistSuggestions) ); + gtk_clist_thaw(GTK_CLIST(m_clistSuggestions) ); } @@ -537,19 +472,20 @@ if (m_iSelectedRow != -1) { replace = (UT_UCSChar*) m_Suggestions.word[m_iSelectedRow]; - changeWordWith(replace); + //UT_DEBUGMSG(("Replacing with %s\n", replace)); + fprintf(stderr, "Replacing with %s\n", replace); } else - { - replace = _convertFromMB((char*)gtk_entry_get_text(GTK_ENTRY(m_entryChange))); - if (!UT_UCS_strlen(replace)) { - UT_DEBUGMSG(("replace is 0 length\n")); - FREEP(replace); - return; - } - changeWordWith(replace); - FREEP(replace); - } + { + replace = _convertFromMB((char*)gtk_entry_get_text(GTK_ENTRY(m_entryChange))); + if (!UT_UCS_strlen(replace)) { + UT_DEBUGMSG(("replace is 0 length\n")); + FREEP(replace); + return; + } + changeWordWith(replace); + FREEP(replace); + } gtk_main_quit(); } Index: src/wp/ap/unix/ap_UnixDialog_Spell.h =================================================================== RCS file: /cvsroot/abi/src/wp/ap/unix/ap_UnixDialog_Spell.h,v retrieving revision 1.3 diff -u -r1.3 ap_UnixDialog_Spell.h --- src/wp/ap/unix/ap_UnixDialog_Spell.h 1999/10/14 01:50:45 1.3 +++ src/wp/ap/unix/ap_UnixDialog_Spell.h 2000/10/11 15:34:33 @@ -49,7 +49,11 @@ protected: // private construction functions - GtkWidget * _constructWindow(void); + virtual GtkWidget * _constructWindow(void); + virtual void _constructWindowContents(GtkWidget *box); + virtual void _createButtons(void); + void _connectSignals(void); + void _populateWindowData(void); void _storeWindowData(void); Index: src/wp/ap/unix/gnome/Makefile =================================================================== RCS file: /cvsroot/abi/src/wp/ap/unix/gnome/Makefile,v retrieving revision 1.9 diff -u -r1.9 Makefile --- src/wp/ap/unix/gnome/Makefile 2000/10/11 04:51:23 1.9 +++ src/wp/ap/unix/gnome/Makefile 2000/10/11 15:34:33 @@ -34,6 +34,7 @@ $(OBJDIR)/ap_$(ABI_FE)$(ABI_GNOME_PREFIX)Dialog_WordCount.$(OBJ_SUFFIX) \ $(OBJDIR)/ap_$(ABI_FE)$(ABI_GNOME_PREFIX)Dialog_Paragraph.$(OBJ_SUFFIX) \ $(OBJDIR)/ap_$(ABI_FE)$(ABI_GNOME_PREFIX)Dialog_Lists.$(OBJ_SUFFIX) \ + $(OBJDIR)/ap_$(ABI_FE)$(ABI_GNOME_PREFIX)Dialog_Spell.$(OBJ_SUFFIX) \ $(OBJDIR)/ap_$(ABI_FE)$(ABI_GNOME_PREFIX)Dialog_Tab.$(OBJ_SUFFIX) \ $(OBJDIR)/ap_$(ABI_FE)$(ABI_GNOME_PREFIX)Dialog_Options.$(OBJ_SUFFIX) @@ -47,6 +48,7 @@ ap_$(ABI_FE)$(ABI_GNOME_PREFIX)Dialog_WordCount.cpp \ ap_$(ABI_FE)$(ABI_GNOME_PREFIX)Dialog_Paragraph.cpp \ ap_$(ABI_FE)$(ABI_GNOME_PREFIX)Dialog_Lists.cpp \ + ap_$(ABI_FE)$(ABI_GNOME_PREFIX)Dialog_Spell.cpp \ ap_$(ABI_FE)$(ABI_GNOME_PREFIX)Dialog_Tab.cpp \ ap_$(ABI_FE)$(ABI_GNOME_PREFIX)Dialog_Options.cpp Index: src/wp/ap/unix/gnome/ap_UnixGnomeDialog_Spell.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/ap/unix/gnome/ap_UnixGnomeDialog_Spell.cpp,v retrieving revision 1.3 diff -u -r1.3 ap_UnixGnomeDialog_Spell.cpp --- src/wp/ap/unix/gnome/ap_UnixGnomeDialog_Spell.cpp 1999/12/03 03:35:25 1.3 +++ src/wp/ap/unix/gnome/ap_UnixGnomeDialog_Spell.cpp 2000/10/11 15:34:33 @@ -1,715 +1,116 @@ /* AbiWord - * Copyright (C) 1998,1999 AbiSource, Inc. - * + * Copyright (C) 1998 AbiSource, Inc. + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. */ - -// TODO: still getting some artifacts when doing highligh/replacements - +#include #include - +#include #include "ut_string.h" #include "ut_assert.h" #include "ut_debugmsg.h" - #include "ut_dialogHelper.h" -#include "xap_App.h" +#include "xap_Dialog_Id.h" #include "xap_UnixApp.h" #include "xap_UnixFrame.h" #include "ap_Strings.h" #include "ap_Dialog_Id.h" #include "ap_Dialog_Spell.h" -#include "ap_UnixDialog_Spell.h" - - -XAP_Dialog * AP_UnixDialog_Spell::static_constructor(XAP_DialogFactory * pFactory, XAP_Dialog_Id id) -{ - AP_UnixDialog_Spell * p = new AP_UnixDialog_Spell(pFactory,id); - return p; -} +#include "ap_UnixGnomeDialog_Spell.h" -AP_UnixDialog_Spell::AP_UnixDialog_Spell(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id) - : AP_Dialog_Spell(pDlgFactory,id) +/*****************************************************************/ +XAP_Dialog * AP_UnixGnomeDialog_Spell::static_constructor(XAP_DialogFactory * pFactory, + XAP_Dialog_Id id) { + AP_UnixGnomeDialog_Spell * p = new AP_UnixGnomeDialog_Spell(pFactory,id); + return p; } -AP_UnixDialog_Spell::~AP_UnixDialog_Spell(void) +AP_UnixGnomeDialog_Spell::AP_UnixGnomeDialog_Spell(XAP_DialogFactory * pDlgFactory, + XAP_Dialog_Id id) + : AP_UnixDialog_Spell(pDlgFactory, id) { } -/************************************************************/ -void AP_UnixDialog_Spell::runModal(XAP_Frame * pFrame) +AP_UnixGnomeDialog_Spell::~AP_UnixGnomeDialog_Spell(void) { - UT_DEBUGMSG(("beginning spelling check...\n")); - - // class the base class method to initialize some basic xp stuff - AP_Dialog_Spell::runModal(pFrame); - - m_bCancelled = UT_FALSE; - UT_Bool bRes = nextMisspelledWord(); - - if (bRes) { // we need to prepare the dialog - GtkWidget * mainWindow = _constructWindow(); - UT_ASSERT(mainWindow); - - // Populate the window's data items - _populateWindowData(); - - // To center the dialog, we need the frame of its parent. - XAP_UnixFrame * pUnixFrame = static_cast(pFrame); - UT_ASSERT(pUnixFrame); - - // Get the GtkWindow of the parent frame - GtkWidget * parentWindow = pUnixFrame->getTopLevelWindow(); - UT_ASSERT(parentWindow); - - // Center our new dialog in its parent and make it a transient - // soo it won't get lost underneath - centerDialog(parentWindow, mainWindow); - gtk_window_set_transient_for(GTK_WINDOW(mainWindow), GTK_WINDOW(parentWindow)); - - // Show the top level dialog - gtk_widget_show(mainWindow); - - // Make it modal, and stick it up top - gtk_grab_add(mainWindow); - - // now loop while there are still misspelled words - while (bRes) { - - // show word in main window - makeWordVisible(); - - // update dialog with new misspelled word info/suggestions - _showMisspelledWord(); - - // run into the GTK event loop for this window - gtk_main(); - - _purgeSuggestions(); - - if (m_bCancelled) break; - - // get the next unknown word - bRes = nextMisspelledWord(); - } - - _storeWindowData(); - - gtk_widget_destroy(mainWindow); - } - - // TODO: all done message? - UT_DEBUGMSG(("spelling check complete.\n")); } -/**********************************************************/ - -static void s_change_clicked(GtkWidget * widget, AP_UnixDialog_Spell * dlg) -{ - UT_ASSERT(widget && dlg); - dlg->event_Change(); -} - -static void s_change_all_clicked(GtkWidget * widget, AP_UnixDialog_Spell * dlg) +GtkWidget * AP_UnixGnomeDialog_Spell::_constructWindow (void) { - UT_ASSERT(widget && dlg); - dlg->event_ChangeAll(); -} - -static void s_ignore_clicked(GtkWidget * widget, AP_UnixDialog_Spell * dlg) -{ - UT_ASSERT(widget && dlg); - dlg->event_Ignore(); -} - -static void s_ignore_all_clicked(GtkWidget * widget, AP_UnixDialog_Spell * dlg) -{ - UT_ASSERT(widget && dlg); - dlg->event_IgnoreAll(); -} - -static void s_add_to_dict_clicked(GtkWidget * widget, AP_UnixDialog_Spell * dlg) -{ - UT_ASSERT(widget && dlg); - dlg->event_AddToDict(); -} - -static void s_cancel_clicked(GtkWidget * widget, AP_UnixDialog_Spell * dlg) -{ - UT_ASSERT(widget && dlg); - dlg->event_Cancel(); -} - -static void s_suggestion_selected(GtkWidget * widget, gint row, gint column, - GdkEventButton * /*event*/, AP_UnixDialog_Spell * dlg) -{ - UT_ASSERT(widget && dlg); - dlg->event_SuggestionSelected(row, column); -} - -static void s_replacement_changed(GtkWidget * widget, AP_UnixDialog_Spell * dlg) -{ - UT_ASSERT(widget && dlg); - dlg->event_ReplacementChanged(); -} + const XAP_StringSet * pSS = m_pApp->getStringSet(); -static void s_delete_clicked(GtkWidget * /* widget */, - gpointer /* data */, - AP_UnixDialog_Spell * dlg) -{ - UT_ASSERT(dlg); - dlg->event_Cancel(); -} - -/********************************************************************/ + m_windowMain = gnome_dialog_new (pSS->getValue(AP_STRING_ID_DLG_Spell_SpellTitle), NULL); -GtkWidget * AP_UnixDialog_Spell::_constructWindow(void) -{ - GtkWidget *windowSpell; - GtkWidget *tableMain; - - GtkWidget *label1; - GtkWidget *scroll2; - GtkWidget *textWord; - GtkWidget *label2; - GtkWidget *entryChange; - GtkWidget *scroll1; - GtkWidget *clistSuggestions; - GtkWidget *buttonChange; - GtkWidget *buttonChangeAll; - GtkWidget *buttonIgnore; - GtkWidget *buttonIgnoreAll; - GtkWidget *buttonAddToDict; - GtkWidget *buttonCancel; - - const XAP_StringSet * pSS = m_pApp->getStringSet(); - XML_Char * unixstr = NULL; // used for conversions - - windowSpell = gtk_window_new (GTK_WINDOW_DIALOG); - gtk_object_set_data (GTK_OBJECT (windowSpell), "windowSpell", windowSpell); - gtk_window_set_title (GTK_WINDOW (windowSpell), pSS->getValue(AP_STRING_ID_DLG_Spell_SpellTitle)); - gtk_window_set_policy (GTK_WINDOW (windowSpell), TRUE, TRUE, FALSE); - - tableMain = gtk_table_new (10, 3, FALSE); - gtk_widget_ref (tableMain); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "tableMain", tableMain, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (tableMain); - gtk_container_add (GTK_CONTAINER (windowSpell), tableMain); - gtk_container_set_border_width (GTK_CONTAINER(tableMain), 5); - gtk_table_set_row_spacings (GTK_TABLE(tableMain), 2); - gtk_table_set_row_spacing (GTK_TABLE(tableMain), 4, 7); - gtk_table_set_row_spacing (GTK_TABLE(tableMain), 8, 7); - gtk_table_set_col_spacings (GTK_TABLE(tableMain), 2); - - GtkWidget * alignmentLabel = gtk_alignment_new (0, 1, 0, 0); - gtk_widget_ref (alignmentLabel); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "alignmentLabel", alignmentLabel, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (alignmentLabel); - gtk_table_attach (GTK_TABLE(tableMain), alignmentLabel, 0, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0); - - UT_XML_cloneNoAmpersands(unixstr, pSS->getValue(AP_STRING_ID_DLG_Spell_UnknownWord)); - label1 = gtk_label_new (unixstr); - FREEP(unixstr); - gtk_widget_ref (label1); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "label1", label1, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (label1); - gtk_label_set_justify (GTK_LABEL(label1), GTK_JUSTIFY_LEFT); - gtk_container_add (GTK_CONTAINER(alignmentLabel), label1); - - scroll2 = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_ref (scroll2); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll2), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "scroll2", scroll2, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (scroll2); - gtk_table_attach_defaults (GTK_TABLE(tableMain), scroll2, 0, 2, 1, 4); - - textWord = gtk_text_new (NULL, NULL); - gtk_widget_ref (textWord); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "textWord", textWord, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (textWord); - gtk_container_add (GTK_CONTAINER (scroll2), textWord); - gtk_text_set_word_wrap(GTK_TEXT(textWord), TRUE); - gtk_widget_set_usize (textWord, 350, 80); - - gtk_widget_realize (textWord); - - // ignore button set - GtkWidget * vboxIgnoreButtons = gtk_vbox_new(FALSE, 5); - gtk_widget_ref (vboxIgnoreButtons); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "vboxIgnoreButtons", vboxIgnoreButtons, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (vboxIgnoreButtons); - gtk_table_attach_defaults (GTK_TABLE(tableMain), vboxIgnoreButtons, 2, 3, 1, 4); - - UT_XML_cloneNoAmpersands(unixstr, pSS->getValue(AP_STRING_ID_DLG_Spell_Ignore)); - buttonIgnore = gtk_button_new_with_label (unixstr); - FREEP(unixstr); - gtk_widget_ref (buttonIgnore); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "buttonIgnore", buttonIgnore, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (buttonIgnore); - gtk_box_pack_start (GTK_BOX(vboxIgnoreButtons), buttonIgnore, FALSE, FALSE, 5); -// gtk_table_attach (GTK_TABLE(tableMain), buttonIgnore, 2, 3, 1, 2, GTK_FILL, GTK_EXPAND, 2, 0); - - UT_XML_cloneNoAmpersands(unixstr, pSS->getValue(AP_STRING_ID_DLG_Spell_IgnoreAll)); - buttonIgnoreAll = gtk_button_new_with_label (unixstr); - FREEP(unixstr); - gtk_widget_ref (buttonIgnoreAll); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "buttonIgnoreAll", buttonIgnoreAll, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (buttonIgnoreAll); - gtk_box_pack_start (GTK_BOX(vboxIgnoreButtons), buttonIgnoreAll, FALSE, FALSE, 5); -// gtk_table_attach (GTK_TABLE(tableMain), buttonIgnoreAll, 2, 3, 2, 3, GTK_FILL, GTK_EXPAND, 2, 5); - - UT_XML_cloneNoAmpersands(unixstr, pSS->getValue(AP_STRING_ID_DLG_Spell_AddToDict)); - buttonAddToDict = gtk_button_new_with_label (unixstr); - FREEP(unixstr); - gtk_widget_ref (buttonAddToDict); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "buttonAddToDict", buttonAddToDict, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (buttonAddToDict); - gtk_box_pack_start (GTK_BOX(vboxIgnoreButtons), buttonAddToDict, FALSE, FALSE, 5); -// gtk_table_attach (GTK_TABLE(tableMain), buttonAddToDict, 2, 3, 3, 4, GTK_FILL, GTK_EXPAND, 2, 0); - - - // suggestion half - GtkWidget * hboxChangeTo = gtk_hbox_new(FALSE, 5); - gtk_widget_ref (hboxChangeTo); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "hboxChangeTo", hboxChangeTo, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (hboxChangeTo); - gtk_table_attach_defaults (GTK_TABLE(tableMain), hboxChangeTo, 0, 2, 5, 6); - - UT_XML_cloneNoAmpersands(unixstr, pSS->getValue(AP_STRING_ID_DLG_Spell_ChangeTo)); - label2 = gtk_label_new (unixstr); - FREEP(unixstr); - gtk_widget_ref (label2); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "label2", label2, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (label2); - gtk_box_pack_start (GTK_BOX(hboxChangeTo), label2, FALSE, FALSE, 5); -// gtk_table_attach (GTK_TABLE(tableMain), label2, 0, 1, 5, 6, GTK_SHRINK, GTK_SHRINK, 0, 0); - gtk_label_set_justify( GTK_LABEL(label2), GTK_JUSTIFY_LEFT); -// gtk_misc_set_padding (GTK_MISC (label2), 5, 0); - - entryChange = gtk_entry_new (); - gtk_widget_ref (entryChange); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "entryChange", entryChange, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (entryChange); - gtk_box_pack_start (GTK_BOX(hboxChangeTo), entryChange, TRUE, TRUE, 0); -// gtk_table_attach_defaults (GTK_TABLE(tableMain), entryChange, 1, 2, 5, 6); - - scroll1 = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_ref (scroll1); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll1), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "scroll1", scroll1, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (scroll1); - gtk_table_attach_defaults (GTK_TABLE(tableMain), scroll1, 0, 2, 6, 9); - - clistSuggestions = gtk_clist_new (1); - gtk_widget_ref (clistSuggestions); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "clistSuggestions", - clistSuggestions, (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (clistSuggestions); - gtk_container_add (GTK_CONTAINER (scroll1), clistSuggestions); - gtk_widget_set_usize (clistSuggestions, -2, 100); - gtk_clist_set_column_width (GTK_CLIST (clistSuggestions), 0, 80); - gtk_clist_column_titles_hide (GTK_CLIST (clistSuggestions)); - - - // change buttons - GtkWidget * vboxChangeButtons = gtk_vbox_new(FALSE, 5); - gtk_widget_ref (vboxChangeButtons); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "vboxChangeButtons", vboxChangeButtons, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (vboxChangeButtons); - gtk_table_attach_defaults (GTK_TABLE(tableMain), vboxChangeButtons, 2, 3, 6, 9); - - UT_XML_cloneNoAmpersands(unixstr, pSS->getValue(AP_STRING_ID_DLG_Spell_Change)); - buttonChange = gtk_button_new_with_label (unixstr); - FREEP(unixstr); - gtk_widget_ref (buttonChange); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "buttonChange", buttonChange, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (buttonChange); - gtk_box_pack_start (GTK_BOX(vboxChangeButtons), buttonChange, FALSE, FALSE, 5); -// gtk_table_attach (GTK_TABLE(tableMain), buttonChange, 2, 3, 6, 7, GTK_FILL, GTK_EXPAND, 2, 0); - - UT_XML_cloneNoAmpersands(unixstr, pSS->getValue(AP_STRING_ID_DLG_Spell_ChangeAll)); - buttonChangeAll = gtk_button_new_with_label (unixstr); - FREEP(unixstr); - gtk_widget_ref (buttonChangeAll); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "buttonChangeAll", buttonChangeAll, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (buttonChangeAll); - gtk_box_pack_start (GTK_BOX(vboxChangeButtons), buttonChangeAll, FALSE, FALSE, 5); -// gtk_table_attach (GTK_TABLE(tableMain), buttonChangeAll, 2, 3, 7, 8, GTK_FILL, GTK_EXPAND, 2, 5); - - - - buttonCancel = gtk_button_new_with_label (pSS->getValue(XAP_STRING_ID_DLG_Cancel)); - gtk_widget_ref (buttonCancel); - gtk_object_set_data_full (GTK_OBJECT (windowSpell), "buttonCancel", buttonCancel, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (buttonCancel); - gtk_table_attach (GTK_TABLE(tableMain), buttonCancel, 2, 3, 9, 10, GTK_FILL, GTK_EXPAND, 2, 5); - - // connect signals to handlers - - // buttons - gtk_signal_connect(GTK_OBJECT(buttonChange), "clicked", - GTK_SIGNAL_FUNC(s_change_clicked), - (gpointer) this); - gtk_signal_connect(GTK_OBJECT(buttonChangeAll), "clicked", - GTK_SIGNAL_FUNC(s_change_all_clicked), - (gpointer) this); - gtk_signal_connect(GTK_OBJECT(buttonIgnore), "clicked", - GTK_SIGNAL_FUNC(s_ignore_clicked), - (gpointer) this); - gtk_signal_connect(GTK_OBJECT(buttonIgnoreAll), "clicked", - GTK_SIGNAL_FUNC(s_ignore_all_clicked), - (gpointer) this); - gtk_signal_connect(GTK_OBJECT(buttonAddToDict), "clicked", - GTK_SIGNAL_FUNC(s_add_to_dict_clicked), - (gpointer) this); - gtk_signal_connect(GTK_OBJECT(buttonCancel), "clicked", - GTK_SIGNAL_FUNC(s_cancel_clicked), - (gpointer) this); - - // suggestion list - m_listHandlerID = gtk_signal_connect(GTK_OBJECT(clistSuggestions), "select-row", - GTK_SIGNAL_FUNC(s_suggestion_selected), - (gpointer) this); - - // replacement edited - m_replaceHandlerID = gtk_signal_connect(GTK_OBJECT(entryChange), "changed", - GTK_SIGNAL_FUNC(s_replacement_changed), - (gpointer) this); - - // the catch-alls - gtk_signal_connect_after(GTK_OBJECT(windowSpell), - "delete_event", - GTK_SIGNAL_FUNC(s_delete_clicked), - (gpointer) this); - - gtk_signal_connect_after(GTK_OBJECT(windowSpell), - "destroy", - NULL, - NULL); - - // update member variables with the important widgets - // that we'll interact with later - - m_buttonChange = buttonChange; - m_buttonChangeAll = buttonChangeAll; - m_buttonIgnore = buttonIgnore; - m_buttonIgnoreAll = buttonIgnoreAll; - m_buttonAddToDict = buttonAddToDict; - m_buttonCancel = buttonCancel; - - m_textWord = textWord; - m_entryChange = entryChange; - m_clistSuggestions = clistSuggestions; - - GdkColormap * cm = gdk_colormap_get_system(); - m_highlight.red = 0xffff; - m_highlight.green = 0x0000; - m_highlight.blue = 0x0000; - gdk_colormap_alloc_color(cm, &m_highlight, FALSE, TRUE); - - return windowSpell; -} + UT_ASSERT(m_windowMain); -void AP_UnixDialog_Spell::_showMisspelledWord(void) -{ - - gtk_text_freeze( GTK_TEXT(m_textWord) ); - - gtk_text_set_point( GTK_TEXT(m_textWord), 0 ); - gtk_text_forward_delete( GTK_TEXT(m_textWord), - gtk_text_get_length( GTK_TEXT(m_textWord) ) ); - - UT_UCSChar *p; - - // insert start of sentence - p = _getPreWord(); - gchar * preword = (gchar*) _convertToMB(p); - FREEP(p); - gtk_text_insert(GTK_TEXT(m_textWord), NULL, NULL, NULL, - preword, strlen(preword)); - FREEP(preword); - - // insert misspelled word (in highlight color) - p = _getCurrentWord(); - gchar * word = (gchar*) _convertToMB(p); - FREEP(p); - gtk_text_insert(GTK_TEXT(m_textWord) , NULL, &m_highlight, NULL, - word, strlen(word)); - FREEP(word); - - // insert end of sentence - p = _getPostWord(); - gchar * postword = (gchar*) _convertToMB(p); - FREEP(p); - gtk_text_insert(GTK_TEXT(m_textWord), NULL, NULL, NULL, - postword, strlen(postword)); - FREEP(postword); - - // TODO: set scroll position so misspelled word is centered - - gtk_text_thaw( GTK_TEXT(m_textWord) ); - - gtk_clist_freeze( GTK_CLIST(m_clistSuggestions) ); - - gtk_clist_clear(GTK_CLIST(m_clistSuggestions)); - - gchar *suggest[2] = {NULL, NULL}; - - for (int i = 0; i < m_Suggestions.count; i++) { - suggest[0] = (gchar*) _convertToMB((UT_UCSChar*)m_Suggestions.word[i]); - gtk_clist_append( GTK_CLIST(m_clistSuggestions), suggest); - FREEP(suggest[0]); - } - - if (!m_Suggestions.count) { - - const XAP_StringSet * pSS = m_pApp->getStringSet(); - UT_XML_cloneNoAmpersands(suggest[0], pSS->getValue(AP_STRING_ID_DLG_Spell_NoSuggestions)); - gtk_clist_append( GTK_CLIST(m_clistSuggestions), suggest); - FREEP(suggest[0]); - gtk_clist_set_selectable( GTK_CLIST(m_clistSuggestions), 0, FALSE); - - gtk_signal_handler_block(GTK_OBJECT(m_entryChange), m_replaceHandlerID); - gtk_entry_set_text(GTK_ENTRY(m_entryChange), ""); - gtk_signal_handler_unblock(GTK_OBJECT(m_entryChange), m_replaceHandlerID); - - m_iSelectedRow = -1; - - } else { - - // select first on the list; signal handler should update our entry box - gtk_clist_select_row( GTK_CLIST(m_clistSuggestions), 0, 0); - - } - - gtk_clist_thaw( GTK_CLIST(m_clistSuggestions) ); - -} + _constructWindowContents (GNOME_DIALOG (m_windowMain)->vbox); -void AP_UnixDialog_Spell::_populateWindowData(void) -{ - // TODO: initialize list of user dictionaries -} + _connectSignals (); + gtk_widget_show_all (m_windowMain); -void AP_UnixDialog_Spell::_storeWindowData(void) -{ - // TODO: anything to store? + return (m_windowMain); } -/*************************************************************/ - -void AP_UnixDialog_Spell::event_Change() +void AP_UnixGnomeDialog_Spell::_createButtons(void) { - UT_UCSChar * replace = NULL; - if (m_iSelectedRow != -1) - { - replace = (UT_UCSChar*) m_Suggestions.word[m_iSelectedRow]; - changeWordWith(replace); - } - else - { - replace = _convertFromMB((char*)gtk_entry_get_text(GTK_ENTRY(m_entryChange))); - if (!UT_UCS_strlen(replace)) { - FREEP(replace); - return; - } - changeWordWith(replace); - FREEP(replace); - } + GtkWidget *pixmap; - gtk_main_quit(); -} + const XAP_StringSet * pSS = m_pApp->getStringSet(); + XML_Char * unixstr = NULL; // used for conversions -void AP_UnixDialog_Spell::event_ChangeAll() -{ - UT_UCSChar * replace = NULL; - if (m_iSelectedRow != -1) - { - replace = (UT_UCSChar*) m_Suggestions.word[m_iSelectedRow]; - addChangeAll(replace); - changeWordWith(replace); - } - else - { - replace = _convertFromMB((char*)gtk_entry_get_text(GTK_ENTRY(m_entryChange))); - if (!UT_UCS_strlen(replace)) { - FREEP(replace); - return; - } - addChangeAll(replace); - changeWordWith(replace); - FREEP(replace); - } - - gtk_main_quit(); -} + pixmap = gnome_stock_pixmap_widget(m_windowMain, GNOME_STOCK_PIXMAP_CONVERT); + UT_XML_cloneNoAmpersands(unixstr, + pSS->getValue(AP_STRING_ID_DLG_Spell_Change)); + //m_buttonChange = gtk_button_new_with_label(unixstr); + m_buttonChange = gnome_pixmap_button(pixmap, unixstr); + FREEP(unixstr); -void AP_UnixDialog_Spell::event_Ignore() -{ - ignoreWord(); - gtk_main_quit(); -} + pixmap = gnome_stock_pixmap_widget(m_windowMain, GNOME_STOCK_PIXMAP_CONVERT); + UT_XML_cloneNoAmpersands(unixstr, + pSS->getValue(AP_STRING_ID_DLG_Spell_ChangeAll)); + //m_buttonChangeAll = gtk_button_new_with_label(unixstr); + m_buttonChangeAll = gnome_pixmap_button(pixmap, unixstr); + FREEP(unixstr); -void AP_UnixDialog_Spell::event_IgnoreAll() -{ - addIgnoreAll(); - ignoreWord(); - gtk_main_quit(); -} + pixmap = gnome_stock_pixmap_widget(m_windowMain, GNOME_STOCK_PIXMAP_TRASH); + UT_XML_cloneNoAmpersands(unixstr, + pSS->getValue(AP_STRING_ID_DLG_Spell_Ignore)); + //m_buttonIgnore = gtk_button_new_with_label(unixstr); + m_buttonIgnore = gnome_pixmap_button(pixmap, unixstr); + FREEP(unixstr); -void AP_UnixDialog_Spell::event_AddToDict() -{ - addToDict(); - - ignoreWord(); - gtk_main_quit(); -} - -void AP_UnixDialog_Spell::event_Cancel() -{ - m_bCancelled = UT_TRUE; - gtk_main_quit(); -} + pixmap = gnome_stock_pixmap_widget(m_windowMain, GNOME_STOCK_PIXMAP_TRASH_FULL); + UT_XML_cloneNoAmpersands(unixstr, + pSS->getValue(AP_STRING_ID_DLG_Spell_IgnoreAll)); + //m_buttonIgnoreAll = gtk_button_new_with_label(unixstr); + m_buttonIgnoreAll = gnome_pixmap_button(pixmap, unixstr); + FREEP(unixstr); -void AP_UnixDialog_Spell::event_SuggestionSelected(gint row, gint column) -{ - if (!m_Suggestions.count) return; - - m_iSelectedRow = row; - - gchar * newreplacement = NULL; - gtk_clist_get_text(GTK_CLIST(m_clistSuggestions), row, column, &newreplacement); - UT_ASSERT(newreplacement); - - gtk_signal_handler_block(GTK_OBJECT(m_entryChange), m_replaceHandlerID); - gtk_entry_set_text(GTK_ENTRY(m_entryChange), newreplacement); - gtk_signal_handler_unblock(GTK_OBJECT(m_entryChange), m_replaceHandlerID); -} + pixmap = gnome_stock_pixmap_widget(m_windowMain, GNOME_STOCK_PIXMAP_ADD); + UT_XML_cloneNoAmpersands(unixstr, + pSS->getValue(AP_STRING_ID_DLG_Spell_AddToDict)); + //m_buttonAddToDict = gtk_button_new_with_label(unixstr); + m_buttonAddToDict = gnome_pixmap_button(pixmap, unixstr); + FREEP(unixstr); -void AP_UnixDialog_Spell::event_ReplacementChanged() -{ - gchar * modtext = gtk_entry_get_text(GTK_ENTRY(m_entryChange)); - UT_ASSERT(modtext); - - gchar * suggest = NULL; - for (int i = 0; i < GTK_CLIST(m_clistSuggestions)->row_height; i++) - { - gtk_clist_get_text(GTK_CLIST(m_clistSuggestions), i, 0, &suggest); - UT_ASSERT(suggest); - if (strcmp(modtext, suggest) == 0) { - gtk_signal_handler_block(GTK_OBJECT(m_clistSuggestions), m_listHandlerID); - gtk_clist_select_row(GTK_CLIST(m_clistSuggestions), i, 0); - gtk_signal_handler_unblock(GTK_OBJECT(m_clistSuggestions), m_listHandlerID); - return; - } - } - - gtk_clist_unselect_all(GTK_CLIST(m_clistSuggestions)); - m_iSelectedRow = -1; + m_buttonCancel = gnome_stock_button(GNOME_STOCK_BUTTON_CANCEL); } -// GTK+ uses multibyte strings for i18n -// these functions convert from wide (UCS) to MB and back - -// TODO: these are probably generally useful functions, -// TODO: but I don't know about xp support for them. - -// make a multibyte encoded version of a string -char * AP_UnixDialog_Spell::_convertToMB(UT_UCSChar *wword) -{ - char temp[8]; - int mbindex = 0, wcindex = 0; - int mblength = 0; - int wclength = UT_UCS_strlen(wword); - while (wcindex < wclength) { - int len = wctomb(temp, (wchar_t)(wword[wcindex])); - UT_ASSERT(len >= 0); - mblength += len; - wcindex++; - } - wcindex = 0; - char * word = (char*) calloc(mblength + 1, sizeof(char)); - if (word == NULL) return NULL; - - while (mbindex < mblength) { - int len = wctomb(word+mbindex, (wchar_t)(wword[wcindex])); - UT_ASSERT(len >= 0); - mbindex += len; - wcindex++; - } - word[mblength] = 0; - - UT_DEBUGMSG(("wc2mb: wc %i/%i - mb %i/%i\n", wcindex, wclength, mbindex, mblength)); - UT_ASSERT(mblength >= mbindex); - - return word; -} - -// make a wide string from a multibyte string -UT_UCSChar * AP_UnixDialog_Spell::_convertFromMB(char *word) -{ - int wcindex = 0, mbindex = 0; - int wclength = 0; - int mblength = strlen(word); - while (mbindex < mblength) { - int len = mblen(word+mbindex, mblength-mbindex); - UT_ASSERT(len >= 0); - mbindex += len; - wclength++; - } - mbindex = 0; - - wchar_t wch; // we only support two bytes, so this is a temp Unicode char holder - UT_UCSChar * wword = (UT_UCSChar*) calloc(wclength + 1, sizeof(UT_UCSChar)); - if (wword == NULL) return NULL; - - while (wcindex < wclength) { - int len = mbtowc(&wch, word+mbindex, mblength-mbindex); - UT_ASSERT(len >= 0); - mbindex += len; - wword[wcindex++] = (UT_UCSChar) wch; - } - wword[wclength] = 0; - - UT_DEBUGMSG(("mb2wc: mb %i/%i - wc %i/%i\n", mbindex, mblength, wcindex, wclength)); - UT_ASSERT(wclength >= wcindex); - - return (UT_UCSChar*)wword; -} Index: src/wp/ap/unix/gnome/ap_UnixGnomeDialog_Spell.h =================================================================== RCS file: /cvsroot/abi/src/wp/ap/unix/gnome/ap_UnixGnomeDialog_Spell.h,v retrieving revision 1.1 diff -u -r1.1 ap_UnixGnomeDialog_Spell.h --- src/wp/ap/unix/gnome/ap_UnixGnomeDialog_Spell.h 1999/12/03 01:26:14 1.1 +++ src/wp/ap/unix/gnome/ap_UnixGnomeDialog_Spell.h 2000/10/11 15:34:33 @@ -1,5 +1,5 @@ /* AbiWord - * Copyright (C) 1998,1999 AbiSource, Inc. + * Copyright (C) 1998 AbiSource, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -17,64 +17,24 @@ * 02111-1307, USA. */ -#ifndef AP_UNIXDIALOG_SPELL_H -#define AP_UNIXDIALOG_SPELL_H +#ifndef AP_UNIXGNOMEDIALOG_SPELL_H +#define AP_UNIXGNOMEDIALOG_SPELL_H -#include "ap_Dialog_Spell.h" +#include "ap_UnixDialog_Spell.h" -class XAP_UnixFrame; - /*****************************************************************/ -class AP_UnixDialog_Spell: public AP_Dialog_Spell +class AP_UnixGnomeDialog_Spell: public AP_UnixDialog_Spell { - public: - AP_UnixDialog_Spell(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id); - virtual ~AP_UnixDialog_Spell(void); - - virtual void runModal(XAP_Frame * pFrame); - - static XAP_Dialog * static_constructor(XAP_DialogFactory *, XAP_Dialog_Id id); - - // callbacks can fire these events - virtual void event_Change(void); - virtual void event_ChangeAll(void); - virtual void event_Ignore(void); - virtual void event_IgnoreAll(void); - virtual void event_AddToDict(void); - virtual void event_Cancel(void); - virtual void event_SuggestionSelected(gint row, gint column); - virtual void event_ReplacementChanged(void); - - protected: - - // private construction functions - GtkWidget * _constructWindow(void); - void _populateWindowData(void); - void _storeWindowData(void); - - void _showMisspelledWord(void); - - char * _convertToMB(UT_UCSChar *wword); - UT_UCSChar * _convertFromMB(char *word); - - // pointers to widgets we need to query/set - GtkWidget * m_windowMain; - GtkWidget * m_textWord; - GtkWidget * m_entryChange; - GtkWidget * m_clistSuggestions; - - GtkWidget * m_buttonChange; - GtkWidget * m_buttonChangeAll; - GtkWidget * m_buttonIgnore; - GtkWidget * m_buttonIgnoreAll; - GtkWidget * m_buttonAddToDict; - GtkWidget * m_buttonCancel; - - GdkColor m_highlight; - - guint m_listHandlerID; - guint m_replaceHandlerID; +public: + AP_UnixGnomeDialog_Spell(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id); + virtual ~AP_UnixGnomeDialog_Spell(void); + + static XAP_Dialog * static_constructor(XAP_DialogFactory *, XAP_Dialog_Id id); + +protected: + virtual GtkWidget * _constructWindow (void); + virtual void _createButtons(void); }; -#endif /* AP_UNIXDIALOG_SPELL_H */ +#endif /* AP_UNIXGNOMEDIALOG_SPELL_H */