mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Added result to add and remove from autocomplete
This commit is contained in:
parent
375d9336ef
commit
cac0ea0742
@ -49,15 +49,15 @@ void reset_search_attempts(void)
|
||||
p_autocomplete_reset(ac);
|
||||
}
|
||||
|
||||
void contact_list_remove(const char * const name)
|
||||
gboolean contact_list_remove(const char * const name)
|
||||
{
|
||||
p_autocomplete_remove(ac, name);
|
||||
return p_autocomplete_remove(ac, name);
|
||||
}
|
||||
|
||||
void contact_list_add(const char * const name, const char * const show,
|
||||
gboolean contact_list_add(const char * const name, const char * const show,
|
||||
const char * const status)
|
||||
{
|
||||
p_autocomplete_add(ac, p_contact_new(name, show, status));
|
||||
return p_autocomplete_add(ac, p_contact_new(name, show, status));
|
||||
}
|
||||
|
||||
GSList * get_contact_list(void)
|
||||
|
@ -30,9 +30,9 @@
|
||||
void contact_list_init(void);
|
||||
void contact_list_clear(void);
|
||||
void reset_search_attempts(void);
|
||||
void contact_list_add(const char * const name, const char * const show,
|
||||
gboolean contact_list_add(const char * const name, const char * const show,
|
||||
const char * const status);
|
||||
void contact_list_remove(const char * const name);
|
||||
gboolean contact_list_remove(const char * const name);
|
||||
GSList * get_contact_list(void);
|
||||
char * find_contact(char *search_str);
|
||||
|
||||
|
8
jabber.c
8
jabber.c
@ -335,11 +335,15 @@ static int _jabber_presence_handler(xmpp_conn_t * const conn,
|
||||
|
||||
if (strcmp(short_jid, short_from) !=0) {
|
||||
if (type == NULL) {// online
|
||||
gboolean result = contact_list_add(short_from, show_str, status_str);
|
||||
if (result) {
|
||||
win_contact_online(short_from, show_str, status_str);
|
||||
contact_list_add(short_from, show_str, status_str);
|
||||
}
|
||||
} else {// offline
|
||||
gboolean result = contact_list_remove(short_from);
|
||||
if (result) {
|
||||
win_contact_offline(short_from, show_str, status_str);
|
||||
contact_list_remove(short_from);
|
||||
}
|
||||
}
|
||||
|
||||
win_page_off();
|
||||
|
@ -89,11 +89,11 @@ void p_autocomplete_reset(PAutocomplete ac)
|
||||
}
|
||||
}
|
||||
|
||||
void p_autocomplete_add(PAutocomplete ac, void *item)
|
||||
gboolean p_autocomplete_add(PAutocomplete ac, void *item)
|
||||
{
|
||||
if (ac->items == NULL) {
|
||||
ac->items = g_slist_append(ac->items, item);
|
||||
return;
|
||||
return TRUE;
|
||||
} else {
|
||||
GSList *curr = ac->items;
|
||||
|
||||
@ -103,13 +103,13 @@ void p_autocomplete_add(PAutocomplete ac, void *item)
|
||||
if (g_strcmp0(ac->str_func(curr->data), ac->str_func(item)) > 0) {
|
||||
ac->items = g_slist_insert_before(ac->items,
|
||||
curr, item);
|
||||
return;
|
||||
return TRUE;
|
||||
|
||||
// update
|
||||
} else if (g_strcmp0(ac->str_func(curr->data), ac->str_func(item)) == 0) {
|
||||
ac->free_func(curr->data);
|
||||
curr->data = item;
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
curr = g_slist_next(curr);
|
||||
@ -118,11 +118,11 @@ void p_autocomplete_add(PAutocomplete ac, void *item)
|
||||
// hit end, append
|
||||
ac->items = g_slist_append(ac->items, item);
|
||||
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void p_autocomplete_remove(PAutocomplete ac, const char * const item)
|
||||
gboolean p_autocomplete_remove(PAutocomplete ac, const char * const item)
|
||||
{
|
||||
// reset last found if it points to the item to be removed
|
||||
if (ac->last_found != NULL)
|
||||
@ -130,7 +130,7 @@ void p_autocomplete_remove(PAutocomplete ac, const char * const item)
|
||||
ac->last_found = NULL;
|
||||
|
||||
if (!ac->items) {
|
||||
return;
|
||||
return FALSE;
|
||||
} else {
|
||||
GSList *curr = ac->items;
|
||||
|
||||
@ -140,13 +140,13 @@ void p_autocomplete_remove(PAutocomplete ac, const char * const item)
|
||||
ac->items = g_slist_remove(ac->items, curr->data);
|
||||
ac->free_func(current_item);
|
||||
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
curr = g_slist_next(curr);
|
||||
}
|
||||
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,8 @@ PAutocomplete p_obj_autocomplete_new(PStrFunc str_func, PCopyFunc copy_func,
|
||||
GDestroyNotify free_func);
|
||||
void p_autocomplete_clear(PAutocomplete ac);
|
||||
void p_autocomplete_reset(PAutocomplete ac);
|
||||
void p_autocomplete_add(PAutocomplete ac, void *item);
|
||||
void p_autocomplete_remove(PAutocomplete ac, const char * const item);
|
||||
gboolean p_autocomplete_add(PAutocomplete ac, void *item);
|
||||
gboolean p_autocomplete_remove(PAutocomplete ac, const char * const item);
|
||||
GSList * p_autocomplete_get_list(PAutocomplete ac);
|
||||
gchar * p_autocomplete_complete(PAutocomplete ac, gchar *search_str);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user