patch for getOpenFile,getSaveFile and chooseDirectory
"Roland Minner" <[email protected]> Fri, 23 Mar 2007 00:26:05 +0100
| Newsgroups | gmane.comp.lang.perl.tk |
|---|---|
| Message-ID | <[email protected]> |
Hi,
i'd like to propose/submit a patch for getOpenFile, getSaveFile and chooseDirectory.
Reason:
They can only handle a path if it has the correct Format for the OS involved.
Most Perl Modules are rather flexibel concerning the format of a filepath, so it would be nice if the functions named above would also be as flexible.
For example:
Most Perl modules can handle a path like c:/WINNT, where a slash is used instead of a backslash. Some even return a mixture of both - e.g.:
use File::Find;
find(sub{print "$File::Find::name\n"}, 'c:\WINNT');
this will print a mixture of slashes an backslashes:
c:\windows/system32
getOpenFile & co will silently ignore such directories as it is an invalid path under win32, giving the impression of the option not working.
I attached a simple patch for Tk.pm (Tk-804.027_500), which would correct the path of the options -initialfile and -initialdir using File::Spec->catfile.
Regards
Roland Minner
--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/ptk
tkpatch.txt
(text/plain, 853 B)
18d17
< use File::Spec qw(catfile);
320,332c319
< sub _adapt_path_to_os
< {
< # adapting the path of -initalfile and -initialdir to the operating system
< # (like that getOpenFile(-initialdir => 'c:/WINNT') will work, as it will
< # be converted to c:\WINNT)
< my %args = @_;
< foreach my $option (qw(-initialfile -initialdir)) {
< if ($args{$option}) {
< $args{$option} = File::Spec->catfile($args{$option});
< }
< }
< return %args;
< }
---
>
335c322
< tk_getOpenFile(-parent => shift , _adapt_path_to_os(@_));
---
> tk_getOpenFile(-parent => shift,@_);
340c327
< tk_getSaveFile(-parent => shift,_adapt_path_to_os(@_));
---
> tk_getSaveFile(-parent => shift,@_);
350c337
< tk_chooseDirectory(-parent => shift,_adapt_path_to_os(@_));
---
> tk_chooseDirectory(-parent => shift,@_);