Mercurial > pidgin
comparison finch/libgnt/gntentry.c @ 21699:760a8e024142
Emit the 'completion' signal when tab is pressed from a suggest word.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Fri, 30 Nov 2007 22:36:33 +0000 |
parents | 65f2a29617a2 |
children | c38d72677c8a |
comparison
equal
deleted
inserted
replaced
21698:1d13939502cd | 21699:760a8e024142 |
---|---|
138 } | 138 } |
139 | 139 |
140 static gboolean | 140 static gboolean |
141 complete_suggest(GntEntry *entry, const char *text) | 141 complete_suggest(GntEntry *entry, const char *text) |
142 { | 142 { |
143 gboolean changed = FALSE; | |
144 int offstart = 0, offend = 0; | 143 int offstart = 0, offend = 0; |
145 | 144 |
146 if (entry->word) { | 145 if (entry->word) { |
147 char *s = get_beginning_of_word(entry); | 146 char *s = get_beginning_of_word(entry); |
148 const char *iter = text; | 147 const char *iter = text; |
149 offstart = g_utf8_pointer_to_offset(entry->start, s); | 148 offstart = g_utf8_pointer_to_offset(entry->start, s); |
150 while (*iter && toupper(*s) == toupper(*iter)) { | 149 while (*iter && toupper(*s) == toupper(*iter)) { |
151 if (*s != *iter) | |
152 changed = TRUE; | |
153 *s++ = *iter++; | 150 *s++ = *iter++; |
154 } | 151 } |
155 if (*iter) { | 152 if (*iter) { |
156 gnt_entry_key_pressed(GNT_WIDGET(entry), iter); | 153 gnt_entry_key_pressed(GNT_WIDGET(entry), iter); |
157 changed = TRUE; | |
158 } | 154 } |
159 offend = g_utf8_pointer_to_offset(entry->start, entry->cursor); | 155 offend = g_utf8_pointer_to_offset(entry->start, entry->cursor); |
160 } else { | 156 } else { |
161 offstart = 0; | 157 offstart = 0; |
162 gnt_entry_set_text_internal(entry, text); | 158 gnt_entry_set_text_internal(entry, text); |
163 changed = TRUE; | |
164 offend = g_utf8_strlen(text, -1); | 159 offend = g_utf8_strlen(text, -1); |
165 } | 160 } |
166 | 161 |
167 if (changed) | 162 g_signal_emit(G_OBJECT(entry), signals[SIG_COMPLETION], 0, |
168 g_signal_emit(G_OBJECT(entry), signals[SIG_COMPLETION], 0, | 163 entry->start + offstart, entry->start + offend); |
169 entry->start + offstart, entry->start + offend); | |
170 update_kill_ring(entry, ENTRY_JAIL, NULL, 0); | 164 update_kill_ring(entry, ENTRY_JAIL, NULL, 0); |
171 return changed; | 165 return TRUE; |
172 } | 166 } |
173 | 167 |
174 static int | 168 static int |
175 max_common_prefix(const char *s, const char *t) | 169 max_common_prefix(const char *s, const char *t) |
176 { | 170 { |