From: Kent Sutherland Date: Fri, 30 Jan 2004 01:32:26 +0000 (+0000) Subject: Album art is integrated, but as an NSAppleScript right now. Must switch X-Git-Tag: v1.3~55 X-Git-Url: http://git.ithinksw.org/MenuTunes.git/commitdiff_plain/28ef52fed0fa8f1d49c604cabe52b846bf01d393 Album art is integrated, but as an NSAppleScript right now. Must switch over to AE. --- diff --git a/English.lproj/Preferences.nib/classes.nib b/English.lproj/Preferences.nib/classes.nib index 2bbece9..f19b4b9 100755 --- a/English.lproj/Preferences.nib/classes.nib +++ b/English.lproj/Preferences.nib/classes.nib @@ -16,6 +16,7 @@ CLASS = PreferencesController; LANGUAGE = ObjC; OUTLETS = { + albumArtworkCheckbox = NSButton; albumCheckbox = NSButton; allTableView = NSTableView; appearanceEffectPopup = NSPopUpButton; diff --git a/English.lproj/Preferences.nib/info.nib b/English.lproj/Preferences.nib/info.nib index 126aeb4..9d098d2 100755 --- a/English.lproj/Preferences.nib/info.nib +++ b/English.lproj/Preferences.nib/info.nib @@ -3,7 +3,7 @@ IBDocumentLocation - 37 226 356 240 0 0 1024 746 + 43 33 356 240 0 0 1152 746 IBEditorPositions 634 diff --git a/English.lproj/Preferences.nib/keyedobjects.nib b/English.lproj/Preferences.nib/keyedobjects.nib index 479dffd..a97e923 100755 Binary files a/English.lproj/Preferences.nib/keyedobjects.nib and b/English.lproj/Preferences.nib/keyedobjects.nib differ diff --git a/MainController.m b/MainController.m index afc0db2..f0ca0f8 100755 --- a/MainController.m +++ b/MainController.m @@ -679,6 +679,7 @@ static MainController *sharedController; NSString *artist = nil; NSString *time = nil; NSString *track = nil; + NSImage *art = nil; int rating = -1; NS_DURING @@ -750,6 +751,14 @@ static MainController *sharedController; } } + if ( [df boolForKey:@"showAlbumArtwork"] ) { + NS_DURING + art = [[self currentRemote] currentSongAlbumArt]; + NS_HANDLER + [self networkError:localException]; + NS_ENDHANDLER + } + } else { title = NSLocalizedString(@"noSongPlaying", @"No song is playing."); } @@ -760,7 +769,8 @@ static MainController *sharedController; artist:artist time:time track:track - rating:rating]; + rating:rating + image:art]; } - (void)showUpcomingSongs diff --git a/MenuTunes.xcode/project.pbxproj b/MenuTunes.xcode/project.pbxproj index bcb07f5..4bce21a 100755 --- a/MenuTunes.xcode/project.pbxproj +++ b/MenuTunes.xcode/project.pbxproj @@ -75,9 +75,9 @@ children = ( 1058C7A1FEA54F0111CA2CBB, 7C95A0EF05A92B4800B4F576, - 7C95A02A05A9288F00B4F576, 7C95A03705A928A300B4F576, - 7C95A0DF05A929B200B4F576, + 3740714D05ACE0B500CC2142, + 3740716C05ACE20500CC2142, 7C95A0E805A92B0700B4F576, ); isa = PBXGroup; @@ -293,6 +293,54 @@ //322 //323 //324 +//370 +//371 +//372 +//373 +//374 + 3740714D05ACE0B500CC2142 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + path = ITFoundation.framework; + refType = 4; + sourceTree = ""; + }; + 3740714E05ACE0B500CC2142 = { + fileRef = 3740714D05ACE0B500CC2142; + isa = PBXBuildFile; + settings = { + }; + }; + 3740714F05ACE0B500CC2142 = { + fileRef = 3740714D05ACE0B500CC2142; + isa = PBXBuildFile; + settings = { + }; + }; + 3740716B05ACE14D00CC2142 = { + fileRef = 3740714D05ACE0B500CC2142; + isa = PBXBuildFile; + settings = { + }; + }; + 3740716C05ACE20500CC2142 = { + isa = PBXFileReference; + lastKnownFileType = archive.ar; + path = libValidate.a; + refType = 4; + sourceTree = ""; + }; + 3740716D05ACE20500CC2142 = { + fileRef = 3740716C05ACE20500CC2142; + isa = PBXBuildFile; + settings = { + }; + }; +//370 +//371 +//372 +//373 +//374 //4A0 //4A1 //4A2 @@ -309,7 +357,7 @@ GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_OPTIMIZATION_LEVEL = 0; OPTIMIZATION_CFLAGS = "-O0"; - ZERO_LINK = YES; + ZERO_LINK = NO; }; isa = PBXBuildStyle; name = Development; @@ -472,7 +520,7 @@ files = ( 7C33202105A925BC0088905B, 7C33202005A925BA0088905B, - 7C95A02D05A9288F00B4F576, + 3740714E05ACE0B500CC2142, ); isa = PBXFrameworksBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -487,7 +535,7 @@ buildRules = ( ); buildSettings = { - FRAMEWORK_SEARCH_PATHS = "/Volumes/Data/Desktop/ITFoundation/build /Volumes/Data/Desktop/ITKit/build"; + FRAMEWORK_SEARCH_PATHS = "/Volumes/Data/Desktop/ITFoundation/build /Volumes/Data/Desktop/ITKit/build /Users/kent/Programming/iThink/MenuTunes"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = MenuTunes_Prefix.pch; GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO; @@ -1318,26 +1366,6 @@ settings = { }; }; - 7C95A02A05A9288F00B4F576 = { - isa = PBXFileReference; - lastKnownFileType = wrapper.framework; - name = ITFoundation.framework; - path = ../ITFoundation/build/ITFoundation.framework; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 7C95A02B05A9288F00B4F576 = { - fileRef = 7C95A02A05A9288F00B4F576; - isa = PBXBuildFile; - settings = { - }; - }; - 7C95A02D05A9288F00B4F576 = { - fileRef = 7C95A02A05A9288F00B4F576; - isa = PBXBuildFile; - settings = { - }; - }; 7C95A03705A928A300B4F576 = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; @@ -1366,19 +1394,6 @@ settings = { }; }; - 7C95A0DF05A929B200B4F576 = { - isa = PBXFileReference; - lastKnownFileType = archive.ar; - path = libValidate.a; - refType = 4; - sourceTree = ""; - }; - 7C95A0E005A929B200B4F576 = { - fileRef = 7C95A0DF05A929B200B4F576; - isa = PBXBuildFile; - settings = { - }; - }; 7C95A0E105A929F400B4F576 = { fileEncoding = 4; isa = PBXFileReference; @@ -1440,19 +1455,13 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( + 3740716B05ACE14D00CC2142, 7C95A18A05A92B9700B4F576, 7C95A18905A92B9500B4F576, - 7C95A18805A92B9100B4F576, ); isa = PBXCopyFilesBuildPhase; runOnlyForDeploymentPostprocessing = 0; }; - 7C95A18805A92B9100B4F576 = { - fileRef = 7C95A02A05A9288F00B4F576; - isa = PBXBuildFile; - settings = { - }; - }; 7C95A18905A92B9500B4F576 = { fileRef = 7C95A03705A928A300B4F576; isa = PBXBuildFile; @@ -1503,7 +1512,7 @@ buildRules = ( ); buildSettings = { - FRAMEWORK_SEARCH_PATHS = "../ITFoundation/build ../ITKit/build /Volumes/Data/Desktop/ITFoundation/build"; + FRAMEWORK_SEARCH_PATHS = "../ITFoundation/build ../ITKit/build /Volumes/Data/Desktop/ITFoundation/build /Users/kent/Programming/iThink/MenuTunes"; GCC_ENABLE_TRIGRAPHS = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -1514,7 +1523,7 @@ HEADER_SEARCH_PATHS = "../ITKit/build/ITKit.framework/PrivateHeaders ../ITFoundation/build/ITFoundation.framework/PrivateHeaders "; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Applications"; - LIBRARY_SEARCH_PATHS = /Volumes/Data/Desktop/MenuTunes; + LIBRARY_SEARCH_PATHS = "/Volumes/Data/Desktop/MenuTunes /Users/kent/Programming/iThink/MenuTunes"; MACOSX_DEPLOYMENT_TARGET = 10.2; OTHER_CFLAGS = ""; OTHER_LDFLAGS = ""; @@ -1638,11 +1647,11 @@ files = ( 7C33201F05A925AF0088905B, 8D11072F0486CEB800E47090, - 7C95A02B05A9288F00B4F576, 7C95A03805A928A300B4F576, - 7C95A0E005A929B200B4F576, 7C95A0E905A92B0700B4F576, 7C95A0F005A92B4800B4F576, + 3740714F05ACE0B500CC2142, + 3740716D05ACE20500CC2142, ); isa = PBXFrameworksBuildPhase; runOnlyForDeploymentPostprocessing = 0; diff --git a/PreferencesController.h b/PreferencesController.h index 004e929..d409e8b 100755 --- a/PreferencesController.h +++ b/PreferencesController.h @@ -18,6 +18,7 @@ @interface PreferencesController : NSObject { + IBOutlet NSButton *albumArtworkCheckbox; IBOutlet NSButton *albumCheckbox; IBOutlet NSTableView *allTableView; IBOutlet NSPopUpButton *appearanceEffectPopup; diff --git a/PreferencesController.m b/PreferencesController.m index e82526b..d731bd2 100755 --- a/PreferencesController.m +++ b/PreferencesController.m @@ -146,9 +146,11 @@ static PreferencesController *prefs = nil; [passwordPanelOKButton setTitle:@"Connect"]; [passwordPanelTitle setStringValue:@"Password Required"]; [passwordPanelMessage setStringValue:[NSString stringWithFormat:@"Please enter a password for access to the MenuTunes player named %@ at %@.", [[[NetworkController sharedController] networkObject] serverName], [[NetworkController sharedController] remoteHost]]]; - [passwordPanel center]; [passwordPanel setLevel:NSStatusWindowLevel]; - [passwordPanel makeKeyAndOrderFront:nil]; + [NSApp activateIgnoringOtherApps: YES]; + [window center]; + [window orderFrontRegardless]; + [window makeKeyWindow]; if ([NSApp runModalForWindow:passwordPanel]) { return YES; } else { @@ -162,9 +164,11 @@ static PreferencesController *prefs = nil; [passwordPanelOKButton setTitle:@"Retry"]; [passwordPanelTitle setStringValue:@"Invalid Password"]; [passwordPanelMessage setStringValue:[NSString stringWithFormat:@"The password entered for access to the MenuTunes player named %@ at %@ is invalid. Please provide a new password.", [[[NetworkController sharedController] networkObject] serverName], [[NetworkController sharedController] remoteHost]]]; - [passwordPanel center]; [passwordPanel setLevel:NSStatusWindowLevel]; - [passwordPanel makeKeyAndOrderFront:nil]; + [NSApp activateIgnoringOtherApps: YES]; + [window center]; + [window orderFrontRegardless]; + [window makeKeyWindow]; if ([NSApp runModalForWindow:passwordPanel]) { return YES; } else { @@ -193,8 +197,10 @@ static PreferencesController *prefs = nil; } [self resetRemotePlayerTextFields]; + [NSApp activateIgnoringOtherApps: YES]; [window center]; - [NSApp activateIgnoringOtherApps:YES]; + [window orderFrontRegardless]; + [window makeKeyWindow]; [window performSelector:@selector(makeKeyAndOrderFront:) withObject:self afterDelay:0.0]; } @@ -226,6 +232,8 @@ static PreferencesController *prefs = nil; [df setBool:SENDER_STATE forKey:@"showTrackNumber"]; } else if ( [sender tag] == 1090) { [df setBool:SENDER_STATE forKey:@"showTrackRating"]; + } else if ( [sender tag] == 1100) { + [df setBool:SENDER_STATE forKey:@"showAlbumArtwork"]; } [df synchronize]; } @@ -773,6 +781,7 @@ static PreferencesController *prefs = nil; [trackTimeCheckbox setState:[df boolForKey:@"showTime"] ? NSOnState : NSOffState]; [trackNumberCheckbox setState:[df boolForKey:@"showTrackNumber"] ? NSOnState : NSOffState]; [ratingCheckbox setState:[df boolForKey:@"showTrackRating"] ? NSOnState : NSOffState]; + [albumArtworkCheckbox setState:[df boolForKey:@"showAlbumArtwork"] ? NSOnState : NSOffState]; // Set the launch at login checkbox state ITDebugLog(@"Setting launch at login state."); diff --git a/StatusWindow.h b/StatusWindow.h index c956be7..4b678bc 100755 --- a/StatusWindow.h +++ b/StatusWindow.h @@ -15,23 +15,13 @@ #import #import - -typedef enum _StatusWindowSizing { - StatusWindowRegular, - StatusWindowSmall, - StatusWindowMini -} StatusWindowSizing; - - @interface StatusWindow : ITTransientStatusWindow { NSImage *_image; BOOL _locked; - StatusWindowSizing _sizing; } - (void)setImage:(NSImage *)newImage; - (void)setLocked:(BOOL)flag; -- (void)setSizing:(StatusWindowSizing)newSizing; - (void)buildTextWindowWithString:(NSString *)text; - (void)buildMeterWindowWithCharacter:(NSString *)character diff --git a/StatusWindow.m b/StatusWindow.m index 21dd278..a456861 100755 --- a/StatusWindow.m +++ b/StatusWindow.m @@ -45,7 +45,7 @@ // Set default values. _image = [[NSImage imageNamed:@"NSApplicationIcon"] retain]; _locked = NO; - _sizing = StatusWindowRegular; + _sizing = ITTransientStatusWindowRegular; } return self; @@ -75,7 +75,7 @@ [self setExitMode:(flag ? ITTransientStatusWindowExitOnCommand : ITTransientStatusWindowExitAfterDelay)]; } -- (void)setSizing:(StatusWindowSizing)newSizing +- (void)setSizing:(ITTransientStatusWindowSizing)newSizing { _sizing = newSizing; } @@ -124,9 +124,9 @@ BOOL shouldAnimate = ( ! (([self visibilityState] == ITWindowAppearingState) || ([self visibilityState] == ITWindowVanishingState)) ); - if ( _sizing == StatusWindowSmall ) { + if ( _sizing == ITTransientStatusWindowSmall ) { divisor = SMALL_DIVISOR; - } else if ( _sizing == StatusWindowMini ) { + } else if ( _sizing == ITTransientStatusWindowMini ) { divisor = MINI_DIVISOR; } @@ -212,9 +212,9 @@ NSFont *font; NSDictionary *attr; - if ( _sizing == StatusWindowSmall ) { + if ( _sizing == ITTransientStatusWindowSmall ) { divisor = SMALL_DIVISOR; - } else if ( _sizing == StatusWindowMini ) { + } else if ( _sizing == ITTransientStatusWindowMini ) { divisor = MINI_DIVISOR; } @@ -279,9 +279,9 @@ NSColor *offColor = [NSColor colorWithCalibratedWhite:0.15 alpha:0.50]; NSMatrix *volMatrix; - if ( _sizing == StatusWindowSmall ) { + if ( _sizing == ITTransientStatusWindowSmall ) { divisor = SMALL_DIVISOR; - } else if ( _sizing == StatusWindowMini ) { + } else if ( _sizing == ITTransientStatusWindowMini ) { divisor = MINI_DIVISOR; } diff --git a/StatusWindowController.h b/StatusWindowController.h index ab96a26..a3c36ea 100755 --- a/StatusWindowController.h +++ b/StatusWindowController.h @@ -48,7 +48,8 @@ typedef enum { artist: (NSString *)artist time: (NSString *)time // FLOW: Should probably be NSDate or something. track: (NSString *)track - rating: (int)rating; + rating: (int)rating + image: (NSImage *)art; @end diff --git a/StatusWindowController.m b/StatusWindowController.m index 5cac976..85d94df 100755 --- a/StatusWindowController.m +++ b/StatusWindowController.m @@ -59,7 +59,7 @@ static StatusWindowController *sharedController; [_window setHorizontalPosition:[df integerForKey:@"statusWindowHorizontalPosition"]]; [_window setVerticalPosition:[df integerForKey:@"statusWindowVerticalPosition"]]; - [_window setSizing:(StatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; + [_window setSizing:(ITTransientStatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; if ( [classList containsObject:NSClassFromString(entryClass)] ) { entryEffect = [[[NSClassFromString(entryClass) alloc] initWithWindow:_window] autorelease]; @@ -108,11 +108,19 @@ static StatusWindowController *sharedController; time: (NSString *)time // FLOW: Should probably be NSDate or something. track: (NSString *)track rating: (int)rating + image: (NSImage *)art { NSImage *image = nil; NSString *text = title; - if ( source == ITMTRemoteLibrarySource ) { + if ( art != nil ) { + image = art; + NSSize size = [image size]; + if (size.width > 110) { + [image setScalesWhenResized:YES]; + [image setSize:NSMakeSize(110, (size.width / size.height) * 110)]; + } + } else if ( source == ITMTRemoteLibrarySource ) { image = [NSImage imageNamed:@"Library"]; } else if ( source == ITMTRemoteCDSource ) { image = [NSImage imageNamed:@"CD"]; @@ -125,9 +133,9 @@ static StatusWindowController *sharedController; } else if ( source == ITMTRemoteSharedLibrarySource ) { image = [NSImage imageNamed:@"Library"]; } - + [_window setImage:image]; - + if ( album ) { text = [text stringByAppendingString:[@"\n" stringByAppendingString:album]]; } @@ -160,7 +168,7 @@ static StatusWindowController *sharedController; } - [_window setSizing:(StatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; + [_window setSizing:(ITTransientStatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; [_window buildTextWindowWithString:text]; [_window appear:self]; } @@ -171,7 +179,7 @@ static StatusWindowController *sharedController; NSString *bull = [NSString stringWithUTF8String:"♪ "]; NSString *end = [@"\n" stringByAppendingString:bull]; [_window setImage:[NSImage imageNamed:@"Upcoming"]]; - [_window setSizing:(StatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; + [_window setSizing:(ITTransientStatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; [_window buildTextWindowWithString:[bull stringByAppendingString:[titleStrings componentsJoinedByString:end]]]; [_window appear:self]; } @@ -179,7 +187,7 @@ static StatusWindowController *sharedController; - (void)showVolumeWindowWithLevel:(float)level { [_window setImage:[NSImage imageNamed:@"Volume"]]; - [_window setSizing:(StatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; + [_window setSizing:(ITTransientStatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; [_window buildMeterWindowWithCharacter:[NSString stringWithUTF8String:"▊"] size:18 count:10 @@ -190,7 +198,7 @@ static StatusWindowController *sharedController; - (void)showRatingWindowWithRating:(float)rating { [_window setImage:[NSImage imageNamed:@"Rating"]]; - [_window setSizing:(StatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; + [_window setSizing:(ITTransientStatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; [_window buildMeterWindowWithCharacter:[NSString stringWithUTF8String:"★"] size:48 count:5 @@ -201,7 +209,7 @@ static StatusWindowController *sharedController; - (void)showShuffleWindow:(BOOL)shuffle { [_window setImage:[NSImage imageNamed:@"Shuffle"]]; - [_window setSizing:(StatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; + [_window setSizing:(ITTransientStatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; [_window buildTextWindowWithString:( shuffle ? @"Shuffle On" : @"Shuffle Off")]; [_window appear:self]; } @@ -219,7 +227,7 @@ static StatusWindowController *sharedController; } [_window setImage:[NSImage imageNamed:@"Repeat"]]; - [_window setSizing:(StatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; + [_window setSizing:(ITTransientStatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; [_window buildTextWindowWithString:string]; [_window appear:self]; } @@ -229,7 +237,7 @@ static StatusWindowController *sharedController; NSString *message = @"Would you like MenuTunes to launch\nautomatically at startup?"; [_window setImage:[NSImage imageNamed:@"Setup"]]; - [_window setSizing:(StatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; + [_window setSizing:(ITTransientStatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; [_window buildDialogWindowWithMessage:message defaultButton:@"Launch at Startup" alternateButton:@"Launch Manually" @@ -247,7 +255,7 @@ static StatusWindowController *sharedController; NSString *message = @"Your 7-day unlimited trial period has elapsed.\nYou must register to continue using MenuTunes."; [_window setImage:[NSImage imageNamed:@"Register"]]; - [_window setSizing:(StatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; + [_window setSizing:(ITTransientStatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; [_window buildDialogWindowWithMessage:message defaultButton:@"Register Now" alternateButton:@"Quit MenuTunes" @@ -264,7 +272,7 @@ static StatusWindowController *sharedController; NSString *message = @"The selected shared player is available again.\nWould you like to reconnect to it?."; [_window setImage:[NSImage imageNamed:@"Register"]]; - [_window setSizing:(StatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; + [_window setSizing:(ITTransientStatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; [_window buildDialogWindowWithMessage:message defaultButton:@"Reconnect" alternateButton:@"Ignore" @@ -281,7 +289,7 @@ static StatusWindowController *sharedController; NSString *message = @"The new features in this version of MenuTunes\nrequire you to reconfigure your preferences."; [_window setImage:[NSImage imageNamed:@"Setup"]]; - [_window setSizing:(StatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; + [_window setSizing:(ITTransientStatusWindowSizing)[df integerForKey:@"statusWindowSizing"]]; [_window buildDialogWindowWithMessage:message defaultButton:@"Show Preferences" alternateButton:@"OK" diff --git a/iTunesRemote.m b/iTunesRemote.m index d41f3bd..3c1ce75 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -417,7 +417,17 @@ - (NSImage *)currentSongAlbumArt { - return nil; + NSAppleScript *script; + NSAppleEventDescriptor *moof; + NSData *data; + script = [[NSAppleScript alloc] initWithSource:@"tell application \"iTunes\"\nget data of artwork 1 of current track\nend tell"]; + moof = [script executeAndReturnError:nil]; + data = [moof data]; + if (data) { + return [[[NSImage alloc] initWithData:data] autorelease]; + } else { + return nil; + } } - (float)currentSongRating diff --git a/libValidate.a b/libValidate.a index 61d6029..576d85e 100755 Binary files a/libValidate.a and b/libValidate.a differ