diff options
author | Guy Harris <guy@alum.mit.edu> | 2013-08-23 00:06:26 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2013-08-23 00:06:26 +0000 |
commit | 32e1523bb22a05b6595ac6451f02d9745d0376a5 (patch) | |
tree | d0adaefda6056ed8cd9a88f67864637b2fc914fe /ui/win32 | |
parent | 713012163c779528d8f2563f2444ccbf0d981eb7 (diff) |
For the Windows Open dialog for capture files, get rid of the "(*.*)" in
the "All Files" entry (the current UI guidelines from Microsoft say to
do so, and that's what Paint does, at least), and add an "All Capture
Files" entry with all the file extensions for the file types we support
(it'll pick up all text files, but there's not much we can do about
that, and it won't pick up files with *no* extension or weird
extensions, such as you might get from UN*X systems or from WinDump
commands, but at least it'll filter out some other crud).
Fix what appear to be memory leaks; that should be backported unless
I've missed something and they aren't leaks.
Fix an out-of-date comment, and add an additional comment.
svn path=/trunk/; revision=51481
Diffstat (limited to 'ui/win32')
-rw-r--r-- | ui/win32/file_dlg_win32.c | 59 |
1 files changed, 54 insertions, 5 deletions
diff --git a/ui/win32/file_dlg_win32.c b/ui/win32/file_dlg_win32.c index 955767f156..ec85cc41c1 100644 --- a/ui/win32/file_dlg_win32.c +++ b/ui/win32/file_dlg_win32.c @@ -1499,29 +1499,78 @@ append_file_type(GArray *sa, int ft) str16 = utf_8to16(description_str->str); sa = g_array_append_vals(sa, str16, (guint) strlen(description_str->str)); sa = g_array_append_val(sa, zero); + g_string_free(description_str, TRUE); str16 = utf_8to16(pattern_str->str); sa = g_array_append_vals(sa, str16, (guint) strlen(pattern_str->str)); sa = g_array_append_val(sa, zero); - + g_string_free(pattern_str, TRUE); } static TCHAR * build_file_open_type_list(void) { TCHAR *str16; int ft; - GArray* sa = g_array_new(FALSE /*zero_terminated*/, FALSE /*clear_*/,2 /*element_size*/); - guint16 zero = 0; + GArray* sa; + static const guint16 zero = 0; + GString* pattern_str; + gchar sep; + GSList *extensions_list, *extension; + /* + * Microsoft's UI guidelines say, of the file filters in open and + * save dialogs: + * + * For meta-filters, remove the file extension list to eliminate + * clutter. Examples: "All files," "All pictures," "All music," + * and "All videos." + * + * so we omit them (for "All Capture Files", the filter would be + * *really* long). On both Windows XP and Windows 7, Wordpad doesn't + * do that, but Paint does. + */ + + /* + * Array of hexadectets used as a sequence of null-terminated + * UTF-16 strings. + */ + sa = g_array_new(FALSE /*zero_terminated*/, FALSE /*clear_*/,2 /*element_size*/); /* Add the "All Files" entry. */ - str16 = utf_8to16("All Files (*.*)"); - sa = g_array_append_vals(sa, str16, (guint) strlen("All Files (*.*)")); + str16 = utf_8to16("All Files"); + sa = g_array_append_vals(sa, str16, (guint) strlen("All Files")); sa = g_array_append_val(sa, zero); str16 = utf_8to16("*.*"); sa = g_array_append_vals(sa, str16, (guint) strlen("*.*")); sa = g_array_append_val(sa, zero); + /* + * Add an "All Capture Files" entry, with all the extensions we + * know about. + */ + str16 = utf_8to16("All Capture Files"); + sa = g_array_append_vals(sa, str16, (guint) strlen("All Capture Files")); + sa = g_array_append_val(sa, zero); + + /* + * Construct its list of patterns from a list of all extensions + * we support. + */ + pattern_str = g_string_new(""); + extensions_list = wtap_get_all_file_extensions_list(); + sep = '\0'; + for (extension = extensions_list; extension != NULL; + extension = g_slist_next(extension)) { + if (sep != '\0') + g_string_append_c(pattern_str, sep); + g_string_append_printf(pattern_str, "*.%s", (char *)extension->data); + sep = ';'; + } + wtap_free_file_extensions_list(extensions_list); + str16 = utf_8to16(pattern_str->str); + sa = g_array_append_vals(sa, str16, (guint) strlen(pattern_str->str)); + sa = g_array_append_val(sa, zero); + /* Include all the file types Wireshark supports. */ for (ft = 0; ft < WTAP_NUM_FILE_TYPES; ft++) { if (ft == WTAP_FILE_UNKNOWN) |