Gtk::FileChooser, multiple select, and select_filename



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I've found that, with a FileChooserDialog anyway, using the
select_filename method doesn't work correctly with multiple file selection
enabled.

Here's the relevant bits of code. This is how I would like the code to
work:

            $fileChooser->select_all;
            my @scanFiles = $fileChooser->get_filenames;
            my @selectedFiles = ();
            foreach (@scanFiles) {
                push(@selectedFiles, $_) if (file matches pattern);
            }
            $fileChooser->unselect_all;
            $fileChooser->select_filename ($_) foreach (@selectedFiles);

This is how I have the code working:

            $fileChooser->select_all;
            my @scanFiles = $fileChooser->get_filenames;
            my @unselectedFiles = ();
            foreach (@scanFiles) {
                push(@unselectedFiles, $_) if (file doesn't match pattern);
            }
            $fileChooser->select_all;
            $fileChooser->unselect_filename ($_) foreach (@unselectedFiles);

The second fragment works fine, but it's rather inefficient, especially
when you want to select, say, 12 files out of 200 or more. The problem
with the first fragment is that the select_filename method doesn't seem to
respect the multiple selection mode set in the FileChooser, and the result
is that the last filename to receive a select_filename event is the only
one that gets selected.

This could be a bug in gtk itself, of course. I've got Gtk 2.4.3 on my
system.
- -- 
GnuPG public key available from
http://homepage.mac.com/danflemming/gnupg_key.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Made with pgp4pine 1.76

iD8DBQFA+Wt/ER493M5r4PIRAiigAKCO8vDXYexxuzkxg3bUAI8369uyFwCfRuOc
cEbE04QVbYwa+WgVPJbn7bo=
=C7sE
-----END PGP SIGNATURE-----




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