Album art will be embedded into the menu if on 10.3 and not connected
authorKent Sutherland <ksuther@ithinksw.com>
Sun, 9 May 2004 23:59:36 +0000 (23:59 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Sun, 9 May 2004 23:59:36 +0000 (23:59 +0000)
over a network.

MainController.h
MainController.m
MenuController.m

index 2c0cf32..d29e371 100755 (executable)
@@ -90,3 +90,7 @@
 - (void)showCurrentTrackInfo;
 
 @end
+
+@interface NSImage (SmoothAdditions)
+- (NSImage *)imageScaledSmoothlyToSize:(NSSize)scaledSize;
+@end
\ No newline at end of file
index ca0d38d..6937a6f 100755 (executable)
 #import "StatusWindowController.h"
 #import "StatusItemHack.h"
 
-@interface NSImage (WeeAdditions)
-- (NSImage *)imageScaledSmoothlyToSize:(NSSize)scaledSize;
-@end
-
-@implementation NSImage (WeeAdditions)
+@implementation NSImage (SmoothAdditions)
 
 - (NSImage *)imageScaledSmoothlyToSize:(NSSize)scaledSize
 {
@@ -264,7 +260,7 @@ static MainController *sharedController;
             [self setupHotKeys];
             if (![refreshTimer isValid]) {
                 [refreshTimer release];
-                refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:0.5
+                refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:([networkController isConnectedToServer] ? 10.0 : 0.5)
                              target:self
                              selector:@selector(timerUpdate)
                              userInfo:nil
index a38ec5b..f1e96fb 100755 (executable)
@@ -8,6 +8,7 @@
 
 #import "MenuController.h"
 #import "MainController.h"
+#import "NetworkController.h"
 #import "ITMTRemote.h"
 #import <ITFoundation/ITDebug.h>
 #import <ITKit/ITHotKeyCenter.h>
                     NS_HANDLER
                         [[MainController sharedController] networkError:localException];
                     NS_ENDHANDLER
+                    
+                    if ([tempItem respondsToSelector:@selector(setAttributedTitle:)] && [defaults boolForKey:@"showAlbumArtwork"] && ![[NetworkController sharedController] isConnectedToServer]) {
+                        NSImage *image = [[[MainController sharedController] currentRemote] currentSongAlbumArt];
+                        if (image) {
+                            NSSize oldSize, newSize;
+                            oldSize = [image size];
+                            if (oldSize.width > oldSize.height) newSize = NSMakeSize(110,oldSize.height * (110.0f / oldSize.width));
+                            else newSize = NSMakeSize(oldSize.width * (110.0f / oldSize.height),110);
+                            image = [[[[NSImage alloc] initWithData:[image TIFFRepresentation]] autorelease] imageScaledSmoothlyToSize:newSize];
+                            
+                            tempItem = [menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
+                            NSTextAttachment *attachment = [[[NSTextAttachment alloc] init] autorelease];
+                            [[attachment attachmentCell] setImage:image];
+                            NSAttributedString *attrString = [NSAttributedString attributedStringWithAttachment:attachment];
+                            [tempItem setAttributedTitle:attrString];
+                        }
+                    }
                 }
             } else {
                 ITDebugLog(@"No Track is Playing, Add \"No Song\" menu item.");