+ def awakeFromNib(self):
+ self.handlerURL = NSUserDefaults.standardUserDefaults().stringForKey_("handlerURL")
+ self.secretKey = NSUserDefaults.standardUserDefaults().stringForKey_("secretKey")
+ if not self.handlerURL:
+ self.runConfigurationAlert_title_description_(None, "In order for PostTunes to post tracks, you must set a Handler URL. The optional Secret Key may be used by the script at the Handler URL to validate your posts.")
+ self.observeNote()
+
+ def runConfigurationAlert_title_description_(self, title, description):
+ if not title:
+ title = "PostTunes Configuration"
+ alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(title, "OK", "Quit PostTunes", None, description)
+ alert.setAccessoryView_(self.preferencesWindow.contentView().retain())
+ alert.setAlertStyle_(NSCriticalAlertStyle)
+ alertReturn = alert.runModal()
+ if alertReturn == NSAlertDefaultReturn:
+ self.handlerURL = NSUserDefaults.standardUserDefaults().stringForKey_("handlerURL")
+ if not self.handlerURL:
+ self.runConfigurationAlert_title_description_("PostTunes Handler URL Missing", "You must set a Handler URL for PostTunes to function.")
+ elif alertReturn == NSAlertAlternateReturn:
+ AppHelper.stopEventLoop()
+