问题
I want to display only image files in GTK# File Chooser
fc.SelectMultiple = true;
FileFilter filter = new FileFilter();
filter.Name = "Image files";
filter.AddPattern ("*.jpg;*.jpeg;*.png;*.tif;*.bmp;*.gif;*.tiff");
fc.Filter = filter;
This does not work.The file chooser does not show any Files. Can someone suggest me a proper way to do this.
回答1:
As shown in the sample from the docs, the AddPattern method is meant for adding a single pattern at a time. In contrast to the WinForms implementation and similar implementations, it does not set all patterns at a time, instead it adds one additional pattern to whatever has been added before.
Therefore, try splitting up your command:
fc.SelectMultiple = true;
FileFilter filter = new FileFilter();
filter.Name = "Image files";
filter.AddPattern("*.jpg");
filter.AddPattern("*.jpeg");
filter.AddPattern("*.png");
filter.AddPattern("*.tif");
filter.AddPattern("*.bmp");
filter.AddPattern("*.gif");
filter.AddPattern("*.tiff");
fc.Filter = filter;
来源:https://stackoverflow.com/questions/23495203/gtk-multiple-file-filter