Can anyone explain to me how the Gtk::FileFilter work in a
FileChooserDialog? If I do the following, it works:
filter.add_pattern("*.rb")
However, if I try: filter.add_pattern("*.{rb, txt}") it does not
work. (As does nothing else I try)
And in the cases where it works (i.e. “*.rb”) it gets a dropdown on the
FileChooser that’s labeled “Untitled filter”. Pressing it does nothing.
Obviously, I should be able to set the filter to rows labeled “All
Files, Ruby Files, Text Files”, etc., with a default of say Ruby files
to start with.
Thanks in advanced…
Bill
WoodHacker wrote:
Obviously, I should be able to set the filter to rows labeled “All
Files, Ruby Files, Text Files”, etc., with a default of say Ruby files
to start with.
Thanks in advanced…
Bill
Haven’t use Ruby Gtk, but I have use pygtk. Because python is ruby
cousin, maybe my example in pygtk is useful to you.
# image filter
images_type = (‘rgb’, ‘gif’, ‘pbm’, ‘pgm’, ‘ppm’, ‘tiff’, ‘rast’,
‘xbm’, ‘jpeg’, ‘jpg’, ‘bmp’, ‘png’)
imagefilter = gtk.FileFilter()
for image_type in images_type:
imagefilter.add_pattern(’*.’ + image_type)
imagefilter.set_name(_(“Images”))
filechooser_dialog.add_filter(imagefilter)
# all files filter
allfilter = gtk.FileFilter()
allfilter.add_pattern("*")
allfilter.set_name(_("All files"))
filechooser_dialog.add_filter(allfilter)
My guess is you have to do once for each pattern:
filter.add_pattern(".rb")
filter.add_pattern(".txt")
My understanding is you want a filter for ruby files and text files.
The case will be different if you want to use ruby files filter and
text files filter. Notice the different.
akbarhome wrote:
FileChooser that’s labeled “Untitled filter”. Pressing it does nothing.
# image filter
allfilter.add_pattern("*")
allfilter.set_name(_(“All files”))
filechooser_dialog.add_filter(allfilter)
My guess is you have to do once for each pattern:
filter.add_pattern(".rb")
filter.add_pattern(".txt")
My understanding is you want a filter for ruby files and text files.
The case will be different if you want to use ruby files filter and
text files filter. Notice the different.
Multiple adds did the trick. Thanks…