Added autocompletion for form text-multi values

This commit is contained in:
James Booth
2014-09-17 23:21:14 +01:00
parent fa7b6f3000
commit 45ba6f1fed
3 changed files with 40 additions and 11 deletions

View File

@@ -115,20 +115,22 @@ autocomplete_add(Autocomplete ac, const char *item)
void
autocomplete_remove(Autocomplete ac, const char * const item)
{
GSList *curr = g_slist_find_custom(ac->items, item, (GCompareFunc)strcmp);
if (ac != NULL) {
GSList *curr = g_slist_find_custom(ac->items, item, (GCompareFunc)strcmp);
if (!curr) {
return;
if (!curr) {
return;
}
// reset last found if it points to the item to be removed
if (ac->last_found == curr) {
ac->last_found = NULL;
}
free(curr->data);
ac->items = g_slist_delete_link(ac->items, curr);
}
// reset last found if it points to the item to be removed
if (ac->last_found == curr) {
ac->last_found = NULL;
}
free(curr->data);
ac->items = g_slist_delete_link(ac->items, curr);
return;
}