mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-13 11:38:19 +00:00
b7d452d2a0
Add libnotify support for linux client Also unify notification management Make libnotify mandatory for the client. It is installed on 100% of Arch Linux systems and on 70% of Debian systems. I'd guess the remaining Debian systems are servers. Detect dependent libraries of `libnotify` using `pkg-config`. Remove library-specific code from the game module. Decrement refcount for libnotify notification object before leaving the function.
27 lines
886 B
Objective-C
27 lines
886 B
Objective-C
#import <engine/client/notifications.h>
|
|
|
|
#import <Foundation/Foundation.h>
|
|
#import <Foundation/NSUserNotification.h>
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
void NotificationsInit()
|
|
{
|
|
}
|
|
void NotificationsUninit()
|
|
{
|
|
}
|
|
void NotificationsNotify(const char *pTitle, const char *pMessage)
|
|
{
|
|
NSString* pNsTitle = [NSString stringWithCString:pTitle encoding:NSUTF8StringEncoding];
|
|
NSString* pNsMsg = [NSString stringWithCString:pMessage encoding:NSUTF8StringEncoding];
|
|
|
|
NSUserNotification *pNotification = [[NSUserNotification alloc] autorelease];
|
|
pNotification.title = pNsTitle;
|
|
pNotification.informativeText = pNsMsg;
|
|
pNotification.soundName = NSUserNotificationDefaultSoundName;
|
|
|
|
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:pNotification];
|
|
|
|
[NSApp requestUserAttention:NSInformationalRequest]; // use NSCriticalRequest to annoy the user (doesn't stop bouncing)
|
|
}
|