More fixes to the new playlist implementation.
NSTimer *registerTimer;
BOOL timerUpdating, _checkingForServer, _popped, _open, _needsPolling;
BOOL blinged;
+ int _timeUpdateCount; //Keeps track of how many times the time has been updated in the info status window
NSLock *_serverCheckLock;
}
+ (MainController *)sharedController;
NS_HANDLER
[self networkError:localException];
NS_ENDHANDLER
+ _timeUpdateCount = 0;
+ [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateTime:) userInfo:nil repeats:YES];
}
if ( [df boolForKey:@"showTrackNumber"] ) {
image:art];
}
+- (void)updateTime:(NSTimer *)timer
+{
+ _timeUpdateCount++;
+ if (_timeUpdateCount > (int)[df floatForKey:@"statusWindowVanishDelay"] - 1) {
+ NSString *time = nil;
+ NS_DURING
+ time = [NSString stringWithFormat:@"%@: %@ / %@",
+ NSLocalizedString(@"time", @"Time"),
+ [[self currentRemote] currentSongElapsed],
+ [[self currentRemote] currentSongLength]];
+ [[StatusWindowController sharedController] updateTime:time];
+ NS_HANDLER
+ [self networkError:localException];
+ NS_ENDHANDLER
+ }
+}
+
- (void)showUpcomingSongs
{
int numSongs = 0;
[tempItem setTag:p + [nextNode index] + 1];
[tempItem setTarget:self];
}
+
+ PlaylistNode *root = node;
+ while ([root type] == ITMTPlaylistNode || [root type] == ITMTFolderNode) {
+ root = [root parent];
+ }
+
+ if ([root index] == [[[MainController sharedController] currentRemote] currentSourceIndex] && [nextNode index] == _currentPlaylist) {
+ [tempItem setState:NSOnState];
+ }
}
}
}
//Add other sources as needed (shared music, iPods, CDs)
- for (i = 2; i < [playlists count]; i++) {
+ for (i = [playlists count] - 1; i > 1 ; i--) {
PlaylistNode *nextSource = [playlists objectAtIndex:i];
if ([nextSource type] != ITMTRemoteRadioSource) {
NSString *name = [nextSource name];
}
}
}
- ITDebugLog(@"Checking the current source.");
NS_DURING
if (_currentPlaylist != -1) {
if ( (source == ITMTRemoteSharedLibrarySource) || (source == ITMTRemoteiPodSource) || (source == ITMTRemoteGenericDeviceSource) || (source == ITMTRemoteCDSource) ) {
tempItem = [playlistsMenu itemAtIndex:[playlistsMenu numberOfItems] + [indices indexOfObject:[NSNumber numberWithInt:[[[MainController sharedController] currentRemote] currentSourceIndex]]] - [indices count]];
[tempItem setState:NSOnState];
- [[[tempItem submenu] itemAtIndex:_currentPlaylist - 1] setState:NSOnState];
- } else if (source == ITMTRemoteLibrarySource && _currentPlaylist) {
- [[playlistsMenu itemAtIndex:_currentPlaylist - 2] setState:NSOnState];
}
}
NS_HANDLER
@interface StatusWindow : ITTransientStatusWindow {
NSImage *_image;
BOOL _locked;
+ NSTextField *_textField;
}
- (void)setImage:(NSImage *)newImage;
target:(id)target
defaultAction:(SEL)okAction
alternateAction:(SEL)alternateAction;
-
+
+- (void)updateTime:(NSString *)time range:(NSRange)range;
@end
// Display the window.
[[self contentView] setNeedsDisplay:YES];
-
+ _textField = textField;
}
}
}
}
+- (void)updateTime:(NSString *)time range:(NSRange)range
+{
+ NSMutableAttributedString *string = [[_textField attributedStringValue] mutableCopy];
+ [string replaceCharactersInRange:range withString:time];
+ [_textField setAttributedStringValue:[string autorelease]];
+ [[self contentView] setNeedsDisplay:YES];
+}
+
- (NSTimeInterval)animationResizeTime:(NSRect)newFrame
{
return (NSTimeInterval)0.25;
@interface StatusWindowController : NSObject {
StatusWindow *_window;
NSUserDefaults *df;
+ NSRange _timeRange;
}
+ (StatusWindowController *)sharedController;
playCount: (int)playCount
image: (NSImage *)art;
+- (void)updateTime:(NSString *)time;
@end
//text = [text stringByAppendingString:[@"\n" stringByAppendingString:composer]];
}
if ( time ) {
+ _timeRange = NSMakeRange([[text mutableString] length] + 1, [time length]);
[[text mutableString] appendFormat:@"\n%@", time];
//text = [text stringByAppendingString:[@"\n" stringByAppendingString:time]];
}
[_window setLocked:YES];
}
+- (void)updateTime:(NSString *)time
+{
+ if (time && [time length]) {
+ [_window updateTime:time range:_timeRange];
+ }
+}
+
@end
\ No newline at end of file