Project: SWT
Bug 75906 Multiple file type filters broken in file chooser
Reported: 2004-10-08 11:01:24 | Status: resolved fixed

Currently in the file chooser implementation, filters of the form "*.jar;*.zip" are not honoured as they are on Windows. The following patch fixes this. For an example use case, see File > Import > Zip File > Browse. Index: Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java =================================================================== RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java,v retrieving revision 1.38 diff -u -r1.38 FileDialog.java --- Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java 8 Oct 2004 14:01:48 -0000 1.38 +++ Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java 8 Oct 2004 14:47:48 -0000 @@ -397,13 +397,26 @@ if (filterExtensions == null) filterExtensions = new String [0]; for (int i = 0; i < filterExtensions.length; i++) { if (filterExtensions [i] != null) { - byte [] filterString = Converter.wcsToMbcs (null, filterExtensions [i], true); + byte [] filterString; int /*long*/ filter = OS.gtk_file_filter_new (); - OS.gtk_file_filter_add_pattern (filter, filterString); if (filterNames.length > i && filterNames [i] != null) { filterString = Converter.wcsToMbcs (null, filterNames [i], true); + OS.gtk_file_filter_set_name (filter, filterString); + } else { + filterString = Converter.wcsToMbcs (null, filterExtensions [i], true); + OS.gtk_file_filter_set_name (filter, filterString); } - OS.gtk_file_filter_set_name (filter, filterString); + if (filterExtensions[i].indexOf(';') != -1) { + String [] curExtensions = filterExtensions[i].split(";"); //$NON-NLS-1$ + for (int j = 0; j < curExtensions.length; j++) { + filterString = Converter.wcsToMbcs (null, curExtensions [j], true); + OS.gtk_file_filter_add_pattern (filter, filterString); + } + } else { + filterString = Converter.wcsToMbcs (null, filterExtensions [i], true); + OS.gtk_file_filter_add_pattern (filter, filterString); + } + OS.gtk_file_chooser_add_filter (handle, filter); } }

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java