ui/gtk/menu.c

branch
newapi
changeset 286
f6ca4bbbe2a6
parent 284
f93c368518c0
child 287
5370ea7e45a2
--- a/ui/gtk/menu.c	Sun Jun 09 16:14:05 2024 +0200
+++ b/ui/gtk/menu.c	Sun Jun 09 16:21:51 2024 +0200
@@ -243,6 +243,7 @@
     ls->menu = GTK_MENU_SHELL(p);
     ls->index = index;
     ls->oldcount = 0;
+    ls->getvalue = il->getvalue;
     
     UiVar* var = uic_create_var(ui_global_context(), il->varname, UI_VAR_LIST);
     ls->list = var->value;
@@ -274,15 +275,19 @@
         }
     }
     
-    char *str = ui_list_first(list->list);
-    if(str) {
+    void* elm = ui_list_first(list->list);
+    if(elm) {
         GtkWidget *widget = gtk_separator_menu_item_new();
         gtk_menu_shell_insert(list->menu, widget, list->index);
         gtk_widget_show(widget);
     }
+    
+    ui_getvaluefunc getvalue = list->getvalue;
     int i = 1;
-    while(str) {
-        GtkWidget *widget = gtk_menu_item_new_with_label(str);
+    while(elm) {
+        char *label = (char*) (getvalue ? getvalue(elm, 0) : elm);
+        
+        GtkWidget *widget = gtk_menu_item_new_with_label(label);
         gtk_menu_shell_insert(list->menu, widget, list->index + i);
         gtk_widget_show(widget);
         
@@ -307,7 +312,7 @@
                 event);
         }
         
-        str = ui_list_next(list->list);
+        elm = ui_list_next(list->list);
         i++;
     }
     

mercurial