From: Miroslav Lichvar Date: Mon, 25 Mar 2013 12:38:48 +0000 (+0100) Subject: allow newtWinMenu and newtWinEntries with no buttons or items X-Git-Tag: r0-52-15~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8c73c94c9635f926f2f1c8e43e5ff7ddf48cc2a0;p=thirdparty%2Fnewt.git allow newtWinMenu and newtWinEntries with no buttons or items --- diff --git a/windows.c b/windows.c index 239fad4..f1381ae 100644 --- a/windows.c +++ b/windows.c @@ -173,7 +173,7 @@ int newtWinMenu(char * title, char * text, int suggestedWidth, int flexDown, buttons[numButtons++] = newtButton(-1, -1, buttonName); va_end(args); - buttonBar = newtCreateGrid(numButtons, 1); + buttonBar = newtCreateGrid(numButtons ? numButtons : 1, 1); for (i = 0; i < numButtons; i++) { newtGridSetField(buttonBar, i, 0, NEWT_GRID_COMPONENT, buttons[i], @@ -232,14 +232,14 @@ int newtWinEntries(char * title, char * text, int suggestedWidth, int flexDown, buttons[numButtons++] = newtButton(-1, -1, buttonName); va_end(args); - buttonBar = newtCreateGrid(numButtons, 1); + buttonBar = newtCreateGrid(numButtons ? numButtons : 1, 1); for (i = 0; i < numButtons; i++) { newtGridSetField(buttonBar, i, 0, NEWT_GRID_COMPONENT, buttons[i], i ? 1 : 0, 0, 0, 0, 0, 0); } - subgrid = newtCreateGrid(2, numItems); + subgrid = newtCreateGrid(2, numItems ? numItems : 1); for (i = 0; i < numItems; i++) { newtGridSetField(subgrid, 0, i, NEWT_GRID_COMPONENT, newtLabel(-1, -1, items[i].text), @@ -268,7 +268,8 @@ int newtWinEntries(char * title, char * text, int suggestedWidth, int flexDown, for (rc = 0; rc < numItems; rc++) *items[rc].value = strdup(*items[rc].value); - for (rc = 0; result != buttons[rc] && rc < numButtons; rc++); + for (rc = 0; rc < numButtons && result != buttons[rc]; rc++) + ; if (rc == numButtons) rc = 0; /* F12 */ else