如何让 Spotlight 属性显示在获取信息窗口中?

发布于 2024-09-01 15:44:18 字数 1564 浏览 1 评论 0原文

我为漫画文件创建了一个聚光灯导入器。属性已成功导入并可搜索。剩下的一件事是让属性显示在文件的获取信息窗口中。

看起来这应该是编辑 schema.xml 文件的简单问题,以便属性嵌套在 displayattrs 标记内。不幸的是,这似乎不起作用。

我简化了测试插件。以下是所有重要文件。

schema.xml

<types>
<type name="cx.c3.cbz-archive">  
    <allattrs>
        kMDItemTitle
        kMDItemAuthors
    </allattrs>
    <displayattrs>
        kMDItemTitle
        kMDItemAuthors
    </displayattrs>
    </type>
<type name="cx.c3.cbr-archive">  
    <allattrs>
        kMDItemTitle
        kMDItemAuthors
        </allattrs>
    <displayattrs>
        kMDItemTitle
        kMDItemAuthors
    </displayattrs>
</type>
</types>

GetMetadataForFile.m

Boolean GetMetadataForFile(void* thisInterface, 
                       CFMutableDictionaryRef attributes, 
                       CFStringRef contentTypeUTI,
                       CFStringRef pathToFile)
{
    NSAutoreleasePool * pool = [NSAutoreleasePool new];
    NSString * file = (NSString *)pathToFile;
    NSArray * authors = [[UKXattrMetadataStore stringForKey: @"com_opencomics_authors" atPath: file traverseLink: NO] componentsSeparatedByString: @","];
    [(NSMutableDictionary *)attributes setObject: authors forKey: (id)kMDItemAuthors];
    NSString * title = [UKXattrMetadataStore stringForKey: @"com_opencomics_title" atPath: file traverseLink: NO];
    [(NSMutableDictionary *)attributes setObject: title forKey: (id)kMDItemTitle];
    [pool release];
    return true;
}

I have created a spotlight importer for comic files. The attributes are successfully imported and searchable. The one thing that remains is getting the attributes to display in a file's get info window.

It seems that this should be a simple matter of editing the schema.xml file so the attributes are nested inside displayattrs tags. Unfortunately this does not seem to be working.

I simplified the plugin for testing. The following are all of the important files.

schema.xml

<types>
<type name="cx.c3.cbz-archive">  
    <allattrs>
        kMDItemTitle
        kMDItemAuthors
    </allattrs>
    <displayattrs>
        kMDItemTitle
        kMDItemAuthors
    </displayattrs>
    </type>
<type name="cx.c3.cbr-archive">  
    <allattrs>
        kMDItemTitle
        kMDItemAuthors
        </allattrs>
    <displayattrs>
        kMDItemTitle
        kMDItemAuthors
    </displayattrs>
</type>
</types>

GetMetadataForFile.m

Boolean GetMetadataForFile(void* thisInterface, 
                       CFMutableDictionaryRef attributes, 
                       CFStringRef contentTypeUTI,
                       CFStringRef pathToFile)
{
    NSAutoreleasePool * pool = [NSAutoreleasePool new];
    NSString * file = (NSString *)pathToFile;
    NSArray * authors = [[UKXattrMetadataStore stringForKey: @"com_opencomics_authors" atPath: file traverseLink: NO] componentsSeparatedByString: @","];
    [(NSMutableDictionary *)attributes setObject: authors forKey: (id)kMDItemAuthors];
    NSString * title = [UKXattrMetadataStore stringForKey: @"com_opencomics_title" atPath: file traverseLink: NO];
    [(NSMutableDictionary *)attributes setObject: title forKey: (id)kMDItemTitle];
    [pool release];
    return true;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜雨飘雪 2024-09-08 15:44:18

您似乎缺少 标签。编写问题时复制/粘贴错误,或者 XML 文件中也缺少该问题吗?

如果文件中缺少它,则 XML 无效。

You seem to be missing a </types> tag. Copy/paste error in writing the question, or is it missing in the XML file, too?

If it's missing in the file, the XML is invalid.

清音悠歌 2024-09-08 15:44:18

您的插件文件夹结构是什么样的?

它应该是这样的(取自 QuartzComposer),以便 Spotlight 导入程序进程找到并处理 schema.xml:

Contents
   Info.plist
   MacOS
      QuartzComposer
   Resources
      schema.xml
   version.plist

What does your plugin folder structure look like?

It should be something like this (taken from QuartzComposer) in order for the schema.xml to be found and processed by the Spotlight importer process:

Contents
   Info.plist
   MacOS
      QuartzComposer
   Resources
      schema.xml
   version.plist
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文