X-Git-Url: https://code.delx.au/notipod/blobdiff_plain/e596efbde0143236274c54b56eda54d99d995ef7..7e72e7071a1b8d4c8044c7673de0a310ad3a8924:/notipod_gui.py diff --git a/notipod_gui.py b/notipod_gui.py index ee97365..39d911f 100644 --- a/notipod_gui.py +++ b/notipod_gui.py @@ -48,16 +48,23 @@ class PlaylistModel(NSObject): return len(playlist.children) def outlineView_objectValueForTableColumn_byItem_(self, _, col, playlist): - col = col.identifier() if col else "playlist" + if not col: + return + col = col.identifier() if col == "selected": selected = NSApp.delegate().playlists() return playlist.pid in selected - if col == None or col == "playlist": + if col == "icon": + return NSImage.imageNamed_("playlist-" + playlist.ptype) + if col == "playlist": return playlist.name def outlineView_setObjectValue_forTableColumn_byItem_(self, _, v, col, playlist): - col = col.identifier() if col else "playlist" + if not col: + return + col = col.identifier() + if col != "selected": return @@ -111,7 +118,7 @@ class NotiPodController(NSObject): loadingLabel = objc.IBOutlet() def awakeFromNib(self): - self.gen = None + self.runningGenerator = False # Delegate methods def applicationWillFinishLaunching_(self, _): @@ -132,6 +139,8 @@ class NotiPodController(NSObject): # Utility methods def runGenerator(self, func, finish): + assert not self.runningGenerator + self.runningGenerator = True NSApp.beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo_(self.loadingSheet, self.window, None, None, None) arg = (func(), finish) self.performSelectorInBackground_withObject_(self.runGeneratorThread, arg) @@ -139,21 +148,24 @@ class NotiPodController(NSObject): def runGeneratorThread(self, (gen, finish)): pool = NSAutoreleasePool.alloc().init() for msg in gen: + if not self.runningGenerator: + break self.loadingLabel.performSelectorOnMainThread_withObject_waitUntilDone_( self.loadingLabel.setStringValue_, msg, True) self.performSelectorOnMainThread_withObject_waitUntilDone_( self.stopGenerator, finish, True) + self.runningGenerator = False del pool - + def stopGenerator(self, finish): + self.runningGenerator = False NSApp.endSheet_(self.loadingSheet) self.loadingSheet.orderOut_(self) - if finish: - finish() + finish() @objc.IBAction def doCancel_(self, sender): - self.stopGenerator(None) + self.runningGenerator = False @objc.IBAction def doSync_(self, sender):