mamburu: Info window now shows info for currently playing track in mini mode

CQTexperiment
Chris Moeller 2013-10-11 12:10:30 -07:00
parent 012ef22b40
commit 7b416e5877
2 changed files with 35 additions and 3 deletions

View File

@ -7,13 +7,19 @@
//
#import <Cocoa/Cocoa.h>
#import "AppController.h"
@interface InfoWindowController : NSWindowController {
@interface InfoWindowController : NSWindowController
{
IBOutlet id playlistSelectionController;
IBOutlet id currentEntryController;
IBOutlet AppController *appController;
id valueToDisplay;
}
@property(readonly) id playlistSelectionController;
@property(assign) id valueToDisplay;
- (IBAction)toggleWindow:(id)sender;

View File

@ -8,10 +8,12 @@
#import "InfoWindowController.h"
#import "MissingAlbumArtTransformer.h"
#import "Logging.h"
#import "AppController.h"
@implementation InfoWindowController
@synthesize playlistSelectionController;
@synthesize valueToDisplay;
+ (void)initialize
{
@ -25,6 +27,30 @@
return [super initWithWindowNibName:@"InfoInspector"];
}
- (void)awakeFromNib
{
[playlistSelectionController addObserver:self forKeyPath:@"selection" options:NSKeyValueObservingOptionNew context:nil];
[currentEntryController addObserver:self forKeyPath:@"content" options:NSKeyValueObservingOptionNew context:nil];
[appController addObserver:self forKeyPath:@"miniMode" options:NSKeyValueObservingOptionNew context:nil];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
BOOL miniMode = [appController miniMode];
BOOL currentEntryChanged = (object == currentEntryController && [keyPath isEqualTo:@"content"]);
BOOL selectionChanged = (object == playlistSelectionController && [keyPath isEqualTo:@"selection"]);
BOOL miniModeSwitched = (object == appController && [keyPath isEqual:@"miniMode"]);
if (miniMode && (currentEntryChanged || miniModeSwitched))
{
[self setValueToDisplay:[currentEntryController content]];
}
else if (!miniMode && (selectionChanged || miniModeSwitched))
{
[self setValueToDisplay:[playlistSelectionController selection]];
}
}
- (IBAction)toggleWindow:(id)sender
{
if ([[self window] isVisible])