Re: [Pyobjc-dev] quick command-line browser utility
Brought to you by:
ronaldoussoren
From: Bob I. <bo...@re...> - 2003-09-16 22:33:42
|
On Tuesday, Sep 16, 2003, at 18:18 America/New_York, David Eppstein wrote: > Maybe someone other than me will find this useful. I got frustrated > with the inability to drag typeless and creatorless files onto my > browser; this command line utility was the result. PyObjC makes this > sort of thing almost trivial to implement. Of course it would be nicer > if it didn't delay 3 seconds before taking effect... > > > #! /usr/bin/env python > > # browse file*: open file(s) in browser > # D. Eppstein, UC Irvine, 9/16/2003 > # > # Browser hardcoded to Camino because many others can't open files... > > import AppKit > import sys > > w = AppKit.NSWorkspace.sharedWorkspace() > for file in sys.argv[1:]: > w.openFile_withApplication_(file, "Camino") Although it's a little more annoying, you could have a long-running application that's registered to open any kind of file, and have it do whatever you want with the files when dragging them to the dock icon. My LaunchServices module will let you find out all sorts of things about the file that NSWorkspace and its kin may or may not give you (the ObjC APIs are higher level than LaunchServices and may or may not wrap all of the functionality, I also don't know the ObjC APIs as well as I know LaunchServices). You could also make a contextual menu plugin that lets you ctrl-click files in finder and send them to this application (though, I can't see how one would write one of those reasonably in Python.. maybe you could, but it'd end up embedding Python in Finder and you'd have to write a C/C++ plugin anyways.. I'll have to try that and see what happens). -bob |