19 #import <Foundation/Foundation.h>
21 #if (defined MAC_OS_X_VERSION_10_8) && (MAC_OS_X_VERSION_10_8 <= MAC_OS_X_VERSION_MAX_ALLOWED)
22 #define HAVE_NS_USER_NOTIFICATION
26 #import "Growl/Growl.h"
28 @interface WesnothGrowlDelegate : NSObject <GrowlApplicationBridgeDelegate>
31 @implementation WesnothGrowlDelegate
38 #ifdef HAVE_NS_USER_NOTIFICATION
45 #pragma clang diagnostic push
46 #pragma clang diagnostic ignored "-Wunused-parameter"
47 #ifdef HAVE_NS_USER_NOTIFICATION
50 Class appleNotificationClass = NSClassFromString(
@"NSUserNotificationCenter");
51 if (appleNotificationClass) {
52 send_cocoa_notification(owner, message);
55 send_growl_notification(owner, message, note_type);
60 #else // HAVE_NS_USER_NOTIFICATION
64 send_growl_notification(owner, message, note_type);
68 #endif //end else HAVE_NS_USER_NOTIFICATION
69 #pragma clang diagnostic pop
71 #ifdef HAVE_NS_USER_NOTIFICATION
73 NSString *title = [NSString stringWithCString:owner.c_str() encoding:NSUTF8StringEncoding];
74 NSString *description = [NSString stringWithCString:message.c_str() encoding:NSUTF8StringEncoding];
75 NSUserNotification *notification = [[NSUserNotification alloc] init];
76 notification.title = title;
77 notification.informativeText = description;
78 notification.deliveryDate = [NSDate date];
80 [[NSUserNotificationCenter defaultUserNotificationCenter] scheduleNotification:notification];
82 #endif //end HAVE_NS_USER_NOTIFICATION
86 static WesnothGrowlDelegate *delegate = nil;
88 delegate = [[WesnothGrowlDelegate alloc] init];
89 [GrowlApplicationBridge setGrowlDelegate:delegate];
92 NSString *notificationName =
@"";
95 notificationName =
@"Chat Message";
98 notificationName =
@"Turn Changed";
101 notificationName =
@"Wesnoth";
104 NSString *title = [NSString stringWithCString:owner.c_str() encoding:NSUTF8StringEncoding];
105 NSString *description = [NSString stringWithCString:message.c_str() encoding:NSUTF8StringEncoding];
106 [GrowlApplicationBridge notifyWithTitle:title
107 description:description
108 notificationName:notificationName
114 #endif //end HAVE_GROWL
117 #endif //end __APPLE__
void send_notification(const std::string &owner, const std::string &message, const desktop::notifications::type note_type)
GLsizei GLenum GLuint GLuint GLsizei char * message
GLsizei const GLcharARB ** string