From ba1c027718cbb862a2f87a417d8bdc94a9897dcf Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 27 May 2013 17:56:06 +0000 Subject: Remove use of WINAPI macro to fix compile under MSVC. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2602 --- textscreen/txt_fileselect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'textscreen/txt_fileselect.c') diff --git a/textscreen/txt_fileselect.c b/textscreen/txt_fileselect.c index 56fa1108..6e492734 100644 --- a/textscreen/txt_fileselect.c +++ b/textscreen/txt_fileselect.c @@ -149,7 +149,7 @@ static char *ExecReadOutput(char **argv) #include #include -static BOOL WINAPI (*MyGetOpenFileName)(LPOPENFILENAME) = NULL; +static BOOL (*MyGetOpenFileName)(LPOPENFILENAME) = NULL; static LPITEMIDLIST (*MySHBrowseForFolder)(LPBROWSEINFO) = NULL; static BOOL (*MySHGetPathFromIDList)(LPITEMIDLIST, LPTSTR) = NULL; -- cgit v1.2.3 From e10af52152ba793d983497cd86d7ccc10d32a13d Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 8 Sep 2013 18:57:20 +0000 Subject: Fix file select widget to emit "changed" signal properly. Reset variable value to empty string rather than NULL if cancel is pressed in dialog (thanks Alexandre Xavier). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2638 --- textscreen/txt_fileselect.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'textscreen/txt_fileselect.c') diff --git a/textscreen/txt_fileselect.c b/textscreen/txt_fileselect.c index 6e492734..52b0dc1c 100644 --- a/textscreen/txt_fileselect.c +++ b/textscreen/txt_fileselect.c @@ -591,6 +591,16 @@ static int DoSelectFile(txt_fileselect_t *fileselect) { path = TXT_SelectFile(fileselect->prompt, fileselect->extensions); + + // Update inputbox variable. + // If cancel was pressed (ie. NULL was returned by TXT_SelectFile) + // then reset to empty string, not NULL). + + if (path == NULL) + { + path = strdup(""); + } + var = fileselect->inputbox->value; free(*var); *var = path; @@ -658,6 +668,16 @@ txt_widget_class_t txt_fileselect_class = TXT_FileSelectFocused, }; +// If the (inner) inputbox widget is changed, emit a change to the +// outer (fileselect) widget. + +static void InputBoxChanged(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(fileselect)) +{ + TXT_CAST_ARG(txt_fileselect_t, fileselect); + + TXT_EmitSignal(&fileselect->widget, "changed"); +} + txt_fileselect_t *TXT_NewFileSelector(char **variable, int size, char *prompt, char **extensions) { @@ -671,6 +691,9 @@ txt_fileselect_t *TXT_NewFileSelector(char **variable, int size, fileselect->prompt = prompt; fileselect->extensions = extensions; + TXT_SignalConnect(fileselect->inputbox, "changed", + InputBoxChanged, fileselect); + return fileselect; } -- cgit v1.2.3