969 // check which elements in the list are already in the container |
969 // check which elements in the list are already in the container |
970 void *elm = list->first(list); |
970 void *elm = list->first(list); |
971 int j = 0; |
971 int j = 0; |
972 while(elm) { |
972 while(elm) { |
973 CxHashKey key = cx_hash_key(&elm, sizeof(void*)); |
973 CxHashKey key = cx_hash_key(&elm, sizeof(void*)); |
974 UiObject *item_obj = cxMapRemoveAndGet(ct->current_items, key); |
974 UiObject *item_obj = NULL; |
|
975 cxMapRemoveAndGet(ct->current_items, key, &item_obj); |
975 if(item_obj) { |
976 if(item_obj) { |
976 g_object_ref(G_OBJECT(item_obj->widget)); |
977 g_object_ref(G_OBJECT(item_obj->widget)); |
977 BOX_REMOVE(ct->widget, item_obj->widget); |
978 BOX_REMOVE(ct->widget, item_obj->widget); |
978 cxMapPut(new_items, key, item_obj); |
979 cxMapPut(new_items, key, item_obj); |
979 } |
980 } |
980 elm = list->next(list); |
981 elm = list->next(list); |
981 j++; |
982 j++; |
982 } |
983 } |
983 |
984 |
984 // ct->current_items only contains elements, that are not in the list |
985 // ct->current_items only contains elements, that are not in the list |
985 cxMapDestroy(ct->current_items); // calls destructor remove_item |
986 cxMapFree(ct->current_items); // calls destructor remove_item |
986 ct->current_items = new_items; |
987 ct->current_items = new_items; |
987 |
988 |
988 // add all items |
989 // add all items |
989 int index = 0; |
990 int index = 0; |
990 elm = list->first(list); |
991 elm = list->first(list); |
1019 } |
1020 } |
1020 } |
1021 } |
1021 |
1022 |
1022 static void destroy_itemlist_container(GtkWidget *w, UiGtkItemListContainer *container) { |
1023 static void destroy_itemlist_container(GtkWidget *w, UiGtkItemListContainer *container) { |
1023 container->remove_items = FALSE; |
1024 container->remove_items = FALSE; |
1024 cxMapDestroy(container->current_items); |
1025 cxMapFree(container->current_items); |
1025 free(container); |
1026 free(container); |
1026 } |
1027 } |
1027 |
1028 |
1028 UIWIDGET ui_itemlist_create(UiObject *obj, UiItemListContainerArgs args) { |
1029 UIWIDGET ui_itemlist_create(UiObject *obj, UiItemListContainerArgs args) { |
1029 UiObject *current = uic_current_obj(obj); |
1030 UiObject *current = uic_current_obj(obj); |