From: Matthew Judy Date: Wed, 1 Oct 2003 11:40:42 +0000 (+0000) Subject: OMG HUEG COMMIT!!! IT SI LIEK AN XBOX, BECAUES IT SI SO HUEG!! ALL STATUS WINDOW... X-Git-Tag: v1.0~32 X-Git-Url: http://git.ithinksw.org/MenuTunes.git/commitdiff_plain/3a1a21d1ea3e060f88ca1d24ea881f3ccb97640c OMG HUEG COMMIT!!! IT SI LIEK AN XBOX, BECAUES IT SI SO HUEG!! ALL STATUS WINDOW CONTENT IN, AND VARIPUS OTHER STUFF HAHA --- diff --git a/English.lproj/Preferences.nib/info.nib b/English.lproj/Preferences.nib/info.nib index 32b0c27..6d64f8c 100755 --- a/English.lproj/Preferences.nib/info.nib +++ b/English.lproj/Preferences.nib/info.nib @@ -3,9 +3,9 @@ IBDocumentLocation - 6 66 356 240 0 0 1152 746 + 5 69 356 240 0 0 1056 770 IBFramework Version - 291.0 + 286.0 IBGroupedObjects 0 @@ -25,6 +25,6 @@ 6 IBSystem Version - 6R65 + 6L60 diff --git a/English.lproj/Preferences.nib/keyedobjects.nib b/English.lproj/Preferences.nib/keyedobjects.nib index fada2b3..5587b1e 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 06ae1d9..523936c 100755 --- a/MainController.m +++ b/MainController.m @@ -36,7 +36,7 @@ static MainController *sharedController; sharedController = self; remoteArray = [[NSMutableArray alloc] initWithCapacity:1]; - statusWindowController = [[StatusWindowController alloc] init]; + statusWindowController = [StatusWindowController sharedController]; menuController = [[MenuController alloc] init]; df = [[NSUserDefaults standardUserDefaults] retain]; } @@ -89,6 +89,8 @@ static MainController *sharedController; [statusItem setImage:[NSImage imageNamed:@"MenuNormal"]]; [statusItem setAlternateImage:[NSImage imageNamed:@"MenuInverted"]]; + + [NSApp deactivate]; } - (ITMTRemote *)loadRemote @@ -207,7 +209,7 @@ static MainController *sharedController; [menuController rebuildSubmenus]; if ( [df boolForKey:@"showSongInfoOnChange"] ) { -// [self performSelector:@selector(showCurrentTrackInfo) withObject:nil afterDelay:0.0]; + [self performSelector:@selector(showCurrentTrackInfo) withObject:nil afterDelay:0.0]; } } } @@ -493,10 +495,11 @@ static MainController *sharedController; NSString *album = nil; NSString *artist = nil; NSString *time = nil; - int trackNumber = 0; - int trackTotal = 0; + NSString *track = nil; int rating = -1; + ITDebugLog(@"Showing track info status window."); + if ( title ) { if ( [df boolForKey:@"showAlbum"] ) { @@ -508,15 +511,23 @@ static MainController *sharedController; } if ( [df boolForKey:@"showTime"] ) { - time = [currentRemote currentSongLength]; + time = [NSString stringWithFormat:@"%@: %@ / %@", + @"Time", + [currentRemote currentSongElapsed], + [currentRemote currentSongLength]]; } - if ( [df boolForKey:@"showNumber"] ) { - trackNumber = [currentRemote currentSongTrack]; - trackTotal = [currentRemote currentAlbumTrackCount]; + if ( [df boolForKey:@"showTrackNumber"] ) { + int trackNo = [currentRemote currentSongTrack]; + int trackCount = [currentRemote currentAlbumTrackCount]; + + if ( (trackNo > 0) || (trackCount > 0) ) { + track = [NSString stringWithFormat:@"%@: %i %@ %i", + @"Track", trackNo, @"of", trackCount]; + } } - if ( [df boolForKey:@"showRating"] ) { + if ( [df boolForKey:@"showTrackRating"] ) { rating = ( [currentRemote currentSongRating] * 5 ); } @@ -529,8 +540,7 @@ static MainController *sharedController; album:album artist:artist time:time - trackNumber:trackNumber - trackTotal:trackTotal + track:track rating:rating]; } @@ -652,12 +662,12 @@ static MainController *sharedController; - (void)toggleShuffle { - bool newShuffleEnabled = ![currentRemote shuffleEnabled]; + BOOL newShuffleEnabled = ( ! [currentRemote shuffleEnabled] ); ITDebugLog(@"Toggling shuffle mode."); [currentRemote setShuffleEnabled:newShuffleEnabled]; //Show shuffle status window ITDebugLog(@"Setting shuffle mode to %i", newShuffleEnabled); - [statusWindowController showRepeatWindowWithMode:newShuffleEnabled]; + [statusWindowController showShuffleWindow:newShuffleEnabled]; } /*************************************************************************/ diff --git a/MenuController.m b/MenuController.m index 86a65ec..632d45d 100755 --- a/MenuController.m +++ b/MenuController.m @@ -224,7 +224,7 @@ if ([defaults boolForKey:@"showAlbum"]) { NSString *curAlbum = [currentRemote currentSongAlbum]; ITDebugLog(@"Add Track Album (\"%@\") menu item.", curAlbum); - if ([curAlbum length]) { + if ( curAlbum ) { [menu indentItem: [menu addItemWithTitle:curAlbum action:nil keyEquivalent:@""]]; } @@ -233,7 +233,7 @@ if ([defaults boolForKey:@"showArtist"]) { NSString *curArtist = [currentRemote currentSongArtist]; ITDebugLog(@"Add Track Artist (\"%@\") menu item.", curArtist); - if ([curArtist length]) { + if ( curArtist ) { [menu indentItem: [menu addItemWithTitle:curArtist action:nil keyEquivalent:@""]]; } @@ -242,7 +242,7 @@ if ([defaults boolForKey:@"showTrackNumber"]) { int track = [currentRemote currentSongTrack]; ITDebugLog(@"Add Track Number (\"Track %i\") menu item.", track); - if (track) { + if ( track ) { [menu indentItem: [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %i", NSLocalizedString(@"track", @"Track"), track] action:nil keyEquivalent:@""]]; } diff --git a/OldMainController.m b/OldMainController.m index 87d184e..0ade694 100755 --- a/OldMainController.m +++ b/OldMainController.m @@ -390,7 +390,7 @@ if ([defaults boolForKey:@"showAlbum"]) { NSString *album = [currentRemote currentSongAlbum]; - if ([album length] > 0) { + if ( album ) { [menu insertItemWithTitle:[NSString stringWithFormat:@" %@", album] action:nil keyEquivalent:@"" atIndex:trackInfoIndex + 1]; } } @@ -765,7 +765,7 @@ if ([defaults boolForKey:@"showAlbum"]) { NSString *trackAlbum = [currentRemote currentSongAlbum]; - if ([trackAlbum length]) { + if ( trackAlbum ) { stringToShow = [stringToShow stringByAppendingString:trackAlbum]; stringToShow = [stringToShow stringByAppendingString:@"\n"]; } diff --git a/PreferencesController.m b/PreferencesController.m index b827375..590e6de 100755 --- a/PreferencesController.m +++ b/PreferencesController.m @@ -1,6 +1,7 @@ #import "PreferencesController.h" #import "MainController.h" #import "StatusWindow.h" +#import "StatusWindowController.h" #import "CustomMenuTableView.h" #import @@ -105,9 +106,10 @@ static PreferencesController *prefs = nil; //Change the launch player checkbox to the proper name [launchPlayerAtLaunchCheckbox setTitle:[NSString stringWithFormat:@"Launch %@ when MenuTunes launches", [[controller currentRemote] playerSimpleName]]]; //This isn't localized... } - [window setLevel:NSStatusWindowLevel]; + [window center]; - [window makeKeyAndOrderFront:self]; + [NSApp activateIgnoringOtherApps:YES]; + [window performSelector:@selector(makeKeyAndOrderFront:) withObject:self afterDelay:0.0]; } - (IBAction)changeGeneralSetting:(id)sender @@ -308,12 +310,26 @@ static PreferencesController *prefs = nil; [loginWindow release]; if (!found) { - if (NSRunInformationalAlertPanel(NSLocalizedString(@"autolaunch", @"Auto-launch MenuTunes"), NSLocalizedString(@"autolaunch_msg", @"Would you like MenuTunes to automatically launch at login?"), @"Yes", @"No", nil) == NSOKButton) { - [self setLaunchesAtLogin:YES]; - } + [[StatusWindowController sharedController] showSetupQueryWindow]; } } +- (void)autoLaunchOK +{ + [[StatusWindow sharedWindow] setLocked:NO]; + [[StatusWindow sharedWindow] vanish:self]; + [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES]; + + [self setLaunchesAtLogin:YES]; +} + +- (void)autoLaunchCancel +{ + [[StatusWindow sharedWindow] setLocked:NO]; + [[StatusWindow sharedWindow] vanish:self]; + [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES]; +} + - (IBAction)cancelHotKey:(id)sender { ITDebugLog(@"Hot key canceled."); diff --git a/Rating.tiff b/Rating.tiff new file mode 100755 index 0000000..1f875c3 Binary files /dev/null and b/Rating.tiff differ diff --git a/StatusWindow.h b/StatusWindow.h index 6e72123..8432e05 100755 --- a/StatusWindow.h +++ b/StatusWindow.h @@ -16,12 +16,16 @@ #import -#define SW_PAD 24.0 -#define SW_SPACE 24.0 -#define SW_MINW 211.0 -#define SW_BORDER 32.0 -#define SW_METER_PAD 4.0 - +#define SW_PAD 24.00 +#define SW_SPACE 24.00 +#define SW_MINW 211.00 +#define SW_BORDER 32.00 +#define SW_METER_PAD 4.00 +#define SW_BUTTON_PAD_R 30.00 +#define SW_BUTTON_PAD_B 24.00 +#define SW_BUTTON_DIV 12.00 +#define SW_BUTTON_EXTRA_W 8.00 +#define SW_SHADOW_SAT 1.25 @interface StatusWindow : ITTransientStatusWindow { NSImage *_image; @@ -33,6 +37,7 @@ - (void)buildTextWindowWithString:(NSString *)text; - (void)buildMeterWindowWithCharacter:(NSString *)character + size:(float)size count:(int)count active:(int)active; - (void)buildDialogWindowWithMessage:(NSString *)message diff --git a/StatusWindow.m b/StatusWindow.m index 5e1bcfd..0a1ba7f 100755 --- a/StatusWindow.m +++ b/StatusWindow.m @@ -8,12 +8,15 @@ #import "StatusWindow.h" + @interface StatusWindow (Private) - (NSRect)setupWindowWithDataSize:(NSSize)dataSize; @end + @implementation StatusWindow + /*************************************************************************/ #pragma mark - #pragma mark INITIALIZATION / DEALLOCATION METHODS @@ -55,6 +58,7 @@ - (void)setLocked:(BOOL)flag { _locked = flag; + [self setExitMode:(flag ? ITTransientStatusWindowExitOnCommand : ITTransientStatusWindowExitAfterDelay)]; } @@ -63,6 +67,20 @@ #pragma mark INSTANCE METHODS /*************************************************************************/ +- (void)appear:(id)sender +{ + if ( ! _locked ) { + [super appear:sender]; + } +} + +- (void)vanish:(id)sender +{ + if ( ! _locked ) { + [super vanish:sender]; + } +} + - (NSRect)setupWindowWithDataSize:(NSSize)dataSize { NSRect imageRect; @@ -105,97 +123,108 @@ - (void)buildTextWindowWithString:(NSString *)text { - float dataWidth = 0.0; - float dataHeight = 0.0; - NSRect dataRect; - NSArray *lines = [text componentsSeparatedByString:@"\n"]; - id oneLine = nil; - NSEnumerator *lineEnum = [lines objectEnumerator]; - NSFont *font = [NSFont fontWithName:@"Lucida Grande Bold" size:18]; - NSDictionary *attr = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName]; - ITTextField *textField; - -// Iterate over each line to get text width and height - while ( (oneLine = [lineEnum nextObject]) ) { -// Get the width of one line, adding 8.0 because Apple sucks donkey rectum. - float oneLineWidth = ( [oneLine sizeWithAttributes:attr].width + 8.0 ); -// Add the height of this line to the total text height - dataHeight += [oneLine sizeWithAttributes:attr].height; -// If this line wider than the last one, set it as the text width. - dataWidth = ( ( dataWidth > oneLineWidth ) ? dataWidth : oneLineWidth ); - } + if ( ! _locked ) { + + float dataWidth = 0.0; + float dataHeight = 0.0; + NSRect dataRect; + NSArray *lines = [text componentsSeparatedByString:@"\n"]; + id oneLine = nil; + NSEnumerator *lineEnum = [lines objectEnumerator]; + NSFont *font = [NSFont fontWithName:@"Lucida Grande Bold" size:18]; + NSDictionary *attr = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName]; + ITTextField *textField; -// Add 4.0 to the final dataHeight to accomodate the shadow. - dataHeight += 4.0; - - dataRect = [self setupWindowWithDataSize:NSMakeSize(dataWidth, dataHeight)]; - -// Create, position, setup, fill, and add the text view to the content view. - textField = [[[ITTextField alloc] initWithFrame:dataRect] autorelease]; - [textField setEditable:NO]; - [textField setSelectable:NO]; - [textField setBordered:NO]; - [textField setDrawsBackground:NO]; - [textField setFont:font]; - [textField setTextColor:[NSColor whiteColor]]; - [textField setCastsShadow:YES]; - [textField setStringValue:text]; - [[self contentView] addSubview:textField]; - -// Display the window. - [[self contentView] setNeedsDisplay:YES]; +// Iterate over each line to get text width and height + while ( (oneLine = [lineEnum nextObject]) ) { +// Get the width of one line, adding 8.0 because Apple sucks donkey rectum. + float oneLineWidth = ( [oneLine sizeWithAttributes:attr].width + 8.0 ); +// Add the height of this line to the total text height + dataHeight += [oneLine sizeWithAttributes:attr].height; +// If this line wider than the last one, set it as the text width. + dataWidth = ( ( dataWidth > oneLineWidth ) ? dataWidth : oneLineWidth ); + } + +// Add 4.0 to the final dataHeight to accomodate the shadow. + dataHeight += 4.0; + + dataRect = [self setupWindowWithDataSize:NSMakeSize(dataWidth, dataHeight)]; + +// Create, position, setup, fill, and add the text view to the content view. + textField = [[[ITTextField alloc] initWithFrame:dataRect] autorelease]; + [textField setEditable:NO]; + [textField setSelectable:NO]; + [textField setBordered:NO]; + [textField setDrawsBackground:NO]; + [textField setFont:font]; + [textField setTextColor:[NSColor whiteColor]]; + [textField setCastsShadow:YES]; + [textField setStringValue:text]; + [textField setShadowSaturation:SW_SHADOW_SAT]; + [[self contentView] addSubview:textField]; + +// Display the window. + [[self contentView] setNeedsDisplay:YES]; + + } } - (void)buildMeterWindowWithCharacter:(NSString *)character + size:(float)size count:(int)count active:(int)active { - NSFont *font = [NSFont fontWithName:@"Lucida Grande Bold" size:18]; - NSDictionary *attr = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName]; - NSSize charSize = [character sizeWithAttributes:attr]; - float cellHeight = ( charSize.height + 4.0 ); // Add 4.0 for shadow - float cellWidth = ( (charSize.width) + SW_METER_PAD ); // Add 8.0 for Apple suck - float dataWidth = ( cellWidth * count ); - NSRect dataRect = [self setupWindowWithDataSize:NSMakeSize(dataWidth, cellHeight)]; - NSEnumerator *cellEnum = nil; - id aCell = nil; - int activeCount = 0; - NSColor *onColor = [NSColor whiteColor]; - NSColor *offColor = [NSColor colorWithCalibratedWhite:0.0 alpha:0.50]; - NSMatrix *volMatrix = [[[NSMatrix alloc] initWithFrame:dataRect - mode:NSHighlightModeMatrix - cellClass:NSClassFromString(@"ITTextFieldCell") - numberOfRows:1 - numberOfColumns:count] autorelease]; - - [volMatrix setCellSize:NSMakeSize(cellWidth, cellHeight)]; - [volMatrix setIntercellSpacing:NSMakeSize(0, 0)]; - - cellEnum = [[volMatrix cells] objectEnumerator]; - - while ( (aCell = [cellEnum nextObject]) ) { - [aCell setEditable:NO]; - [aCell setSelectable:NO]; - [aCell setBordered:NO]; - [aCell setDrawsBackground:NO]; - [aCell setAlignment:NSCenterTextAlignment]; - [aCell setFont:font]; - [aCell setStringValue:character]; - - activeCount ++; - - if ( active >= activeCount ) { - [aCell setCastsShadow:YES]; - [aCell setTextColor:onColor]; - } else { - [aCell setCastsShadow:NO]; - [aCell setTextColor:offColor]; + if ( ! _locked ) { + + NSFont *font = [NSFont fontWithName:@"Lucida Grande Bold" size:size]; + NSDictionary *attr = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName]; + NSSize charSize = [character sizeWithAttributes:attr]; + float cellHeight = ( charSize.height + 4.0 ); // Add 4.0 for shadow + float cellWidth = ( (charSize.width) + SW_METER_PAD ); // Add 8.0 for Apple suck + float dataWidth = ( cellWidth * count ); + NSRect dataRect = [self setupWindowWithDataSize:NSMakeSize(dataWidth, cellHeight)]; + NSEnumerator *cellEnum = nil; + id aCell = nil; + int activeCount = 0; + NSColor *onColor = [NSColor whiteColor]; + NSColor *offColor = [NSColor colorWithCalibratedWhite:0.0 alpha:0.50]; + NSMatrix *volMatrix = [[[NSMatrix alloc] initWithFrame:dataRect + mode:NSHighlightModeMatrix + cellClass:NSClassFromString(@"ITTextFieldCell") + numberOfRows:1 + numberOfColumns:count] autorelease]; + + [volMatrix setCellSize:NSMakeSize(cellWidth, cellHeight)]; + [volMatrix setIntercellSpacing:NSMakeSize(0, 0)]; + + cellEnum = [[volMatrix cells] objectEnumerator]; + + while ( (aCell = [cellEnum nextObject]) ) { + [aCell setEditable:NO]; + [aCell setSelectable:NO]; + [aCell setBordered:NO]; + [aCell setDrawsBackground:NO]; + [aCell setAlignment:NSCenterTextAlignment]; + [aCell setFont:font]; + [aCell setStringValue:character]; + [aCell setShadowSaturation:SW_SHADOW_SAT]; + + activeCount ++; + + if ( active >= activeCount ) { + [aCell setCastsShadow:YES]; + [aCell setTextColor:onColor]; + } else { + [aCell setCastsShadow:NO]; + [aCell setTextColor:offColor]; + } + } + + [[self contentView] addSubview:volMatrix]; + [[self contentView] setNeedsDisplay:YES]; } - - [[self contentView] addSubview:volMatrix]; - [[self contentView] setNeedsDisplay:YES]; } - (void)buildDialogWindowWithMessage:(NSString *)message @@ -205,7 +234,135 @@ defaultAction:(SEL)okAction alternateAction:(SEL)alternateAction { + if ( ! _locked ) { + + float textWidth = 0.0; + float textHeight = 0.0; + float okWidth = 0.0; + float cancelWidth = 0.0; + float wideButtonW = 0.0; + float buttonWidth = 0.0; + float dataHeight = 0.0; + float dataWidth = 0.0; + NSRect dataRect; + float textY = 0.0; + NSRect textRect; + float textAddBelow = 32.0; + float dataMinH = 92.0; + float textMinH = 48.0; + NSArray *lines = [message componentsSeparatedByString:@"\n"]; + id oneLine = nil; + NSEnumerator *lineEnum = [lines objectEnumerator]; + ITTextField *textField; + ITButton *okButton; + ITButton *cancelButton; + NSColor *textColor = [NSColor whiteColor]; + NSFont *font = [NSFont fontWithName:@"Lucida Grande Bold" size:18]; + NSDictionary *attr = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName]; + NSFont *buttonFont = [NSFont fontWithName:@"Lucida Grande Bold" size:14]; + NSDictionary *buttonAttr = [NSDictionary dictionaryWithObjectsAndKeys: + buttonFont , NSFontAttributeName, + textColor , NSForegroundColorAttributeName, + nil]; + +// Iterate over each line to get text width and height + while ( (oneLine = [lineEnum nextObject]) ) { +// Get the width of one line, adding 8.0 because Apple sucks donkey rectum. + float oneLineWidth = ( [oneLine sizeWithAttributes:attr].width + 8.0 ); +// Add the height of this line to the total text height + textHeight += [oneLine sizeWithAttributes:attr].height; +// If this line wider than the last one, set it as the text width. + textWidth = ( ( textWidth > oneLineWidth ) ? textWidth : oneLineWidth ); + } + +// Add 4.0 to the final dataHeight to accomodate the shadow. + textHeight += 4.0; + +// Add extra padding below the text + dataHeight = (textHeight + textAddBelow); + +// Test to see if data height is tall enough + if ( dataHeight < dataMinH ) { + dataHeight = dataMinH; + } + +// Make the buttons, set the titles, and size them to fit their titles + okButton = [[ITButton alloc] initWithFrame:NSMakeRect(0, 0, 300, 24)]; + cancelButton = [[ITButton alloc] initWithFrame:NSMakeRect(0, 0, 300, 24)]; + [okButton setBezelStyle:ITGrayRoundedBezelStyle]; + [cancelButton setBezelStyle:ITGrayRoundedBezelStyle]; + [okButton setAlignment:NSRightTextAlignment]; + [cancelButton setAlignment:NSCenterTextAlignment]; + [okButton setImagePosition:NSNoImage]; + [cancelButton setImagePosition:NSNoImage]; + [okButton setAttributedTitle:[[[NSAttributedString alloc] initWithString:defaultTitle + attributes:buttonAttr] autorelease]]; + [cancelButton setAttributedTitle:[[[NSAttributedString alloc] initWithString:alternateTitle + attributes:buttonAttr] autorelease]]; + [okButton sizeToFit]; + [cancelButton sizeToFit]; + +// Get the button widths. Add any extra width here. + okWidth = ([okButton frame].size.width + SW_BUTTON_EXTRA_W); + cancelWidth = ([cancelButton frame].size.width + SW_BUTTON_EXTRA_W); + +// Figure out which button is wider. + wideButtonW = ( (okWidth > cancelWidth) ? okWidth : cancelWidth ); + +// Get the total width of the buttons. Add the divider space. + buttonWidth = ( (wideButtonW * 2) + SW_BUTTON_DIV ); +// Set the dataWidth to whichever is greater: text width or button width. + dataWidth = ( (textWidth > buttonWidth) ? textWidth : buttonWidth); + +// Setup the window + dataRect = [self setupWindowWithDataSize:NSMakeSize(dataWidth, dataHeight)]; + +// Set an initial vertical point for the textRect's origin. + textY = dataRect.origin.y + textAddBelow; + +// Move that point up if the minimimum height of the text area is not occupied. + if ( textHeight < textMinH ) { + textY += ( (textMinH - textHeight) / 2 ); + } + +// Build the text rect. + textRect = NSMakeRect(dataRect.origin.x, + textY, + textWidth, + textHeight); + +// Create, position, setup, fill, and add the text view to the content view. + textField = [[[ITTextField alloc] initWithFrame:textRect] autorelease]; + [textField setEditable:NO]; + [textField setSelectable:NO]; + [textField setBordered:NO]; + [textField setDrawsBackground:NO]; + [textField setFont:font]; + [textField setTextColor:textColor]; + [textField setCastsShadow:YES]; + [textField setStringValue:message]; + [textField setShadowSaturation:SW_SHADOW_SAT]; + [[self contentView] addSubview:textField]; + +// Set the button frames, and add them to the content view. + [okButton setFrame:NSMakeRect( ([[self contentView] frame].size.width - (wideButtonW + SW_BUTTON_PAD_R) ), + SW_BUTTON_PAD_B, + wideButtonW, + 24.0)]; + [cancelButton setFrame:NSMakeRect( ([[self contentView] frame].size.width - ((wideButtonW * 2) + SW_BUTTON_DIV + SW_BUTTON_PAD_R) ), + SW_BUTTON_PAD_B, + wideButtonW, + 24.0)]; + [[self contentView] addSubview:okButton]; + [[self contentView] addSubview:cancelButton]; + NSLog(@"%@", [[self contentView] description]); + + [self setIgnoresMouseEvents:NO]; + +// Display the window. + [[self contentView] setNeedsDisplay:YES]; + } } diff --git a/StatusWindowController.h b/StatusWindowController.h index 2cf440b..01f36f3 100755 --- a/StatusWindowController.h +++ b/StatusWindowController.h @@ -20,9 +20,9 @@ typedef enum { - StatusWindowRepeatNone, + StatusWindowRepeatNone = -1, StatusWindowRepeatGroup, - StatusWindowRepeatSong + StatusWindowRepeatTrack } StatusWindowRepeatMode; @@ -31,10 +31,12 @@ typedef enum { NSUserDefaults *df; } ++ (StatusWindowController *)sharedController; + - (void)showUpcomingSongsWindowWithTitles:(NSArray *)titleStrings; - (void)showVolumeWindowWithLevel:(float)level; -- (void)showRatingWindowWithRating:(int)rating; +- (void)showRatingWindowWithRating:(float)rating; - (void)showShuffleWindow:(BOOL)shuffle; - (void)showRepeatWindowWithMode:(StatusWindowRepeatMode)mode; - (void)showSetupQueryWindow; @@ -43,9 +45,8 @@ typedef enum { title: (NSString *)title album: (NSString *)album artist: (NSString *)artist - time: (NSString *)time - trackNumber: (int)trackNumber - trackTotal: (int)trackTotal + time: (NSString *)time // FLOW: Should probably be NSDate or something. + track: (NSString *)track rating: (int)rating; diff --git a/StatusWindowController.m b/StatusWindowController.m index 49cbf89..e8b1eef 100755 --- a/StatusWindowController.m +++ b/StatusWindowController.m @@ -1,13 +1,6 @@ -// -// StatusWindowController.m -// MenuTunes -// -// Created by Matthew L. Judy on Thu Apr 17 2003. -// Copyright (c) 2003 NibFile.com. All rights reserved. -// - #import "StatusWindowController.h" #import "StatusWindow.h" +#import "PreferencesController.h" #import #import @@ -16,9 +9,23 @@ #import #import + +static StatusWindowController *sharedController; + + @implementation StatusWindowController ++ (StatusWindowController *)sharedController +{ + if ( ! sharedController ) { + sharedController = [[StatusWindowController alloc] init]; + } + + return sharedController; +} + + - (id)init { if ( ( self = [super init] ) ) { @@ -90,47 +97,131 @@ album: (NSString *)album artist: (NSString *)artist time: (NSString *)time // FLOW: Should probably be NSDate or something. - trackNumber: (int)trackNumber - trackTotal: (int)trackTotal + track: (NSString *)track rating: (int)rating { - [_window setImage:[NSImage imageNamed:@"Library"]]; - [_window buildTextWindowWithString:title]; + NSImage *image = nil; + NSString *text = title; + + if ( source == ITMTRemoteLibrarySource ) { + image = [NSImage imageNamed:@"Library"]; + } else if ( source == ITMTRemoteCDSource ) { + image = [NSImage imageNamed:@"CD"]; + } else if ( source == ITMTRemoteRadioSource ) { + image = [NSImage imageNamed:@"Radio"]; + } else if ( source == ITMTRemoteiPodSource ) { + image = [NSImage imageNamed:@"iPod"]; + } else if ( source == ITMTRemoteGenericDeviceSource ) { + image = [NSImage imageNamed:@"MP3Player"]; + } else if ( source == ITMTRemoteSharedLibrarySource ) { + image = [NSImage imageNamed:@"Library"]; + } + + [_window setImage:image]; + + if ( album ) { + text = [text stringByAppendingString:[@"\n" stringByAppendingString:album]]; + } + if ( artist ) { + text = [text stringByAppendingString:[@"\n" stringByAppendingString:artist]]; + } + if ( time ) { + text = [text stringByAppendingString:[@"\n" stringByAppendingString:time]]; + } + if ( track ) { + text = [text stringByAppendingString:[@"\n" stringByAppendingString:track]]; + } + if ( rating > -1 ) { + + NSString *ratingString = [NSString string]; + NSString *emptyChar = [NSString stringWithUTF8String:"☆"]; + NSString *fullChar = [NSString stringWithUTF8String:"★"]; + int i; + + for ( i = 1; i < 6; i++ ) { + + if ( rating >= i ) { + ratingString = [ratingString stringByAppendingString:fullChar]; + } else { + ratingString = [ratingString stringByAppendingString:emptyChar]; + } + } + + text = [text stringByAppendingString:[@"\n" stringByAppendingString:ratingString]]; + } + + [_window buildTextWindowWithString:text]; [_window appear:self]; } - (void)showUpcomingSongsWindowWithTitles:(NSArray *)titleStrings { - +// NSString *bull = [NSString stringWithUTF8String:"‣ "]; + NSString *bull = [NSString stringWithUTF8String:"♪ "]; + NSString *end = [@"\n" stringByAppendingString:bull]; + [_window setImage:[NSImage imageNamed:@"Upcoming"]]; + [_window buildTextWindowWithString:[bull stringByAppendingString:[titleStrings componentsJoinedByString:end]]]; + [_window appear:self]; } - (void)showVolumeWindowWithLevel:(float)level { [_window setImage:[NSImage imageNamed:@"Volume"]]; [_window buildMeterWindowWithCharacter:[NSString stringWithUTF8String:"▊"] + size:18 count:10 active:( ceil(level * 100) / 10 )]; [_window appear:self]; } -- (void)showRatingWindowWithRating:(int)rating +- (void)showRatingWindowWithRating:(float)rating { - + [_window setImage:[NSImage imageNamed:@"Rating"]]; + [_window buildMeterWindowWithCharacter:[NSString stringWithUTF8String:"★"] + size:48 + count:5 + active:( ceil(rating * 100) / 20 )]; + [_window appear:self]; } - (void)showShuffleWindow:(BOOL)shuffle { - + [_window setImage:[NSImage imageNamed:@"Shuffle"]]; + [_window buildTextWindowWithString:( shuffle ? @"Shuffle On" : @"Shuffle Off")]; + [_window appear:self]; } - (void)showRepeatWindowWithMode:(StatusWindowRepeatMode)mode { - + NSString *string = nil; + + if ( mode == StatusWindowRepeatNone ) { + string = @"Repeat Off"; + } else if ( mode == StatusWindowRepeatGroup ) { + string = @"Repeat Playlist"; + } else if ( mode == StatusWindowRepeatTrack ) { + string = @"Repeat One Track"; + } + + [_window setImage:[NSImage imageNamed:@"Repeat"]]; + [_window buildTextWindowWithString:string]; + [_window appear:self]; } - (void)showSetupQueryWindow { + NSString *message = @"Would you like MenuTunes to launch\nautomatically at startup?"; + [_window setImage:[NSImage imageNamed:@"Setup"]]; + [_window buildDialogWindowWithMessage:message + defaultButton:@"Launch at Startup" + alternateButton:@"Launch Manually" + target:[PreferencesController sharedPrefs] + defaultAction:@selector(autoLaunchOK) + alternateAction:@selector(autoLaunchCancel)]; + + [_window appear:self]; + [_window setLocked:YES]; } diff --git a/TODO.rtf b/TODO.rtf index f73d332..86e1598 100755 --- a/TODO.rtf +++ b/TODO.rtf @@ -38,12 +38,6 @@ Status: Analyze\ Issue: iTunesRemote - Toggle loop and shuffle do not work.\ \ - Priority: IMPORTANT\ - Owner: Joseph Spiros\ - Status: Analyze\ - Issue: Menu - Needs to show "Space" as the key equivalent.\ -\pard\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li720\ql\qnatural -\cf0 \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural @@ -78,4 +72,10 @@ No entries yet.\ Issue: Upcoming Songs - should show the last songs played.\ \pard\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li720\ql\qnatural \cf0 \ +\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural +\cf0 Priority: FUTURE\ + Status: Analyze\ + Issue: Menu - Needs to show "Space" as the key equivalent.\ +\pard\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li720\ql\qnatural +\cf0 \ } \ No newline at end of file diff --git a/iTunesRemote.m b/iTunesRemote.m index c00d5fa..cb976a6 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -222,7 +222,7 @@ ITDebugLog(@"Getting song title at index %i.", index); temp1 = [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pnam'), from:obj { form:'indx', want:type('cTrk'), seld:long(%lu), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } } }",index] eventClass:@"core" eventID:@"getd" appPSN:savedPSN]; ITDebugLog(@"Getting song title at index %i done.", index); - return temp1; + return ( ([temp1 length]) ? temp1 : nil ) ; } - (int)currentAlbumTrackCount @@ -249,7 +249,7 @@ ITDebugLog(@"Getting current unique identifier."); temp1 = [NSString stringWithFormat:@"%i-%i", [self currentPlaylistIndex], [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pDID" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:savedPSN]]; ITDebugLog(@"Getting current unique identifier done."); - return temp1; + return ( ([temp1 length]) ? temp1 : nil ) ; } - (int)currentSongIndex @@ -267,7 +267,7 @@ ITDebugLog(@"Getting current song title."); temp1 = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKey:@"pnam" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:savedPSN]; ITDebugLog(@"Getting current song title done."); - return temp1; + return ( ([temp1 length]) ? temp1 : nil ) ; } - (NSString *)currentSongArtist @@ -276,7 +276,7 @@ ITDebugLog(@"Getting current song artist."); temp1 = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKey:@"pArt" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:savedPSN]; ITDebugLog(@"Getting current song artist done."); - return temp1; + return ( ([temp1 length]) ? temp1 : nil ) ; } - (NSString *)currentSongAlbum @@ -285,7 +285,7 @@ ITDebugLog(@"Getting current song album."); temp1 = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKey:@"pAlb" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:savedPSN]; ITDebugLog(@"Getting current song album done."); - return temp1; + return ( ([temp1 length]) ? temp1 : nil ) ; } - (NSString *)currentSongGenre @@ -294,7 +294,7 @@ ITDebugLog(@"Getting current song genre."); temp1 = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKey:@"pGen" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:savedPSN]; ITDebugLog(@"Getting current song genre done."); - return temp1; + return ( ([temp1 length]) ? temp1 : nil ) ; } - (NSString *)currentSongLength diff --git a/libValidate.a b/libValidate.a index d2a54bb..2b0cd4b 100755 Binary files a/libValidate.a and b/libValidate.a differ