Last active
August 7, 2017 01:07
-
-
Save braham-snyder/3c5213448def8f4a00a8a6c429f17784 to your computer and use it in GitHub Desktop.
merely a diff corresponding to @jaeschliman's code: https://gist.github.com/jaeschliman/8591515
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff -ur emacs-25.2-unpatched/src/nsfns.m emacs-25.2/src/nsfns.m | |
| --- emacs-25.2-unpatched/src/nsfns.m 2017-02-03 04:25:45.000000000 -0600 | |
| +++ emacs-25.2/src/nsfns.m 2017-07-14 21:04:06.000000000 -0500 | |
| @@ -2169,6 +2169,29 @@ | |
| as_script = Qnil; | |
| } | |
| +DEFUN ("ns-set-application-icon", Fns_set_application_icon, Sns_set_application_icon, 1, 1, 0, | |
| +doc: /* Set the running application's icon to PATH, | |
| +and return true, or return nil if it fails. */) | |
| + (Lisp_Object path) | |
| + { | |
| + CHECK_STRING (path); | |
| + char *s = SSDATA(path); | |
| + NSString *ns = [[NSString stringWithUTF8String:s] stringByExpandingTildeInPath]; | |
| + NSURL *url = [NSURL fileURLWithPath:ns]; | |
| + if(!url) { | |
| + NSLog(@"could not create url for path: %@", ns); | |
| + return Qnil; | |
| + } | |
| + NSImage *img = [[NSImage alloc] initWithContentsOfURL: url]; | |
| + if(!img) { | |
| + NSLog(@"could not create image from url: %@", url); | |
| + return Qnil; | |
| + } | |
| + NSLog(@"setting application icon"); | |
| + [NSApp setApplicationIconImage:img]; | |
| + return Qt; | |
| +} | |
| + | |
| DEFUN ("ns-do-applescript", Fns_do_applescript, Sns_do_applescript, 1, 1, 0, | |
| doc: /* Execute AppleScript SCRIPT and return the result. | |
| If compilation and execution are successful, the resulting script value | |
| @@ -3144,6 +3167,7 @@ | |
| defsubr (&Sns_font_name); | |
| defsubr (&Sns_list_colors); | |
| #ifdef NS_IMPL_COCOA | |
| + defsubr (&Sns_set_application_icon); | |
| defsubr (&Sns_do_applescript); | |
| #endif | |
| defsubr (&Sxw_color_defined_p); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment