From 0e96faf46397725b657c4947d13cd31fa75aa170 Mon Sep 17 00:00:00 2001 From: Kent Sutherland Date: Sun, 29 May 2005 07:01:40 +0000 Subject: [PATCH] Added a small main menu to allow command-keys to work in the registration window and the prefs window. Checks iTunes version at startup to avoid starting the polling timer if it isn't needed. --- English.lproj/MainMenu.nib/info.nib | 15 +++++- English.lproj/MainMenu.nib/keyedobjects.nib | Bin 1159 -> 4991 bytes MainController.h | 2 +- MainController.m | 55 ++++++++++++++------ 4 files changed, 52 insertions(+), 20 deletions(-) diff --git a/English.lproj/MainMenu.nib/info.nib b/English.lproj/MainMenu.nib/info.nib index adeae52..20f1589 100755 --- a/English.lproj/MainMenu.nib/info.nib +++ b/English.lproj/MainMenu.nib/info.nib @@ -2,9 +2,20 @@ + IBDocumentLocation + 69 53 356 240 0 0 1152 746 + IBEditorPositions + + 200 + 69 298 222 44 0 0 1152 746 + IBFramework Version - 291.0 + 437.0 + IBOpenObjects + + 200 + IBSystem Version - 6I32 + 8B15 diff --git a/English.lproj/MainMenu.nib/keyedobjects.nib b/English.lproj/MainMenu.nib/keyedobjects.nib index d50a1fb1a9d3a5dca574b004f6f479cb25324154..446609cdcf1ccca3a23a766d6aeaecfa6b196ad7 100755 GIT binary patch literal 4991 zcmaJ^33wIN+5XO%xwFqO351;xA?y&s4q*vN*a9SwJwO(3ZU(q;b8omy5-61;AR+=% zOD$E=kkl4s(I1ggwJH=TB1MRl3Q`g3?_=Fstjq7p|IJJi_@(^!KF__gob!I~_rBlx z=1f&>z#oaGrk(==6gc3)0|JPkEJ*f-eM|jyR=6}7ej;pSPSc5J=_PI;C^@jeh%B=m+&y`gk7*3_QF2c4^P9h@B+LDe}I?ZD7*$I z;dM9-EpP!Y!rSl;T!nwYhwu@63ZKE(@C|$mKM+b}q7aoBB%TZ+!^uc8hKwcSNfwz! zvdL^Rhvbk_;w8)QcsZ#dD@YxwC#y*+p5H?@lPzQ`UU`800)J*O>!OU{umXlL4mcBS2DciMyYq`hb&?M;*D9k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!v&HMS@ z_rBRu)ik&pk3RsUyV}}!*9tM+DX$vWnUjyngB!M$kJ+U)R(APJ%(bgaN?6q{u}xMP zYZdkoxOwX%rN3j(Bd5Z-A3ZaCbXjai;){-A_ALwmdS zg_Z7}-pKv~2M--S(swl4f9&|ciHBkjpB!9JwMpA@GrFa(Feeu)n>yzORa4mwH)~Xu z6h+l?1~*D3n=`D6UE?`bo3?FtUe#ot=XBF!yh$?Yx3X45;wEj&l55C~xV)+Q`u}p- zU_-eVF9txq>o)};{_TpS=E$y^?Oc<76Tpu*hqVBL@q&n`@`czfP#hKq#U2q6iZ~<= zh&ItHdbUH4K6Xk1G@*SIu}jcGhFRW>XEDA#^mzPleIZF0?ct}gY{nzfCQXMLRDvK@N< z+^7^_$PV-n9k*oLg)u4ae@)D7To_Nx$`0nr^3;R~Z%vBM2cZ|z7cX7TMCVlPvR-1Q z)Go!iYgoFkxIe-6oH7&pM3)Hp5@f~R#f)xP@>yKRHck1*RhY?EbeGAQ+RTy?ks=$V ztmm4{Z9SgtG_=`-R6-_pLb7}=FJmo=V~(S5Hs%TmNu}vanpfsU_f|$078dJ;gdbSm ziu$Hhk7j&Zsk5xu@9VfSKWUh3kRQ+1Eav#R(VgR3Bbu4?Z|e=qu8Jd~PaIW1`CPdt zp}p&pLwY=Tk(BQ0buaPNjm?GhcuUTTj0qqeq?`1S7&$`{Bt_C>ja127fX&8YNAP(aQj$#rga0=5njYV9=4dm!y4PU`m@lAXO z-@{MvQ@o4!@jLt;f5e~hSNskCz(4VC{D&fKqn)&ihG~Qj(3A8OjniRzmY$>M=@?DY b2|7j7RHX}anU?7WX?_TSB`>#Z%TWF=?W1aY diff --git a/MainController.h b/MainController.h index 86efb71..027db07 100755 --- a/MainController.h +++ b/MainController.h @@ -44,7 +44,7 @@ MTBlingController *bling; NSTimer *registerTimer; - BOOL timerUpdating, _checkingForServer, _popped, _open; + BOOL timerUpdating, _checkingForServer, _popped, _open, _needsPolling; BOOL blinged; NSLock *_serverCheckLock; } diff --git a/MainController.m b/MainController.m index c2502c5..2a3d6b3 100755 --- a/MainController.m +++ b/MainController.m @@ -98,11 +98,28 @@ static MainController *sharedController; - (void)applicationDidFinishLaunching:(NSNotification *)note { + NSString *iTunesPath = [df stringForKey:@"CustomPlayerPath"]; + NSDictionary *iTunesInfoPlist; + float iTunesVersion; + //Turn on debug mode if needed if ([df boolForKey:@"ITDebugMode"]) { SetITDebugMode(YES); } - + + //Check if iTunes 4.7 or later is installed + if (!iTunesPath) { + iTunesPath = [[NSWorkspace sharedWorkspace] fullPathForApplication:@"iTunes.app"]; + } + iTunesInfoPlist = [[NSBundle bundleWithPath:iTunesPath] infoDictionary]; + iTunesVersion = [[iTunesInfoPlist objectForKey:@"CFBundleVersion"] floatValue]; + ITDebugLog(@"iTunes version found: %f.", iTunesVersion); + if (iTunesVersion >= 4.7) { + _needsPolling = NO; + } else { + _needsPolling = YES; + } + if (([df integerForKey:@"appVersion"] < 1200) && ([df integerForKey:@"SongsInAdvance"] > 0)) { [df removePersistentDomainForName:@"com.ithinksw.menutunes"]; [df synchronize]; @@ -301,7 +318,7 @@ static MainController *sharedController; if (blinged) { [statusItem setEnabled:YES]; [[ITHotKeyCenter sharedCenter] setEnabled:YES]; - if (![refreshTimer isValid]) { + if (_needsPolling && ![refreshTimer isValid]) { [refreshTimer release]; refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:([networkController isConnectedToServer] ? 10.0 : 0.5) target:self @@ -489,12 +506,12 @@ static MainController *sharedController; - (void)trackChanged:(NSNotification *)note { //If we're running the timer, shut it off since we don't need it! - if (refreshTimer && [refreshTimer isValid]) { + /*if (refreshTimer && [refreshTimer isValid]) { ITDebugLog(@"Invalidating refresh timer."); [refreshTimer invalidate]; [refreshTimer release]; refreshTimer = nil; - } + }*/ if (![self songChanged]) { return; @@ -992,7 +1009,7 @@ static MainController *sharedController; NSImage *art = nil; int rating = -1; int playCount = -1; - + ITDebugLog(@"Showing track info status window."); NS_DURING @@ -1344,14 +1361,16 @@ static MainController *sharedController; [self setupHotKeys]; //playerRunningState = ITMTRemotePlayerRunning; playerRunningState = [[self currentRemote] playerRunningState]; - if (refreshTimer) { - [refreshTimer invalidate]; + if (_needsPolling) { + if (refreshTimer) { + [refreshTimer invalidate]; + } + refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:([networkController isConnectedToServer] ? 10.0 : 0.5) + target:self + selector:@selector(timerUpdate) + userInfo:nil + repeats:YES] retain]; } - 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; @@ -1487,11 +1506,13 @@ static MainController *sharedController; [[self currentRemote] begin]; [self setLatestSongIdentifier:@""]; [self timerUpdate]; - refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:([networkController isConnectedToServer] ? 10.0 : 0.5) - target:self - selector:@selector(timerUpdate) - userInfo:nil - repeats:YES] retain]; + if (_needsPolling) { + refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:([networkController isConnectedToServer] ? 10.0 : 0.5) + target:self + selector:@selector(timerUpdate) + userInfo:nil + repeats:YES] retain]; + } //[NSThread detachNewThreadSelector:@selector(startTimerInNewThread) toTarget:self withObject:nil]; if (![df boolForKey:@"UsePollingOnly"]) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(trackChanged:) name:@"ITMTTrackChanged" object:nil]; -- 2.20.1