application/main.c

changeset 742
f63d8125fcbd
parent 738
0dbf92544d4f
child 745
a4ee36ff7147
--- a/application/main.c	Sat Aug 30 16:39:56 2025 +0200
+++ b/application/main.c	Sat Aug 30 16:59:35 2025 +0200
@@ -434,7 +434,8 @@
 }
 
 void action_sourcelist_activate(UiEvent *event, void *userdata) {
-    printf("sourcelist %s index %d\n", event->eventdata, event->intval);
+    UiSubListEventData *eventdata = event->eventdata;
+    printf("sourcelist %s index %d\n", eventdata->row_data, event->intval);
 }
 
 void action_table_activate(UiEvent *event, void *userdata) {
@@ -451,11 +452,12 @@
 
 void* table_getvalue(void *row, int col) {
     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";
+        case 0: return ui_foldericon(16);
+        case 1: return row;
+        case 2: return (void*)(intptr_t)1234;
+        case 3: return ui_foldericon(16);
+        case 4: return ui_fileicon(16);
+        case 5: return "file";
     }
     return NULL;
 }
@@ -463,9 +465,9 @@
 UiBool table_getstyle(UiList *list, void *elm, int row, int col, void *userdata, UiTextStyle *style) {
     if(row < 2 && col != -1) {
         style->text_style = UI_TEXT_STYLE_BOLD;
-        style->fg.blue = col == 0 ? 255 : 0;
-        style->fg.green = col == 1 ? 255 : 0;
-        style->fg.red = col == 4 ? 255 : 0;
+        style->fg.blue = col == 1 ? 255 : 0;
+        style->fg.green = col == 2 ? 255 : 0;
+        style->fg.red = col == 5 ? 255 : 0;
         return TRUE;
     }
     return FALSE;
@@ -576,7 +578,7 @@
                 .onactivate = action_sourcelist_activate);
     }
     
-    ui_tabview(obj, .spacing=10, .margin=10, .tabview = UI_TABVIEW_NAVIGATION_SIDE, .varname="tabview") {
+    ui_tabview(obj, .spacing=10, .margin=10, .tabview = UI_TABVIEW_NAVIGATION_SIDE, .varname="tabview", .fill = TRUE) {
         ui_tab(obj, "Tab 0") {
             ui_vbox(obj, .fill = FALSE, .margin = 15, .spacing = 15) {
                 ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button);
@@ -636,7 +638,7 @@
             }
         }
         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);
+            UiModel *model = ui_model(obj->ctx, UI_ICON_TEXT, "col1", UI_INTEGER, "col2", UI_ICON, "col3", UI_ICON_TEXT, "col4", UI_INTEGER, "col5", -1);
             model->columnsize[0] = -1;
             ui_table(obj, .model = model, .list = doc->list2, .colspan = 2, .fill = TRUE, .contextmenu = menubuilder, .multiselection = TRUE, .fill = TRUE,
                     .getvalue = table_getvalue, .getstyle = table_getstyle,

mercurial