# HG changeset patch # User Sadrul Habib Chowdhury # Date 1154921079 0 # Node ID 9c4bec886220b93e2e5185093128ba1c7400b3be # Parent c5bfede3362256227966f8865fcbf0798881348e [gaim-migrate @ 16661] Allow multi-select to work for requests. committer: Tailor Script diff -r c5bfede33622 -r 9c4bec886220 console/gntrequest.c --- a/console/gntrequest.c Mon Aug 07 02:15:58 2006 +0000 +++ b/console/gntrequest.c Mon Aug 07 03:24:39 2006 +0000 @@ -252,8 +252,27 @@ else if (type == GAIM_REQUEST_FIELD_LIST) { GntWidget *tree = field->ui_data; - gpointer data = gnt_tree_get_selection_data(GNT_TREE(tree)); - GList *list = g_list_append(NULL, data); /* XXX: Update when multi-select is allowed */ + GList *list = NULL; + + if (gaim_request_field_list_get_multi_select(field)) + { + const GList *iter; + + iter = gaim_request_field_list_get_items(field); + for (; iter; iter = iter->next) + { + const char *text = list->data; + gpointer key = gaim_request_field_list_get_data(field, text); + if (gnt_tree_get_choice(GNT_TREE(tree), key)) + list = g_list_prepend(list, key); + } + } + else + { + gpointer data = gnt_tree_get_selection_data(GNT_TREE(tree)); + list = g_list_append(list, data); + } + gaim_request_field_list_set_selected(field, list); g_list_free(list); } @@ -355,8 +374,8 @@ } else if (type == GAIM_REQUEST_FIELD_LIST) { - /* XXX: Yet to allow multi-select, because the feature is absent in GntTree */ const GList *list; + gboolean multi = gaim_request_field_list_get_multi_select(field); GntWidget *tree = gnt_tree_new(); gnt_box_add_widget(GNT_BOX(hbox), tree); field->ui_data = tree; @@ -366,10 +385,20 @@ { const char *text = list->data; gpointer key = gaim_request_field_list_get_data(field, text); - gnt_tree_add_row_after(GNT_TREE(tree), key, - gnt_tree_create_row(GNT_TREE(tree), text), NULL, NULL); - if (gaim_request_field_list_is_selected(field, text)) - gnt_tree_set_selected(GNT_TREE(tree), key); + if (multi) + { + gnt_tree_add_choice(GNT_TREE(tree), key, + gnt_tree_create_row(GNT_TREE(tree), text), NULL, NULL); + if (gaim_request_field_list_is_selected(field, text)) + gnt_tree_set_choice(GNT_TREE(tree), key, TRUE); + } + else + { + gnt_tree_add_row_after(GNT_TREE(tree), key, + gnt_tree_create_row(GNT_TREE(tree), text), NULL, NULL); + if (gaim_request_field_list_is_selected(field, text)) + gnt_tree_set_selected(GNT_TREE(tree), key); + } } } #if 0