Auto merge of #7752 - tamird:fix-osx-notifications, r=nox

mach: fix OS X notifications

Since mach now puts everything into a virtualenv, we need to set the bundle identifier to allow sending notifications.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7752)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-09-27 07:35:50 -06:00
commit a1fb8cfbb0

View file

@ -66,19 +66,20 @@ def notify_win(title, text):
def notify_darwin(title, text): def notify_darwin(title, text):
try: try:
import Foundation import Foundation
import objc
NSUserNotification = objc.lookUpClass("NSUserNotification") bundleDict = Foundation.NSBundle.mainBundle().infoDictionary()
NSUserNotificationCenter = objc.lookUpClass("NSUserNotificationCenter") bundleIdentifier = 'CFBundleIdentifier'
if bundleIdentifier not in bundleDict:
bundleDict[bundleIdentifier] = 'mach'
note = NSUserNotification.alloc().init() note = Foundation.NSUserNotification.alloc().init()
note.setTitle_(title) note.setTitle_(title)
note.setInformativeText_(text) note.setInformativeText_(text)
now = Foundation.NSDate.dateWithTimeInterval_sinceDate_(0, Foundation.NSDate.date()) now = Foundation.NSDate.dateWithTimeInterval_sinceDate_(0, Foundation.NSDate.date())
note.setDeliveryDate_(now) note.setDeliveryDate_(now)
centre = NSUserNotificationCenter.defaultUserNotificationCenter() centre = Foundation.NSUserNotificationCenter.defaultUserNotificationCenter()
centre.scheduleNotification_(note) centre.scheduleNotification_(note)
except ImportError: except ImportError:
raise Exception("Please make sure that the Python pyobjc module is installed!") raise Exception("Please make sure that the Python pyobjc module is installed!")