Crawler file icon icon (overlay icon) on mac osx> = 10.6

I am looking for a solution for overlaying icon files (icon icon) (e.g. Dropbox does this on Mac) from cocoa on mac. Does anyone know how to do this? I searched for Xcode docs and also look at scpplugins source code, which is a kind of old carbon code.

Thanks for any help

+4
source share
5 answers

Since the Finder has been redesigned in Snow Leopard, older Carbon methods will no longer work. The route I got to have icon badges in Finder includes creating a custom package that you then need to enter in Finder.

Take a look at Wolf Rentzsch mach_inject (https://github.com/rentzsch/mach_star/tree/master/mach_inject) to be able to inject a custom package into a Cocoa application.

Use the dump class to be able to look into Cocoa application header files (e.g. Finder in Snow Leopard and Lion) to get an idea of ​​what you will need to override in your own package.

+4
source

A little late, but maybe this will help someone.

I solved the same problem with the NSWorkspace class (see setIcon: forFile: options )

Main idea:

1.) Try to get a preview of the file with QLThumbnailImageCreate (if not NULL, you will get a thumbnail icon)

2.) If you didn’t receive the sketch, you will get the default OS X icon for the file (NSWorkspace iconForFile )

3.) Combine the thumbnail (or default icon) with your icon

4.) Install the new icon in the file (NSWorkspace setIcon: forFile: options )

+5
source

I know this is an old question.

Recently, there is a library that implements this functionality: https://github.com/liferay/liferay-nativity .

+1
source

NSDockTile makes this very simple:

 NSDockTile *dockTile = [NSApp dockTile]; [dockTile setBadgeLabel:@"33"]; 
0
source

You can use the following two methods to overlay icons on folders / files.

  • You can use the -setIcon: forFile: options: method in NSWorkspace if you want to change the file or folder icon in Mac OS X. However, after you apply the icon overlay with this method, the overlay is complete even if you move this file / folder outside. This may not be the exact solution.

  • Instead, use the Finder Sync Extension application (File - New - Target - Finder Sync Extension) inside your application. After creating the extension, your application does not have a direct connection for this purpose. To activate, use the AppleScript command (I don't think there is a better alternative for this.)

To activate

NSString * pluginPath = [[[NSBundle mainBundle] builtInPlugInsPath] stringByAppendingPathComponent: @ "yourextension.appex"];

NSString * pluginkitString = [NSString stringWithFormat: @ "pluginkit -e use -a \"% @ \ "", pluginPath]; system ([pluginkitString cStringUsingEncoding: NSUTF8StringEncoding]);

After activating a goal, there are several ways our application can interact with this extension. Few of them:

Using NSDistributedNotificationCenter. This class provides a way to send notifications to objects in other tasks (for example, an extension).

Another way is to use [[NSUserDefaults alloc] initWithSuiteName: @ "teamid.com.company.test"];

Both your application and the goal must have a common group identifier (for example, teamid.com.company.test). To do this, turn on "Application groups" in the "Target" - "Application groups" section and specify an identifier similar to the above (for example, "teamid.com.company.test"), were teamid - this is the identifier that you will receive from the developer's portal Apple Follow the same steps for your expansion goal.

Before you complete, make sure the extension is activated or not. To verify that go to "System Preferences" - "Extensions" - "Search for applications." This is the global point at which the user can enable / disable icon mapping for your application.

0
source

Source: https://habr.com/ru/post/900671/


All Articles