soc.2008.finch: 5d89479d: Reset the wordlist if the entire text is...

sadrul at pidgin.im sadrul at pidgin.im
Tue Sep 9 22:25:23 EDT 2008


-----------------------------------------------------------------
Revision: 5d89479d6528b46fed537e8e0f3a00f15ac7e3e5
Ancestor: 234c3dbcf7bb9e267b6fb6dde1b990c74fa2d6d3
Author: sadrul at pidgin.im
Date: 2008-09-10T02:30:40
Branch: im.pidgin.soc.2008.finch
URL: http://d.pidgin.im/viewmtn/revision/info/5d89479d6528b46fed537e8e0f3a00f15ac7e3e5

Modified files:
        finch/libgnt/gntentry.c

ChangeLog: 

Reset the wordlist if the entire text is changed.

-------------- next part --------------
============================================================
--- finch/libgnt/gntentry.c	68a466383ada15cf7101c36abb4ab883d5001aa8
+++ finch/libgnt/gntentry.c	bd2ee4fd5884b198c96a46b7f2b1f834b2572e7a
@@ -1651,6 +1651,10 @@ GntWidget *gnt_entry_new(const char *tex
 	GntEntry *entry = GNT_ENTRY(widget);
 
 	gnt_entry_set_text_internal(entry, text);
+#ifdef USE_ENCHANT
+	if (text)
+		gnt_entry_parse_words(entry);
+#endif
 
 	return widget;
 }
@@ -1660,7 +1664,12 @@ gnt_entry_set_text_internal(GntEntry *en
 {
 	int len;
 	int scroll, cursor;
+	gboolean changed = FALSE;
 
+	if (strncmp(SAFE(text), entry->start, entry->end - entry->start) != 0 ||
+			(entry->end == entry->start && SAFE(text)[0] != '\0'))
+		changed = TRUE;
+
 	g_free(entry->start);
 
 	if (text && text[0])
@@ -1681,6 +1690,10 @@ gnt_entry_set_text_internal(GntEntry *en
 	if (text)
 		snprintf(entry->start, len + 1, "%s", text);
 	entry->end = entry->start + len;
+#ifdef USE_ENCHANT
+	if (changed)
+		gnt_entry_parse_words(entry);
+#endif
 
 	set_scroll_position(entry, entry->start + scroll);
 	set_cursor_position(entry, entry->end - cursor);
@@ -1858,6 +1871,8 @@ gnt_entry_parse_words(GntEntry *entry)
 		g_free(start);
 	}
 	entry->spell->word_list = NULL;
+	entry->spell->cursor_word = NULL;
+	entry->spell->scroll_word = NULL;
 
 	/* only spell check if enabled and box isn't empty */
 	if (!entry->spell->enable || (entry->start == entry->end))
@@ -1895,7 +1910,7 @@ gnt_entry_parse_words(GntEntry *entry)
 		s = g_utf8_find_next_char(e, entry->end);
 	}
 
-	return start;
+	return (entry->spell->word_list = start);
 }
 
 /* the GntEntryWord linked list operators */


More information about the Commits mailing list