#import "StatusWindowController.h"
#import "StatusItemHack.h"
-@interface NSImage (WeeAdditions)
-- (NSImage *)imageScaledSmoothlyToSize:(NSSize)scaledSize;
-@end
-
-@implementation NSImage (WeeAdditions)
+@implementation NSImage (SmoothAdditions)
- (NSImage *)imageScaledSmoothlyToSize:(NSSize)scaledSize
{
[self setupHotKeys];
if (![refreshTimer isValid]) {
[refreshTimer release];
- refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:0.5
+ refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:([networkController isConnectedToServer] ? 10.0 : 0.5)
target:self
selector:@selector(timerUpdate)
userInfo:nil
- (void)setLatestSongIdentifier:(NSString *)newIdentifier
{
- ITDebugLog(@"Setting latest song identifier to %@", newIdentifier);
+ ITDebugLog(@"Setting latest song identifier:");
+ ITDebugLog(@" - Identifier: %@", newIdentifier);
[_latestSongIdentifier autorelease];
- _latestSongIdentifier = [newIdentifier copy];
+ _latestSongIdentifier = [newIdentifier retain];
}
- (void)timerUpdate
{
- if ([networkController isConnectedToServer]) {
- [statusItem setMenu:[menuController menu]];
- }
-
if ( [self songChanged] && (timerUpdating != YES) && (playerRunningState == ITMTRemotePlayerRunning) ) {
ITDebugLog(@"The song changed.");
while ( (nextScript = [scriptsEnum nextObject]) ) {
NSDictionary *error;
NSAppleScript *currentScript = [[NSAppleScript alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/MenuTunes/Scripts"] stringByAppendingPathComponent:nextScript]] error:&error];
- NSLog(@"Running script: %@", nextScript);
+ ITDebugLog(@"Running script: %@", nextScript);
if (!currentScript || ![currentScript executeAndReturnError:nil]) {
ITDebugLog(@"Error running script %@.", nextScript);
}
}
timerUpdating = YES;
+ [statusItem setEnabled:NO];
NS_DURING
latestPlaylistClass = [[self currentRemote] currentPlaylistClass];
NS_ENDHANDLER
timerUpdating = NO;
+ [statusItem setEnabled:YES];
+ }
+
+ if ([networkController isConnectedToServer]) {
+ [statusItem setMenu:[menuController menu]];
}
}
ITHotKey *hotKey;
ITDebugLog(@"Setting up hot keys.");
- if (playerRunningState == ITMTRemotePlayerNotRunning) {
+ if (playerRunningState == ITMTRemotePlayerNotRunning && ![[NetworkController sharedController] isConnectedToServer]) {
return;
}
NSImage *art = nil;
int rating = -1;
+ ITDebugLog(@"Showing track info status window.");
+
NS_DURING
source = [[self currentRemote] currentSource];
title = [[self currentRemote] currentSongTitle];
[self networkError:localException];
NS_ENDHANDLER
- ITDebugLog(@"Showing track info status window.");
-
if ( title ) {
if ( [df boolForKey:@"showAlbum"] ) {
} else {
title = NSLocalizedString(@"noSongPlaying", @"No song is playing.");
}
+ ITDebugLog(@"Showing current track info status window.");
[statusWindowController showSongInfoWindowWithSource:source
title:title
album:album
[currentRemote release];
currentRemote = [remoteArray objectAtIndex:0];
[networkController disconnect];
+
+ if ([[self currentRemote] playerRunningState] == ITMTRemotePlayerRunning) {
+ [self applicationLaunched:nil];
+ } else {
+ [self applicationTerminated:nil];
+ }
[self timerUpdate];
return YES;
}