]> code.delx.au - notipod/blobdiff - NotiPod.py
Win!
[notipod] / NotiPod.py
index df65459724b4f0a44deaeb8253bd1338498efd8a..b844b34409d71b84976e32b2cb344ba8505a0dde 100644 (file)
@@ -113,7 +113,10 @@ class NotiPodAppDelegate(NSObject):
 
        def applicationDidFinishLaunching_(self, _):
                NSApp.beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo_(self.loadingSheet, self.window, None, None, None)
-               self.performSelectorInBackground_withObject_(self.loadFromThread, None)
+               self.library = libsyncitunes.ITunesLibrary.alloc().init()
+               self.playlistModel.setPlaylists(self.library.get_playlists())
+               NSApp.endSheet_(self.loadingSheet)
+               self.loadingSheet.orderOut_(self)
 
        def applicationWillTerminate_(self, _):
                self.prefs().synchronize()
@@ -121,25 +124,9 @@ class NotiPodAppDelegate(NSObject):
        def applicationShouldTerminateAfterLastWindowClosed_(self, _):
                return True
 
-
-       def loadFromThread(self):
-               pool = NSAutoreleasePool.alloc().init()
-               self.library = libsyncitunes.ITunesLibrary.alloc().init()
-               self.performSelectorOnMainThread_withObject_waitUntilDone_(self.finishLoading, None, True)
-               del pool
-
-       def finishLoading(self):
-               self.playlistModel.setPlaylists(self.library.get_playlists())
-               NSApp.endSheet_(self.loadingSheet)
-               self.loadingSheet.close()
-
        @objc.IBAction
        def doSync_(self, sender):
                NSApp.beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo_(self.synchronizingSheet, self.window, None, None, None)
-               self.performSelectorInBackground_withObject_(self.syncFromThread, None)
-
-       def syncFromThread(self):
-               pool = NSAutoreleasePool.alloc().init()
 
                folder = self.folders()[0]
                playlists = [self.library.get_playlist_pid(pid) for pid in self.playlists()]
@@ -153,12 +140,10 @@ class NotiPodAppDelegate(NSObject):
                libsyncitunes.sync(dry_run=False,
                        source=self.library.folder, dest=folder, files=all_tracks)
 
-               self.performSelectorOnMainThread_withObject_waitUntilDone_(self.finishSync, None, True)
-               del pool
-
-       def finishSync(self):
                NSApp.endSheet_(self.synchronizingSheet)
-               self.synchronizingSheet.close()
+               self.synchronizingSheet.orderOut_(self)
+
+               NSRunAlertPanel("Complete!", "Synchronisation is complete", "Ok", None, None)
 
 
        # Public accessors