Added support for attributed strings, which allows us to have non-sucky stars in...
authorKent Sutherland <ksuther@ithinksw.com>
Sun, 31 Jul 2005 18:47:02 +0000 (18:47 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Sun, 31 Jul 2005 18:47:02 +0000 (18:47 +0000)
English.lproj/InfoPlist.strings
English.lproj/Localizable.strings
MainController.m
StatusWindow.h
StatusWindow.m
StatusWindowController.h
StatusWindowController.m

index 286e922..6036df3 100755 (executable)
Binary files a/English.lproj/InfoPlist.strings and b/English.lproj/InfoPlist.strings differ
index 40eb0c0..0b70ce5 100755 (executable)
@@ -67,4 +67,5 @@ radio = "Radio";
 genericDevice = "Generic Device";
 iPod = "iPod";
 cd = "CD";
-sharedLibrary = "Shared Library";
\ No newline at end of file
+sharedLibrary = "Shared Library";
+debugmodeenabled = "Debug Mode Enabled\nAll actions MenuTunes performs will be logged\nto the console. To disable debug mode, quit\nand relaunch MenuTunes.\n\n(debug mode is enabled by holding down\nthe control key while MenuTunes opens)";
\ No newline at end of file
index 2a3d6b3..d185d83 100755 (executable)
@@ -103,8 +103,12 @@ static MainController *sharedController;
        float iTunesVersion;
        
     //Turn on debug mode if needed
-    if ([df boolForKey:@"ITDebugMode"]) {
+       /*if ((GetCurrentKeyModifiers() & (controlKey | rightControlKey)) != 0)
+    if ((GetCurrentKeyModifiers() & (optionKey | rightOptionKey)) != 0)
+    if ((GetCurrentKeyModifiers() & (shiftKey | rightShiftKey)) != 0)*/
+    if ([df boolForKey:@"ITDebugMode"] || ((GetCurrentKeyModifiers() & (controlKey | rightControlKey)) != 0)) {
         SetITDebugMode(YES);
+               [[StatusWindowController sharedController] showDebugModeEnabledWindow];
     }
 
        //Check if iTunes 4.7 or later is installed     
index 4b678bc..7bc9762 100755 (executable)
@@ -15,6 +15,9 @@
 #import <Cocoa/Cocoa.h>
 #import <ITKit/ITKit.h>
 
+#define SMALL_DIVISOR       1.33333
+#define MINI_DIVISOR        1.66667
+
 @interface StatusWindow : ITTransientStatusWindow {
     NSImage            *_image;
     BOOL                _locked;
@@ -23,7 +26,7 @@
 - (void)setImage:(NSImage *)newImage;
 - (void)setLocked:(BOOL)flag;
 
-- (void)buildTextWindowWithString:(NSString *)text;
+- (void)buildTextWindowWithString:(id)text;
 - (void)buildMeterWindowWithCharacter:(NSString *)character
                                  size:(float)size
                                 count:(int)count
index 253f075..0fdc52d 100755 (executable)
@@ -19,8 +19,6 @@
 #define SW_BUTTON_DIV      12.00
 #define SW_BUTTON_EXTRA_W   8.00
 #define SW_SHADOW_SAT       1.25
-#define SMALL_DIVISOR       1.33333
-#define MINI_DIVISOR        1.66667
 
 @interface StatusWindow (Private)
 - (NSRect)setupWindowWithDataSize:(NSSize)dataSize;
                        dataHeight);
 }
 
-- (void)buildTextWindowWithString:(NSString *)text
+- (void)buildTextWindowWithString:(id)text
 {
     if ( ! _locked ) {
 
         float         dataWidth     = 0.0;
         float         dataHeight    = 0.0;
         NSRect        dataRect;
-        NSArray      *lines         = [text componentsSeparatedByString:@"\n"];
+        NSArray      *lines                    = [(([text isKindOfClass:[NSString class]]) ? text : [text mutableString]) componentsSeparatedByString:@"\n"];
         id                       oneLine       = nil;
-        NSEnumerator *lineEnum      = [lines objectEnumerator];
+        NSEnumerator *lineEnum         = [lines objectEnumerator];
         float         baseFontSize  = 18.0;
         ITTextField  *textField;
         NSFont       *font;
         } else if ( _sizing == ITTransientStatusWindowMini ) {
             divisor = MINI_DIVISOR;
         }
-
-        font = [NSFont fontWithName:@"LucidaGrande-Bold" size:(baseFontSize / divisor)];
-        attr = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
-        
+               
+               font = [NSFont fontWithName:@"LucidaGrande-Bold" size:(baseFontSize / divisor)];
+               attr = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
+               
 //      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.
         [textField setTextColor:[NSColor whiteColor]];
         [textField setCastsShadow:YES];
         [[textField cell] setWraps:NO];
-        [textField setStringValue:text];
+               
+               if ([text isKindOfClass:[NSString class]]) {
+                       [textField setStringValue:text];
+               } else {
+                       [textField setAttributedStringValue:text];
+               }
+               
         [textField setShadowSaturation:SW_SHADOW_SAT];
         [[self contentView] addSubview:textField];
         
             divisor = MINI_DIVISOR;
         }
         
-        font        = [NSFont fontWithName:@"LucidaGrande-Bold" size:( size / divisor )];
+        font        = [NSFont fontWithName:@"AppleGothic" size:( size / divisor )];
         attr        = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
         charSize    = [character sizeWithAttributes:attr];
         cellHeight  = ( charSize.height + 4.0 );  // Add 4.0 for shadow
index 118ca38..c5a4566 100755 (executable)
@@ -42,6 +42,7 @@ typedef enum {
 - (void)showReconnectQueryWindow;
 - (void)showNetworkErrorQueryWindow;
 - (void)showPreferencesUpdateWindow;
+- (void)showDebugModeEnabledWindow;
 
 - (void)showSongInfoWindowWithSource:(ITMTRemotePlayerSource)source
                                title:            (NSString *)title
index 633c31c..e06176f 100755 (executable)
@@ -119,7 +119,7 @@ static StatusWindowController *sharedController;
                                image:             (NSImage *)art
 {
     NSImage  *image = nil;
-    NSString *text  = title;
+    NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:title];
     
     if ( art != nil ) {
         image = art;
@@ -138,31 +138,38 @@ static StatusWindowController *sharedController;
     }
     
     [_window setImage:image];
+       [_window setSizing:(ITTransientStatusWindowSizing)[df integerForKey:@"statusWindowSizing"]];
     
     if ( album ) {
-        text = [text stringByAppendingString:[@"\n" stringByAppendingString:album]];
+               [[text mutableString] appendFormat:@"\n%@", album];
+        //text = [text stringByAppendingString:[@"\n" stringByAppendingString:album]];
     }
     if ( artist ) {
-        text = [text stringByAppendingString:[@"\n" stringByAppendingString:artist]];
+               [[text mutableString] appendFormat:@"\n%@", artist];
+        //text = [text stringByAppendingString:[@"\n" stringByAppendingString:artist]];
     }
     if ( composer ) {
-        text = [text stringByAppendingString:[@"\n" stringByAppendingString:composer]];
+               [[text mutableString] appendFormat:@"\n%@", composer];
+        //text = [text stringByAppendingString:[@"\n" stringByAppendingString:composer]];
     }
     if ( time ) {
-        text = [text stringByAppendingString:[@"\n" stringByAppendingString:time]];
+               [[text mutableString] appendFormat:@"\n%@", time];
+        //text = [text stringByAppendingString:[@"\n" stringByAppendingString:time]];
     }
     if ( track ) {
-        text = [text stringByAppendingString:[@"\n" stringByAppendingString:track]];
+               [[text mutableString] appendFormat:@"\n%@", track];
+        //text = [text stringByAppendingString:[@"\n" stringByAppendingString:track]];
     }
     if (playCount > -1) {
-        text = [text stringByAppendingString:[NSString stringWithFormat:@"\n%@: %i", NSLocalizedString(@"playCount", @"Play Count"), playCount]];
+               [[text mutableString] appendFormat:@"\n%@: %i", NSLocalizedString(@"playCount", @"Play Count"), playCount];
+        //text = [text stringByAppendingString:[NSString stringWithFormat:@"\n%@: %i", NSLocalizedString(@"playCount", @"Play Count"), playCount]];
     }
     if ( rating > -1 ) {
 
         NSString *ratingString = [NSString string];
         NSString *emptyChar    = [NSString stringWithUTF8String:"☆"];
         NSString *fullChar     = [NSString stringWithUTF8String:"★"];
-        int       i;
+        int       i, start = [[text mutableString] length], size = 18;
         
         for ( i = 1; i < 6; i++ ) {
                
@@ -172,11 +179,17 @@ static StatusWindowController *sharedController;
                 ratingString = [ratingString stringByAppendingString:emptyChar];
             }
         }
-    
-        text = [text stringByAppendingString:[@"\n" stringByAppendingString:ratingString]];
+               
+               [[text mutableString] appendFormat:@"\n%@", ratingString];
+               if ([_window sizing] == ITTransientStatusWindowSmall) {
+                       size /= SMALL_DIVISOR;
+               } else if ([_window sizing] == ITTransientStatusWindowMini) {
+                       size /= MINI_DIVISOR;
+               }
+               [text setAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[NSFont fontWithName:@"AppleGothic" size:size], NSFontAttributeName, nil, nil] range:NSMakeRange(start + 1, 5)];
+        //text = [text stringByAppendingString:[@"\n" stringByAppendingString:ratingString]];
     }
     
-    [_window setSizing:(ITTransientStatusWindowSizing)[df integerForKey:@"statusWindowSizing"]];
     [_window buildTextWindowWithString:text];
     [_window appear:self];
 }
@@ -326,4 +339,18 @@ static StatusWindowController *sharedController;
     [_window setLocked:YES];
 }
 
+- (void)showDebugModeEnabledWindow
+{
+       [_window setImage:[NSImage imageNamed:@"Setup"]];
+    [_window setSizing:(ITTransientStatusWindowSizing)[df integerForKey:@"statusWindowSizing"]];
+    [_window buildDialogWindowWithMessage:NSLocalizedString(@"debugmodeenabled", @"Debug Mode Enabled")
+                            defaultButton:@"OK"
+                          alternateButton:nil
+                                   target:[MainController sharedController]
+                            defaultAction:@selector(cancelReconnect)
+                          alternateAction:nil];
+    [_window appear:self];
+       [_window setLocked:YES];
+}
+
 @end
\ No newline at end of file