Gtk::FileChooserDialog + FileFilters




I'm having a bit of a problem trying to get FileFilters to work with the FilerChooserDialog.

I've created both the dialog and the filter. And set it via chooser.set_filter( filter ). The problem is that the files aren't filtered. I've managed to use the chooser.add_filter( filter ) which works in adding it to the user-selectable list of filters. Then at run time its possible to select the filter, and the list of files is filtered appropriately. This is mostly an anal retentive its not exactly right type of problem, but I was just wondering if anyone else had seen something like this. Or if I completely missed any reference to such a thing searching through the list archives.

Things I should probably mention:
Not really sure about where to get the versions, so I'm listing whats in the pkg-config files for each package.
gtkmm-2.4    2.6.2
gtk+-2.0        2.6.7

My non anal-retentive satisfying code:

<snip>
Gtk::FileChooserDialog chooser( "Open Experiment File", Gtk::FILE_CHOOSER_ACTION_OPEN ) ;
   chooser.set_transient_for( *this ) ;

   chooser.add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL ) ;
   chooser.add_button( Gtk::Stock::OPEN, Gtk::RESPONSE_OK ) ;

   Gtk::FileFilter filter ;
   filter.set_name( "XML Files" ) ;
   filter.add_mime_type( "text/xml" ) ;

//This just adds the filter to the list. There's no initial setting of the filter.
   //chooser.add_filter( filter ) ;

   chooser.set_filter( filter ) ;

   string defaultLoc = "/usr/local/data/E1001" ;

   chooser.set_filename( defaultLoc ) ;

   int result = chooser.run() ;
</snip>

Sorry to bother anyone if I'm just completely missing an old bug or something.

Paul Davis
University of Iowa



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]