Tk-JFileDialog

 view release on metacpan or  search on metacpan

lib/Tk/JFileDialog.pm  view on Meta::CPAN

	$self->{'SABox'} = $patFrame->Checkbutton(-variable => \$self->{'Configure'}{'-ShowAll'},
			-command => sub { &RescanFiles($self);}
	)->pack(@leftPack);

	### JWT:Build the Favorites Dropdown list.

	### FINALLY!!! the button frame
	my $butFrame = $self->Frame(@raised);
	$butFrame->pack(-padx => '2m', -pady => '2m', @topPack, @xfill);

	$self->{'OK'} = $butFrame->Button(-command => sub
	{
		&GetReturn($self);
	})->pack(-padx => '2m', -pady => '2m', @leftPack, @expand, @xfill);

	$self->{'Rescan'} = $butFrame->Button(-command => sub
	{
		if ($bummer && $self->{'Configure'}{'-Path'} !~ /\S/)
		{
			$self->{'Configure'}{'-Path'} = Win32::GetFullPathName($driveletter);
			$self->{'Configure'}{'-Path'} =~ s#\\#\/#g;
		}
		$self->{'Configure'}{'-Path'} = $lastPaths{$driveletter} || &cwd() || &getcwd()  if ($self->{'Configure'}{'-Path'} !~ /\S/);
		$self->{'Configure'}{'-File'} = '';
		&RescanFiles($self);
	})->pack(-padx => '2m', -pady => '2m', @leftPack, @expand, @xfill);

	$self->{'Reset'} = $butFrame->Button(
		-text => 'Reset', 
		-underline => 2,
		-command => sub
		{
			if ($bummer && $self->{'Configure'}{'-Path'} !~ /\S/)
			{
				$self->{'Configure'}{'-Path'} = Win32::GetFullPathName($driveletter);
				$self->{'Configure'}{'-Path'} =~ s#\\#\/#g;
			}
			$self->{'Configure'}{'-Path'} = &cwd() || &getcwd()  if ($self->{'Configure'}{'-Path'} !~ /\S/);
			$self->{'Configure'}{'-File'} = '';
			&RescanFiles($self, $self->{'Configure'}{'-DefaultFile'});
		}
	)->pack(-padx => '2m', -pady => '2m', @leftPack, @expand, @xfill);

	$self->{'Can'} = $butFrame->Button(-command => sub
	{
		$self->{'Retval'} = -1;
	})->pack(-padx => '2m', -pady => '2m', @leftPack, @expand, @xfill);

	$self->{'Home'} = $butFrame->Button(
		-text => 'Home', 
		-underline => 0,
		-command => sub
		{
			$self->{'Configure'}{'-Path'} = $homedir;
			if ($bummer)
			{
				$self->{'Configure'}{'-Path'} =~ s#\\#\/#g;
			}
			else
			{
				$self->{'Configure'}{'-Path'} = (getpwuid($<))[7]
						unless (!$< || $self->{'Configure'}{'-Path'});
			}
			$self->{'Configure'}{'-Path'} ||= &cwd() || &getcwd();
			if ($bummer && $self->{'Configure'}{'-Path'} =~ /^(\w\:)/)
			{
				$driveletter = $1;
				$self->{'Configure'}{'-Path'} =~ s/^(\w\:)//;  #STRANGE: PERL WOULDN'T DO THIS AS A SINGLE TEST & GRAB $1?!
			}
			&RescanFiles($self);
		}
	)->pack(-padx => '2m', -pady => '2m', @leftPack, @expand, @xfill);

	$self->{'Current'} = $butFrame->Button(
		-text => 'CWD',
		-underline => 1,
		-command => sub
		{
			$self->{'Configure'}{'-Path'} = &cwd() || &getcwd();
			&RescanFiles($self);
		}
	)->pack(-padx => '2m', -pady => '2m', @leftPack, @expand, @xfill);

#	if (-e "${homedir}/.cdout")  #SPECIAL BUTTON USED W/JFM4 FILEMANAGER:
	if ($self->_fidtest('-e', "${homedir}/.cdout"))  #SPECIAL BUTTON USED W/JFM4 FILEMANAGER:
	{
		my $cdir0 = &cwd() || &getcwd();
		my $cdir = $cdir0;
		open (CD, "${homedir}/.cdout") || last;
		$cdir = <CD>;
		chomp($cdir);
		close CD;
		if ($cdir ne $cdir0) {  #JFM4'S "CURRENT DIR" IS DIFFERENT FROM SHELL'S:
			$self->{'CDOUT'} = $butFrame->Button(
				-text => 'Cdir',
				-underline => 1,
				-command => sub
				{
					$self->{'Configure'}{'-Path'} = $cdir;
					$self->{'Configure'}{'-Path'} =~ s#\\#\/#g;
					&RescanFiles($self);
				}
			)->pack(-padx => '2m', -pady => '2m', @leftPack, @expand, @xfill);
		}
	}
}

sub RescanFiles
{
	### Fill the file and directory boxes
	my $self = shift;
	my $defaultfid = shift || '';
	my $defaultdir = '';
	my $defaultfile = '';
	my $path = $self->{'Configure'}{'-Path'};
	my $show = $self->{'Configure'}{'-ShowAll'};
	my $chdir = $self->{'Configure'}{'-ShowDirList'};
	my $chfile = $self->{'Configure'}{'-ShowFileList'};

	if ($path =~ m#^\.\.[\/\\]?$#o)
	{



( run in 0.635 second using v1.01-cache-2.11-cpan-39bf76dae61 )