On Fri, 28 May 2021, Sven Schreiber wrote:
Am 28.05.2021 um 20:46 schrieb Allin Cottrell:
> On Fri, 28 May 2021, Sven Schreiber wrote:
>
>> The question is, how is it possible to specify one pattern which covers
>> two file extensions (*.zip and *.gfn) ? The doc just says use a glob,
>> but what exactly is supported there? Would curly braces be expected to
>> work to denote multiple patterns, like this: {*.zip,*.gfn}
>
> Not sure about that -- in fact I doubt it, a glob is not a regular
> expression -- but what I had in mind is to add two patterns to the one
> filter, as in
>
> GtkFileFilter *filt = gtk_file_filter_new();
>
> gtk_file_filter_set_name(filt, _(desc));
> gtk_file_filter_add_pattern(filt, pat1);
> gtk_file_filter_add_pattern(filt, pat2);
> gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(filesel), filt);
>
> where desc is the description, pat1 would be "*.gfn", and pat2 would
> be "*.zip".
Hm, I thought that would just create the two to-choose-from filters, but
I see that perhaps the hierarchy of what the "filter" entity is has
different semantics. Hopefully I can experiment with that a little.
A filter is one thing, a pattern is another. One filter can comprise
more than one pattern -- and it's filters, not patterns, that are
the units in the drop-down thingy.
A point I've just discovered is that if you issue a single call to
gtk_file_chooser_add_filter() you end up with a "pseudo-drop-down"
with just one entry. To suppress the drop-down you instead call
gtk_file_chooser_set_filter(). That's now in git: we "set" a filter
with the two patterns "*.gfn" and "*.zip".
But for questions and issues like these, is there a web location to
which you would point people, where the nesting or internal structure of
the gtk widgets is explained? (Because the developer reference I quoted
before does not do that.)
https://developer.gnome.org/gtk3/stable/ (or the gtk2 version) is
all you get. I find that it does mostly contain what you need to
know, though sometimes, as here, a little experimentation is needed.
Allin