Example #1
0
        void SetGtkFileFilters(FileSelector fdiag)
        {
            var list = new List <Gtk.FileFilter> ();

            Gtk.FileFilter defaultGtkFilter = null;

            foreach (var filter in data.Filters)
            {
                var gf = new Gtk.FileFilter();
                if (!string.IsNullOrEmpty(filter.Name))
                {
                    gf.Name = filter.Name;
                }
                if (filter.Patterns != null)
                {
                    foreach (var pattern in filter.Patterns)
                    {
                        gf.AddPattern(pattern);
                    }
                }
                if (filter.MimeTypes != null)
                {
                    foreach (var mimetype in filter.MimeTypes)
                    {
                        gf.AddMimeType(mimetype);
                    }
                }
                list.Add(gf);
                if (filter == DefaultFilter)
                {
                    defaultGtkFilter = gf;
                }
            }

            foreach (var filter in list)
            {
                fdiag.AddFilter(filter);
            }

            if (defaultGtkFilter != null)
            {
                fdiag.Filter = defaultGtkFilter;
            }

            fdiag.Destroyed += CaptureDefaultFilter;
        }