ui/common/types.c

changeset 1055
02af1d4a88df
parent 1016
ccde46662db7
child 1056
541cec5e913c
equal deleted inserted replaced
1054:c08c2c9f11b3 1055:02af1d4a88df
194 } else { 194 } else {
195 return (UiListSelection){0, NULL}; 195 return (UiListSelection){0, NULL};
196 } 196 }
197 } 197 }
198 198
199 UIEXPORT void ui_list_set_selection(UiList *list, UiListSelection sel) {
200 if(list->setselection) {
201 list->setselection(list, sel);
202 }
203 }
204
199 void ui_list_addobsv(UiList *list, ui_callback f, void *data) { 205 void ui_list_addobsv(UiList *list, ui_callback f, void *data) {
200 list->observers = ui_add_observer(list->observers, f, data); 206 list->observers = ui_add_observer(list->observers, f, data);
201 } 207 }
202 208
203 void ui_list_notify(UiList *list) { 209 void ui_list_notify(UiList *list) {
787 g->set = NULL; 793 g->set = NULL;
788 g->obj = NULL; 794 g->obj = NULL;
789 } 795 }
790 796
791 797
792 UIEXPORT UiListSelection ui_list_getselection(UiList *list) { 798 UIEXPORT int ui_list_getselection(UiList *list) {
799 int selection = -1;
793 if (list->getselection) { 800 if (list->getselection) {
794 return list->getselection(list); 801 UiListSelection sel = list->getselection(list);
795 } 802 if(sel.count > 0) {
796 return (UiListSelection){ 0, NULL }; 803 selection = sel.rows[0];
804 }
805 ui_listselection_free(sel);
806 }
807 return selection;
797 } 808 }
798 809
799 UIEXPORT void ui_list_setselection(UiList *list, int index) { 810 UIEXPORT void ui_list_setselection(UiList *list, int index) {
800 if (list->setselection) { 811 if (list->setselection) {
801 UiListSelection sel = { 0, NULL }; 812 UiListSelection sel = { 0, NULL };

mercurial