diff options
| -rw-r--r-- | SwifTools/Notifier/NotificationCenterNotifier.mm | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/SwifTools/Notifier/NotificationCenterNotifier.mm b/SwifTools/Notifier/NotificationCenterNotifier.mm index df092ff..28cacb6 100644 --- a/SwifTools/Notifier/NotificationCenterNotifier.mm +++ b/SwifTools/Notifier/NotificationCenterNotifier.mm @@ -47,18 +47,23 @@ NotificationCenterNotifier::NotificationCenterNotifier() { [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate: p->delegate.get()]; } NotificationCenterNotifier::~NotificationCenterNotifier() { [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate: nil]; p->callbacksForNotifications.clear(); } void NotificationCenterNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void ()> callback) { + std::vector<Notifier::Type> defaultTypes = getDefaultTypes(); + if (std::find(defaultTypes.begin(), defaultTypes.end(), type) == defaultTypes.end()) { + return; + } + NSUserNotification* notification = [[NSUserNotification alloc] init]; notification.title = STD2NSSTRING(typeToString(type)); notification.subtitle = STD2NSSTRING(subject); notification.informativeText = STD2NSSTRING(description); notification.contentImage = [[NSImage alloc] initWithContentsOfFile: STD2NSSTRING(picture.string())]; // The OS X Notification Center API does not allow to attach custom data, like a pointer to a callback function, // to the NSUserNotification object. Therefore we maintain a mapping from a NSUserNotification instance's identification // to their respective callbacks. |
Swift