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

Re: [MacPerl] Modify folder sort order settings?



At 12.50 -0400 1999.05.31, Kevin van Haaren wrote:
>I sent out a CD that had a couple of hundred folders in it.  Some of the
>folders would open sorted by Date Modified, others by name.  Is there a way
>in MacPerl I can change the default settings used by the window when the
>folder is double-clicked on?  This is after the window has been opened by
>someone else, the sort order changed and then closed (so it won't inherit
>from the enclosing window).

I am not sure what you want.  You want the settings to be changed when the
window is opened?  That cannot be reasonably done, except with Folder
Actions in Mac OS 8.5.  But it can be done.  In AppleScript:

    on opening folder foo
        tell application "Finder"
            set view of window of foo to icon
        end tell
    end opening folder

I don't know of a good way to do this with MacPerl right now.  The problem
is twofold: triggering the event call ('tell app "Finder" to set view
...'), and it would have to be saved as a compiled AppleScript for Folder
Actions to recognize it.  One alternative would be:

    on opening folder foo
        tell application "MacPerl"
            Do Script {"
                use Mac::Glue ':glue';
                $f = new Mac::Glue 'Finder';
                $f->set(
                    $f->prop(view => property => window => folder => $ARGV[0]),
                    to => enum('icon')
                );
            ", foo as Text}
        end tell
    end opening folder

This does indeed work with the new Mac::Glue I just released, but it is
significantly slower, of course.  You might also be able to change the info
using Mac::Files stuff, but it would still be slower than just using
AppleScript.

But it isn't necessarily very slow ... the Glue example above takes about 2
seconds on my PowerBook G3/292.  Too slow, I think (especially when the
AppleScript version is so easy, and you are using AppleScript anyway), but
not horrendously bad.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

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