1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-18 19:41:01 -05:00

Windows: rewrite request_file() to support Unicode.

This centralises into windows/utils/request_file.c all of the code
that deals with the OPENFILENAME structure, and decides centrally
whether to use the Unicode or ANSI version of that structure and its
associated APIs. Now the output of any request_file function is our
own 'Filename' abstract type, instead of a raw char or wchar_t buffer,
which means that _any_ file dialog can produce a full Unicode filename
if the user wants to select one - and yet, in the w32old build, they
all uniformly fall back to the ANSI version, which is the only one
that works at all pre-NT.

A side effect: I've turned the FILTER_FOO_FILES family of definitions
from platform-specific #defines into a reasonably sensible enum. This
didn't affect the GTK side of things , because I'd never got round to
figuring out how to filter a file dialog down to a subset of files in
GTK, and still haven't. So I've just moved the existing FIXME comment
from platform.h to dialog.c.
This commit is contained in:
Simon Tatham
2024-12-13 19:23:30 +00:00
parent 22dfc46fb2
commit f8e1a2b3a9
13 changed files with 442 additions and 254 deletions

View File

@ -348,21 +348,8 @@ struct dlgcontrol {
* files the file selector would do well to only show .PPK
* files (on those systems where this is the chosen
* extension).
*
* The precise contents of `filter' are platform-defined,
* unfortunately. The special value NULL means `all files'
* and is always a valid fallback.
*
* Unlike almost all strings in this structure, this value
* is NOT expected to require freeing (although of course
* you can always use ctrl_alloc if you do need to create
* one on the fly). This is because the likely mode of use
* is to define string constants in a platform-specific
* header file, and directly reference those. Or worse, a
* particular platform might choose to cast integers into
* this pointer type...
*/
FILESELECT_FILTER_TYPE filter;
FilereqFilter filter;
/*
* Some systems like to know whether a file selector is
* choosing a file to read or one to write (and possibly
@ -552,7 +539,7 @@ dlgcontrol *ctrl_draglist(struct controlset *, const char *label,
char shortcut, HelpCtx helpctx,
handler_fn handler, intorptr context);
dlgcontrol *ctrl_filesel(struct controlset *, const char *label,
char shortcut, FILESELECT_FILTER_TYPE filter,
char shortcut, FilereqFilter filter,
bool write, const char *title, HelpCtx helpctx,
handler_fn handler, intorptr context);
dlgcontrol *ctrl_fontsel(struct controlset *, const char *label,