X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/a1367a46347952261b0e04a09dc061695a6511d0..2404965b693451fd71dcffd06eb82695e9085389:/MainController.m diff --git a/MainController.m b/MainController.m index 1c7905b..67ce65d 100755 --- a/MainController.m +++ b/MainController.m @@ -14,7 +14,6 @@ - (ITMTRemote *)loadRemote; - (void)timerUpdate; - (void)setLatestSongIdentifier:(NSString *)newIdentifier; -- (void)showCurrentTrackInfo; - (void)applicationLaunched:(NSNotification *)note; - (void)applicationTerminated:(NSNotification *)note; @end @@ -39,10 +38,10 @@ static MainController *sharedController; sharedController = self; remoteArray = [[NSMutableArray alloc] initWithCapacity:1]; + [[PreferencesController sharedPrefs] setController:self]; statusWindowController = [StatusWindowController sharedController]; menuController = [[MenuController alloc] init]; df = [[NSUserDefaults standardUserDefaults] retain]; - [[PreferencesController sharedPrefs] setController:self]; timerUpdating = NO; blinged = NO; } @@ -244,7 +243,7 @@ static MainController *sharedController; - (BOOL)songIsPlaying { - NSString *identifier; + NSString *identifier = nil; NS_DURING identifier = [[self currentRemote] playerStateUniqueIdentifier]; NS_HANDLER @@ -255,7 +254,7 @@ static MainController *sharedController; - (BOOL)radioIsPlaying { - ITMTRemotePlayerPlaylistClass class; + ITMTRemotePlayerPlaylistClass class = nil; NS_DURING class = [[self currentRemote] currentPlaylistClass]; NS_HANDLER @@ -266,7 +265,7 @@ static MainController *sharedController; - (BOOL)songChanged { - NSString *identifier; + NSString *identifier = nil; NS_DURING identifier = [[self currentRemote] playerStateUniqueIdentifier]; NS_HANDLER @@ -476,6 +475,11 @@ static MainController *sharedController; [[PreferencesController sharedPrefs] showPrefsWindow:self]; } +- (void)showTestWindow +{ + [self showCurrentTrackInfo]; +} + - (void)quitMenuTunes { ITDebugLog(@"Quitting MenuTunes."); @@ -648,8 +652,8 @@ static MainController *sharedController; - (void)showCurrentTrackInfo { - ITMTRemotePlayerSource source; - NSString *title; + ITMTRemotePlayerSource source = 0; + NSString *title = nil; NSString *album = nil; NSString *artist = nil; NSString *time = nil; @@ -695,8 +699,8 @@ static MainController *sharedController; } if ( [df boolForKey:@"showTrackNumber"] ) { - int trackNo; - int trackCount; + int trackNo = 0; + int trackCount = 0; NS_DURING trackNo = [[self currentRemote] currentSongTrack]; @@ -712,7 +716,7 @@ static MainController *sharedController; } if ( [df boolForKey:@"showTrackRating"] ) { - float currentRating; + float currentRating = 0; NS_DURING currentRating = [[self currentRemote] currentSongRating]; @@ -740,7 +744,7 @@ static MainController *sharedController; - (void)showUpcomingSongs { - int numSongs; + int numSongs = 0; NS_DURING numSongs = [[self currentRemote] numberOfSongsInPlaylistAtIndex:[[self currentRemote] currentPlaylistIndex]]; NS_HANDLER @@ -955,6 +959,12 @@ static MainController *sharedController; if (result == 1) { [[PreferencesController sharedPrefs] resetRemotePlayerTextFields]; currentRemote = [[[networkController networkObject] remote] retain]; + [refreshTimer invalidate]; + refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:([networkController isConnectedToServer] ? 10.0 : 0.5) + target:self + selector:@selector(timerUpdate) + userInfo:nil + repeats:YES] retain]; [self timerUpdate]; ITDebugLog(@"Connection successful."); return 1; @@ -1065,6 +1075,17 @@ static MainController *sharedController; refreshTimer = nil; [self clearHotKeys]; playerRunningState = ITMTRemotePlayerNotRunning; + + if ([df objectForKey:@"ShowPlayer"] != nil) { + ITHotKey *hotKey; + ITDebugLog(@"Setting up show player hot key."); + hotKey = [[ITHotKey alloc] init]; + [hotKey setName:@"ShowPlayer"]; + [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"ShowPlayer"]]]; + [hotKey setTarget:self]; + [hotKey setAction:@selector(showPlayer)]; + [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]]; + } } NS_HANDLER [self networkError:localException];