File Selector

Thanks for the ointer to the Gtk2::FileChooserDialog.
I am including here a working example so that you can tell me if it is ok that 
I used the simple keywords "open", "cancel" and "accept" instead on the 
GTK_FILE_CHOOSER_ACTION_OPEN and similar constants.

If that's OK then someone might want to put in the examples directory in CVS.


use strict;
use warnings;

use Gtk2 '-init';

my $window = Gtk2::Window->new;
$window->set_title ("File Selector");
$window->signal_connect (destroy => sub { Gtk2->main_quit; });

my $button = Gtk2::Button->new("Select");
$button->signal_connect(clicked => \&file_selector);


sub file_selector {
        my $f = Gtk2::FileChooserDialog->new("FS", $window, "open",
                                "Cancel" => "cancel",
                                "OK"     => "accept",
        my $response = $f->run();
        if ("accept"  eq $response) {
                print $f->get_filename(), "\n";

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