--- a/application/main.c Sun Jan 05 10:30:39 2025 +0100 +++ b/application/main.c Sun Jan 05 16:44:37 2025 +0100 @@ -273,10 +273,27 @@ printf("sourcelist %s index %d\n", event->eventdata, event->intval); } +void action_table_activate(UiEvent *event, void *userdata) { + char *s = userdata; + printf("table event: %s\n", s); + UiListSelection *sel = event->eventdata; + for(int i=0;i<sel->count;i++) { + printf("%d\n", sel->rows[i]); + } + printf("\n"); +} + UiMenuBuilder *menubuilder; void* table_getvalue(void *row, int col) { - return row; + switch(col) { + case 0: return row; + case 1: return (void*)(intptr_t)1234; + case 2: return ui_foldericon(16); + case 3: return ui_fileicon(16); + case 4: return "file"; + } + return NULL; } void sourcelist_getvalue(void *sublistdata, void *rowdata, int index, UiSubListItem *item) { @@ -345,7 +362,7 @@ } ui_tabview(obj, .spacing=10, .margin=10, .tabview = UI_TABVIEW_NAVIGATION_SIDE, .varname="tabview") { - ui_tab(obj, "Tab 1") { + ui_tab(obj, "Tab 0") { ui_vbox(obj, .fill = UI_OFF, .margin = 15, .spacing = 15) { ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button); ui_togglebutton(obj, .label = "Toggle"); @@ -392,12 +409,15 @@ ui_radiobutton(obj, .label = "Radio 3", .varname = "radio"); } ui_newline(obj); - - UiModel *model = ui_model(obj->ctx, UI_STRING, "col1", -1); - model->getvalue = table_getvalue; - ui_table(obj, .model = model, .list = doc->list2, .colspan = 2, .hexpand = TRUE, .contextmenu = menubuilder); } } + ui_tab(obj, "Tab 1") { + UiModel *model = ui_model(obj->ctx, UI_STRING, "col1", UI_INTEGER, "col2", UI_ICON, "col3", UI_ICON_TEXT, "col4", UI_INTEGER, "col5", -1); + model->getvalue = table_getvalue; + ui_table(obj, .model = model, .list = doc->list2, .colspan = 2, .fill = UI_ON, .contextmenu = menubuilder, .multiselection = TRUE, + .onactivate = action_table_activate, .onactivatedata = "activate", + .onselection = action_table_activate, .onselectiondata = "selection"); + } ui_tab(obj, "Tab 2") { ui_button(obj, .label = "Button 1 Start Thread", .onclick=action_start_thread); ui_button(obj, .label = "Button 2 Notify Thread", .onclick=action_notify_thread);