0

In OSX 10.5+ the application icon is drawn on the miniaturized windows.

Notice "the application icon is positioned automatically in the tile".

How can I change the application icon with objective-c? Or any other methods?

admdrew
  • 3,790
  • 4
  • 27
  • 39
Noitidart
  • 35,443
  • 37
  • 154
  • 323

1 Answers1

4

You can either use -[NSApplication setApplicationIconImage:] or provide a view (like an NSImageView) to -[NSDockTile setContentView:].

DarkDust
  • 90,870
  • 19
  • 190
  • 224
  • Thanks DarkDust, if I do setapplication icon image it changes the dock icon but it doesn't change the one on the minaturized windows. Is this expected? Do you have firefox? If you you, you can install addon [DevPrefs](https://addons.mozilla.org/en-US/firefox/addon/devprefs/), open scrtachpad with Shift + F4, go to menu bar at top and set "Environment" to "Browser". Then copy this gist [HERE](https://gist.github.com/Noitidart/6e39b7a0b2c3419a1165) in and set `IMAGE_PATH` to an image on your desktop and run the script. It does `setApplicationIconImage` but it wont update the mini windows. – Noitidart Jan 16 '15 at 01:23
  • Here is image showing effect after `setApplicationIconImage` in Firefox, red arrow points to the mini icon in the mini window which remains unchanged: http://i.imgur.com/hsRTSk6.png – Noitidart Jan 16 '15 at 01:25
  • 1
    I have no idea whether this behavior is intended or not. I found a [nice demo project](https://github.com/venj/Cocoa-blog-code) (download as ZIP and open the "Play With Dock" project). I see the same behavior you describe here (and in some of your other, similar questions about this ;-) on OS X 10.10, don't know about other versions. The icon on the minimized window is always the bundle icon here. But you can _remove_ the app icon from the minimized window: `[[self.window dockTile] setShowsApplicationBadge:NO];` – DarkDust Jan 16 '15 at 08:33
  • Haha thanks nice find. There are subtle differences between my topics. Like bundle (1) icon association and then (2) forcing update on appbundle on icon change and then (3) this one which is setting the mini icon on the mini window. I tried the `[[self.window dockTile] setShowsApplicationBadge:NO];` you can see the snippet here and run same as running previous snippet, minimize a browser window that has tabs though: [GitHubGIST :: Noitidart / _ff-addon-snippet-ObjC_SetShowsApplicationBadge.js](https://gist.github.com/Noitidart/4f7b5e754d996b57ef5b) the function doesn't do anything for >=10.5 – Noitidart Jan 16 '15 at 08:40
  • I thought doing setShowsApplicationBadge to false then to true would update it but it didn't. I also then tryed to do setMiniwindowImage to something then back to nil in hopes that it would update but that also didn't update it that snippet is here: [GitHubGIST :: Noitidart /_ff-addon-snippet-ObjC_SetMiniwindowImage.js](https://gist.github.com/Noitidart/3012db7edc7d4e8c469a). :( Any other ideas you think I can try to get that sucker mini icon to update? – Noitidart Jan 16 '15 at 08:44
  • Sorry, no idea. You might want to file a bug report (Radar). – DarkDust Jan 16 '15 at 09:50