Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.

Commit

Permalink
Merge branch 'pr/273'
Browse files Browse the repository at this point in the history
* pr/273:
  Rearranged some code and the preference
  Add option to show album art in the dock

Conflicts:
	radiant-player-mac/Preferences/PreferencesWindowController.xib
  • Loading branch information
kbhomes committed Apr 5, 2015
2 parents 687db09 + c057930 commit 90232b9
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 47 deletions.
1 change: 1 addition & 0 deletions radiant-player-mac/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
- (void) setupRatingMenuItems;
- (void) useTallTitleBar;
- (void) useNormalTitleBar;
- (void) toggleDockArt:(BOOL)showArt;

- (IBAction) dockPopup:(id)sender;

Expand Down
35 changes: 35 additions & 0 deletions radiant-player-mac/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,17 @@ - (void)useNormalTitleBar
[[self window] setFrame:frame display:NO];
}

- (void) toggleDockArt:(BOOL)showArt
{
if (showArt && currentArt) {
[NSApp setApplicationIconImage:currentArt];
}
else
{
[NSApp setApplicationIconImage:nil];
}
}

- (void) windowDidResize:(NSNotification *)notification
{
[self _adjustTitleBar];
Expand Down Expand Up @@ -766,6 +777,25 @@ - (void)notifySong:(NSString *)title withArtist:(NSString *)artist album:(NSStri
{
[[NotificationCenter center] scheduleNotificationWithTitle:title artist:artist album:album imageURL:art];
}

if ([defaults boolForKey:@"dock.show-art"])
{
if (art != nil) {
[self performSelectorInBackground:@selector(downloadAlbumArt:) withObject:art];
}
else
{
[NSApp setApplicationIconImage: nil];
}
}
}

- (void)downloadAlbumArt:(NSString *)art
{
NSURL *url = [NSURL URLWithString:art];
currentArt = [[NSImage alloc] initWithContentsOfURL:url];

[self toggleDockArt:[defaults boolForKey:@"dock.show-art"]];
}

- (NSString *)currentSongURL
Expand Down Expand Up @@ -797,6 +827,11 @@ - (void)playbackChanged:(NSInteger)mode
[starRatingLabel setTextColor:[NSColor controlTextColor]];
}
}

if (mode == MUSIC_STOPPED) {
[NSApp setApplicationIconImage: nil];
currentArt = nil;
}
}

- (void)playbackTimeChanged:(NSInteger)currentTime totalTime:(NSInteger)totalTime
Expand Down
2 changes: 2 additions & 0 deletions radiant-player-mac/Preferences.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>dock.show-art</key>
<false/>
<key>lastfm.api-secret</key>
<string>1142932de0c86a98c00f4dbe90d911de</string>
<key>lastfm.api-key</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@
@property (assign) BOOL isNotificationImageSupportAvailable;
@property (assign) BOOL isGrowlSupportAvailable;

- (IBAction)toggleDockArt:(NSButton *)sender;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

#import "GeneralPreferencesViewController.h"
#import "AppDelegate.h"

@implementation GeneralPreferencesViewController

Expand Down Expand Up @@ -39,4 +40,10 @@ - (NSString *)toolbarItemLabel
return @"General";
}

- (IBAction) toggleDockArt:(NSButton *)sender
{
BOOL showArt = [sender state] == NSOnState;
[(AppDelegate *)[NSApp delegate] toggleDockArt:showArt];
}

@end
Loading

0 comments on commit 90232b9

Please sign in to comment.