mirror of
https://github.com/mpv-player/mpv
synced 2025-01-12 09:59:44 +00:00
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.
This commit is contained in:
parent
e32adef9c4
commit
9dc9254da2
@ -420,6 +420,10 @@ video/out/gl_video.c: video/out/gl_video_shaders.h
|
|||||||
video/out/gl_video_shaders.h: TOOLS/file2string.pl video/out/gl_video_shaders.glsl
|
video/out/gl_video_shaders.h: TOOLS/file2string.pl video/out/gl_video_shaders.glsl
|
||||||
./$^ >$@
|
./$^ >$@
|
||||||
|
|
||||||
|
osdep/macosx_application.m: osdep/macosx_icon.inc
|
||||||
|
osdep/macosx_icon.inc: TOOLS/file2string.pl TOOLS/osxbundle/mpv.app/Contents/Resources/icon.icns
|
||||||
|
./$^ >$@
|
||||||
|
|
||||||
video/out/x11_common.c: video/out/x11_icon.inc
|
video/out/x11_common.c: video/out/x11_icon.inc
|
||||||
video/out/x11_icon.inc: TOOLS/file2string.pl video/out/x11_icon.bin
|
video/out/x11_icon.inc: TOOLS/file2string.pl video/out/x11_icon.bin
|
||||||
./$^ >$@
|
./$^ >$@
|
||||||
@ -541,6 +545,7 @@ clean:
|
|||||||
-$(RM) demux/ebml_types.h demux/ebml_defs.c
|
-$(RM) demux/ebml_types.h demux/ebml_defs.c
|
||||||
-$(RM) video/out/gl_video_shaders.h
|
-$(RM) video/out/gl_video_shaders.h
|
||||||
-$(RM) video/out/x11_icon.inc
|
-$(RM) video/out/x11_icon.inc
|
||||||
|
-$(RM) osdep/macosx_icon.inc
|
||||||
-$(RM) sub/osd_font.h
|
-$(RM) sub/osd_font.h
|
||||||
-$(RM) player/lua/defaults.inc
|
-$(RM) player/lua/defaults.inc
|
||||||
-$(RM) player/lua/assdraw.inc
|
-$(RM) player/lua/assdraw.inc
|
||||||
|
@ -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)
|
void macosx_finder_args_preinit(int *argc, char ***argv)
|
||||||
{
|
{
|
||||||
Application *app = mpv_shared_app();
|
Application *app = mpv_shared_app();
|
||||||
@ -489,6 +504,7 @@ void macosx_finder_args_preinit(int *argc, char ***argv)
|
|||||||
*argc = cocoa_argc;
|
*argc = cocoa_argc;
|
||||||
*argv = cocoa_argv;
|
*argv = cocoa_argv;
|
||||||
} else {
|
} else {
|
||||||
|
set_application_icon(app);
|
||||||
for (int i = 0; i < *argc; i++ ) {
|
for (int i = 0; i < *argc; i++ ) {
|
||||||
NSString *arg = [NSString stringWithUTF8String:(*argv)[i]];
|
NSString *arg = [NSString stringWithUTF8String:(*argv)[i]];
|
||||||
[app.argumentsList addObject:arg];
|
[app.argumentsList addObject:arg];
|
||||||
|
@ -34,6 +34,10 @@ def build(ctx):
|
|||||||
ctx.load('waf_customizations')
|
ctx.load('waf_customizations')
|
||||||
ctx.load('generators.sources')
|
ctx.load('generators.sources')
|
||||||
|
|
||||||
|
ctx.file2string(
|
||||||
|
source = "TOOLS/osxbundle/mpv.app/Contents/Resources/icon.icns",
|
||||||
|
target = "osdep/macosx_icon.inc")
|
||||||
|
|
||||||
ctx.file2string(
|
ctx.file2string(
|
||||||
source = "video/out/x11_icon.bin",
|
source = "video/out/x11_icon.bin",
|
||||||
target = "video/out/x11_icon.inc")
|
target = "video/out/x11_icon.inc")
|
||||||
|
Loading…
Reference in New Issue
Block a user