Frage

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.

War es hilfreich?

Lösung

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;
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top