#!/usr/bin/perl -w
######################################################################
# (c) Michael Schilli 1999
######################################################################

###############################################################
# Anwendung des File-Selektors
###############################################################
use Tk;                              # Tk package einbinden
use Fs;                              # Fileselektor 
use strict;


my $top = MainWindow->new();

                                     # Variablen initialisieren
chop(my $startpath = `pwd`);         # Start: aktueller Pfad
my $fileSelected = "Noch nichts ausgewählt";

my $uframe       = $top->Frame();    # Widgets definieren

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();                         # Alles packen
$startbutton->pack(-side => "left");
$exitbutton->pack(-side => "left");
$fixtext->pack(-side => "left");
$lframe->pack(-fill => "both", -expand => "yes", 
              -side => "left");
$label->pack();

MainLoop;

###############################################################
# File-Selektor erzeugen und aktivieren: fsStartup();
###############################################################
sub fsStartup { 
    my $fs = Fs->new($top, \&fsCallback, "Test-Selektor");
    $fs->start($startpath);
}

###############################################################
# Callback-Funktion Ok/Cancel Button: fsCallback($filename);
###############################################################
sub fsCallback {
    my $file = shift;

    $fileSelected = $file;
}
