ui/gtk/list.c

changeset 683
ba226c243f3f
parent 680
a4795b40e679
child 684
3c9b430fb160
equal deleted inserted replaced
682:326e7a5122fa 683:ba226c243f3f
624 ui_update_liststore(view->liststore, list); 624 ui_update_liststore(view->liststore, list);
625 } else { 625 } else {
626 void *value = list->get(list, i); 626 void *value = list->get(list, i);
627 if(value) { 627 if(value) {
628 ObjWrapper *obj = obj_wrapper_new(value, i); 628 ObjWrapper *obj = obj_wrapper_new(value, i);
629 UiListSelection sel = list->getselection(list);
629 // TODO: if index i is selected, the selection is lost 630 // TODO: if index i is selected, the selection is lost
630 // is it possible to update the item without removing it? 631 // is it possible to update the item without removing it?
632 // workaround: save selection and reapply it
631 int count = g_list_model_get_n_items(G_LIST_MODEL(view->liststore)); 633 int count = g_list_model_get_n_items(G_LIST_MODEL(view->liststore));
632 if(count <= i) { 634 if(count <= i) {
633 g_list_store_splice(view->liststore, i, 0, (void **)&obj, 1); 635 g_list_store_splice(view->liststore, i, 0, (void **)&obj, 1);
634 } else { 636 } else {
635 g_list_store_splice(view->liststore, i, 1, (void **)&obj, 1); 637 g_list_store_splice(view->liststore, i, 1, (void **)&obj, 1);
636 } 638 }
639 if(sel.count > 0) {
640 list->setselection(list, sel);
641 }
642 ui_listselection_free(sel);
637 } 643 }
638 } 644 }
639 } 645 }
640 646
641 UiListSelection ui_listview_getselection2(UiList *list) { 647 UiListSelection ui_listview_getselection2(UiList *list) {

mercurial