Monday, November 08, 2010 at 12:01 AM.
system.verbs.apps.FinderMenu.commands.iconSorter
local (hdist = 100, vdist = 50);
local (ctperline = 3);
local (maxh, maxv);
on sortIcons (folder) {
local (f);
local (h = 0, v = 0);
local (ct = 0);
maxh = 0;
maxv = 0;
on bumppos () {
if ++ct >= ctperline {
h = 0;
v = v + vdist;
ct = 0}
else {
h = h + hdist};
if h > maxh {
maxh = h};
if v > maxv {
maxv = v};
msg (maxh + ", " + maxv)};
fileloop (f in folder) { <<do files first
if not file.isFolder (f) {
rollBeachball ();
file.setIconPos (f, h, v);
bumppos ()}};
fileloop (f in folder) { <<do folders second
if file.isFolder (f) {
rollBeachball ();
file.setIconPos (f, h, v);
bumppos ()}}};
<<fileloop (f in folder) <<dive into each folder
<<if file.isFolder (f)
<<sortIcons (f)
on visit (path) {
local (folder = path);
if not file.isFolder (path) {
folder = file.folderFromPath (path)};
Finder.close (folder);
clock.waitSeconds (1);
sortIcons (folder);
clock.waitSeconds (1);
Finder.open (folder);
Finder.grow (folder, maxh + hdist, maxv + (2 * vdist));
return (true)};
FinderMenu.visitPaths (@visit)
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.