Mercurial > dwindows
comparison mac/dw.m @ 2116:cdc5124b6525
Mac: Fix building on Mac after the notification image changes.
Implament attaching an image to the notification on Mojave and later.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 23 Jun 2020 08:39:44 +0000 |
parents | 251d050d306b |
children | 34963d1e6f62 |
comparison
equal
deleted
inserted
replaced
2115:79e5842fb609 | 2116:cdc5124b6525 |
---|---|
10845 if(notification) | 10845 if(notification) |
10846 { | 10846 { |
10847 notification.title = [NSString stringWithUTF8String:title]; | 10847 notification.title = [NSString stringWithUTF8String:title]; |
10848 if(description) | 10848 if(description) |
10849 notification.body = [NSString stringWithUTF8String:outbuf]; | 10849 notification.body = [NSString stringWithUTF8String:outbuf]; |
10850 if(imagepath) | |
10851 { | |
10852 NSURL *url = [NSURL fileURLWithPath:[NSString stringWithUTF8String:imagepath]]; | |
10853 NSError *error; | |
10854 UNNotificationAttachment *attachment = [UNNotificationAttachment attachmentWithIdentifier:@"imageID" | |
10855 URL:url | |
10856 options:nil | |
10857 error:&error]; | |
10858 if(attachment) | |
10859 notification.attachments = @[attachment]; | |
10860 } | |
10850 retval = notification; | 10861 retval = notification; |
10851 } | 10862 } |
10852 } | 10863 } |
10853 } | 10864 } |
10854 else | 10865 else |
10860 if(notification) | 10871 if(notification) |
10861 { | 10872 { |
10862 notification.title = [NSString stringWithUTF8String:title]; | 10873 notification.title = [NSString stringWithUTF8String:title]; |
10863 notification.informativeText = [NSString stringWithUTF8String:outbuf]; | 10874 notification.informativeText = [NSString stringWithUTF8String:outbuf]; |
10864 if(imagepath) | 10875 if(imagepath) |
10865 notification.contentImage = [NSImage initByReferencingFile:[NSString stringWithUTF8String:imagepath]]; | 10876 notification.contentImage = [[NSImage alloc] initWithContentsOfFile:[NSString stringWithUTF8String:imagepath]]; |
10866 retval = notification; | 10877 retval = notification; |
10867 } | 10878 } |
10868 } | 10879 } |
10869 return retval; | 10880 return retval; |
10870 #else | 10881 #else |