g_slist_foreach(checkers, free_checkers, NULL);
g_slist_free(checkers);
+ gtkaspellcheckers->checkers = NULL;
}
if ((dict_list = gtkaspellcheckers->dictionary_list)) {
}
g_free(gtkaspellcheckers->error_message);
-
+ gtkaspellcheckers->error_message = NULL;
return;
}
return gtkaspell;
}
-void gtkaspell_delete(GtkAspell * gtkaspell)
+void gtkaspell_delete(GtkAspell *gtkaspell)
{
GtkTextView *gtktext = gtkaspell->gtktext;
g_signal_handlers_disconnect_by_func(G_OBJECT(gtktext),
G_CALLBACK(entry_insert_cb),
- gtkaspell);
+ gtkaspell);
g_signal_handlers_disconnect_by_func(G_OBJECT(gtktext),
G_CALLBACK(entry_delete_cb),
- gtkaspell);
+ gtkaspell);
g_signal_handlers_disconnect_by_func(G_OBJECT(gtktext),
- G_CALLBACK(button_press_intercept_cb),
- gtkaspell);
+ G_CALLBACK(button_press_intercept_cb),
+ gtkaspell);
gtkaspell_uncheck_all(gtkaspell);
free_suggestions_list(gtkaspell);
g_free((gchar *)gtkaspell->dictionary_path);
+ gtkaspell->dictionary_path = NULL;
debug_print("Aspell: deleting gtkaspell %0x\n", (guint) gtkaspell);
{
char *themode;
- gtk_label_get(GTK_LABEL(GTK_BIN(w)->child), (gchar **) &themode);
+ themode = (char *) gtk_label_get_text(GTK_LABEL(GTK_BIN(w)->child));
+ themode = g_strdup(themode);
set_real_sug_mode(gtkaspell, themode);
+ g_free(themode);
if (gtkaspell->config_menu)
populate_submenu(gtkaspell, gtkaspell->config_menu);
elements = aspell_word_list_elements(suggestions);
list = g_list_append(list, g_strdup(word));
- while (newword = aspell_string_enumeration_next(elements))
+ while ((newword = aspell_string_enumeration_next(elements)) != NULL)
list = g_list_append(list, g_strdup(newword));
gtkaspell->max_sug = g_list_length(list) - 1;
static gboolean iswordsep(unsigned char c)
{
- return !isalpha(c) && c != '\'';
+ return (isspace(c) || ispunct(c)) && c != '\'';
}
static guchar get_text_index_whar(GtkAspell *gtkaspell, int pos)
c = get_text_index_whar(gtkaspell, start);
if (c == '\'') {
if (start > 0) {
- if (!isalpha(get_text_index_whar(gtkaspell,
+ if (isspace(get_text_index_whar(gtkaspell,
+ start - 1))
+ || ispunct(get_text_index_whar(gtkaspell,
+ start - 1))
+ || isdigit(get_text_index_whar(gtkaspell,
start - 1))) {
/* start_quote = TRUE; */
break;
break;
}
}
- else if (!isalpha(c))
+ else if (isspace(c) || ispunct(c) || isdigit(c))
break;
}
c = get_text_index_whar(gtkaspell, end);
if (c == '\'') {
if (end < get_textview_buffer_charcount(gtktext)) {
- if (!isalpha(get_text_index_whar(gtkaspell,
+ if (isspace(get_text_index_whar(gtkaspell,
+ end + 1))
+ || ispunct(get_text_index_whar(gtkaspell,
+ end + 1))
+ || isdigit(get_text_index_whar(gtkaspell,
end + 1))) {
/* end_quote = TRUE; */
break;
break;
}
}
- else if(!isalpha(c))
+ else if (isspace(c) || ispunct(c) || isdigit(c))
break;
}
if (buf) {
if (end - start < buflen) {
- for (pos = start; pos < end; pos++) {
- buf[pos - start] =
- get_text_index_whar(gtkaspell, pos);
- }
- buf[pos - start] = 0;
+ GtkTextIter iterstart, iterend;
+ gchar *tmp, *conv;
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer(gtktext);
+ gtk_text_buffer_get_iter_at_offset(buffer, &iterstart, start);
+ gtk_text_buffer_get_iter_at_offset(buffer, &iterend, end);
+ tmp = gtk_text_buffer_get_text(buffer, &iterstart, &iterend, FALSE);
+ conv = conv_iconv_strdup(tmp, CS_UTF_8,
+ gtkaspell->gtkaspeller->dictionary->encoding);
+ g_free(tmp);
+ strncpy(buf, conv, buflen-1);
+ buf[buflen-1]='\0';
+ g_free(conv);
} else
return FALSE;
}
if (!get_word_from_pos(gtkaspell, from_pos, buf, sizeof(buf),
&start, &end))
return FALSE;
-
if (misspelled_test(gtkaspell, buf)) {
strncpy(gtkaspell->theword, buf, GTKASPELLWORDSIZE - 1);
gtkaspell->theword[GTKASPELLWORDSIZE - 1] = 0;
GtkAspell *gtkaspell = (GtkAspell *) data;
GdkEvent *e= (GdkEvent *) gtk_get_current_event();
- gtk_label_get(GTK_LABEL(GTK_BIN(w)->child), (gchar**) &newword);
+ newword = (unsigned char *) gtk_label_get_text(GTK_LABEL(GTK_BIN(w)->child));
+ newword = g_strdup(newword);
replace_real_word(gtkaspell, newword);
gtk_menu_shell_deactivate(GTK_MENU_SHELL(w->parent));
set_point_continue(gtkaspell);
+ g_free(newword);
}
static void replace_real_word(GtkAspell *gtkaspell, gchar *newword)
g_signal_connect(G_OBJECT(menu), "cancel",
G_CALLBACK(cancel_menu_cb), gtkaspell);
+ utf8buf = conv_codeset_strdup((unsigned char*)l->data,
+ conv_get_locale_charset_str(),
+ CS_UTF_8);
caption = g_strdup_printf(_("\"%s\" unknown in %s"),
- (unsigned char*) l->data,
+ utf8buf,
gtkaspell->gtkaspeller->dictionary->dictname);
item = gtk_menu_item_new_with_label(caption);
+ g_free(utf8buf);
gtk_widget_show(item);
gtk_menu_append(GTK_MENU(menu), item);
gtk_misc_set_alignment(GTK_MISC(GTK_BIN(item)->child), 0.5, 0.5);
conv_get_locale_charset_str(),
CS_UTF_8);
item = gtk_menu_item_new_with_label(utf8buf);
+ g_free(utf8buf);
gtk_widget_show(item);
gtk_menu_append(GTK_MENU(curmenu), item);
g_signal_connect(G_OBJECT(item), "activate",
dict == gtkaspell->alternate_speller->dictionary) {
use_alternate_dict(gtkaspell);
dictionary_delete(dict);
+ gtkaspell->alternate_speller->dictionary = NULL;
return TRUE;
}
color->blue = (int) (((gdouble) (rgbvalue & 0x0000ff) / 255.0)
* 65535.0);
- gtk_text_buffer_create_tag(buffer, "misspelled",
+ if (rgbvalue != 0)
+ gtk_text_buffer_create_tag(buffer, "misspelled",
"foreground-gdk", color, NULL);
+ else
+ gtk_text_buffer_create_tag(buffer, "misspelled",
+ "underline", PANGO_UNDERLINE_ERROR, NULL);
+
}
static void change_color(GtkAspell * gtkaspell,
GtkTextBuffer *buffer;
GtkTextIter startiter, enditer;
- g_return_if_fail(start < end);
+ if (start > end)
+ return;
gtktext = gtkaspell->gtktext;
if (color)
gtk_text_buffer_apply_tag_by_name(buffer, "misspelled",
&startiter, &enditer);
- else
+ else {
+ gtk_text_iter_forward_char(&enditer);
gtk_text_buffer_remove_tag_by_name(buffer, "misspelled",
&startiter, &enditer);
+ }
}
/* convert_to_aspell_encoding () - converts ISO-8859-* strings to iso8859-*
list = list->next)
g_free(list->data);
- g_list_free(list);
+ g_list_free(gtkaspell->suggestions_list);
gtkaspell->max_sug = -1;
gtkaspell->suggestions_list = NULL;