[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Mac::Navigation glue



On the recent topic of Nav Services, I have written a "glue" for the 
Mac::Navigation" module. Name the module "NavServices.pl" and put it in your
site_perl folder. To test it, use the following script:

#!perl -w
use strict;
print &GetFiles("Select some files to open.", undef, qw[TEXT ttro]);

Here is the complete definition for the GetFiles subroutine:
&GetFiles(prompt, defaultFolder, typeList, dialogOptions);

The sub will automatically use StandardFile.pl if Nav Services are not
available.

More coming soon, stay tuned!

#!perl -w

# &GetFiles(prompt, defaultFolder, typeList, dialogOptions);

sub GetFiles {
use Mac::Navigation;
use Mac::Files;
use strict;
my($text, $default, @types, $options, $nav, $file, $numFiles, $i, @files) =
@_;
if (NavServicesAvailable && NavServicesCanRun) {
if (!defined ($options)) {$options = NavGetDefaultDialogOptions()};
$options->message($text);
$options->windowTitle($text);
$options->dialogOptionFlags(
  $options->dialogOptionFlags | kNavNoTypePopup); # Get rid of type popup
my $types = new NavTypeListHandle "McPL", [@types];
local($^W) = undef;
$nav = NavGetFile($default, $options, $types, sub {use
Mac::Events;Mac::Events::DispatchEvent($_[1]->event);});
if ($nav && $nav->file(1)) {
if (wantarray()) {
    $numFiles = $nav->count;
    for $i (1 .. $numFiles) {
        push(@files, $nav->file($i));
    }
    return @files;
} else {
    $file = $nav->file(1);
    return $file;
}
}
} else {
    require "StandardFile.pl";
    return $_ if defined($_ = StandardFile::GetFile($text, @types));
}
}

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org