#!/usr/bin/perl -w
######################################################################
# fs.pl
######################################################################
# Perl Power! - Michael Schilli 1998
######################################################################

######################################################################
# Application of the file selector
######################################################################
use Tk;                                  # include Tk package
use Fs;                                  # file selector 
use strict;

my $top = MainWindow->new();

                                         # initialize variables
chop(my $startpath = `pwd`);             # start: current path
my $fileSelected = "Nothing selected as yet";

my $uframe       = $top->Frame();        # define widgets

my $startbutton = $uframe->Button(-text => "Fileselector Startup", 
                                  -command => \&fsStartup);

my $exitbutton  = $uframe->Button(-text => "Exit", 
                            -command => sub { exit 0 } );

my $lframe       = $top->Frame(-relief, "sunken", -bd => 2);
my $fixtext      = $top->Label(-text, "Selected:");
my $label        = $lframe->Label(-textvariable, \$fileSelected);

$uframe->pack();                         # pack all
$startbutton->pack(-side => "left");
$exitbutton->pack(-side => "left");
$fixtext->pack(-side => "left");
$lframe->pack(-fill => "both", -expand => "yes", -side => "left");
$label->pack();

MainLoop;

######################################################################
# Create and activate file selektor: fsStartup();
######################################################################
sub fsStartup { 
    my $fs = Fs->new($top, \&fscallback, "Test selector");
    $fs->start($startpath);
}

######################################################################
# Callback function for OK/Cancel button: fscallback($filename);
######################################################################
sub fscallback {
    my $file = shift;

    $fileSelected = $file;
}

