From 9dc9254da25b784fe32ec6bedfc258efe2254ba5 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 14 Jan 2014 08:18:05 +0100 Subject: cocoa: add application icon to the Dock when run from CLI Application icon was added to the Dock only when run inside of a bundle. That was handled automatically by OS X using the Info.plist definition. To add the Application icon when run as a CLI program, I used the samme approach in the X11 code and loaded the icon as a static binary blob inside of mpv's binary. This is the simplest approach as it avoid headackes when relocating the binary and such. --- osdep/macosx_application.m | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'osdep') diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m index 8632cfc987..86bfc61a08 100644 --- a/osdep/macosx_application.m +++ b/osdep/macosx_application.m @@ -468,6 +468,21 @@ static bool bundle_started_from_finder(int argc, char **argv) } } +static const char macosx_icon[] = +#include "osdep/macosx_icon.inc" +; + +static void set_application_icon(NSApplication *app) +{ + NSData *icon_data = [NSData dataWithBytesNoCopy:(void *)macosx_icon + length:sizeof(macosx_icon) + freeWhenDone:NO]; + NSImage *icon = [[NSImage alloc] initWithData:icon_data]; + [app setApplicationIconImage:icon]; + [icon release]; + [icon_data release]; +} + void macosx_finder_args_preinit(int *argc, char ***argv) { Application *app = mpv_shared_app(); @@ -489,6 +504,7 @@ void macosx_finder_args_preinit(int *argc, char ***argv) *argc = cocoa_argc; *argv = cocoa_argv; } else { + set_application_icon(app); for (int i = 0; i < *argc; i++ ) { NSString *arg = [NSString stringWithUTF8String:(*argv)[i]]; [app.argumentsList addObject:arg]; -- cgit v1.2.3