diff -r c39e71be2e18 -r 867ff911492d ui/gtk/list.c --- a/ui/gtk/list.c Wed Sep 24 21:00:42 2025 +0200 +++ b/ui/gtk/list.c Wed Sep 24 21:33:33 2025 +0200 @@ -2178,7 +2178,7 @@ } } -static GtkWidget* create_listbox_row(UiListBox *listbox, UiListBoxSubList *sublist, UiSubListItem *item, int index) { +static void listbox_fill_row(UiListBox *listbox, GtkWidget *row, UiListBoxSubList *sublist, UiSubListItem *item, int index) { GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10); if(item->icon) { GtkWidget *icon = ICON_IMAGE(item->icon); @@ -2190,7 +2190,6 @@ if(item->badge) { } - GtkWidget *row = gtk_list_box_row_new(); LISTBOX_ROW_SET_CHILD(row, hbox); // signals @@ -2241,8 +2240,36 @@ event ); } +} + +static void update_sublist_item(UiListBox *listbox, UiListBoxSubList *sublist, int index) { + GtkListBoxRow *row = gtk_list_box_get_row_at_index(listbox->listbox, sublist->startpos + index); + if(!row) { + return; + } + UiList *list = sublist->var->value; + if(!list) { + return; + } - return row; + void *elm = list->get(list, index); + UiSubListItem item = { NULL, NULL, NULL, NULL, NULL, NULL }; + if(listbox->getvalue) { + listbox->getvalue(list, sublist->userdata, elm, index, &item, listbox->getvaluedata); + } else { + item.label = strdup(elm); + } + + LISTBOX_ROW_REMOVE_CHILD(row); + + listbox_fill_row(listbox, GTK_WIDGET(row), sublist, &item, index); + + // cleanup + free(item.label); + free(item.icon); + free(item.button_label); + free(item.button_icon); + free(item.badge); } void ui_listbox_update_sublist(UiListBox *listbox, UiListBoxSubList *sublist, size_t listbox_insert_index) { @@ -2289,7 +2316,8 @@ } // create listbox item - GtkWidget *row = create_listbox_row(listbox, sublist, &item, (int)index); + GtkWidget *row = gtk_list_box_row_new(); + listbox_fill_row(listbox, row, sublist, &item, (int)index); if(index == 0) { // first row in the sublist, set ui_listbox data to the row // which is then used by the headerfunc @@ -2323,14 +2351,17 @@ void ui_listbox_list_update(UiList *list, int i) { UiListBoxSubList *sublist = list->obj; - ui_listbox_update_sublist(sublist->listbox, sublist, sublist->startpos); - size_t pos = 0; - CxIterator it = cxListIterator(sublist->listbox->sublists); - cx_foreach(UiListBoxSubList *, ls, it) { - ls->startpos = pos; - pos += sublist->numitems; + if(i < 0) { + ui_listbox_update_sublist(sublist->listbox, sublist, sublist->startpos); + size_t pos = 0; + CxIterator it = cxListIterator(sublist->listbox->sublists); + cx_foreach(UiListBoxSubList *, ls, it) { + ls->startpos = pos; + pos += ls->numitems; + } + } else { + update_sublist_item(sublist->listbox, sublist, i); } - } void ui_listbox_row_activate(GtkListBox *self, GtkListBoxRow *row, gpointer user_data) {