| 21 * |
21 * |
| 22 * You should have received a copy of the GNU General Public License |
22 * You should have received a copy of the GNU General Public License |
| 23 * along with this program; if not, write to the Free Software |
23 * along with this program; if not, write to the Free Software |
| 24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 25 */ |
25 */ |
| |
26 #define _PURPLE_REQUEST_C_ |
| |
27 |
| 26 #include "internal.h" |
28 #include "internal.h" |
| 27 |
29 |
| 28 #include "notify.h" |
30 #include "notify.h" |
| 29 #include "request.h" |
31 #include "request.h" |
| 30 #include "debug.h" |
32 #include "debug.h" |
| 821 |
823 |
| 822 void |
824 void |
| 823 purple_request_field_list_add(PurpleRequestField *field, const char *item, |
825 purple_request_field_list_add(PurpleRequestField *field, const char *item, |
| 824 void *data) |
826 void *data) |
| 825 { |
827 { |
| |
828 purple_request_field_list_add_icon(field, item, NULL, data); |
| |
829 } |
| |
830 |
| |
831 void |
| |
832 purple_request_field_list_add_icon(PurpleRequestField *field, const char *item, const char* icon_path, |
| |
833 void *data) |
| |
834 { |
| 826 g_return_if_fail(field != NULL); |
835 g_return_if_fail(field != NULL); |
| 827 g_return_if_fail(item != NULL); |
836 g_return_if_fail(item != NULL); |
| 828 g_return_if_fail(data != NULL); |
837 g_return_if_fail(data != NULL); |
| 829 g_return_if_fail(field->type == PURPLE_REQUEST_FIELD_LIST); |
838 g_return_if_fail(field->type == PURPLE_REQUEST_FIELD_LIST); |
| 830 |
839 |
| |
840 if (icon_path) |
| |
841 { |
| |
842 if (field->u.list.icons == NULL) |
| |
843 { |
| |
844 GList *l; |
| |
845 for (l = field->u.list.items ; l != NULL ; l = l->next) |
| |
846 { |
| |
847 /* Order doesn't matter, because we're just |
| |
848 * filing in blank items. So, we use |
| |
849 * g_list_prepend() because it's faster. */ |
| |
850 field->u.list.icons = g_list_prepend(field->u.list.icons, NULL); |
| |
851 } |
| |
852 } |
| |
853 field->u.list.icons = g_list_append(field->u.list.icons, g_strdup(icon_path)); |
| |
854 } |
| |
855 else if (field->u.list.icons) |
| |
856 { |
| |
857 /* Keep this even with the items list. */ |
| |
858 field->u.list.icons = g_list_append(field->u.list.icons, NULL); |
| |
859 } |
| |
860 |
| 831 field->u.list.items = g_list_append(field->u.list.items, g_strdup(item)); |
861 field->u.list.items = g_list_append(field->u.list.items, g_strdup(item)); |
| 832 |
|
| 833 g_hash_table_insert(field->u.list.item_data, g_strdup(item), data); |
862 g_hash_table_insert(field->u.list.item_data, g_strdup(item), data); |
| 834 } |
863 } |
| 835 |
864 |
| 836 void |
865 void |
| 837 purple_request_field_list_add_selected(PurpleRequestField *field, const char *item) |
866 purple_request_field_list_add_selected(PurpleRequestField *field, const char *item) |
| 931 { |
960 { |
| 932 g_return_val_if_fail(field != NULL, NULL); |
961 g_return_val_if_fail(field != NULL, NULL); |
| 933 g_return_val_if_fail(field->type == PURPLE_REQUEST_FIELD_LIST, NULL); |
962 g_return_val_if_fail(field->type == PURPLE_REQUEST_FIELD_LIST, NULL); |
| 934 |
963 |
| 935 return field->u.list.items; |
964 return field->u.list.items; |
| |
965 } |
| |
966 |
| |
967 GList * |
| |
968 purple_request_field_list_get_icons(const PurpleRequestField *field) |
| |
969 { |
| |
970 g_return_val_if_fail(field != NULL, NULL); |
| |
971 g_return_val_if_fail(field->type == PURPLE_REQUEST_FIELD_LIST, NULL); |
| |
972 |
| |
973 return field->u.list.icons; |
| 936 } |
974 } |
| 937 |
975 |
| 938 PurpleRequestField * |
976 PurpleRequestField * |
| 939 purple_request_field_label_new(const char *id, const char *text) |
977 purple_request_field_label_new(const char *id, const char *text) |
| 940 { |
978 { |