# HG changeset patch # User Richard Laager # Date 1226830217 0 # Node ID 50dbd779f1bbdcdeb5e926e1ebd407806903db11 # Parent 245f3432a5ab9edbdb6f36e4b6c19f853e862cf6 Deprecate purple_request_field_list_add() in favor of the new purple_request_field_list_add_icon() which now works whether or not icons are being provided. diff -r 245f3432a5ab -r 50dbd779f1bb libpurple/request.c --- a/libpurple/request.c Sun Nov 16 10:06:26 2008 +0000 +++ b/libpurple/request.c Sun Nov 16 10:10:17 2008 +0000 @@ -823,14 +823,7 @@ purple_request_field_list_add(PurpleRequestField *field, const char *item, void *data) { - g_return_if_fail(field != NULL); - g_return_if_fail(item != NULL); - g_return_if_fail(data != NULL); - g_return_if_fail(field->type == PURPLE_REQUEST_FIELD_LIST); - - field->u.list.items = g_list_append(field->u.list.items, g_strdup(item)); - - g_hash_table_insert(field->u.list.item_data, g_strdup(item), data); + purple_request_field_list_add_icon(field, item, NULL, data); } void @@ -840,12 +833,30 @@ g_return_if_fail(field != NULL); g_return_if_fail(item != NULL); g_return_if_fail(data != NULL); - g_return_if_fail(icon_path != NULL); g_return_if_fail(field->type == PURPLE_REQUEST_FIELD_LIST); + if (icon_path) + { + if (field->u.list.icons == NULL) + { + GList *l; + for (l = field->u.list.items ; l != NULL ; l = l->next) + { + /* Order doesn't matter, because we're just + * filing in blank items. So, we use + * g_list_prepend() because it's faster. */ + field->u.list.icons = g_list_prepend(field->u.list.icons, NULL); + } + } + field->u.list.icons = g_list_append(field->u.list.icons, g_strdup(icon_path)); + } + else if (field->u.list.icons) + { + /* Keep this even with the items list. */ + field->u.list.icons = g_list_append(field->u.list.icons, NULL); + } + field->u.list.items = g_list_append(field->u.list.items, g_strdup(item)); - field->u.list.icons = g_list_append(field->u.list.icons, g_strdup(icon_path)); - g_hash_table_insert(field->u.list.item_data, g_strdup(item), data); } diff -r 245f3432a5ab -r 50dbd779f1bb libpurple/request.h --- a/libpurple/request.h Sun Nov 16 10:06:26 2008 +0000 +++ b/libpurple/request.h Sun Nov 16 10:10:17 2008 +0000 @@ -146,8 +146,8 @@ struct { GList *items; + GList *icons; GHashTable *item_data; - GList *icons; GList *selected; GHashTable *selected_table; @@ -914,6 +914,8 @@ * @param field The list field. * @param item The list item. * @param data The associated data. + * + * @deprecated Use purple_request_field_list_add_icon() instead. */ void purple_request_field_list_add(PurpleRequestField *field, const char *item, void *data); @@ -990,9 +992,12 @@ /** * Returns a list of icons in a list field. * + * The icons will correspond with the items, in order. + * * @param field The field. * - * @constreturn The list of icons. + * @constreturn The list of icons or @c NULL (i.e. the empty GList) if no + * items have icons. */ GList *purple_request_field_list_get_icons(const PurpleRequestField *field);