| 945 { |
945 { |
| 946 g_list_free_full(field->u.choice.elements, (GDestroyNotify)purple_key_value_pair_free); |
946 g_list_free_full(field->u.choice.elements, (GDestroyNotify)purple_key_value_pair_free); |
| 947 } |
947 } |
| 948 else if (field->type == PURPLE_REQUEST_FIELD_LIST) |
948 else if (field->type == PURPLE_REQUEST_FIELD_LIST) |
| 949 { |
949 { |
| 950 g_list_free_full(field->u.list.items, g_free); |
950 g_list_free_full(field->u.list.items, (GDestroyNotify)purple_key_value_pair_free); |
| 951 g_list_free_full(field->u.list.selected, g_free); |
951 g_list_free_full(field->u.list.selected, g_free); |
| 952 g_hash_table_destroy(field->u.list.item_data); |
952 g_hash_table_destroy(field->u.list.item_data); |
| 953 g_hash_table_destroy(field->u.list.selected_table); |
953 g_hash_table_destroy(field->u.list.selected_table); |
| 954 } |
954 } |
| 955 else if (field->type == PURPLE_REQUEST_FIELD_DATASHEET) |
955 else if (field->type == PURPLE_REQUEST_FIELD_DATASHEET) |
| 1576 |
1576 |
| 1577 void |
1577 void |
| 1578 purple_request_field_list_add_icon(PurpleRequestField *field, const char *item, const char* icon_path, |
1578 purple_request_field_list_add_icon(PurpleRequestField *field, const char *item, const char* icon_path, |
| 1579 void *data) |
1579 void *data) |
| 1580 { |
1580 { |
| |
1581 PurpleKeyValuePair *kvp; |
| |
1582 |
| 1581 g_return_if_fail(field != NULL); |
1583 g_return_if_fail(field != NULL); |
| 1582 g_return_if_fail(item != NULL); |
1584 g_return_if_fail(item != NULL); |
| 1583 g_return_if_fail(data != NULL); |
1585 g_return_if_fail(data != NULL); |
| 1584 g_return_if_fail(field->type == PURPLE_REQUEST_FIELD_LIST); |
1586 g_return_if_fail(field->type == PURPLE_REQUEST_FIELD_LIST); |
| 1585 |
1587 |
| 1586 if (icon_path) |
1588 field->u.list.has_icons = field->u.list.has_icons || (icon_path != NULL); |
| 1587 { |
1589 kvp = purple_key_value_pair_new_full(item, g_strdup(icon_path), g_free); |
| 1588 if (field->u.list.icons == NULL) |
1590 field->u.list.items = g_list_append(field->u.list.items, kvp); |
| 1589 { |
|
| 1590 GList *l; |
|
| 1591 for (l = field->u.list.items ; l != NULL ; l = l->next) |
|
| 1592 { |
|
| 1593 /* Order doesn't matter, because we're just |
|
| 1594 * filing in blank items. So, we use |
|
| 1595 * g_list_prepend() because it's faster. */ |
|
| 1596 field->u.list.icons = g_list_prepend(field->u.list.icons, NULL); |
|
| 1597 } |
|
| 1598 } |
|
| 1599 field->u.list.icons = g_list_append(field->u.list.icons, g_strdup(icon_path)); |
|
| 1600 } |
|
| 1601 else if (field->u.list.icons) |
|
| 1602 { |
|
| 1603 /* Keep this even with the items list. */ |
|
| 1604 field->u.list.icons = g_list_append(field->u.list.icons, NULL); |
|
| 1605 } |
|
| 1606 |
|
| 1607 field->u.list.items = g_list_append(field->u.list.items, g_strdup(item)); |
|
| 1608 g_hash_table_insert(field->u.list.item_data, g_strdup(item), data); |
1591 g_hash_table_insert(field->u.list.item_data, g_strdup(item), data); |
| 1609 } |
1592 } |
| 1610 |
1593 |
| 1611 void |
1594 void |
| 1612 purple_request_field_list_add_selected(PurpleRequestField *field, const char *item) |
1595 purple_request_field_list_add_selected(PurpleRequestField *field, const char *item) |
| 1705 g_return_val_if_fail(field->type == PURPLE_REQUEST_FIELD_LIST, NULL); |
1688 g_return_val_if_fail(field->type == PURPLE_REQUEST_FIELD_LIST, NULL); |
| 1706 |
1689 |
| 1707 return field->u.list.items; |
1690 return field->u.list.items; |
| 1708 } |
1691 } |
| 1709 |
1692 |
| 1710 GList * |
1693 gboolean |
| 1711 purple_request_field_list_get_icons(const PurpleRequestField *field) |
1694 purple_request_field_list_has_icons(const PurpleRequestField *field) |
| 1712 { |
1695 { |
| 1713 g_return_val_if_fail(field != NULL, NULL); |
1696 g_return_val_if_fail(field != NULL, FALSE); |
| 1714 g_return_val_if_fail(field->type == PURPLE_REQUEST_FIELD_LIST, NULL); |
1697 g_return_val_if_fail(field->type == PURPLE_REQUEST_FIELD_LIST, FALSE); |
| 1715 |
1698 |
| 1716 return field->u.list.icons; |
1699 return field->u.list.has_icons; |
| 1717 } |
1700 } |
| 1718 |
1701 |
| 1719 PurpleRequestField * |
1702 PurpleRequestField * |
| 1720 purple_request_field_label_new(const char *id, const char *text) |
1703 purple_request_field_label_new(const char *id, const char *text) |
| 1721 { |
1704 { |