Mac OS X: Where is the Application folder's icon? - macos

Does anyone know where the icons in the Finder sidebar are located? I'd like to use that small resolution optimized Applications icon in my app, but I can't find the original anywhere.

If you want to use the icon in your source code you can get the NSImage by calling:
[[NSWorkspace sharedWorkspace] iconForFileType: NSFileTypeForHFSTypeCode(kToolbarApplicationsFolderIcon)]
You can change to kToolbar{theIcon} for getting any other icon that appears on the toolbar.

Found it.
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/SidebarApplicationsFolder.icns

Related

Get a file's icon or thumbnail

Is there a way, in OSX SDK, to represent a file in UI, by presenting its icon ?
In other words, is it possible to access the icon for a specific file, to show it in a NSImageView for example ?
PS: I'm using MonoMac, but Objective-C code will certainly help me too :)
Thanks in advance
You can use NSWorkspace's iconForFile:
e.g.:
[[NSWorkspace sharedWorkspace] iconForFile:#"/Applications/Launchpad.app"];
If you need icons for a certain file type, you can use iconForFileType:
I used this category
https://github.com/incbee/NSImage-QuickLook very helpful.

how do you put a simple banner/image in OS X app window?

In IB, I put an Image View object in app window, and dragged a tiff from the finder into that space, turned off editing, and positioned/sized the image as a header banner. Looked fine in IB, but when built and ran, ImageView object is there only as a background filled box (without my tiff).
Could someone explain what steps I am missing or point me to an existing relevant answer?
Cheers!
PS: By banner I only mean a static image, nothing to do with html, nor iOS.
Have you put the image in an NSURL or CGImage variable? I haven't worked with any of the image frameworks lately but I know that the app needs to know where the image is. That's the first thing I would look at.
I didn't know you could drag an image from the Finder into an NSImageView. What I would do is add the image to the Xcode project, so that it will be added to the built app. Then the name of the image should appear in the list of choices for the image in the IB inspector for the NSImageView.

Dynamically updating app icon in OSX

When I was using Chrome to download something in Lion, a badge with downloading progress which dynamically updates itself is shown on my dock.
How may one go about achieving that?
I think you are looking for this piece of code:
[[[NSApplication sharedApplication] dockTile] setBadgeLabel:#"My String"];
Here you can find all the information you need (it's the NSDockTile Class Reference).

How to add other application's icon to Toolbar in Cocoa?

I have a window with some content that could be previewed, mailed,...
I decided that the best way to do this is to put appropriate application icons in toolbar, namely from Mail, Preview,...
Trick is, how to do that? Is thee any way too access other's application package and have access to its icon? Or is there any other elegant way?
Code:
// Get icon
NSImage *theIcon = [[NSWorkspace sharedWorkspace] iconForFile:#"/Applications/Mail.app"];
// Display icon (irrelevant in your case)
[theIcon setSize:NSMakeSize(128, 128)];
[theImageView setImage:theIcon];
There is also one other way of doing it, especially if you are building toolbar in IB:
right-click application icon
copy it
open Preview
select New from Clipboard
You will get complete set of application icons in any size. You can export them and put them in Image Well in IB

how to add a menu into the Safari MenuBar or add a button into it's MainWindow?

I want to develop a plugin with Safari. Now I wan to make a demo for add a button into it's MainWindow or menu into it's MenuBar. I have seen to Document WebKitPluginProgTopic and the sample:/Developer/Examples/Webkit/WebKitMoviePlugIn . But they didn't tell the full process of make a plugin with safari and how to add some menu or button in the safari window . Someone can give me some advice or simple code to resolve this problem, Thank you very much!
The plug-in architecture isn't thought for enhancing the browser but to support special media formats like flash or quicktime. The problem is that the plugin is only loaded when the corresponding media type is found.
Agile Web Solutions have found a way to load the plug-in all sites in 1Password and insert code into Safari. They've documented it in their blog. For other means of injecting code have a look at this question: InputManager plug-ins in Snow Leopard.
I haven't got any experience in building menus programmatically, but it should work like this:
NSMenu *newMenu = [[[NSMenu alloc] initWithTitle:#"MyMenu"] autorelease];
NSMenu *mainMenu = [NSApp mainMenu];
[mainMenu addItem:newMenu];
Changing the windows isn't that easy. Your best guess is probably [NSApp orderedWindows], which exists only for scripting purposes, but should be usefull to your task.

Resources