Re: NSServices with files
Re: NSServices with files
- Subject: Re: NSServices with files
- From: Ondra Cada <email@hidden>
- Date: Fri, 3 Jun 2005 22:09:39 +0200
Chad,
On 3.6.2005, at 5:38, Chad Armstrong wrote:
Is it possible to have a service interact with a file?
Sure.
From the services I've seen so far, they only interacted with
selected text. I would like to be able to select a file, folder,
or volume in the Finder, and be able to interact with the file.
Any pasteboard type can be used (I bet your own would work too,
although I've never tried: the benefits would be self-evidently
negligible :))
What you want here is NSFilenamesPboardType. I do not know though
whether Finder supports it properly.
Also, is it possible to call a Service without having anything
selected?
Not quite. A Service can be called with no selection provided (a) the
Service registers a type in NSReturnTypes, and (b) the current
application, when selection is cleared, says through
validRequestorForSendType:returnType: that this type can be consumed.
Again, although you can do anything in (a), the (b) depends on the
current application, and I regret to say I kind of doubt Finder would
do it right. I haven't checked though; it is possible it does :)
If I have, say, a backup program, and if I select some files and
then run the Service, those files will be backed up. But if I just
run the service without having any files selected, I would want the
entire hard drive (or a set of files specified by the program) to
be backed up.
If possible at all, it would have to be the latter, since, in the
former case, you would not know *which* hard drive, would you?
Anyway, IMHO it would be better to use applescript or Automator API
or whatever to find the contents of the current Finder window and
select *it* to be backed up. That's, of course, my personal opinion
only :)
From the quick experiments I tried today, I did them under Mac OS
10.1 (I have other machines with Jaguar, Tiger, and Panther,
though), and if I remember correctly, Carbon and Cocoa programs
didn't always play well with Services.
Cocoa apps, save a preciously small number of exceptions (alas some
of them from Apple, including Xcode, which does not export
NSFilenamesPboardType from its group/file browser: fie!) support
Services well. Carbon apps, on the other hand, tend to ignore them,
alas.
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden