如何编写OS X Finder插件 [英] How to Write OS X Finder plugin

查看:509
本文介绍了如何编写OS X Finder插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找用于编写Mac OS X Finder插件的指南或示例代码?


  1. 将图像叠加层添加到图标

  2. 添加上下文菜单项

  3. 收听文件更改

我找到了以下两个资源: / p>



我试图查看 SCPlugin 代码

很遗憾,编程Finder插件实际上是

em>仍然需要让你的手脏的COM。如果你看一下SCPlugin项目的SCFinderPlugin子项目,你会发现它跟第一个链接中描述的技术完全相同,包括为COM设置一个vtable,编写AddRef / ReleaseRef函数等等。编写一个插件,在那里你同时管理老式的Carbon内存管理,COM风格的内存管理和Cocoa /新式Carbon内存管理,可能是一个令人难以置信的痛苦,而且完全忽视了你会在三个或更多完全不同的API中交互,具有不同的命名约定和调用语义。



在光明一面,Mac OS X 10.6 Snow Leopard中的Finder已在Cocoa中完全重写,并且来得非常优秀的插件接口。如果你幸运地处于你实际上只能瞄准雪豹的情况下,你可能应该获得ADC总裁或更高的会员资格,下载预发布版本,并编码。此外,你的插件可能不工作在10.6反正没有Cocoa重写,所以它可能是有意义的,看看雪豹在它被释放之前,无论如何。


I'm looking for a guide or sample code for writing Mac OS X Finder plugins? It would like to know how to do some simple actions:

  1. adding image overlayers to icons
  2. adding context menu items
  3. listen to file changes

I found the following two resources:

I am tempted to review the SCPlugin code, but was hoping to find an easier sample to digest.

解决方案

Sadly, programming a Finder plugin actually does still require getting your hands dirty with COM. If you look at the SCFinderPlugin subproject of the SCPlugin project, you will find that it follows exactly the same techniques outlined in your first link, including setting up a vtable for COM, writing AddRef/ReleaseRef functions, and so on. Writing a plugin, where you're simultaneously managing old-school Carbon memory management, COM-style memory management, and Cocoa/new-style Carbon memory management, can be an incredible pain—and that totally ignores the fact that you'll be interacting in three or more radically different APIs, with different naming conventions and calling semantics. Calling the situation hysterically poor would be a vast understatement.

On the bright side, the Finder in Mac OS X 10.6 Snow Leopard has been fully rewritten in Cocoa--and with that come vastly superior plugin interfaces. If you are lucky enough to be in a situation where you can actually only target Snow Leopard, you probably should grab an ADC Premier or higher membership, download the prerelease builds, and code against that. Besides, your plugin may not work on 10.6 anyway without a Cocoa rewrite, so it might make good sense to take a look at Snow Leopard before it gets released, regardless.

这篇关于如何编写OS X Finder插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆