Question

The OS X Finder previews selected documents using quicklook.

[Q] How must my app be configured to be able intercept these requests and draw the preview?

Is there any way for my app to just forward the request of one file extension to another app that already handles a similar extension?

(This would be particularly useful for previewing my Ruby dsl using the existing ruby previewer. Or .scala files using the .java previewer built into XCode, for example.)

Was it helpful?

Solution

qlmanage -p -d1 somefile.java gives:

Testing Quick Look preview with files:
    somefile.java

[DEBUG] Registering <QLGenerator Built-in 0x7fbf5b00b890> for public.image
[DEBUG] Preview test for somefile.java -- file://localhost/Users/XXX/. Content type UTI: com.sun.java-source
[DEBUG] Previewing file://localhost/Users/XXX/somefile.java. Content type UTI: com.sun.java-source. Generator used: <QLGenerator Text.qlgenerator>
[DEBUG] Loading <QLGenerator Text.qlgenerator>
[DEBUG] Previewing file://localhost/Users/XXX/somefile.java finished

Note that com.sun.java-source conforms to public.source-code which conforms to public.plain-text. Any type declared as conforming to public.plain-text will use the Text generator except if there is a more specific plugin.

The mapping file extension / content type is provided by applications (or Quick Look plugins). Look at the documentation for more info.

Notes:

  • you can't change the list of types a generator supports without modifying the plug-in itself (which is a bad idea for a built-in system generator). The mapping type -> generator is built automatically based on what the generators declare in their Info.plist.
  • if you want a type XXX to be handled by the Text generator, you have to declare XXX as conforming to public.plain-text in your application.
  • if you don't want to formally declare that XXX conforms to public.plain-text, you'll have to write a generator yourself.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top