Bug 994633

Summary: Wrong return value in newtWinMenu (and others)
Product: [Fedora] Fedora Reporter: bill <freestyler7>
Component: newtAssignee: Miroslav Lichvar <mlichvar>
Status: CLOSED CANTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 20CC: mlichvar
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-12-04 16:48:17 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Fix return value none

Description bill 2013-08-07 16:27:06 UTC
Description of problem:
newtWinMenu and some other convenient functions from the windows.c family, return incorrect values in my opinion.
Let's take for example: status = newtWinMenu("List", "test list", 40, 0, 0, 5, list_entries, &selection, "Ok", "Cancel", NULL);
. Displays a list of items with the NEWT_FLAG_RETURNEXIT enabled. That means, if i press enter on a list entry, it immediately returns.
The problem is that it returns with status 0. The comment on newt.h says: "Returns the button number pressed, 0 on F12"
Since both pressing enter on a list entry and pressing F12 (or other exit keys) return 0, now i have no way to differentiate them.
Pressing OK button returns 1, cancel 2 next button 3 etc.
Pressing enter on list entry should return 1 as if OK was pressed.

Version-Release number of selected component (if applicable):
newt-0.52.16


How reproducible:
Always

Steps to Reproduce:
1. Use helper function newtWinMenu to make a list component
2. Press enter to select a list entry
3. Check return value 

Actual results:
0

Expected results:
1

Additional info:
There needs to be a way to differentiate exiting or pressing enter on a list entry.
I attach a patch with a proposed situation that uses the new newtFormRun interface instead of the obsolete newtRunForm
newtWinEntries() can use the same fix as well.

Comment 1 bill 2013-08-07 16:28:01 UTC
Created attachment 783991 [details]
Fix return value

Comment 2 Fedora End Of Life 2013-09-16 16:26:45 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 20 development cycle.
Changing version to '20'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora20

Comment 3 Miroslav Lichvar 2013-10-17 10:52:49 UTC
If the application had a different button than "OK" in the first position, returning 1 when the enter key is pressed on an item in the list might not be the correct thing to do. 

I don't see an easy way how to fix this without breaking the API. Suggestions are welcome.

Comment 4 Miroslav Lichvar 2013-12-04 16:48:17 UTC
I'm closing this bug. Please reopen if you see how this can be fixed without breaking the API.