]> gitweb.factorcode.org Git - factor.git/commitdiff
notifications.macos: Notifications for macOS.
authorDoug Coleman <doug.coleman@gmail.com>
Sun, 16 Dec 2018 17:35:12 +0000 (11:35 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Sun, 16 Dec 2018 17:38:14 +0000 (11:38 -0600)
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 [new file with mode: 0644]
extra/notifications/macos/macos.factor [new file with mode: 0644]
extra/notifications/macos/platforms.txt [new file with mode: 0644]

diff --git a/extra/notifications/macos/authors.txt b/extra/notifications/macos/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/notifications/macos/macos.factor b/extra/notifications/macos/macos.factor
new file mode 100644 (file)
index 0000000..a2345f7
--- /dev/null
@@ -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 <NSString> -> setTitle: ] keep
+    [ text <NSString> -> 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 (file)
index 0000000..6e806f4
--- /dev/null
@@ -0,0 +1 @@
+macosx