Fri, 24 Apr 2026 12:54:28 +0200
implement getvaluefunc2 for menu item lists (Motif)
| ui/gtk/menu.c | file | annotate | diff | comparison | revisions | |
| ui/motif/menu.c | file | annotate | diff | comparison | revisions |
--- a/ui/gtk/menu.c Fri Apr 24 12:52:18 2026 +0200 +++ b/ui/gtk/menu.c Fri Apr 24 12:54:28 2026 +0200 @@ -344,9 +344,10 @@ ui_getvaluefunc2 getvalue = list->getvalue; void *getvaluedata = list->getvaluedata; int i = 1; + int row = 0; while(elm) { UiBool freeResult = FALSE; - char *label = (char*) (getvalue ? getvalue(ls, elm, i, 0, getvaluedata, &freeResult) : elm); + char *label = (char*) (getvalue ? getvalue(ls, elm, row, 0, getvaluedata, &freeResult) : elm); GtkWidget *widget = gtk_menu_item_new_with_label(label); gtk_menu_shell_insert(list->menu, widget, list->index + i); @@ -375,6 +376,7 @@ elm = ui_list_next(ls); i++; + row++; if(freeResult) { free(label);
--- a/ui/motif/menu.c Fri Apr 24 12:52:18 2026 +0200 +++ b/ui/motif/menu.c Fri Apr 24 12:54:28 2026 +0200 @@ -302,11 +302,14 @@ i++; } - ui_getvaluefunc getvalue = list->getvalue; + int row = 0; + ui_getvaluefunc2 getvalue = list->getvalue; + void *getvaluedata = list->getvaluedata; int pos = list->index; while(elm) { n = 0; - char *label = (char*) (getvalue ? getvalue(elm, 0) : elm); + UiBool freeResult = FALSE; + char *label = (char*) (getvalue ? getvalue(ls, elm, row, 0, getvaluedata, &freeResult) : elm); if(label) { s = XmStringCreateLocalized(label); XtSetArg(args[n], XmNlabelString, s); n++; @@ -341,7 +344,12 @@ eventdata); } + if(freeResult) { + free(label); + } + elm = ui_list_next(ls); + row++; i++; }