From 4df5b7a6f44e423bb38036187b7a1102865d1942 Mon Sep 17 00:00:00 2001 From: James Bunton Date: Mon, 3 Jan 2011 09:29:10 +1100 Subject: [PATCH] Added preview feature --- English.lproj/NotiPod.xib | 510 ++++++++++++++++++++++++++++++++++++-- notipod_gui.py | 40 ++- 2 files changed, 526 insertions(+), 24 deletions(-) diff --git a/English.lproj/NotiPod.xib b/English.lproj/NotiPod.xib index 7e59475..db670b5 100644 --- a/English.lproj/NotiPod.xib +++ b/English.lproj/NotiPod.xib @@ -8,8 +8,8 @@ 461.00 YES - + @@ -187,23 +187,24 @@ _NSMainMenu - 7 + 15 2 - {{335, 205}, {381, 545}} + {{335, 223}, {381, 527}} 1946157056 NotiPod NSWindow {3.40282e+38, 3.40282e+38} + {381, 527} - 256 + 274 YES 268 - {{17, 508}, {161, 17}} + {{17, 490}, {161, 17}} YES @@ -238,8 +239,8 @@ - 268 - {{17, 125}, {254, 17}} + 292 + {{17, 117}, {254, 17}} YES @@ -254,7 +255,7 @@ - 268 + 292 {{26, 12}, {120, 32}} YES @@ -272,10 +273,30 @@ 25 + + + 292 + {{146, 12}, {120, 32}} + + YES + + 67239424 + 134217728 + Preview + + + -2038284033 + 129 + + + 200 + 25 + + - 268 - {{29, 93}, {335, 26}} + 290 + {{29, 85}, {335, 26}} YES @@ -330,7 +351,7 @@ - 268 + 292 {{17, 52}, {105, 17}} YES @@ -346,7 +367,7 @@ - 268 + 274 YES @@ -531,7 +552,7 @@ 9.969512e-01 - {{32, 160}, {329, 340}} + {{32, 142}, {329, 340}} 562 @@ -541,10 +562,11 @@ QSAAAEEgAABBmAAAQZgAAA - {381, 545} + {381, 527} {{0, 0}, {1024, 746}} + {381, 549} {3.40282e+38, 3.40282e+38} @@ -560,7 +582,7 @@ {3.40282e+38, 3.40282e+38} - + 256 YES @@ -612,7 +634,6 @@ {342, 100} - {{0, 0}, {1024, 746}} {3.40282e+38, 3.40282e+38} @@ -623,6 +644,331 @@ FolderModel + + 15 + 2 + {{196, -30}, {637, 540}} + 603979776 + Preview + NSWindow + + + + 256 + + YES + + + 274 + + YES + + + 2304 + + YES + + + 2322 + {580, 72} + + + + + + Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum Et harumd und lookum like Greek to me, dereud facilis est er expedit distinct. Nam liber te conscient to factor tum poen legum odioque civiuda + + + YES + + YES + + YES + NSFont + NSParagraphStyle + + + YES + + LucidaGrande + 1.000000e+01 + 2843 + + + 3 + + YES + + 0.000000e+00 + + + 5.600000e+01 + + + 1.120000e+02 + + + 1.680000e+02 + + + 2.240000e+02 + + + 2.800000e+02 + + + 3.360000e+02 + + + 3.920000e+02 + + + 4.480000e+02 + + + 5.040000e+02 + + + 5.600000e+02 + + + 6.160000e+02 + + + 6.720000e+02 + + + 7.280000e+02 + + + 7.840000e+02 + + + 8.400000e+02 + + + 8.960000e+02 + + + 9.520000e+02 + + + 1.008000e+03 + + + 1.064000e+03 + + + 1.120000e+03 + + + 1.176000e+03 + + + 1.232000e+03 + + + 1.288000e+03 + + + 1.344000e+03 + + + 1.400000e+03 + + + 1.456000e+03 + + + 1.512000e+03 + + + 1.568000e+03 + + + 1.624000e+03 + + + 1.680000e+03 + + + 1.736000e+03 + + + + + + + YES + + YES + NSFont + NSParagraphStyle + + + YES + + LucidaGrande-Bold + 1.000000e+01 + 16 + + + 3 + + YES + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GQAEAQgADAEiAAcBhAQAA + + + + + YES + + + 6 + + + + 5.800000e+02 + 1 + + + 11105 + 0 + + + + YES + + YES + NSBackgroundColor + NSColor + + + YES + + 6 + System + selectedTextBackgroundColor + + + + 6 + System + selectedTextColor + + + + + + + YES + + YES + NSColor + NSUnderline + + + YES + + 1 + MCAwIDEAA + + + + + + + 6 + {594, 1e+07} + {223, 59} + + + + {{1, 1}, {580, 504}} + + + + + + {4, -5} + 1 + + 4 + + + + 256 + {{581, 1}, {15, 504}} + + + _doScroller: + 9.415205e-01 + + + + -2147483392 + {{-100, -100}, {87, 18}} + + 1 + + _doScroller: + 1.000000e+00 + 9.456522e-01 + + + {{20, 20}, {597, 506}} + + + 18 + + + + + + {637, 540} + + + {{0, 0}, {1280, 778}} + {3.40282e+38, 3.40282e+38} + @@ -779,6 +1125,30 @@ 524 + + + doPreview: + + + + 531 + + + + previewWindow + + + + 532 + + + + previewText + + + + 539 + @@ -940,11 +1310,12 @@ YES - - + + + @@ -1186,6 +1557,65 @@ + + 525 + + + YES + + + + + + 526 + + + + + 527 + + + YES + + + + PreviewWindow + + + 528 + + + YES + + + + + + 534 + + + YES + + + + + + + + 535 + + + + + 536 + + + + + 537 + + + @@ -1231,6 +1661,8 @@ 371.IBWindowTemplateEditedContentRect 371.NSWindowTemplate.visibleAtLaunch 371.editorWindowContentRectSynchronizationRect + 371.windowTemplate.hasMinSize + 371.windowTemplate.minSize 372.IBPluginDependency 391.IBPluginDependency 392.IBPluginDependency @@ -1265,8 +1697,21 @@ 510.IBPluginDependency 514.IBPluginDependency 515.IBPluginDependency + 517.IBPluginDependency + 518.IBPluginDependency 521.IBPluginDependency 522.IBPluginDependency + 525.IBPluginDependency + 526.IBPluginDependency + 527.IBEditorWindowLastContentRect + 527.IBPluginDependency + 527.IBWindowTemplateEditedContentRect + 527.NSWindowTemplate.visibleAtLaunch + 528.IBPluginDependency + 534.IBPluginDependency + 535.IBPluginDependency + 536.IBPluginDependency + 537.IBPluginDependency 56.IBPluginDependency 56.ImportedFromIB2 57.IBPluginDependency @@ -1281,7 +1726,7 @@ com.apple.InterfaceBuilderKit com.apple.InterfaceBuilderKit com.apple.InterfaceBuilder.CocoaPlugin - + {{87, 691}, {163, 23}} com.apple.InterfaceBuilder.CocoaPlugin @@ -1312,10 +1757,12 @@ {74, 862} {{529, 476}, {148, 20}} - {{249, 142}, {381, 545}} - {{249, 142}, {381, 545}} + {{249, 160}, {381, 527}} + {{249, 160}, {381, 527}} {{505, 213}, {252, 190}} + + {381, 527} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1353,6 +1800,19 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{158, 122}, {637, 540}} + com.apple.InterfaceBuilder.CocoaPlugin + {{158, 122}, {637, 540}} + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1377,7 +1837,7 @@ - 524 + 539 @@ -1415,12 +1875,14 @@ YES doCancel: + doPreview: doSync: YES id id + id @@ -1432,6 +1894,8 @@ loadingLabel loadingSheet playlistModel + previewText + previewWindow window @@ -1442,6 +1906,8 @@ id id id + id + id diff --git a/notipod_gui.py b/notipod_gui.py index f4c6dde..4c175a9 100644 --- a/notipod_gui.py +++ b/notipod_gui.py @@ -112,12 +112,18 @@ class FolderModel(NSObject): class NotiPodController(NSObject): window = objc.IBOutlet() - playlistModel = objc.IBOutlet() - folderModel = objc.IBOutlet() + loadingSheet = objc.IBOutlet() loadingLabel = objc.IBOutlet() loadingIndicator = objc.IBOutlet() + previewWindow = objc.IBOutlet() + previewText = objc.IBOutlet() + + playlistModel = objc.IBOutlet() + folderModel = objc.IBOutlet() + + def awakeFromNib(self): self.runningGenerator = False @@ -170,6 +176,36 @@ class NotiPodController(NSObject): def doCancel_(self, sender): self.runningGenerator = False + def doPreviewThread(self): + yield "Calculating changes..." + + folder = self.folders()[0] + playlists = [self.library.get_playlist_pid(pid) for pid in self.playlists()] + + all_tracks = [] + for playlist in playlists: + all_tracks.extend(playlist.tracks) + + gen = libnotipod.sync( + dry_run=True, + source=self.library.folder, + dest=folder, + files_to_copy=all_tracks + ) + self.previewResult = "\n".join(gen) + + @objc.IBAction + def doPreview_(self, sender): + self.previewResult = "" + self.previewWindow.orderOut_(self) + + def finish(): + self.previewText.textStorage().mutableString().setString_(self.previewResult) + self.previewWindow.center() + self.previewWindow.makeKeyAndOrderFront_(self) + + self.runGenerator(self.doPreviewThread, finish) + @objc.IBAction def doSync_(self, sender): folder = self.folders()[0] -- 2.39.2