From 00fd59aa3904fa1af1446421ffa086e6a41768f1 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 16 Dec 2018 11:35:12 -0600 Subject: [PATCH] notifications.macos: Notifications for macOS. They don't seem to always pop up. I think the delegate needs to be set to respond to a message to always show the notification. --- extra/notifications/macos/authors.txt | 1 + extra/notifications/macos/macos.factor | 19 +++++++++++++++++++ extra/notifications/macos/platforms.txt | 1 + 3 files changed, 21 insertions(+) create mode 100644 extra/notifications/macos/authors.txt create mode 100644 extra/notifications/macos/macos.factor create mode 100644 extra/notifications/macos/platforms.txt diff --git a/extra/notifications/macos/authors.txt b/extra/notifications/macos/authors.txt new file mode 100644 index 0000000000..7c1b2f2279 --- /dev/null +++ b/extra/notifications/macos/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/extra/notifications/macos/macos.factor b/extra/notifications/macos/macos.factor new file mode 100644 index 0000000000..a2345f7b87 --- /dev/null +++ b/extra/notifications/macos/macos.factor @@ -0,0 +1,19 @@ +! Copyright (C) 2018 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: cocoa cocoa.application cocoa.classes kernel locals ; +IN: notifications.macos + +IMPORT: NSUserNotification +IMPORT: NSUserNotificationCenter + +:: make-notification ( title text -- notification ) + NSUserNotification -> alloc -> init -> autorelease + [ title -> setTitle: ] keep + [ text -> setInformativeText: ] keep ; + +: send-notification ( title text -- ) + make-notification + [ + NSUserNotificationCenter -> defaultUserNotificationCenter + ] dip + -> deliverNotification: ; diff --git a/extra/notifications/macos/platforms.txt b/extra/notifications/macos/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/extra/notifications/macos/platforms.txt @@ -0,0 +1 @@ +macosx