Skip to content

Commit

Permalink
mach: fix OS X notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
tamird committed Sep 26, 2015
1 parent d39c854 commit b6bbd75
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions python/servo/build_commands.py
Expand Up @@ -66,19 +66,20 @@ class FLASHWINDOW(Structure):
def notify_darwin(title, text):
try:
import Foundation
import objc

NSUserNotification = objc.lookUpClass("NSUserNotification")
NSUserNotificationCenter = objc.lookUpClass("NSUserNotificationCenter")
bundleDict = Foundation.NSBundle.mainBundle().infoDictionary()
bundleIdentifier = 'CFBundleIdentifier'
if bundleIdentifier not in bundleDict:
bundleDict[bundleIdentifier] = 'mach'

note = NSUserNotification.alloc().init()
note = Foundation.NSUserNotification.alloc().init()
note.setTitle_(title)
note.setInformativeText_(text)

now = Foundation.NSDate.dateWithTimeInterval_sinceDate_(0, Foundation.NSDate.date())
note.setDeliveryDate_(now)

centre = NSUserNotificationCenter.defaultUserNotificationCenter()
centre = Foundation.NSUserNotificationCenter.defaultUserNotificationCenter()
centre.scheduleNotification_(note)
except ImportError:
raise Exception("Please make sure that the Python pyobjc module is installed!")
Expand Down

0 comments on commit b6bbd75

Please sign in to comment.