Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Gtk::FileFilter

Reply
Thread Tools

Gtk::FileFilter

 
 
WoodHacker
Guest
Posts: n/a
 
      11-01-2006
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

 
Reply With Quote
 
 
 
 
akbarhome
Guest
Posts: n/a
 
      11-01-2006
WoodHacker wrote:
> 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


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.

 
Reply With Quote
 
 
 
 
WoodHacker
Guest
Posts: n/a
 
      11-02-2006

akbarhome wrote:
> WoodHacker wrote:
> > 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

>
> 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.


Multiple adds did the trick. Thanks...

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments