Finderアイコンオーバーレイのサンプルプロジェクトは、小さくて非常に基本的ですが、実際に機能する以下の回答の例を表しています。
https://github.com/lesnie/Finder-Icon-Overlay
これはとても古いことは知っていますが、まだトピックに興味がある人もいるかもしれません(?)
Leopard(10.6)で行ったことは次のとおりです。最初に、適切なFinderのヘッダーが必要です。クラスダンプツールを使用して取得します。次に、コードをSIMBLプラグインとして記述し(その方法についてはドキュメントを参照)、いくつかのメソッドをスウィズリングします。たとえば、ListViewのアイコンの上に何かを描画するには、drawIconWithFrame:TIconAndTextCellメソッドのメソッドをオーバーライドする必要があります。
メソッドスウィズリングのコードは次のとおりです。
+ (void) Plugin_load
{
Method old, new;
Class self_class = [self class];
Class finder_class = [objc_getClass("TIconAndTextCell") class];
class_addMethod(finder_class, @selector(FT_drawIconWithFrame:),
class_getMethodImplementation(self_class, @selector(FT_drawIconWithFrame:)),"v@:{CGRect={CGPoint=dd}{CGSize=dd}}");
old = class_getInstanceMethod(finder_class, @selector(drawIconWithFrame:));
new = class_getInstanceMethod(finder_class, @selector(FT_drawIconWithFrame:));
method_exchangeImplementations(old, new);
}
「drawIconWithFrame:」メソッドを「FT_drawIconWithFrame:」メソッドでオーバーライドしています。以下は、このメソッドの実装例です。
- (void) FT_drawIconWithFrame:(struct CGRect)arg1
{
[self FT_drawIconWithFrame:arg1];
if ([self respondsToSelector:@selector(node)]) {
if ([[[[NSClassFromString(@"FINode") nodeWithFENode:[(TNodeIconAndNameCell *)self node]] fullPath] lastPathComponent] hasPrefix:@"A"])
[myPrettyIconOverlayImage drawInRect:NSMakeRect(arg1.origin.x, arg1.origin.y, arg1.size.height, arg1.size.height) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
}
}
基本的に、ファイル名が文字「A」で始まるファイルのすべてのアイコンに「myPrettyIconOverlayImage」を描画します。このロジックはあなた次第です。
この行に注意してください。[self FT_drawIconWithFrame:arg1];
これは、通常のアイコンや名前などを取得するために「スーパー」を呼び出す方法です。ループのように奇妙に見えますが、実際にはそうではありません。次に、SIMBLプラグインにラップインし、SIMBLをインストールして...実行します。
Lionの変更により、いくつかの作業を最初から行う必要があります(必要なすべての宣言を含む新しい「Finder.h」ファイルを作成し、オーバーライドする適切なクラスとメソッドを見つけます)が、この手法は引き続き機能します。
ハッピーハッキング!