sort channel user list by op and alphabetical
Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
parent
4e7f0a85f4
commit
5135603dcc
|
@ -147,6 +147,32 @@ _cb_userlist_go(void *data, Evas_Object *obj EINA_UNUSED, const char *sig EINA_U
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_cb_userlist_compare(const void *data1, const void *data2)
|
||||
{
|
||||
const char *label1, *label2;
|
||||
const Elm_Object_Item *item1, *item2;
|
||||
const Evas_Object *icon1, *icon2;
|
||||
|
||||
item1 = data1;
|
||||
item2 = data2;
|
||||
|
||||
label1 = elm_object_item_text_get(item1);
|
||||
label2 = elm_object_item_text_get(item2);
|
||||
|
||||
icon1 = elm_object_item_part_content_get(item1, "elm.swallow.icon");
|
||||
icon2 = elm_object_item_part_content_get(item2, "elm.swallow.icon");
|
||||
|
||||
if ((icon1) && (icon2))
|
||||
return strcasecmp(label1, label2);
|
||||
else if ((icon1) && (!icon2))
|
||||
return 1;
|
||||
else if ((!icon1) && (icon2))
|
||||
return 1;
|
||||
|
||||
return strcasecmp(label1, label2);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_options_done(void *data)
|
||||
{
|
||||
|
@ -646,7 +672,8 @@ void
|
|||
_channel_userlist_user_append(Channel *chl, const char *user, Eina_Bool op)
|
||||
{
|
||||
if (!op)
|
||||
elm_list_item_append(chl->userlist.o_list, user, NULL, NULL, NULL, NULL);
|
||||
elm_list_item_sorted_insert(chl->userlist.o_list, user, NULL, NULL,
|
||||
NULL, NULL, _cb_userlist_compare);
|
||||
else
|
||||
{
|
||||
Evas_Object *icon;
|
||||
|
@ -662,7 +689,8 @@ _channel_userlist_user_append(Channel *chl, const char *user, Eina_Bool op)
|
|||
elm_image_file_set(icon, buff, NULL);
|
||||
evas_object_show(icon);
|
||||
|
||||
elm_list_item_append(chl->userlist.o_list, user, icon, NULL, NULL, NULL);
|
||||
elm_list_item_sorted_insert(chl->userlist.o_list, user, icon, NULL,
|
||||
NULL, NULL, _cb_userlist_compare);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue