diff --git a/plugins/spell/languages-dialog.ui b/plugins/spell/languages-dialog.ui index 1bc8603..28ec4fb 100644 --- a/plugins/spell/languages-dialog.ui +++ b/plugins/spell/languages-dialog.ui @@ -1,136 +1,132 @@ - + + + + False 5 Set language - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE True - True True - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - True - False + dialog - + True - False + False 2 - + True - GTK_BUTTONBOX_END + False + end - True - True - True gtk-help + True + True + True + False True - GTK_RELIEF_NORMAL - True + + True + True + 0 + - True - True - True gtk-cancel + True + True + True + False True - GTK_RELIEF_NORMAL - True + + True + True + 1 + - True - True - True gtk-ok + True + True + True + False True - GTK_RELIEF_NORMAL - True + + True + True + 2 + - 0 False True - GTK_PACK_END + end + 0 - - 5 + True - False + False + True + True + 5 + vertical 11 True + False Select the _language of the current document. True - False - GTK_JUSTIFY_LEFT True - False - 0 - 0.5 - 0 - 0 languages_treeview - PANGO_ELLIPSIZE_NONE - -1 - False - 0 + 0 - 0 False False + 0 + 180 True True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_ETCHED_IN - GTK_CORNER_TOP_LEFT + etched-in 180 True True False - False - False - True - False - False - False + + + - 0 True True + 1 - 0 - True + False True + 0 diff --git a/plugins/spell/spell-checker.ui b/plugins/spell/spell-checker.ui index ea84290..f5f8a30 100644 --- a/plugins/spell/spell-checker.ui +++ b/plugins/spell/spell-checker.ui @@ -1,479 +1,366 @@ - - + + - - gtk-spell-check - 4 - - - gtk-add - 4 - - - gtk-go-down - 4 - - - gtk-convert - 4 - - - gtk-goto-bottom - 4 - - - gtk-convert - 4 - + - True - Check spelling - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False + False False - False + True + dialog + True + Check spelling - - 12 + True - False + False + 12 + vertical 6 - + True - 2 - 2 - False + False + True 6 12 True + False Misspelled word: - False - False - GTK_JUSTIFY_CENTER - False - False 0 - 0.5 - 0 - 0 0 - 1 0 - 1 - fill - True + False word - False True - GTK_JUSTIFY_CENTER - False - False + center 0 - 0.5 - 0 - 0 - - - 1 - 2 0 - 1 - fill - - + True + False Change _to: True - False - GTK_JUSTIFY_CENTER - False - False 0 - 0.5 - 0 - 0 - word_entry 0 - 1 1 - 2 - fill - - + True - False + False + True 12 True True - True - True - 0 - - True - False + True - 0 - True + False True + 0 + Check _Word True True - GTK_RELIEF_NORMAL - check_word_image - Check _Word + True True - 0 False - False + True + 1 1 - 2 1 - 2 - fill - 0 False True + 0 - + True - 3 - 2 - False + False 6 12 - + True + False _Suggestions: True - False - GTK_JUSTIFY_CENTER - False - False 0 - 0.5 - 0 - 0 - suggestions_list 0 - 1 0 - 1 - fill - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_ETCHED_IN - GTK_CORNER_TOP_LEFT + True + True + True + in - 200 True True False - False - False - True + + + 0 - 1 1 - 2 - + True - True + False + 6 + vertical 12 - + True - 2 - 2 - True + False 12 12 - True - True - GTK_RELIEF_NORMAL - ignore_image _Ignore - True - - - 0 - 1 - 0 - 1 - expand - - - - True True - GTK_RELIEF_NORMAL - change_image - Cha_nge + True True 0 - 1 - 1 - 2 - expand + 0 + Ignore _All True True - GTK_RELIEF_NORMAL - ignore_all_image - Ignore _All + True True 1 - 2 0 - 1 - expand + + + + + Cha_nge + True + True + True + True + + + 0 + 1 + Change A_ll True True - GTK_RELIEF_NORMAL - change_all_image - Change A_ll + True True 1 - 2 1 - 2 - expand - 0 - True + False True + 0 - + True - False + False + vertical 11 - + True + False User dictionary: - False True - GTK_JUSTIFY_LEFT - False - False - 7.45058e-09 - 0.5 - 0 - 0 + 0 - 0 False True + 0 - + True - True + False 6 + True + Add w_ord True True - GTK_RELIEF_NORMAL - add_word_image - Add w_ord + True True - 0 - True + False True + 0 - 0 False - False + True + 2 - 0 - True - False + False + True + 1 1 - 2 1 - 2 - + True - False + False 12 - + True + False Language: - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - 0 False - False + True + 0 True + False Language - False True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - - 0 False - False + True + 1 0 - 1 2 - 3 - fill - fill - + True - GTK_BUTTONBOX_END - 0 + False + True + end + _Close True - True True - gtk-close - True - GTK_RELIEF_NORMAL + True + end + True + + + True + True + 0 + 1 - 2 - 2 - 3 - fill - fill + 3 + + + + + + + + + - 0 True True + 1 diff --git a/plugins/spell/xed-automatic-spell-checker.c b/plugins/spell/xed-automatic-spell-checker.c index 35feec0..1202920 100644 --- a/plugins/spell/xed-automatic-spell-checker.c +++ b/plugins/spell/xed-automatic-spell-checker.c @@ -3,7 +3,7 @@ * xed-automatic-spell-checker.c * This file is part of xed * - * Copyright (C) 2002 Paolo Maggi + * Copyright (C) 2002 Paolo Maggi * * 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 @@ -17,14 +17,14 @@ * * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. + * Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. */ /* - * Modified by the xed Team, 2002. See the AUTHORS file for a - * list of people on the xed Team. - * See the ChangeLog files for a list of changes. + * Modified by the xed Team, 2002. See the AUTHORS file for a + * list of people on the xed Team. + * See the ChangeLog files for a list of changes. */ /* This is a modified version of gtkspell 2.0.5 (gtkspell.sf.net) */ @@ -43,18 +43,19 @@ #include "xed-automatic-spell-checker.h" #include "xed-spell-utils.h" -struct _XedAutomaticSpellChecker { - XedDocument *doc; - GSList *views; - - GtkTextMark *mark_insert_start; - GtkTextMark *mark_insert_end; - gboolean deferred_check; +struct _XedAutomaticSpellChecker +{ + XedDocument *doc; + GSList *views; - GtkTextTag *tag_highlight; - GtkTextMark *mark_click; + GtkTextMark *mark_insert_start; + GtkTextMark *mark_insert_end; + gboolean deferred_check; - XedSpellChecker *spell_checker; + GtkTextTag *tag_highlight; + GtkTextMark *mark_click; + + XedSpellChecker *spell_checker; }; static GQuark automatic_spell_checker_id = 0; @@ -63,164 +64,164 @@ static GQuark suggestion_id = 0; static void xed_automatic_spell_checker_free_internal (XedAutomaticSpellChecker *spell); static void -view_destroy (XedView *view, XedAutomaticSpellChecker *spell) +view_destroy (XedView *view, + XedAutomaticSpellChecker *spell) { - xed_automatic_spell_checker_detach_view (spell, view); + xed_automatic_spell_checker_detach_view (spell, view); } static void -check_word (XedAutomaticSpellChecker *spell, GtkTextIter *start, GtkTextIter *end) +check_word (XedAutomaticSpellChecker *spell, + GtkTextIter *start, + GtkTextIter *end) { - gchar *word; + gchar *word; - word = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (spell->doc), start, end, FALSE); + word = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (spell->doc), start, end, FALSE); - /* - g_print ("Check word: %s [%d - %d]\n", word, gtk_text_iter_get_offset (start), - gtk_text_iter_get_offset (end)); - */ + /* + g_print ("Check word: %s [%d - %d]\n", word, gtk_text_iter_get_offset (start), + gtk_text_iter_get_offset (end)); + */ - if (!xed_spell_checker_check_word (spell->spell_checker, word, -1)) - { - /* - g_print ("Apply tag: [%d - %d]\n", gtk_text_iter_get_offset (start), - gtk_text_iter_get_offset (end)); - */ - gtk_text_buffer_apply_tag (GTK_TEXT_BUFFER (spell->doc), - spell->tag_highlight, - start, - end); - } - - g_free (word); + if (!xed_spell_checker_check_word (spell->spell_checker, word, -1)) + { + /* + g_print ("Apply tag: [%d - %d]\n", gtk_text_iter_get_offset (start), + gtk_text_iter_get_offset (end)); + */ + gtk_text_buffer_apply_tag (GTK_TEXT_BUFFER (spell->doc), spell->tag_highlight, start, end); + } + + g_free (word); } static void -check_range (XedAutomaticSpellChecker *spell, - GtkTextIter start, - GtkTextIter end, - gboolean force_all) +check_range (XedAutomaticSpellChecker *spell, + GtkTextIter start, + GtkTextIter end, + gboolean force_all) { - /* we need to "split" on word boundaries. - * luckily, Pango knows what "words" are - * so we don't have to figure it out. */ + /* we need to "split" on word boundaries. + * luckily, Pango knows what "words" are + * so we don't have to figure it out. */ - GtkTextIter wstart; - GtkTextIter wend; - GtkTextIter cursor; - GtkTextIter precursor; - gboolean highlight; + GtkTextIter wstart; + GtkTextIter wend; + GtkTextIter cursor; + GtkTextIter precursor; + gboolean highlight; - /* - g_print ("Check range: [%d - %d]\n", gtk_text_iter_get_offset (&start), - gtk_text_iter_get_offset (&end)); - */ + /* + g_print ("Check range: [%d - %d]\n", gtk_text_iter_get_offset (&start), + gtk_text_iter_get_offset (&end)); + */ - if (gtk_text_iter_inside_word (&end)) - gtk_text_iter_forward_word_end (&end); - - if (!gtk_text_iter_starts_word (&start)) - { - if (gtk_text_iter_inside_word (&start) || - gtk_text_iter_ends_word (&start)) - { - gtk_text_iter_backward_word_start (&start); - } - else - { - /* if we're neither at the beginning nor inside a word, - * me must be in some spaces. - * skip forward to the beginning of the next word. */ - - if (gtk_text_iter_forward_word_end (&start)) - gtk_text_iter_backward_word_start (&start); - } - } + if (gtk_text_iter_inside_word (&end)) + { + gtk_text_iter_forward_word_end (&end); + } - gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (spell->doc), - &cursor, - gtk_text_buffer_get_insert (GTK_TEXT_BUFFER (spell->doc))); - - precursor = cursor; - gtk_text_iter_backward_char (&precursor); - - highlight = gtk_text_iter_has_tag (&cursor, spell->tag_highlight) || - gtk_text_iter_has_tag (&precursor, spell->tag_highlight); - - gtk_text_buffer_remove_tag (GTK_TEXT_BUFFER (spell->doc), - spell->tag_highlight, - &start, - &end); + if (!gtk_text_iter_starts_word (&start)) + { + if (gtk_text_iter_inside_word (&start) || gtk_text_iter_ends_word (&start)) + { + gtk_text_iter_backward_word_start (&start); + } + else + { + /* if we're neither at the beginning nor inside a word, + * me must be in some spaces. + * skip forward to the beginning of the next word. */ - /* Fix a corner case when replacement occurs at beginning of buffer: - * An iter at offset 0 seems to always be inside a word, - * even if it's not. Possibly a pango bug. - */ - if (gtk_text_iter_get_offset (&start) == 0) - { - gtk_text_iter_forward_word_end(&start); - gtk_text_iter_backward_word_start(&start); - } + if (gtk_text_iter_forward_word_end (&start)) + { + gtk_text_iter_backward_word_start (&start); + } + } + } - wstart = start; - - while (xed_spell_utils_skip_no_spell_check (&wstart, &end) && - gtk_text_iter_compare (&wstart, &end) < 0) - { - gboolean inword; + gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (spell->doc), + &cursor, + gtk_text_buffer_get_insert (GTK_TEXT_BUFFER (spell->doc))); - /* move wend to the end of the current word. */ - wend = wstart; - - gtk_text_iter_forward_word_end (&wend); + precursor = cursor; + gtk_text_iter_backward_char (&precursor); - inword = (gtk_text_iter_compare (&wstart, &cursor) < 0) && - (gtk_text_iter_compare (&cursor, &wend) <= 0); - - if (inword && !force_all) - { - /* this word is being actively edited, - * only check if it's already highligted, - * otherwise defer this check until later. */ - if (highlight) - check_word (spell, &wstart, &wend); - else - spell->deferred_check = TRUE; - } - else - { - check_word (spell, &wstart, &wend); - spell->deferred_check = FALSE; - } + highlight = gtk_text_iter_has_tag (&cursor, spell->tag_highlight) || + gtk_text_iter_has_tag (&precursor, spell->tag_highlight); - /* now move wend to the beginning of the next word, */ - gtk_text_iter_forward_word_end (&wend); - gtk_text_iter_backward_word_start (&wend); - - /* make sure we've actually advanced - * (we don't advance in some corner cases), */ - if (gtk_text_iter_equal (&wstart, &wend)) - break; /* we're done in these cases.. */ + gtk_text_buffer_remove_tag (GTK_TEXT_BUFFER (spell->doc), spell->tag_highlight, &start, &end); - /* and then pick this as the new next word beginning. */ - wstart = wend; - } + /* Fix a corner case when replacement occurs at beginning of buffer: + * An iter at offset 0 seems to always be inside a word, + * even if it's not. Possibly a pango bug. + */ + if (gtk_text_iter_get_offset (&start) == 0) + { + gtk_text_iter_forward_word_end(&start); + gtk_text_iter_backward_word_start(&start); + } + + wstart = start; + + while (xed_spell_utils_skip_no_spell_check (&wstart, &end) && gtk_text_iter_compare (&wstart, &end) < 0) + { + gboolean inword; + + /* move wend to the end of the current word. */ + wend = wstart; + + gtk_text_iter_forward_word_end (&wend); + + inword = (gtk_text_iter_compare (&wstart, &cursor) < 0) && (gtk_text_iter_compare (&cursor, &wend) <= 0); + + if (inword && !force_all) + { + /* this word is being actively edited, + * only check if it's already highligted, + * otherwise defer this check until later. */ + if (highlight) + { + check_word (spell, &wstart, &wend); + } + else + { + spell->deferred_check = TRUE; + } + } + else + { + check_word (spell, &wstart, &wend); + spell->deferred_check = FALSE; + } + + /* now move wend to the beginning of the next word, */ + gtk_text_iter_forward_word_end (&wend); + gtk_text_iter_backward_word_start (&wend); + + /* make sure we've actually advanced + * (we don't advance in some corner cases), */ + if (gtk_text_iter_equal (&wstart, &wend)) + { + break; /* we're done in these cases.. */ + } + + /* and then pick this as the new next word beginning. */ + wstart = wend; + } } static void -check_deferred_range (XedAutomaticSpellChecker *spell, - gboolean force_all) +check_deferred_range (XedAutomaticSpellChecker *spell, + gboolean force_all) { - GtkTextIter start, end; + GtkTextIter start, end; - gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (spell->doc), - &start, - spell->mark_insert_start); - gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (spell->doc), - &end, - spell->mark_insert_end); + gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (spell->doc), &start, spell->mark_insert_start); + gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (spell->doc), &end, spell->mark_insert_end); - check_range (spell, start, end, force_all); + check_range (spell, start, end, force_all); } /* insertion works like this: @@ -231,24 +232,30 @@ check_deferred_range (XedAutomaticSpellChecker *spell, * this may be overkill for the common case (inserting one character). */ static void -insert_text_before (GtkTextBuffer *buffer, GtkTextIter *iter, - gchar *text, gint len, XedAutomaticSpellChecker *spell) +insert_text_before (GtkTextBuffer *buffer, + GtkTextIter *iter, + gchar *text, + gint len, + XedAutomaticSpellChecker *spell) { - gtk_text_buffer_move_mark (buffer, spell->mark_insert_start, iter); + gtk_text_buffer_move_mark (buffer, spell->mark_insert_start, iter); } static void -insert_text_after (GtkTextBuffer *buffer, GtkTextIter *iter, - gchar *text, gint len, XedAutomaticSpellChecker *spell) +insert_text_after (GtkTextBuffer *buffer, + GtkTextIter *iter, + gchar *text, + gint len, + XedAutomaticSpellChecker *spell) { - GtkTextIter start; + GtkTextIter start; - /* we need to check a range of text. */ - gtk_text_buffer_get_iter_at_mark (buffer, &start, spell->mark_insert_start); - - check_range (spell, start, *iter, FALSE); + /* we need to check a range of text. */ + gtk_text_buffer_get_iter_at_mark (buffer, &start, spell->mark_insert_start); - gtk_text_buffer_move_mark (buffer, spell->mark_insert_end, iter); + check_range (spell, start, *iter, FALSE); + + gtk_text_buffer_move_mark (buffer, spell->mark_insert_end, iter); } /* deleting is more simple: we're given the range of deleted text. @@ -259,757 +266,702 @@ insert_text_after (GtkTextBuffer *buffer, GtkTextIter *iter, */ static void -delete_range_after (GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *end, - XedAutomaticSpellChecker *spell) +delete_range_after (GtkTextBuffer *buffer, + GtkTextIter *start, + GtkTextIter *end, + XedAutomaticSpellChecker *spell) { - check_range (spell, *start, *end, FALSE); + check_range (spell, *start, *end, FALSE); } static void -mark_set (GtkTextBuffer *buffer, - GtkTextIter *iter, - GtkTextMark *mark, - XedAutomaticSpellChecker *spell) +mark_set (GtkTextBuffer *buffer, + GtkTextIter *iter, + GtkTextMark *mark, + XedAutomaticSpellChecker *spell) { - /* if the cursor has moved and there is a deferred check so handle it now */ - if ((mark == gtk_text_buffer_get_insert (buffer)) && spell->deferred_check) - check_deferred_range (spell, FALSE); + /* if the cursor has moved and there is a deferred check so handle it now */ + if ((mark == gtk_text_buffer_get_insert (buffer)) && spell->deferred_check) + { + check_deferred_range (spell, FALSE); + } } static void -get_word_extents_from_mark (GtkTextBuffer *buffer, - GtkTextIter *start, - GtkTextIter *end, - GtkTextMark *mark) +get_word_extents_from_mark (GtkTextBuffer *buffer, + GtkTextIter *start, + GtkTextIter *end, + GtkTextMark *mark) { - gtk_text_buffer_get_iter_at_mark(buffer, start, mark); - - if (!gtk_text_iter_starts_word (start)) - gtk_text_iter_backward_word_start (start); - - *end = *start; - - if (gtk_text_iter_inside_word (end)) - gtk_text_iter_forward_word_end (end); + gtk_text_buffer_get_iter_at_mark(buffer, start, mark); + + if (!gtk_text_iter_starts_word (start)) + { + gtk_text_iter_backward_word_start (start); + } + + *end = *start; + + if (gtk_text_iter_inside_word (end)) + { + gtk_text_iter_forward_word_end (end); + } } static void -remove_tag_to_word (XedAutomaticSpellChecker *spell, const gchar *word) +remove_tag_to_word (XedAutomaticSpellChecker *spell, + const gchar *word) { - GtkTextIter iter; - GtkTextIter match_start, match_end; + GtkTextIter iter; + GtkTextIter match_start, match_end; - gboolean found; + gboolean found; - gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (spell->doc), &iter, 0); - - found = TRUE; + gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (spell->doc), &iter, 0); - while (found) - { - found = gtk_text_iter_forward_search (&iter, - word, - GTK_TEXT_SEARCH_VISIBLE_ONLY | GTK_TEXT_SEARCH_TEXT_ONLY, - &match_start, - &match_end, - NULL); + found = TRUE; - if (found) - { - if (gtk_text_iter_starts_word (&match_start) && - gtk_text_iter_ends_word (&match_end)) - { - gtk_text_buffer_remove_tag (GTK_TEXT_BUFFER (spell->doc), - spell->tag_highlight, - &match_start, - &match_end); - } + while (found) + { + found = gtk_text_iter_forward_search (&iter, + word, + GTK_TEXT_SEARCH_VISIBLE_ONLY | GTK_TEXT_SEARCH_TEXT_ONLY, + &match_start, + &match_end, + NULL); - iter = match_end; - } - } + if (found) + { + if (gtk_text_iter_starts_word (&match_start) && gtk_text_iter_ends_word (&match_end)) + { + gtk_text_buffer_remove_tag (GTK_TEXT_BUFFER (spell->doc), + spell->tag_highlight, + &match_start, + &match_end); + } + + iter = match_end; + } + } } static void -add_to_dictionary (GtkWidget *menuitem, XedAutomaticSpellChecker *spell) +add_to_dictionary (GtkWidget *menuitem, + XedAutomaticSpellChecker *spell) { - gchar *word; - - GtkTextIter start, end; - - get_word_extents_from_mark (GTK_TEXT_BUFFER (spell->doc), &start, &end, spell->mark_click); + gchar *word; - word = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (spell->doc), - &start, - &end, - FALSE); - - xed_spell_checker_add_word_to_personal (spell->spell_checker, word, -1); + GtkTextIter start, end; - g_free (word); + get_word_extents_from_mark (GTK_TEXT_BUFFER (spell->doc), &start, &end, spell->mark_click); + + word = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (spell->doc), &start, &end, FALSE); + + xed_spell_checker_add_word_to_personal (spell->spell_checker, word, -1); + + g_free (word); } static void -ignore_all (GtkWidget *menuitem, XedAutomaticSpellChecker *spell) +ignore_all (GtkWidget *menuitem, + XedAutomaticSpellChecker *spell) { - gchar *word; - - GtkTextIter start, end; - - get_word_extents_from_mark (GTK_TEXT_BUFFER (spell->doc), &start, &end, spell->mark_click); + gchar *word; - word = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (spell->doc), - &start, - &end, - FALSE); - - xed_spell_checker_add_word_to_session (spell->spell_checker, word, -1); + GtkTextIter start, end; - g_free (word); + get_word_extents_from_mark (GTK_TEXT_BUFFER (spell->doc), &start, &end, spell->mark_click); + + word = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (spell->doc), &start, &end, FALSE); + + xed_spell_checker_add_word_to_session (spell->spell_checker, word, -1); + + g_free (word); } static void -replace_word (GtkWidget *menuitem, XedAutomaticSpellChecker *spell) +replace_word (GtkWidget *menuitem, + XedAutomaticSpellChecker *spell) { - gchar *oldword; - const gchar *newword; - - GtkTextIter start, end; + gchar *oldword; + const gchar *newword; - get_word_extents_from_mark (GTK_TEXT_BUFFER (spell->doc), &start, &end, spell->mark_click); + GtkTextIter start, end; - oldword = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (spell->doc), &start, &end, FALSE); - - newword = g_object_get_qdata (G_OBJECT (menuitem), suggestion_id); - g_return_if_fail (newword != NULL); + get_word_extents_from_mark (GTK_TEXT_BUFFER (spell->doc), &start, &end, spell->mark_click); - gtk_text_buffer_begin_user_action (GTK_TEXT_BUFFER (spell->doc)); + oldword = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (spell->doc), &start, &end, FALSE); - gtk_text_buffer_delete (GTK_TEXT_BUFFER (spell->doc), &start, &end); - gtk_text_buffer_insert (GTK_TEXT_BUFFER (spell->doc), &start, newword, -1); + newword = g_object_get_qdata (G_OBJECT (menuitem), suggestion_id); + g_return_if_fail (newword != NULL); - gtk_text_buffer_end_user_action (GTK_TEXT_BUFFER (spell->doc)); + gtk_text_buffer_begin_user_action (GTK_TEXT_BUFFER (spell->doc)); - xed_spell_checker_set_correction (spell->spell_checker, - oldword, strlen (oldword), - newword, strlen (newword)); + gtk_text_buffer_delete (GTK_TEXT_BUFFER (spell->doc), &start, &end); + gtk_text_buffer_insert (GTK_TEXT_BUFFER (spell->doc), &start, newword, -1); - g_free (oldword); + gtk_text_buffer_end_user_action (GTK_TEXT_BUFFER (spell->doc)); + + xed_spell_checker_set_correction (spell->spell_checker, + oldword, strlen (oldword), + newword, strlen (newword)); + + g_free (oldword); } static GtkWidget * -build_suggestion_menu (XedAutomaticSpellChecker *spell, const gchar *word) +build_suggestion_menu (XedAutomaticSpellChecker *spell, + const gchar *word) { - GtkWidget *topmenu, *menu; - GtkWidget *mi; - GSList *suggestions; - GSList *list; - gchar *label_text; - - topmenu = menu = gtk_menu_new(); + GtkWidget *topmenu, *menu; + GtkWidget *mi; + GSList *suggestions; + GSList *list; + gchar *label_text; - suggestions = xed_spell_checker_get_suggestions (spell->spell_checker, word, -1); + topmenu = menu = gtk_menu_new(); - list = suggestions; + suggestions = xed_spell_checker_get_suggestions (spell->spell_checker, word, -1); - if (suggestions == NULL) - { - /* no suggestions. put something in the menu anyway... */ - GtkWidget *label; - /* Translators: Displayed in the "Check Spelling" dialog if there are no suggestions for the current misspelled word */ - label = gtk_label_new (_("(no suggested words)")); - - mi = gtk_menu_item_new (); - gtk_widget_set_sensitive (mi, FALSE); - gtk_container_add (GTK_CONTAINER(mi), label); - gtk_widget_show_all (mi); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi); - } - else - { - gint count = 0; - - /* build a set of menus with suggestions. */ - while (suggestions != NULL) - { - GtkWidget *label; + list = suggestions; - if (count == 10) - { - /* Separator */ - mi = gtk_menu_item_new (); - gtk_widget_show (mi); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - - mi = gtk_menu_item_new_with_mnemonic (_("_More...")); - gtk_widget_show (mi); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); + if (suggestions == NULL) + { + /* no suggestions. put something in the menu anyway... */ + GtkWidget *label; + /* Translators: Displayed in the "Check Spelling" dialog if there are no suggestions for the current misspelled word */ + label = gtk_label_new (_("(no suggested words)")); - menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), menu); - count = 0; - } - - label_text = g_strdup_printf ("%s", (gchar*) suggestions->data); - - label = gtk_label_new (label_text); - gtk_label_set_use_markup (GTK_LABEL (label), TRUE); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + mi = gtk_menu_item_new (); + gtk_widget_set_sensitive (mi, FALSE); + gtk_container_add (GTK_CONTAINER(mi), label); + gtk_widget_show_all (mi); + gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi); + } + else + { + gint count = 0; - mi = gtk_menu_item_new (); - gtk_container_add (GTK_CONTAINER(mi), label); - - gtk_widget_show_all (mi); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); + /* build a set of menus with suggestions. */ + while (suggestions != NULL) + { + GtkWidget *label; - g_object_set_qdata_full (G_OBJECT (mi), - suggestion_id, - g_strdup (suggestions->data), - (GDestroyNotify)g_free); + if (count == 10) + { + /* Separator */ + mi = gtk_menu_item_new (); + gtk_widget_show (mi); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - g_free (label_text); - g_signal_connect (mi, - "activate", - G_CALLBACK (replace_word), - spell); + mi = gtk_menu_item_new_with_mnemonic (_("_More...")); + gtk_widget_show (mi); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - count++; + menu = gtk_menu_new (); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), menu); + count = 0; + } - suggestions = g_slist_next (suggestions); - } - } + label_text = g_strdup_printf ("%s", (gchar*) suggestions->data); - /* free the suggestion list */ - suggestions = list; + label = gtk_label_new (label_text); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_widget_set_halign (label, GTK_ALIGN_START); - while (list) - { - g_free (list->data); - list = g_slist_next (list); - } + mi = gtk_menu_item_new (); + gtk_container_add (GTK_CONTAINER (mi), label); - g_slist_free (suggestions); + gtk_widget_show_all (mi); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - /* Separator */ - mi = gtk_menu_item_new (); - gtk_widget_show (mi); - gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi); + g_object_set_qdata_full (G_OBJECT (mi), + suggestion_id, + g_strdup (suggestions->data), + (GDestroyNotify)g_free); - /* Ignore all */ - mi = gtk_image_menu_item_new_with_mnemonic (_("_Ignore All")); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), - gtk_image_new_from_stock (GTK_STOCK_GOTO_BOTTOM, - GTK_ICON_SIZE_MENU)); - - g_signal_connect (mi, - "activate", - G_CALLBACK(ignore_all), - spell); + g_free (label_text); + g_signal_connect (mi, "activate", + G_CALLBACK (replace_word), spell); - gtk_widget_show_all (mi); + count++; - gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi); + suggestions = g_slist_next (suggestions); + } + } - /* + Add to Dictionary */ - mi = gtk_image_menu_item_new_with_mnemonic (_("_Add")); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), - gtk_image_new_from_stock (GTK_STOCK_ADD, - GTK_ICON_SIZE_MENU)); + /* free the suggestion list */ + suggestions = list; - g_signal_connect (mi, - "activate", - G_CALLBACK (add_to_dictionary), - spell); + while (list) + { + g_free (list->data); + list = g_slist_next (list); + } - gtk_widget_show_all (mi); - - gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi); + g_slist_free (suggestions); - return topmenu; + /* Separator */ + mi = gtk_menu_item_new (); + gtk_widget_show (mi); + gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi); + + /* Ignore all */ + mi = gtk_menu_item_new_with_mnemonic (_("_Ignore All")); + + g_signal_connect (mi, "activate", + G_CALLBACK(ignore_all), spell); + + gtk_widget_show_all (mi); + + gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi); + + /* + Add to Dictionary */ + mi = gtk_menu_item_new_with_mnemonic (_("_Add")); + + g_signal_connect (mi, "activate", + G_CALLBACK (add_to_dictionary), spell); + + gtk_widget_show_all (mi); + + gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi); + + return topmenu; } static void -populate_popup (GtkTextView *textview, GtkMenu *menu, XedAutomaticSpellChecker *spell) +populate_popup (GtkTextView *textview, + GtkMenu *menu, + XedAutomaticSpellChecker *spell) { - GtkWidget *img, *mi; - GtkTextIter start, end; - char *word; + GtkWidget *mi; + GtkTextIter start, end; + char *word; - /* we need to figure out if they picked a misspelled word. */ - get_word_extents_from_mark (GTK_TEXT_BUFFER (spell->doc), &start, &end, spell->mark_click); + /* we need to figure out if they picked a misspelled word. */ + get_word_extents_from_mark (GTK_TEXT_BUFFER (spell->doc), &start, &end, spell->mark_click); - /* if our highlight algorithm ever messes up, - * this isn't correct, either. */ - if (!gtk_text_iter_has_tag (&start, spell->tag_highlight)) - return; /* word wasn't misspelled. */ + /* if our highlight algorithm ever messes up, + * this isn't correct, either. */ + if (!gtk_text_iter_has_tag (&start, spell->tag_highlight)) + { + return; /* word wasn't misspelled. */ + } - /* menu separator comes first. */ - mi = gtk_menu_item_new (); - gtk_widget_show (mi); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi); + /* menu separator comes first. */ + mi = gtk_menu_item_new (); + gtk_widget_show (mi); + gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi); - /* then, on top of it, the suggestions menu. */ - img = gtk_image_new_from_stock (GTK_STOCK_SPELL_CHECK, GTK_ICON_SIZE_MENU); - mi = gtk_image_menu_item_new_with_mnemonic (_("_Spelling Suggestions...")); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img); + /* then, on top of it, the suggestions menu. */ + mi = gtk_menu_item_new_with_mnemonic (_("_Spelling Suggestions...")); - word = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (spell->doc), &start, &end, FALSE); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), - build_suggestion_menu (spell, word)); - g_free(word); + word = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (spell->doc), &start, &end, FALSE); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), build_suggestion_menu (spell, word)); + g_free(word); - gtk_widget_show_all (mi); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi); + gtk_widget_show_all (mi); + gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi); } void xed_automatic_spell_checker_recheck_all (XedAutomaticSpellChecker *spell) { - GtkTextIter start, end; + GtkTextIter start, end; - g_return_if_fail (spell != NULL); + g_return_if_fail (spell != NULL); - gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (spell->doc), &start, &end); + gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (spell->doc), &start, &end); - check_range (spell, start, end, TRUE); + check_range (spell, start, end, TRUE); } -static void -add_word_signal_cb (XedSpellChecker *checker, - const gchar *word, - gint len, - XedAutomaticSpellChecker *spell) +static void +add_word_signal_cb (XedSpellChecker *checker, + const gchar *word, + gint len, + XedAutomaticSpellChecker *spell) { - gchar *w; + gchar *w; - if (len < 0) - w = g_strdup (word); - else - w = g_strndup (word, len); + if (len < 0) + { + w = g_strdup (word); + } + else + { + w = g_strndup (word, len); + } - remove_tag_to_word (spell, w); + remove_tag_to_word (spell, w); - g_free (w); + g_free (w); } -static void +static void set_language_cb (XedSpellChecker *checker, - const XedSpellCheckerLanguage *lang, - XedAutomaticSpellChecker *spell) + const XedSpellCheckerLanguage *lang, + XedAutomaticSpellChecker *spell) { - xed_automatic_spell_checker_recheck_all (spell); + xed_automatic_spell_checker_recheck_all (spell); } -static void +static void clear_session_cb (XedSpellChecker *checker, - XedAutomaticSpellChecker *spell) + XedAutomaticSpellChecker *spell) { - xed_automatic_spell_checker_recheck_all (spell); + xed_automatic_spell_checker_recheck_all (spell); } /* When the user right-clicks on a word, they want to check that word. * Here, we do NOT move the cursor to the location of the clicked-upon word - * since that prevents the use of edit functions on the context menu. + * since that prevents the use of edit functions on the context menu. */ static gboolean -button_press_event (GtkTextView *view, - GdkEventButton *event, - XedAutomaticSpellChecker *spell) +button_press_event (GtkTextView *view, + GdkEventButton *event, + XedAutomaticSpellChecker *spell) { - if (event->button == 3) - { - gint x, y; - GtkTextIter iter; + if (event->button == 3) + { + gint x, y; + GtkTextIter iter; - GtkTextBuffer *buffer = gtk_text_view_get_buffer (view); + GtkTextBuffer *buffer = gtk_text_view_get_buffer (view); - /* handle deferred check if it exists */ - if (spell->deferred_check) - check_deferred_range (spell, TRUE); + /* handle deferred check if it exists */ + if (spell->deferred_check) + { + check_deferred_range (spell, TRUE); + } - gtk_text_view_window_to_buffer_coords (view, - GTK_TEXT_WINDOW_TEXT, - event->x, event->y, - &x, &y); - - gtk_text_view_get_iter_at_location (view, &iter, x, y); + gtk_text_view_window_to_buffer_coords (view, GTK_TEXT_WINDOW_TEXT, event->x, event->y, &x, &y); - gtk_text_buffer_move_mark (buffer, spell->mark_click, &iter); - } + gtk_text_view_get_iter_at_location (view, &iter, x, y); - return FALSE; /* false: let gtk process this event, too. - we don't want to eat any events. */ + gtk_text_buffer_move_mark (buffer, spell->mark_click, &iter); + } + + return FALSE; /* false: let gtk process this event, too. + we don't want to eat any events. */ } /* Move the insert mark before popping up the menu, otherwise it * will contain the wrong set of suggestions. */ static gboolean -popup_menu_event (GtkTextView *view, XedAutomaticSpellChecker *spell) +popup_menu_event (GtkTextView *view, + XedAutomaticSpellChecker *spell) { - GtkTextIter iter; - GtkTextBuffer *buffer; + GtkTextIter iter; + GtkTextBuffer *buffer; - buffer = gtk_text_view_get_buffer (view); + buffer = gtk_text_view_get_buffer (view); - /* handle deferred check if it exists */ - if (spell->deferred_check) - check_deferred_range (spell, TRUE); + /* handle deferred check if it exists */ + if (spell->deferred_check) + { + check_deferred_range (spell, TRUE); + } - gtk_text_buffer_get_iter_at_mark (buffer, &iter, - gtk_text_buffer_get_insert (buffer)); - gtk_text_buffer_move_mark (buffer, spell->mark_click, &iter); + gtk_text_buffer_get_iter_at_mark (buffer, &iter, gtk_text_buffer_get_insert (buffer)); + gtk_text_buffer_move_mark (buffer, spell->mark_click, &iter); - return FALSE; + return FALSE; } static void -tag_table_changed (GtkTextTagTable *table, - XedAutomaticSpellChecker *spell) -{ - g_return_if_fail (spell->tag_highlight != NULL); - - gtk_text_tag_set_priority (spell->tag_highlight, - gtk_text_tag_table_get_size (table) - 1); -} - -static void -tag_added_or_removed (GtkTextTagTable *table, - GtkTextTag *tag, - XedAutomaticSpellChecker *spell) -{ - tag_table_changed (table, spell); -} - -static void -tag_changed (GtkTextTagTable *table, - GtkTextTag *tag, - gboolean size_changed, - XedAutomaticSpellChecker *spell) -{ - tag_table_changed (table, spell); -} - -static void -highlight_updated (GtkSourceBuffer *buffer, - GtkTextIter *start, - GtkTextIter *end, +tag_table_changed (GtkTextTagTable *table, XedAutomaticSpellChecker *spell) { - check_range (spell, *start, *end, FALSE); + g_return_if_fail (spell->tag_highlight != NULL); + + gtk_text_tag_set_priority (spell->tag_highlight, gtk_text_tag_table_get_size (table) - 1); +} + +static void +tag_added_or_removed (GtkTextTagTable *table, + GtkTextTag *tag, + XedAutomaticSpellChecker *spell) +{ + tag_table_changed (table, spell); +} + +static void +tag_changed (GtkTextTagTable *table, + GtkTextTag *tag, + gboolean size_changed, + XedAutomaticSpellChecker *spell) +{ + tag_table_changed (table, spell); +} + +static void +highlight_updated (GtkSourceBuffer *buffer, + GtkTextIter *start, + GtkTextIter *end, + XedAutomaticSpellChecker *spell) +{ + check_range (spell, *start, *end, FALSE); } static void spell_tag_destroyed (XedAutomaticSpellChecker *spell, - GObject *where_the_object_was) + GObject *where_the_object_was) { - spell->tag_highlight = NULL; + spell->tag_highlight = NULL; } XedAutomaticSpellChecker * xed_automatic_spell_checker_new (XedDocument *doc, - XedSpellChecker *checker) + XedSpellChecker *checker) { - XedAutomaticSpellChecker *spell; - GtkTextTagTable *tag_table; - GtkTextIter start, end; + XedAutomaticSpellChecker *spell; + GtkTextTagTable *tag_table; + GtkTextIter start, end; - g_return_val_if_fail (XED_IS_DOCUMENT (doc), NULL); - g_return_val_if_fail (XED_IS_SPELL_CHECKER (checker), NULL); - g_return_val_if_fail ((spell = xed_automatic_spell_checker_get_from_document (doc)) == NULL, - spell); - - /* attach to the widget */ - spell = g_new0 (XedAutomaticSpellChecker, 1); + g_return_val_if_fail (XED_IS_DOCUMENT (doc), NULL); + g_return_val_if_fail (XED_IS_SPELL_CHECKER (checker), NULL); + g_return_val_if_fail ((spell = xed_automatic_spell_checker_get_from_document (doc)) == NULL, spell); - spell->doc = doc; - spell->spell_checker = g_object_ref (checker); + /* attach to the widget */ + spell = g_new0 (XedAutomaticSpellChecker, 1); - if (automatic_spell_checker_id == 0) - { - automatic_spell_checker_id = - g_quark_from_string ("XedAutomaticSpellCheckerID"); - } - if (suggestion_id == 0) - { - suggestion_id = g_quark_from_string ("XedAutoSuggestionID"); - } + spell->doc = doc; + spell->spell_checker = g_object_ref (checker); - g_object_set_qdata_full (G_OBJECT (doc), - automatic_spell_checker_id, - spell, - (GDestroyNotify)xed_automatic_spell_checker_free_internal); + if (automatic_spell_checker_id == 0) + { + automatic_spell_checker_id = g_quark_from_string ("XedAutomaticSpellCheckerID"); + } + if (suggestion_id == 0) + { + suggestion_id = g_quark_from_string ("XedAutoSuggestionID"); + } - g_signal_connect (doc, - "insert-text", - G_CALLBACK (insert_text_before), - spell); - g_signal_connect_after (doc, - "insert-text", - G_CALLBACK (insert_text_after), - spell); - g_signal_connect_after (doc, - "delete-range", - G_CALLBACK (delete_range_after), - spell); - g_signal_connect (doc, - "mark-set", - G_CALLBACK (mark_set), - spell); + g_object_set_qdata_full (G_OBJECT (doc), automatic_spell_checker_id, + spell, (GDestroyNotify)xed_automatic_spell_checker_free_internal); - g_signal_connect (doc, - "highlight-updated", - G_CALLBACK (highlight_updated), - spell); + g_signal_connect (doc, "insert-text", + G_CALLBACK (insert_text_before), spell); + g_signal_connect_after (doc, "insert-text", + G_CALLBACK (insert_text_after), spell); + g_signal_connect_after (doc, "delete-range", + G_CALLBACK (delete_range_after), spell); + g_signal_connect (doc, "mark-set", + G_CALLBACK (mark_set), spell); - g_signal_connect (spell->spell_checker, - "add_word_to_session", - G_CALLBACK (add_word_signal_cb), - spell); - g_signal_connect (spell->spell_checker, - "add_word_to_personal", - G_CALLBACK (add_word_signal_cb), - spell); - g_signal_connect (spell->spell_checker, - "clear_session", - G_CALLBACK (clear_session_cb), - spell); - g_signal_connect (spell->spell_checker, - "set_language", - G_CALLBACK (set_language_cb), - spell); + g_signal_connect (doc, "highlight-updated", + G_CALLBACK (highlight_updated), spell); - spell->tag_highlight = gtk_text_buffer_create_tag ( - GTK_TEXT_BUFFER (doc), - "gtkspell-misspelled", - "underline", PANGO_UNDERLINE_ERROR, - NULL); + g_signal_connect (spell->spell_checker, "add_word_to_session", + G_CALLBACK (add_word_signal_cb), spell); + g_signal_connect (spell->spell_checker, "add_word_to_personal", + G_CALLBACK (add_word_signal_cb), spell); + g_signal_connect (spell->spell_checker, "clear_session", + G_CALLBACK (clear_session_cb), spell); + g_signal_connect (spell->spell_checker, "set_language", + G_CALLBACK (set_language_cb), spell); - g_object_weak_ref (G_OBJECT (spell->tag_highlight), - (GWeakNotify)spell_tag_destroyed, - spell); + spell->tag_highlight = gtk_text_buffer_create_tag (GTK_TEXT_BUFFER (doc), + "gtkspell-misspelled", + "underline", PANGO_UNDERLINE_ERROR, + NULL); - tag_table = gtk_text_buffer_get_tag_table (GTK_TEXT_BUFFER (doc)); + g_object_weak_ref (G_OBJECT (spell->tag_highlight), (GWeakNotify)spell_tag_destroyed, spell); - gtk_text_tag_set_priority (spell->tag_highlight, - gtk_text_tag_table_get_size (tag_table) - 1); + tag_table = gtk_text_buffer_get_tag_table (GTK_TEXT_BUFFER (doc)); - g_signal_connect (tag_table, - "tag-added", - G_CALLBACK (tag_added_or_removed), - spell); - g_signal_connect (tag_table, - "tag-removed", - G_CALLBACK (tag_added_or_removed), - spell); - g_signal_connect (tag_table, - "tag-changed", - G_CALLBACK (tag_changed), - spell); + gtk_text_tag_set_priority (spell->tag_highlight, gtk_text_tag_table_get_size (tag_table) - 1); - /* we create the mark here, but we don't use it until text is - * inserted, so we don't really care where iter points. */ - gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (doc), &start, &end); - - spell->mark_insert_start = gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc), - "xed-automatic-spell-checker-insert-start"); + g_signal_connect (tag_table, "tag-added", + G_CALLBACK (tag_added_or_removed), spell); + g_signal_connect (tag_table, "tag-removed", + G_CALLBACK (tag_added_or_removed), spell); + g_signal_connect (tag_table, "tag-changed", + G_CALLBACK (tag_changed), spell); - if (spell->mark_insert_start == NULL) - { - spell->mark_insert_start = - gtk_text_buffer_create_mark (GTK_TEXT_BUFFER (doc), - "xed-automatic-spell-checker-insert-start", - &start, - TRUE); - } - else - { - gtk_text_buffer_move_mark (GTK_TEXT_BUFFER (doc), - spell->mark_insert_start, - &start); - } + /* we create the mark here, but we don't use it until text is + * inserted, so we don't really care where iter points. */ + gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (doc), &start, &end); - spell->mark_insert_end = gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc), - "xed-automatic-spell-checker-insert-end"); + spell->mark_insert_start = gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc), + "xed-automatic-spell-checker-insert-start"); - if (spell->mark_insert_end == NULL) - { - spell->mark_insert_end = - gtk_text_buffer_create_mark (GTK_TEXT_BUFFER (doc), - "xed-automatic-spell-checker-insert-end", - &start, - TRUE); - } - else - { - gtk_text_buffer_move_mark (GTK_TEXT_BUFFER (doc), - spell->mark_insert_end, - &start); - } + if (spell->mark_insert_start == NULL) + { + spell->mark_insert_start = gtk_text_buffer_create_mark (GTK_TEXT_BUFFER (doc), + "xed-automatic-spell-checker-insert-start", + &start, + TRUE); + } + else + { + gtk_text_buffer_move_mark (GTK_TEXT_BUFFER (doc), spell->mark_insert_start, &start); + } - spell->mark_click = gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc), - "xed-automatic-spell-checker-click"); + spell->mark_insert_end = gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc), + "xed-automatic-spell-checker-insert-end"); - if (spell->mark_click == NULL) - { - spell->mark_click = - gtk_text_buffer_create_mark (GTK_TEXT_BUFFER (doc), - "xed-automatic-spell-checker-click", - &start, - TRUE); - } - else - { - gtk_text_buffer_move_mark (GTK_TEXT_BUFFER (doc), - spell->mark_click, - &start); - } + if (spell->mark_insert_end == NULL) + { + spell->mark_insert_end = gtk_text_buffer_create_mark (GTK_TEXT_BUFFER (doc), + "xed-automatic-spell-checker-insert-end", + &start, + TRUE); + } + else + { + gtk_text_buffer_move_mark (GTK_TEXT_BUFFER (doc), spell->mark_insert_end, &start); + } - spell->deferred_check = FALSE; + spell->mark_click = gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc), + "xed-automatic-spell-checker-click"); - return spell; + if (spell->mark_click == NULL) + { + spell->mark_click = gtk_text_buffer_create_mark (GTK_TEXT_BUFFER (doc), + "xed-automatic-spell-checker-click", + &start, + TRUE); + } + else + { + gtk_text_buffer_move_mark (GTK_TEXT_BUFFER (doc), spell->mark_click, &start); + } + + spell->deferred_check = FALSE; + + return spell; } XedAutomaticSpellChecker * xed_automatic_spell_checker_get_from_document (const XedDocument *doc) { - g_return_val_if_fail (XED_IS_DOCUMENT (doc), NULL); + g_return_val_if_fail (XED_IS_DOCUMENT (doc), NULL); - if (automatic_spell_checker_id == 0) - return NULL; + if (automatic_spell_checker_id == 0) + { + return NULL; + } - return g_object_get_qdata (G_OBJECT (doc), automatic_spell_checker_id); -} + return g_object_get_qdata (G_OBJECT (doc), automatic_spell_checker_id); +} void xed_automatic_spell_checker_free (XedAutomaticSpellChecker *spell) { - g_return_if_fail (spell != NULL); - g_return_if_fail (xed_automatic_spell_checker_get_from_document (spell->doc) == spell); - - if (automatic_spell_checker_id == 0) - return; + g_return_if_fail (spell != NULL); + g_return_if_fail (xed_automatic_spell_checker_get_from_document (spell->doc) == spell); - g_object_set_qdata (G_OBJECT (spell->doc), automatic_spell_checker_id, NULL); + if (automatic_spell_checker_id == 0) + { + return; + } + + g_object_set_qdata (G_OBJECT (spell->doc), automatic_spell_checker_id, NULL); } static void xed_automatic_spell_checker_free_internal (XedAutomaticSpellChecker *spell) { - GtkTextTagTable *table; - GtkTextIter start, end; - GSList *list; - - g_return_if_fail (spell != NULL); + GtkTextTagTable *table; + GtkTextIter start, end; + GSList *list; - table = gtk_text_buffer_get_tag_table (GTK_TEXT_BUFFER (spell->doc)); + g_return_if_fail (spell != NULL); - if (table != NULL && spell->tag_highlight != NULL) - { - gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (spell->doc), - &start, - &end); - gtk_text_buffer_remove_tag (GTK_TEXT_BUFFER (spell->doc), - spell->tag_highlight, - &start, - &end); + table = gtk_text_buffer_get_tag_table (GTK_TEXT_BUFFER (spell->doc)); - g_signal_handlers_disconnect_matched (G_OBJECT (table), - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, - spell); + if (table != NULL && spell->tag_highlight != NULL) + { + gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (spell->doc), &start, &end); + gtk_text_buffer_remove_tag (GTK_TEXT_BUFFER (spell->doc), spell->tag_highlight, &start, &end); - gtk_text_tag_table_remove (table, spell->tag_highlight); - } - - g_signal_handlers_disconnect_matched (G_OBJECT (spell->doc), - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, - spell); + g_signal_handlers_disconnect_matched (G_OBJECT (table), + G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, + spell); - g_signal_handlers_disconnect_matched (G_OBJECT (spell->spell_checker), - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, - spell); + gtk_text_tag_table_remove (table, spell->tag_highlight); + } - g_object_unref (spell->spell_checker); + g_signal_handlers_disconnect_matched (G_OBJECT (spell->doc), + G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, + spell); - list = spell->views; - while (list != NULL) - { - XedView *view = XED_VIEW (list->data); - - g_signal_handlers_disconnect_matched (G_OBJECT (view), - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, - spell); + g_signal_handlers_disconnect_matched (G_OBJECT (spell->spell_checker), + G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, + spell); - g_signal_handlers_disconnect_matched (G_OBJECT (view), - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, - spell); + g_object_unref (spell->spell_checker); - list = g_slist_next (list); - } + list = spell->views; + while (list != NULL) + { + XedView *view = XED_VIEW (list->data); - g_slist_free (spell->views); - - g_free (spell); + g_signal_handlers_disconnect_matched (G_OBJECT (view), + G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, + spell); + + g_signal_handlers_disconnect_matched (G_OBJECT (view), + G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, + spell); + + list = g_slist_next (list); + } + + g_slist_free (spell->views); + + g_free (spell); } void -xed_automatic_spell_checker_attach_view ( - XedAutomaticSpellChecker *spell, - XedView *view) +xed_automatic_spell_checker_attach_view (XedAutomaticSpellChecker *spell, + XedView *view) { - g_return_if_fail (spell != NULL); - g_return_if_fail (XED_IS_VIEW (view)); + g_return_if_fail (spell != NULL); + g_return_if_fail (XED_IS_VIEW (view)); - g_return_if_fail (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)) == - GTK_TEXT_BUFFER (spell->doc)); + g_return_if_fail (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)) == GTK_TEXT_BUFFER (spell->doc)); - g_signal_connect (view, - "button-press-event", - G_CALLBACK (button_press_event), - spell); - g_signal_connect (view, - "popup-menu", - G_CALLBACK (popup_menu_event), - spell); - g_signal_connect (view, - "populate-popup", - G_CALLBACK (populate_popup), - spell); - g_signal_connect (view, - "destroy", - G_CALLBACK (view_destroy), - spell); + g_signal_connect (view, "button-press-event", + G_CALLBACK (button_press_event), spell); + g_signal_connect (view, "popup-menu", + G_CALLBACK (popup_menu_event), spell); + g_signal_connect (view, "populate-popup", + G_CALLBACK (populate_popup), spell); + g_signal_connect (view, "destroy", + G_CALLBACK (view_destroy), spell); - spell->views = g_slist_prepend (spell->views, view); + spell->views = g_slist_prepend (spell->views, view); } -void -xed_automatic_spell_checker_detach_view ( - XedAutomaticSpellChecker *spell, - XedView *view) +void +xed_automatic_spell_checker_detach_view (XedAutomaticSpellChecker *spell, + XedView *view) { - g_return_if_fail (spell != NULL); - g_return_if_fail (XED_IS_VIEW (view)); + g_return_if_fail (spell != NULL); + g_return_if_fail (XED_IS_VIEW (view)); - g_return_if_fail (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)) == - GTK_TEXT_BUFFER (spell->doc)); - g_return_if_fail (spell->views != NULL); + g_return_if_fail (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)) == GTK_TEXT_BUFFER (spell->doc)); + g_return_if_fail (spell->views != NULL); - g_signal_handlers_disconnect_matched (G_OBJECT (view), - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, - spell); + g_signal_handlers_disconnect_matched (G_OBJECT (view), + G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, + spell); - g_signal_handlers_disconnect_matched (G_OBJECT (view), - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, - spell); + g_signal_handlers_disconnect_matched (G_OBJECT (view), + G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, + spell); - spell->views = g_slist_remove (spell->views, view); + spell->views = g_slist_remove (spell->views, view); } diff --git a/plugins/spell/xed-spell-language-dialog.c b/plugins/spell/xed-spell-language-dialog.c index b0d9029..ee1efab 100644 --- a/plugins/spell/xed-spell-language-dialog.c +++ b/plugins/spell/xed-spell-language-dialog.c @@ -3,7 +3,7 @@ * xed-spell-language-dialog.c * This file is part of xed * - * Copyright (C) 2002 Paolo Maggi + * Copyright (C) 2002 Paolo Maggi * * 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 @@ -17,14 +17,14 @@ * * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. + * Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. */ - + /* - * Modified by the xed Team, 2002. See the AUTHORS file for a - * list of people on the xed Team. - * See the ChangeLog files for a list of changes. + * Modified by the xed Team, 2002. See the AUTHORS file for a + * list of people on the xed Team. + * See the ChangeLog files for a list of changes. */ #ifdef HAVE_CONFIG_H @@ -41,268 +41,244 @@ enum { - COLUMN_LANGUAGE_NAME = 0, - COLUMN_LANGUAGE_POINTER, - ENCODING_NUM_COLS + COLUMN_LANGUAGE_NAME = 0, + COLUMN_LANGUAGE_POINTER, + ENCODING_NUM_COLS }; -struct _XedSpellLanguageDialog +struct _XedSpellLanguageDialog { - GtkDialog dialog; + GtkDialog dialog; - GtkWidget *languages_treeview; - GtkTreeModel *model; + GtkWidget *languages_treeview; + GtkTreeModel *model; }; -G_DEFINE_TYPE(XedSpellLanguageDialog, xed_spell_language_dialog, GTK_TYPE_DIALOG) +G_DEFINE_TYPE (XedSpellLanguageDialog, xed_spell_language_dialog, GTK_TYPE_DIALOG) -static void +static void xed_spell_language_dialog_class_init (XedSpellLanguageDialogClass *klass) { - /* GObjectClass *object_class = G_OBJECT_CLASS (klass); */ + /* GObjectClass *object_class = G_OBJECT_CLASS (klass); */ } static void dialog_response_handler (GtkDialog *dlg, - gint res_id) + gint res_id) { - if (res_id == GTK_RESPONSE_HELP) - { - xed_help_display (GTK_WINDOW (dlg), - NULL, - "xed-spell-checker-plugin"); + if (res_id == GTK_RESPONSE_HELP) + { + xed_help_display (GTK_WINDOW (dlg), NULL, "xed-spell-checker-plugin"); - g_signal_stop_emission_by_name (dlg, "response"); - } -} - -static void -scroll_to_selected (GtkTreeView *tree_view) -{ - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkTreeIter iter; - - model = gtk_tree_view_get_model (tree_view); - g_return_if_fail (model != NULL); - - /* Scroll to selected */ - selection = gtk_tree_view_get_selection (tree_view); - g_return_if_fail (selection != NULL); - - if (gtk_tree_selection_get_selected (selection, NULL, &iter)) - { - GtkTreePath* path; - - path = gtk_tree_model_get_path (model, &iter); - g_return_if_fail (path != NULL); - - gtk_tree_view_scroll_to_cell (tree_view, - path, NULL, TRUE, 1.0, 0.0); - gtk_tree_path_free (path); - } + g_signal_stop_emission_by_name (dlg, "response"); + } } static void -language_row_activated (GtkTreeView *tree_view, - GtkTreePath *path, - GtkTreeViewColumn *column, - XedSpellLanguageDialog *dialog) +scroll_to_selected (GtkTreeView *tree_view) { - gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); + GtkTreeModel *model; + GtkTreeSelection *selection; + GtkTreeIter iter; + + model = gtk_tree_view_get_model (tree_view); + g_return_if_fail (model != NULL); + + /* Scroll to selected */ + selection = gtk_tree_view_get_selection (tree_view); + g_return_if_fail (selection != NULL); + + if (gtk_tree_selection_get_selected (selection, NULL, &iter)) + { + GtkTreePath* path; + + path = gtk_tree_model_get_path (model, &iter); + g_return_if_fail (path != NULL); + + gtk_tree_view_scroll_to_cell (tree_view, path, NULL, TRUE, 1.0, 0.0); + gtk_tree_path_free (path); + } +} + +static void +language_row_activated (GtkTreeView *tree_view, + GtkTreePath *path, + GtkTreeViewColumn *column, + XedSpellLanguageDialog *dialog) +{ + gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); } static void create_dialog (XedSpellLanguageDialog *dlg, - const gchar *data_dir) + const gchar *data_dir) { - GtkWidget *error_widget; - GtkWidget *content; - gboolean ret; - GtkCellRenderer *cell; - GtkTreeViewColumn *column; - gchar *ui_file; - gchar *root_objects[] = { - "content", - NULL - }; - - gtk_dialog_add_buttons (GTK_DIALOG (dlg), - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, - GTK_RESPONSE_OK, - GTK_STOCK_HELP, - GTK_RESPONSE_HELP, - NULL); + GtkWidget *error_widget; + GtkWidget *content; + gboolean ret; + GtkCellRenderer *cell; + GtkTreeViewColumn *column; + gchar *ui_file; + gchar *root_objects[] = { + "content", + NULL + }; - gtk_window_set_title (GTK_WINDOW (dlg), _("Set language")); - gtk_window_set_modal (GTK_WINDOW (dlg), TRUE); - gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE); + gtk_dialog_add_buttons (GTK_DIALOG (dlg), + _("_Cancel"), GTK_RESPONSE_CANCEL, + _("_OK"), GTK_RESPONSE_OK, + _("_Help"), GTK_RESPONSE_HELP, + NULL); - /* HIG defaults */ - gtk_container_set_border_width (GTK_CONTAINER (dlg), 5); - gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), - 2); /* 2 * 5 + 2 = 12 */ - gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (dlg))), - 5); - gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dlg))), - 6); + gtk_window_set_title (GTK_WINDOW (dlg), _("Set language")); + gtk_window_set_modal (GTK_WINDOW (dlg), TRUE); + gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE); - g_signal_connect (dlg, - "response", - G_CALLBACK (dialog_response_handler), - NULL); + /* HIG defaults */ + gtk_container_set_border_width (GTK_CONTAINER (dlg), 5); + gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), 2); + gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (dlg))), 5); + gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dlg))), 6); - ui_file = g_build_filename (data_dir, "languages-dialog.ui", NULL); - ret = xed_utils_get_ui_objects (ui_file, - root_objects, - &error_widget, - "content", &content, - "languages_treeview", &dlg->languages_treeview, - NULL); - g_free (ui_file); - - if (!ret) - { - gtk_widget_show (error_widget); + g_signal_connect (dlg, "response", + G_CALLBACK (dialog_response_handler), NULL); - gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), - error_widget, - TRUE, TRUE, 0); + ui_file = g_build_filename (data_dir, "languages-dialog.ui", NULL); + ret = xed_utils_get_ui_objects (ui_file, + root_objects, + &error_widget, + "content", &content, + "languages_treeview", &dlg->languages_treeview, + NULL); + g_free (ui_file); - return; - } + if (!ret) + { + gtk_widget_show (error_widget); - gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), - content, TRUE, TRUE, 0); - g_object_unref (content); - gtk_container_set_border_width (GTK_CONTAINER (content), 5); + gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), error_widget, TRUE, TRUE, 0); - dlg->model = GTK_TREE_MODEL (gtk_list_store_new (ENCODING_NUM_COLS, - G_TYPE_STRING, - G_TYPE_POINTER)); + return; + } - gtk_tree_view_set_model (GTK_TREE_VIEW (dlg->languages_treeview), - dlg->model); + gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), content, TRUE, TRUE, 0); + g_object_unref (content); + gtk_container_set_border_width (GTK_CONTAINER (content), 5); - g_object_unref (dlg->model); + dlg->model = GTK_TREE_MODEL (gtk_list_store_new (ENCODING_NUM_COLS, G_TYPE_STRING, G_TYPE_POINTER)); - /* Add the encoding column */ - cell = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Languages"), - cell, - "text", - COLUMN_LANGUAGE_NAME, - NULL); - - gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->languages_treeview), - column); + gtk_tree_view_set_model (GTK_TREE_VIEW (dlg->languages_treeview), dlg->model); - gtk_tree_view_set_search_column (GTK_TREE_VIEW (dlg->languages_treeview), - COLUMN_LANGUAGE_NAME); + g_object_unref (dlg->model); - g_signal_connect (dlg->languages_treeview, - "realize", - G_CALLBACK (scroll_to_selected), - dlg); - g_signal_connect (dlg->languages_treeview, - "row-activated", - G_CALLBACK (language_row_activated), - dlg); + /* Add the encoding column */ + cell = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes (_("Languages"), + cell, + "text", + COLUMN_LANGUAGE_NAME, + NULL); + + gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->languages_treeview), column); + + gtk_tree_view_set_search_column (GTK_TREE_VIEW (dlg->languages_treeview), COLUMN_LANGUAGE_NAME); + + g_signal_connect (dlg->languages_treeview, "realize", + G_CALLBACK (scroll_to_selected), dlg); + g_signal_connect (dlg->languages_treeview, "row-activated", + G_CALLBACK (language_row_activated), dlg); } static void xed_spell_language_dialog_init (XedSpellLanguageDialog *dlg) { - + } static void populate_language_list (XedSpellLanguageDialog *dlg, - const XedSpellCheckerLanguage *cur_lang) + const XedSpellCheckerLanguage *cur_lang) { - GtkListStore *store; - GtkTreeIter iter; + GtkListStore *store; + GtkTreeIter iter; - const GSList* langs; + const GSList* langs; - /* create list store */ - store = GTK_LIST_STORE (dlg->model); + /* create list store */ + store = GTK_LIST_STORE (dlg->model); - langs = xed_spell_checker_get_available_languages (); + langs = xed_spell_checker_get_available_languages (); - while (langs) - { - const gchar *name; + while (langs) + { + const gchar *name; - name = xed_spell_checker_language_to_string ((const XedSpellCheckerLanguage*)langs->data); + name = xed_spell_checker_language_to_string ((const XedSpellCheckerLanguage*)langs->data); - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - COLUMN_LANGUAGE_NAME, name, - COLUMN_LANGUAGE_POINTER, langs->data, - -1); + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, + COLUMN_LANGUAGE_NAME, name, + COLUMN_LANGUAGE_POINTER, langs->data, + -1); - if (langs->data == cur_lang) - { - GtkTreeSelection *selection; + if (langs->data == cur_lang) + { + GtkTreeSelection *selection; - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->languages_treeview)); - g_return_if_fail (selection != NULL); + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->languages_treeview)); + g_return_if_fail (selection != NULL); - gtk_tree_selection_select_iter (selection, &iter); - } + gtk_tree_selection_select_iter (selection, &iter); + } - langs = g_slist_next (langs); - } + langs = g_slist_next (langs); + } } GtkWidget * -xed_spell_language_dialog_new (GtkWindow *parent, - const XedSpellCheckerLanguage *cur_lang, - const gchar *data_dir) +xed_spell_language_dialog_new (GtkWindow *parent, + const XedSpellCheckerLanguage *cur_lang, + const gchar *data_dir) { - XedSpellLanguageDialog *dlg; + XedSpellLanguageDialog *dlg; - g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL); + g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL); - dlg = g_object_new (XED_TYPE_SPELL_LANGUAGE_DIALOG, NULL); + dlg = g_object_new (XED_TYPE_SPELL_LANGUAGE_DIALOG, NULL); - create_dialog (dlg, data_dir); + create_dialog (dlg, data_dir); - populate_language_list (dlg, cur_lang); + populate_language_list (dlg, cur_lang); - gtk_window_set_transient_for (GTK_WINDOW (dlg), parent); - gtk_widget_grab_focus (dlg->languages_treeview); + gtk_window_set_transient_for (GTK_WINDOW (dlg), parent); + gtk_widget_grab_focus (dlg->languages_treeview); - return GTK_WIDGET (dlg); + return GTK_WIDGET (dlg); } const XedSpellCheckerLanguage * xed_spell_language_get_selected_language (XedSpellLanguageDialog *dlg) { - GValue value = {0, }; - const XedSpellCheckerLanguage* lang; + GValue value = {0, }; + const XedSpellCheckerLanguage* lang; - GtkTreeIter iter; - GtkTreeSelection *selection; + GtkTreeIter iter; + GtkTreeSelection *selection; - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->languages_treeview)); - g_return_val_if_fail (selection != NULL, NULL); + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->languages_treeview)); + g_return_val_if_fail (selection != NULL, NULL); - if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) - return NULL; + if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) + { + return NULL; + } - gtk_tree_model_get_value (dlg->model, - &iter, - COLUMN_LANGUAGE_POINTER, - &value); + gtk_tree_model_get_value (dlg->model, &iter, COLUMN_LANGUAGE_POINTER, &value); - lang = (const XedSpellCheckerLanguage* ) g_value_get_pointer (&value); + lang = (const XedSpellCheckerLanguage* ) g_value_get_pointer (&value); - return lang; + return lang; } diff --git a/plugins/spell/xed-spell-language-dialog.h b/plugins/spell/xed-spell-language-dialog.h index 488040c..b11c454 100644 --- a/plugins/spell/xed-spell-language-dialog.h +++ b/plugins/spell/xed-spell-language-dialog.h @@ -3,7 +3,7 @@ * xed-spell-language-dialog.h * This file is part of xed * - * Copyright (C) 2002 Paolo Maggi + * Copyright (C) 2002 Paolo Maggi * * 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 @@ -17,14 +17,14 @@ * * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. + * Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. */ - + /* - * Modified by the xed Team, 2002. See the AUTHORS file for a - * list of people on the xed Team. - * See the ChangeLog files for a list of changes. + * Modified by the xed Team, 2002. See the AUTHORS file for a + * list of people on the xed Team. + * See the ChangeLog files for a list of changes. */ #ifndef __XED_SPELL_LANGUAGE_DIALOG_H__ @@ -44,22 +44,20 @@ G_BEGIN_DECLS typedef struct _XedSpellLanguageDialog XedSpellLanguageDialog; - typedef struct _XedSpellLanguageDialogClass XedSpellLanguageDialogClass; -struct _XedSpellLanguageDialogClass +struct _XedSpellLanguageDialogClass { - GtkDialogClass parent_class; + GtkDialogClass parent_class; }; -GType xed_spell_language_dialog_get_type (void) G_GNUC_CONST; +GType xed_spell_language_dialog_get_type (void) G_GNUC_CONST; -GtkWidget *xed_spell_language_dialog_new (GtkWindow *parent, - const XedSpellCheckerLanguage *cur_lang, - const gchar *data_dir); +GtkWidget *xed_spell_language_dialog_new (GtkWindow *parent, + const XedSpellCheckerLanguage *cur_lang, + const gchar *data_dir); -const XedSpellCheckerLanguage * - xed_spell_language_get_selected_language (XedSpellLanguageDialog *dlg); +const XedSpellCheckerLanguage *xed_spell_language_get_selected_language (XedSpellLanguageDialog *dlg); G_END_DECLS diff --git a/plugins/spell/xed-spell-plugin.c b/plugins/spell/xed-spell-plugin.c index a457a58..2765bc0 100644 --- a/plugins/spell/xed-spell-plugin.c +++ b/plugins/spell/xed-spell-plugin.c @@ -27,7 +27,7 @@ #include /* For strlen */ -#include +#include #include #include @@ -1039,7 +1039,6 @@ auto_spell_cb (GtkAction *action, XedSpellPlugin *plugin) { XedSpellPluginPrivate *priv; - XedWindow *window; XedDocument *doc; gboolean active; @@ -1319,7 +1318,7 @@ xed_spell_plugin_activate (XedWindowActivatable *activatable) { XedDocument *doc = XED_DOCUMENT (l->data); - set_auto_spell_from_metadata (activatable, doc, priv->action_group); + set_auto_spell_from_metadata (XED_SPELL_PLUGIN (activatable), doc, priv->action_group); g_signal_handlers_disconnect_by_func (doc, on_document_loaded, activatable); g_signal_handlers_disconnect_by_func (doc, on_document_saved, activatable); diff --git a/plugins/spell/xed-spell-setup-dialog.ui b/plugins/spell/xed-spell-setup-dialog.ui index abc878d..d9b56ab 100644 --- a/plugins/spell/xed-spell-setup-dialog.ui +++ b/plugins/spell/xed-spell-setup-dialog.ui @@ -1,29 +1,25 @@ - + - + + False - _Configure Spell Checker plugin... - False - normal + dialog - True False - 8 + vertical + 2 - True False end - - gtk-help + + button True True - True - False - True + True True @@ -32,13 +28,11 @@ - - gtk-cancel + + button True True - True - False - True + True True @@ -47,13 +41,11 @@ - - gtk-ok + + button True True - True - False - True + True True @@ -64,42 +56,208 @@ False - True - end + False 0 - + True False + 12 + 8 vertical + 12 True False - Autocheck spelling on document load... + Autocheck settings 0 + False - False + True 0 - - _Never autocheck + True - True - False - True - 0 - True - True + False + 30 + vertical + 12 + + + True + False + 12 + + + True + True + False + 0 + True + True + + + 0 + 0 + 2 + + + + + True + False + Never + 0 + + + + + + 1 + 0 + + + + + True + False + Never autocheck spelling on document load + 0 + + + 1 + 1 + + + + + False + True + 0 + + + + + True + False + 12 + + + True + True + False + 0 + True + True + autocheck_never + + + 0 + 0 + 2 + + + + + True + False + Remember by document + 0 + + + + + + 1 + 0 + + + + + True + False + Remembers the setting for each document on load + 0 + + + 1 + 1 + + + + + False + True + 1 + + + + + True + False + 12 + + + True + True + False + 0 + True + True + autocheck_never + + + 0 + 0 + 2 + + + + + True + False + Always + 0 + + + + + + 1 + 0 + + + + + True + False + Always autocheck on document load + 0 + + + 1 + 1 + + + + + False + True + 2 + + False @@ -107,42 +265,6 @@ 1 - - - _Remember autocheck by document - True - True - False - True - 0 - True - True - autocheck_never - - - False - True - 2 - - - - - _Always autocheck - True - True - False - True - 0 - True - True - autocheck_never - - - False - True - 3 - - False @@ -152,10 +274,5 @@ - - button1 - button3 - button4 -