mamburu: Info window now shows info for currently playing track in mini mode
parent
012ef22b40
commit
7b416e5877
|
@ -7,13 +7,19 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#import "AppController.h"
|
||||||
|
|
||||||
|
|
||||||
@interface InfoWindowController : NSWindowController {
|
@interface InfoWindowController : NSWindowController
|
||||||
|
{
|
||||||
IBOutlet id playlistSelectionController;
|
IBOutlet id playlistSelectionController;
|
||||||
|
IBOutlet id currentEntryController;
|
||||||
|
IBOutlet AppController *appController;
|
||||||
|
|
||||||
|
id valueToDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property(readonly) id playlistSelectionController;
|
@property(assign) id valueToDisplay;
|
||||||
|
|
||||||
- (IBAction)toggleWindow:(id)sender;
|
- (IBAction)toggleWindow:(id)sender;
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,12 @@
|
||||||
|
|
||||||
#import "InfoWindowController.h"
|
#import "InfoWindowController.h"
|
||||||
#import "MissingAlbumArtTransformer.h"
|
#import "MissingAlbumArtTransformer.h"
|
||||||
|
#import "Logging.h"
|
||||||
|
#import "AppController.h"
|
||||||
|
|
||||||
@implementation InfoWindowController
|
@implementation InfoWindowController
|
||||||
|
|
||||||
@synthesize playlistSelectionController;
|
@synthesize valueToDisplay;
|
||||||
|
|
||||||
+ (void)initialize
|
+ (void)initialize
|
||||||
{
|
{
|
||||||
|
@ -25,6 +27,30 @@
|
||||||
return [super initWithWindowNibName:@"InfoInspector"];
|
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
|
- (IBAction)toggleWindow:(id)sender
|
||||||
{
|
{
|
||||||
if ([[self window] isVisible])
|
if ([[self window] isVisible])
|
||||||
|
|
Loading…
Reference in New Issue