mirror of
https://github.com/servo/servo.git
synced 2025-08-13 09:25:32 +01:00
Auto merge of #6506 - mt2d2:darwin_notification_imports, r=metajack
notify_darwin should trap import errors. notify_darwin should trap import errors and should provide the useful package name for the user to install. Fix for issue #6479. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6506) <!-- Reviewable:end -->
This commit is contained in:
commit
3df35c2f42
1 changed files with 14 additions and 11 deletions
|
@ -64,21 +64,24 @@ def notify_win(title, text):
|
||||||
|
|
||||||
|
|
||||||
def notify_darwin(title, text):
|
def notify_darwin(title, text):
|
||||||
import Foundation
|
try:
|
||||||
import objc
|
import Foundation
|
||||||
|
import objc
|
||||||
|
|
||||||
NSUserNotification = objc.lookUpClass("NSUserNotification")
|
NSUserNotification = objc.lookUpClass("NSUserNotification")
|
||||||
NSUserNotificationCenter = objc.lookUpClass("NSUserNotificationCenter")
|
NSUserNotificationCenter = objc.lookUpClass("NSUserNotificationCenter")
|
||||||
|
|
||||||
note = NSUserNotification.alloc().init()
|
note = 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 = NSUserNotificationCenter.defaultUserNotificationCenter()
|
||||||
centre.scheduleNotification_(note)
|
centre.scheduleNotification_(note)
|
||||||
|
except ImportError:
|
||||||
|
raise Exception("Please make sure that the Python pyobjc module is installed!")
|
||||||
|
|
||||||
|
|
||||||
def notify_build_done(elapsed):
|
def notify_build_done(elapsed):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue