2005-06-02 18:16:43 +00:00
|
|
|
#import "AppController.h"
|
2013-10-11 10:03:23 +00:00
|
|
|
#import "FileTreeViewController.h"
|
2007-03-09 01:16:06 +00:00
|
|
|
#import "PlaybackController.h"
|
|
|
|
#import "PlaylistController.h"
|
|
|
|
#import "PlaylistView.h"
|
2013-10-09 09:02:49 +00:00
|
|
|
#import "PlaylistEntry.h"
|
2013-10-11 16:37:45 +00:00
|
|
|
#import <NDHotKey/NDHotKeyEvent.h>
|
2007-03-09 01:16:06 +00:00
|
|
|
#import "AppleRemote.h"
|
|
|
|
#import "PlaylistLoader.h"
|
2007-05-26 14:43:31 +00:00
|
|
|
#import "OpenURLPanel.h"
|
2008-02-11 09:20:52 +00:00
|
|
|
#import "SpotlightWindowController.h"
|
2008-02-18 01:46:34 +00:00
|
|
|
#import "StringToURLTransformer.h"
|
2008-02-18 09:27:27 +00:00
|
|
|
#import "FontSizetoLineHeightTransformer.h"
|
2013-10-11 10:03:23 +00:00
|
|
|
#import "PathNode.h"
|
2013-10-09 09:02:49 +00:00
|
|
|
#import <CogAudio/Status.h>
|
2005-06-02 18:16:43 +00:00
|
|
|
|
2013-10-11 12:03:55 +00:00
|
|
|
#import "Logging.h"
|
2013-10-11 19:02:05 +00:00
|
|
|
#import "MiniModeMenuTitleTransformer.h"
|
|
|
|
#import "DualWindow.h"
|
2013-10-11 12:03:55 +00:00
|
|
|
|
2005-06-02 18:16:43 +00:00
|
|
|
@implementation AppController
|
|
|
|
|
2008-02-18 01:46:34 +00:00
|
|
|
+ (void)initialize
|
|
|
|
{
|
2008-02-18 09:27:27 +00:00
|
|
|
// Register transformers
|
2008-02-18 01:46:34 +00:00
|
|
|
NSValueTransformer *stringToURLTransformer = [[[StringToURLTransformer alloc] init]autorelease];
|
|
|
|
[NSValueTransformer setValueTransformer:stringToURLTransformer
|
|
|
|
forName:@"StringToURLTransformer"];
|
2008-02-18 09:27:27 +00:00
|
|
|
|
|
|
|
NSValueTransformer *fontSizetoLineHeightTransformer =
|
|
|
|
[[[FontSizetoLineHeightTransformer alloc] init]autorelease];
|
|
|
|
[NSValueTransformer setValueTransformer:fontSizetoLineHeightTransformer
|
|
|
|
forName:@"FontSizetoLineHeightTransformer"];
|
2013-10-11 19:02:05 +00:00
|
|
|
|
|
|
|
NSValueTransformer *miniModeMenuTitleTransformer = [[[MiniModeMenuTitleTransformer alloc] init] autorelease];
|
|
|
|
[NSValueTransformer setValueTransformer:miniModeMenuTitleTransformer
|
|
|
|
forName:@"MiniModeMenuTitleTransformer"];
|
2008-02-18 01:46:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-30 13:25:45 +00:00
|
|
|
- (id)init
|
|
|
|
{
|
|
|
|
self = [super init];
|
|
|
|
if (self)
|
|
|
|
{
|
|
|
|
[self initDefaults];
|
2007-11-01 01:53:52 +00:00
|
|
|
|
2007-02-18 23:00:55 +00:00
|
|
|
remote = [[AppleRemote alloc] init];
|
|
|
|
[remote setDelegate: self];
|
2008-03-01 18:29:14 +00:00
|
|
|
|
|
|
|
queue = [[NSOperationQueue alloc]init];
|
2006-09-30 13:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2008-03-01 18:29:14 +00:00
|
|
|
- (void)dealloc
|
|
|
|
{
|
|
|
|
[queue release];
|
2013-10-11 10:03:23 +00:00
|
|
|
[expandedNodes release];
|
2008-03-01 18:29:14 +00:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2007-02-18 23:00:55 +00:00
|
|
|
// Listen to the remote in exclusive mode, only when Cog is the active application
|
|
|
|
- (void)applicationDidBecomeActive:(NSNotification *)notification
|
|
|
|
{
|
2007-02-25 02:43:56 +00:00
|
|
|
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"remoteEnabled"] && [[NSUserDefaults standardUserDefaults] boolForKey:@"remoteOnlyOnActive"]) {
|
2007-02-19 00:42:12 +00:00
|
|
|
[remote startListening: self];
|
|
|
|
}
|
2007-02-18 23:00:55 +00:00
|
|
|
}
|
2013-10-11 10:03:23 +00:00
|
|
|
- (void)applicationDidResignActive:(NSNotification *)notification
|
2007-02-18 23:00:55 +00:00
|
|
|
{
|
2007-02-25 02:43:56 +00:00
|
|
|
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"remoteEnabled"] && [[NSUserDefaults standardUserDefaults] boolForKey:@"remoteOnlyOnActive"]) {
|
2007-02-19 00:42:12 +00:00
|
|
|
[remote stopListening: self];
|
|
|
|
}
|
2007-02-18 23:00:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper method for the remote control interface in order to trigger forward/backward and volume
|
|
|
|
increase/decrease as long as the user holds the left/right, plus/minus button */
|
|
|
|
- (void) executeHoldActionForRemoteButton: (NSNumber*) buttonIdentifierNumber
|
|
|
|
{
|
2008-02-13 18:03:06 +00:00
|
|
|
static int incrementalSearch = 1;
|
|
|
|
|
2007-02-18 23:00:55 +00:00
|
|
|
if (remoteButtonHeld)
|
|
|
|
{
|
|
|
|
switch([buttonIdentifierNumber intValue])
|
|
|
|
{
|
|
|
|
case kRemoteButtonRight_Hold:
|
2008-02-13 18:03:06 +00:00
|
|
|
[playbackController seekForward:incrementalSearch];
|
2007-02-18 23:00:55 +00:00
|
|
|
break;
|
|
|
|
case kRemoteButtonLeft_Hold:
|
2008-02-13 18:03:06 +00:00
|
|
|
[playbackController seekBackward:incrementalSearch];
|
2007-02-18 23:00:55 +00:00
|
|
|
break;
|
|
|
|
case kRemoteButtonVolume_Plus_Hold:
|
|
|
|
//Volume Up
|
2008-02-17 18:44:11 +00:00
|
|
|
[playbackController volumeUp:self];
|
2007-02-18 23:00:55 +00:00
|
|
|
break;
|
|
|
|
case kRemoteButtonVolume_Minus_Hold:
|
|
|
|
//Volume Down
|
2008-02-17 18:44:11 +00:00
|
|
|
[playbackController volumeDown:self];
|
2007-02-18 23:00:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (remoteButtonHeld)
|
|
|
|
{
|
2008-02-13 18:03:06 +00:00
|
|
|
/* there should perhaps be a max amount that incrementalSearch can
|
|
|
|
be, so as to not start skipping ahead unreasonable amounts, even
|
|
|
|
in very long files. */
|
|
|
|
if ((incrementalSearch % 3) == 0)
|
|
|
|
incrementalSearch += incrementalSearch/3;
|
|
|
|
else
|
|
|
|
incrementalSearch++;
|
|
|
|
|
2007-02-18 23:00:55 +00:00
|
|
|
/* trigger event */
|
|
|
|
[self performSelector:@selector(executeHoldActionForRemoteButton:)
|
|
|
|
withObject:buttonIdentifierNumber
|
|
|
|
afterDelay:0.25];
|
|
|
|
}
|
|
|
|
}
|
2008-02-13 18:03:06 +00:00
|
|
|
else
|
|
|
|
// if we're not holding the search button, reset the incremental search
|
|
|
|
// variable, making it ready for another search
|
|
|
|
incrementalSearch = 1;
|
2007-02-18 23:00:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Apple Remote callback */
|
|
|
|
- (void) appleRemoteButton: (AppleRemoteEventIdentifier)buttonIdentifier
|
|
|
|
pressedDown: (BOOL) pressedDown
|
|
|
|
clickCount: (unsigned int) count
|
|
|
|
{
|
|
|
|
switch( buttonIdentifier )
|
|
|
|
{
|
2013-10-12 21:47:39 +00:00
|
|
|
case k2009RemoteButtonPlay:
|
2007-02-18 23:00:55 +00:00
|
|
|
case kRemoteButtonPlay:
|
2007-02-18 23:06:23 +00:00
|
|
|
[self clickPlay];
|
2007-02-18 23:00:55 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
case kRemoteButtonVolume_Plus:
|
2008-02-17 18:44:11 +00:00
|
|
|
[playbackController volumeUp:self];
|
2007-02-18 23:00:55 +00:00
|
|
|
break;
|
|
|
|
case kRemoteButtonVolume_Minus:
|
2008-02-17 18:44:11 +00:00
|
|
|
[playbackController volumeDown:self];
|
2007-02-18 23:00:55 +00:00
|
|
|
break;
|
|
|
|
case kRemoteButtonRight:
|
2007-02-18 23:06:23 +00:00
|
|
|
[self clickNext];
|
2007-02-18 23:00:55 +00:00
|
|
|
break;
|
|
|
|
case kRemoteButtonLeft:
|
2007-02-18 23:06:23 +00:00
|
|
|
[self clickPrev];
|
2007-02-18 23:00:55 +00:00
|
|
|
break;
|
|
|
|
case kRemoteButtonRight_Hold:
|
|
|
|
case kRemoteButtonLeft_Hold:
|
|
|
|
case kRemoteButtonVolume_Plus_Hold:
|
|
|
|
case kRemoteButtonVolume_Minus_Hold:
|
|
|
|
/* simulate an event as long as the user holds the button */
|
|
|
|
remoteButtonHeld = pressedDown;
|
|
|
|
if( pressedDown )
|
|
|
|
{
|
|
|
|
NSNumber* buttonIdentifierNumber = [NSNumber numberWithInt: buttonIdentifier];
|
|
|
|
[self performSelector:@selector(executeHoldActionForRemoteButton:)
|
|
|
|
withObject:buttonIdentifierNumber];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kRemoteButtonMenu:
|
|
|
|
break;
|
2013-10-12 21:47:39 +00:00
|
|
|
case k2009RemoteButtonFullscreen:
|
|
|
|
[mainWindow toggleFullScreen:nil];
|
|
|
|
break;
|
2007-02-18 23:00:55 +00:00
|
|
|
default:
|
|
|
|
/* Add here whatever you want other buttons to do */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-09-02 16:09:20 +00:00
|
|
|
- (IBAction)openFiles:(id)sender
|
2005-06-02 18:16:43 +00:00
|
|
|
{
|
|
|
|
NSOpenPanel *p;
|
|
|
|
|
|
|
|
p = [NSOpenPanel openPanel];
|
|
|
|
|
2013-10-03 08:00:58 +00:00
|
|
|
[p setAllowedFileTypes:[playlistLoader acceptableFileTypes]];
|
2005-06-02 18:16:43 +00:00
|
|
|
[p setCanChooseDirectories:YES];
|
|
|
|
[p setAllowsMultipleSelection:YES];
|
2013-10-03 08:00:58 +00:00
|
|
|
[p setResolvesAliases:YES];
|
2005-06-02 18:16:43 +00:00
|
|
|
|
2013-10-03 08:00:58 +00:00
|
|
|
[p beginSheetModalForWindow:mainWindow completionHandler:^(NSInteger result) {
|
|
|
|
if ( result == NSFileHandlingPanelOKButton ) {
|
|
|
|
[playlistLoader willInsertURLs:[p URLs] origin:URLOriginInternal];
|
|
|
|
[playlistLoader didInsertURLs:[playlistLoader addURLs:[p URLs] sort:YES] origin:URLOriginInternal];
|
|
|
|
} else {
|
|
|
|
[p close];
|
|
|
|
}
|
|
|
|
}];
|
2007-05-26 14:43:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)savePlaylist:(id)sender
|
|
|
|
{
|
|
|
|
NSSavePanel *p;
|
|
|
|
|
|
|
|
p = [NSSavePanel savePanel];
|
2005-06-02 18:16:43 +00:00
|
|
|
|
2013-10-03 08:00:58 +00:00
|
|
|
[p beginSheetModalForWindow:mainWindow completionHandler:^(NSInteger result) {
|
|
|
|
if ( result == NSFileHandlingPanelOKButton ) {
|
|
|
|
[playlistLoader save:[[p URL] path]];
|
|
|
|
} else {
|
|
|
|
[p close];
|
|
|
|
}
|
|
|
|
}];
|
2007-03-02 01:36:52 +00:00
|
|
|
}
|
|
|
|
|
2007-05-26 14:43:31 +00:00
|
|
|
- (IBAction)openURL:(id)sender
|
2007-03-02 01:36:52 +00:00
|
|
|
{
|
2007-05-26 14:43:31 +00:00
|
|
|
OpenURLPanel *p;
|
2007-03-02 01:36:52 +00:00
|
|
|
|
2007-05-26 14:43:31 +00:00
|
|
|
p = [OpenURLPanel openURLPanel];
|
|
|
|
|
|
|
|
[p beginSheetWithWindow:mainWindow delegate:self didEndSelector:@selector(openURLPanelDidEnd:returnCode:contextInfo:) contextInfo:nil];
|
2007-03-02 01:36:52 +00:00
|
|
|
}
|
|
|
|
|
2007-05-26 14:43:31 +00:00
|
|
|
- (void)openURLPanelDidEnd:(OpenURLPanel *)panel returnCode:(int)returnCode contextInfo:(void *)contextInfo
|
2007-03-02 01:36:52 +00:00
|
|
|
{
|
2007-05-26 14:43:31 +00:00
|
|
|
if (returnCode == NSOKButton)
|
|
|
|
{
|
2009-02-28 22:22:33 +00:00
|
|
|
[playlistLoader willInsertURLs:[NSArray arrayWithObject:[panel url]] origin:URLOriginExternal];
|
|
|
|
[playlistLoader didInsertURLs:[playlistLoader addURLs:[NSArray arrayWithObject:[panel url]] sort:NO] origin:URLOriginExternal];
|
2007-05-26 14:43:31 +00:00
|
|
|
}
|
2007-03-02 01:36:52 +00:00
|
|
|
}
|
|
|
|
|
2005-06-02 18:16:43 +00:00
|
|
|
- (IBAction)delEntries:(id)sender
|
|
|
|
{
|
|
|
|
[playlistController remove:self];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (PlaylistEntry *)currentEntry
|
|
|
|
{
|
|
|
|
return [playlistController currentEntry];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)application:(NSApplication *)sender delegateHandlesKey:(NSString *)key
|
|
|
|
{
|
2007-10-03 22:26:39 +00:00
|
|
|
return [key isEqualToString:@"currentEntry"] || [key isEqualToString:@"play"];
|
2005-06-02 18:16:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)awakeFromNib
|
|
|
|
{
|
2007-11-24 20:16:27 +00:00
|
|
|
[[totalTimeField cell] setBackgroundStyle:NSBackgroundStyleRaised];
|
|
|
|
|
2008-01-23 03:03:46 +00:00
|
|
|
[[playbackButtons cell] setToolTip:NSLocalizedString(@"PlayButtonTooltip", @"") forSegment: 1];
|
|
|
|
[[playbackButtons cell] setToolTip:NSLocalizedString(@"PrevButtonTooltip", @"") forSegment: 0];
|
|
|
|
[[playbackButtons cell] setToolTip:NSLocalizedString(@"NextButtonTooltip", @"") forSegment: 2];
|
2005-07-11 20:27:47 +00:00
|
|
|
[infoButton setToolTip:NSLocalizedString(@"InfoButtonTooltip", @"")];
|
|
|
|
[shuffleButton setToolTip:NSLocalizedString(@"ShuffleButtonTooltip", @"")];
|
|
|
|
[repeatButton setToolTip:NSLocalizedString(@"RepeatButtonTooltip", @"")];
|
2013-10-11 12:27:19 +00:00
|
|
|
[randomizeButton setToolTip:NSLocalizedString(@"RandomizeButtonTooltip", @"")];
|
2007-05-28 14:13:57 +00:00
|
|
|
[fileButton setToolTip:NSLocalizedString(@"FileButtonTooltip", @"")];
|
2006-04-13 03:20:31 +00:00
|
|
|
|
2006-09-02 16:09:20 +00:00
|
|
|
[self registerHotKeys];
|
|
|
|
|
2008-02-15 22:47:27 +00:00
|
|
|
[spotlightWindowController init];
|
2008-02-10 13:48:55 +00:00
|
|
|
|
2007-02-19 00:42:12 +00:00
|
|
|
//Init Remote
|
2007-02-25 02:43:56 +00:00
|
|
|
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"remoteEnabled"] && ![[NSUserDefaults standardUserDefaults] boolForKey:@"remoteOnlyOnActive"]) {
|
2007-02-19 00:44:06 +00:00
|
|
|
[remote startListening:self];
|
|
|
|
}
|
2007-02-19 00:42:12 +00:00
|
|
|
|
2008-02-10 18:34:23 +00:00
|
|
|
[[playlistController undoManager] disableUndoRegistration];
|
2013-10-09 15:45:16 +00:00
|
|
|
NSString *basePath = [@"~/Library/Application Support/Cog/" stringByExpandingTildeInPath];
|
|
|
|
NSString *oldFilename = @"Default.m3u";
|
|
|
|
NSString *newFilename = @"Default.xml";
|
|
|
|
|
|
|
|
if ([[NSFileManager defaultManager] fileExistsAtPath:[basePath stringByAppendingPathComponent:newFilename]])
|
|
|
|
{
|
|
|
|
[playlistLoader addURL:[NSURL fileURLWithPath:[basePath stringByAppendingPathComponent:newFilename]]];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[playlistLoader addURL:[NSURL fileURLWithPath:[basePath stringByAppendingPathComponent:oldFilename]]];
|
|
|
|
}
|
|
|
|
|
2008-02-10 18:34:23 +00:00
|
|
|
[[playlistController undoManager] enableUndoRegistration];
|
2013-10-09 09:02:49 +00:00
|
|
|
|
|
|
|
int lastStatus = [[NSUserDefaults standardUserDefaults] integerForKey:@"lastPlaybackStatus"];
|
|
|
|
int lastIndex = [[NSUserDefaults standardUserDefaults] integerForKey:@"lastTrackPlaying"];
|
|
|
|
|
|
|
|
if (lastStatus != kCogStatusStopped && lastIndex >= 0)
|
|
|
|
{
|
2013-10-13 02:16:47 +00:00
|
|
|
[playbackController playEntryAtIndex:lastIndex startPaused:(lastStatus == kCogStatusPaused)];
|
2013-10-09 09:02:49 +00:00
|
|
|
[playbackController seek:[NSNumber numberWithDouble:[[NSUserDefaults standardUserDefaults] floatForKey:@"lastTrackPosition"]]];
|
|
|
|
}
|
2013-10-11 09:09:26 +00:00
|
|
|
|
2013-10-11 19:02:05 +00:00
|
|
|
|
|
|
|
// Restore mini mode
|
|
|
|
[self setMiniMode:[[NSUserDefaults standardUserDefaults] boolForKey:@"miniMode"]];
|
|
|
|
|
2013-10-11 10:03:23 +00:00
|
|
|
// We need file tree view to restore its state here
|
|
|
|
// so attempt to access file tree view controller's root view
|
|
|
|
// to force it to read nib and create file tree view for us
|
|
|
|
//
|
|
|
|
// TODO: there probably is a more elegant way to do all this
|
|
|
|
// but i'm too stupid/tired to figure it out now
|
|
|
|
[fileTreeViewController view];
|
|
|
|
|
|
|
|
FileTreeOutlineView* outlineView = [fileTreeViewController outlineView];
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(nodeExpanded:) name:NSOutlineViewItemDidExpandNotification object:outlineView];
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(nodeCollapsed:) name:NSOutlineViewItemDidCollapseNotification object:outlineView];
|
|
|
|
|
|
|
|
NSArray *expandedNodesArray = [[NSUserDefaults standardUserDefaults] valueForKey:@"fileTreeViewExpandedNodes"];
|
|
|
|
|
|
|
|
if (expandedNodesArray)
|
|
|
|
{
|
|
|
|
expandedNodes = [[NSMutableSet alloc] initWithArray:expandedNodesArray];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
expandedNodes = [[NSMutableSet alloc] init];
|
|
|
|
}
|
|
|
|
|
2013-10-11 12:03:55 +00:00
|
|
|
DLog(@"Nodes to expand: %@", [expandedNodes description]);
|
2013-10-11 10:03:23 +00:00
|
|
|
|
2013-10-11 12:03:55 +00:00
|
|
|
DLog(@"Num of rows: %ld", [outlineView numberOfRows]);
|
2013-10-11 10:03:23 +00:00
|
|
|
|
|
|
|
if (!outlineView)
|
|
|
|
{
|
2013-10-11 12:03:55 +00:00
|
|
|
DLog(@"outlineView is NULL!");
|
2013-10-11 10:03:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[outlineView reloadData];
|
|
|
|
|
|
|
|
for (NSInteger i=0; i<[outlineView numberOfRows]; i++)
|
|
|
|
{
|
|
|
|
PathNode *pn = [outlineView itemAtRow:i];
|
|
|
|
NSString *str = [[pn URL] absoluteString];
|
|
|
|
|
|
|
|
if ([expandedNodes containsObject:str])
|
|
|
|
{
|
|
|
|
[outlineView expandItem:pn];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)nodeExpanded:(NSNotification*)notification
|
|
|
|
{
|
|
|
|
PathNode* node = [[notification userInfo] objectForKey:@"NSObject"];
|
|
|
|
NSString* url = [[node URL] absoluteString];
|
|
|
|
|
|
|
|
[expandedNodes addObject:url];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)nodeCollapsed:(NSNotification*)notification
|
|
|
|
{
|
|
|
|
PathNode* node = [[notification userInfo] objectForKey:@"NSObject"];
|
|
|
|
NSString* url = [[node URL] absoluteString];
|
|
|
|
|
|
|
|
[expandedNodes removeObject:url];
|
2005-06-02 18:16:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)applicationWillTerminate:(NSNotification *)aNotification
|
|
|
|
{
|
2013-10-09 09:02:49 +00:00
|
|
|
int currentStatus = [playbackController playbackStatus];
|
|
|
|
int lastTrackPlaying = -1;
|
|
|
|
double lastTrackPosition = 0;
|
|
|
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] setInteger:currentStatus forKey:@"lastPlaybackStatus"];
|
|
|
|
|
|
|
|
if (currentStatus != kCogStatusStopped)
|
|
|
|
{
|
|
|
|
PlaylistEntry * pe = [playlistController currentEntry];
|
|
|
|
lastTrackPlaying = [pe index];
|
|
|
|
lastTrackPosition = [pe currentPosition];
|
|
|
|
}
|
|
|
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] setInteger:lastTrackPlaying forKey:@"lastTrackPlaying"];
|
|
|
|
[[NSUserDefaults standardUserDefaults] setDouble:lastTrackPosition forKey:@"lastTrackPosition"];
|
|
|
|
|
2007-02-26 05:07:18 +00:00
|
|
|
[playbackController stop:self];
|
|
|
|
|
2005-06-02 18:16:43 +00:00
|
|
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
|
|
NSString *folder = @"~/Library/Application Support/Cog/";
|
|
|
|
|
|
|
|
folder = [folder stringByExpandingTildeInPath];
|
|
|
|
|
|
|
|
if ([fileManager fileExistsAtPath: folder] == NO)
|
|
|
|
{
|
2013-10-03 08:00:58 +00:00
|
|
|
[fileManager createDirectoryAtPath: folder withIntermediateDirectories:NO attributes:nil error:nil];
|
2005-06-02 18:16:43 +00:00
|
|
|
}
|
|
|
|
|
2013-10-09 15:45:16 +00:00
|
|
|
NSString * fileName = @"Default.xml";
|
|
|
|
|
|
|
|
[playlistLoader saveXml:[folder stringByAppendingPathComponent: fileName]];
|
|
|
|
|
|
|
|
fileName = @"Default.m3u";
|
|
|
|
|
|
|
|
NSError *error;
|
|
|
|
[[NSFileManager defaultManager] removeItemAtPath:[folder stringByAppendingPathComponent:fileName] error:&error];
|
2013-10-11 10:03:23 +00:00
|
|
|
|
2013-10-11 12:03:55 +00:00
|
|
|
DLog(@"Saving expanded nodes: %@", [expandedNodes description]);
|
2013-10-11 10:03:23 +00:00
|
|
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] setValue:[expandedNodes allObjects] forKey:@"fileTreeViewExpandedNodes"];
|
2005-06-02 18:16:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
|
|
|
|
{
|
2007-07-05 23:08:10 +00:00
|
|
|
if (flag == NO)
|
2015-01-15 13:57:22 +00:00
|
|
|
[mainWindow makeKeyAndOrderFront:self]; // TODO: do we really need this? We never close the main window.
|
|
|
|
|
|
|
|
for(NSWindow* win in [NSApp windows]) // Maximizing all windows
|
|
|
|
if([win isMiniaturized])
|
|
|
|
[win deminiaturize:self];
|
2005-06-02 18:16:43 +00:00
|
|
|
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
|
|
|
{
|
2008-05-09 21:24:49 +00:00
|
|
|
NSArray* urls = [NSArray arrayWithObject:[NSURL fileURLWithPath:filename]];
|
2009-02-28 22:22:33 +00:00
|
|
|
[playlistLoader willInsertURLs:urls origin:URLOriginExternal];
|
|
|
|
[playlistLoader didInsertURLs:[playlistLoader addURLs:urls sort:NO] origin:URLOriginExternal];
|
2005-06-02 18:16:43 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)application:(NSApplication *)theApplication openFiles:(NSArray *)filenames
|
|
|
|
{
|
2007-03-09 01:16:06 +00:00
|
|
|
//Need to convert to urls
|
|
|
|
NSMutableArray *urls = [NSMutableArray array];
|
|
|
|
|
2008-02-20 00:54:45 +00:00
|
|
|
for (NSString *filename in filenames)
|
2007-03-09 01:16:06 +00:00
|
|
|
{
|
|
|
|
[urls addObject:[NSURL fileURLWithPath:filename]];
|
|
|
|
}
|
2009-02-28 22:22:33 +00:00
|
|
|
[playlistLoader willInsertURLs:urls origin:URLOriginExternal];
|
|
|
|
[playlistLoader didInsertURLs:[playlistLoader addURLs:urls sort:YES] origin:URLOriginExternal];
|
2005-06-02 18:16:43 +00:00
|
|
|
[theApplication replyToOpenOrPrint:NSApplicationDelegateReplySuccess];
|
|
|
|
}
|
|
|
|
|
2006-04-04 01:08:21 +00:00
|
|
|
- (IBAction)toggleInfoDrawer:(id)sender
|
|
|
|
{
|
|
|
|
[mainWindow makeKeyAndOrderFront:self];
|
2006-04-13 03:20:31 +00:00
|
|
|
|
2006-04-04 01:08:21 +00:00
|
|
|
[infoDrawer toggle:self];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)drawerDidOpen:(NSNotification *)notification
|
|
|
|
{
|
2007-02-18 18:59:23 +00:00
|
|
|
if ([notification object] == infoDrawer) {
|
2006-09-02 16:09:20 +00:00
|
|
|
[infoButton setState:NSOnState];
|
2007-02-18 18:59:23 +00:00
|
|
|
}
|
2006-04-04 01:08:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)drawerDidClose:(NSNotification *)notification
|
|
|
|
{
|
2007-02-18 18:59:23 +00:00
|
|
|
if ([notification object] == infoDrawer) {
|
2006-09-02 16:09:20 +00:00
|
|
|
[infoButton setState:NSOffState];
|
2007-02-18 18:59:23 +00:00
|
|
|
}
|
2006-04-04 01:08:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)donate:(id)sender
|
|
|
|
{
|
|
|
|
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://sourceforge.net/project/project_donations.php?group_id=140003"]];
|
|
|
|
}
|
|
|
|
|
2006-09-02 16:09:20 +00:00
|
|
|
- (void)initDefaults
|
|
|
|
{
|
|
|
|
NSMutableDictionary *userDefaultsValuesDict = [NSMutableDictionary dictionary];
|
2007-02-19 00:42:12 +00:00
|
|
|
|
2008-02-18 00:11:38 +00:00
|
|
|
// Font defaults
|
|
|
|
float fFontSize = [NSFont systemFontSizeForControlSize:NSSmallControlSize];
|
|
|
|
NSNumber *fontSize = [NSNumber numberWithFloat:fFontSize];
|
|
|
|
[userDefaultsValuesDict setObject:fontSize forKey:@"fontSize"];
|
|
|
|
|
2006-09-10 21:27:20 +00:00
|
|
|
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:35] forKey:@"hotKeyPlayKeyCode"];
|
|
|
|
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:(NSControlKeyMask|NSCommandKeyMask)] forKey:@"hotKeyPlayModifiers"];
|
2006-09-02 16:09:20 +00:00
|
|
|
|
2006-09-10 21:27:20 +00:00
|
|
|
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:45] forKey:@"hotKeyNextKeyCode"];
|
|
|
|
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:(NSControlKeyMask|NSCommandKeyMask)] forKey:@"hotKeyNextModifiers"];
|
2006-09-02 16:09:20 +00:00
|
|
|
|
2006-09-10 21:27:20 +00:00
|
|
|
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:15] forKey:@"hotKeyPreviousKeyCode"];
|
|
|
|
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:(NSControlKeyMask|NSCommandKeyMask)] forKey:@"hotKeyPreviousModifiers"];
|
2013-10-11 16:37:45 +00:00
|
|
|
|
|
|
|
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:8] forKey:@"hotKeySpamKeyCode"];
|
|
|
|
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:(NSControlKeyMask|NSCommandKeyMask)] forKey:@"hotKeySpamModifiers"];
|
2006-09-10 21:27:20 +00:00
|
|
|
|
2007-02-25 02:43:56 +00:00
|
|
|
[userDefaultsValuesDict setObject:[NSNumber numberWithBool:YES] forKey:@"remoteEnabled"];
|
2007-02-19 00:42:12 +00:00
|
|
|
[userDefaultsValuesDict setObject:[NSNumber numberWithBool:YES] forKey:@"remoteOnlyOnActive"];
|
|
|
|
|
2014-09-06 06:25:32 +00:00
|
|
|
NSString * feedURLdefault = @"https://www.kode54.net/cog/mercury.xml";
|
2013-10-23 00:46:33 +00:00
|
|
|
NSString * feedURLbroken = @"https://kode54.net/cog/stable.xml";
|
2014-09-06 06:25:32 +00:00
|
|
|
NSString * feedURLbroken2 = @"https://kode54.net/cog/mercury.xml";
|
2013-10-23 00:46:33 +00:00
|
|
|
[userDefaultsValuesDict setObject:feedURLdefault forKey:@"SUFeedURL"];
|
2007-05-19 15:07:03 +00:00
|
|
|
|
2008-05-09 21:24:49 +00:00
|
|
|
|
2008-05-18 09:38:53 +00:00
|
|
|
[userDefaultsValuesDict setObject:@"clearAndPlay" forKey:@"openingFilesBehavior"];
|
|
|
|
[userDefaultsValuesDict setObject:@"enqueue" forKey:@"openingFilesAlteredBehavior"];
|
2013-10-02 06:00:16 +00:00
|
|
|
|
|
|
|
[userDefaultsValuesDict setObject:@"albumGainWithPeak" forKey:@"volumeScaling"];
|
2014-03-27 04:49:31 +00:00
|
|
|
|
|
|
|
[userDefaultsValuesDict setObject:@"cubic" forKey:@"resampling"];
|
2013-10-04 11:16:09 +00:00
|
|
|
|
2013-10-09 09:02:49 +00:00
|
|
|
[userDefaultsValuesDict setObject:[NSNumber numberWithInteger:kCogStatusStopped] forKey:@"lastPlaybackStatus"];
|
|
|
|
[userDefaultsValuesDict setObject:[NSNumber numberWithInteger:-1] forKey:@"lastTrackPlaying"];
|
|
|
|
[userDefaultsValuesDict setObject:[NSNumber numberWithDouble:0] forKey:@"lastTrackPosition"];
|
2014-12-04 05:36:55 +00:00
|
|
|
|
2006-09-02 16:09:20 +00:00
|
|
|
//Register and sync defaults
|
|
|
|
[[NSUserDefaults standardUserDefaults] registerDefaults:userDefaultsValuesDict];
|
|
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
2013-10-23 00:46:33 +00:00
|
|
|
|
|
|
|
//And if the existing feed URL is broken due to my ineptitude with the above defaults, fix it
|
2014-09-06 06:25:32 +00:00
|
|
|
if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"SUFeedURL"] isEqualToString:feedURLbroken] ||
|
|
|
|
[[[NSUserDefaults standardUserDefaults] stringForKey:@"SUFeedURL"] isEqualToString:feedURLbroken2])
|
2013-10-23 00:46:33 +00:00
|
|
|
[[NSUserDefaults standardUserDefaults] setValue:feedURLdefault forKey:@"SUFeedURL"];
|
2007-02-25 02:43:56 +00:00
|
|
|
|
|
|
|
//Add observers
|
2006-09-10 21:27:20 +00:00
|
|
|
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.hotKeyPlayKeyCode" options:0 context:nil];
|
|
|
|
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.hotKeyPreviousKeyCode" options:0 context:nil];
|
|
|
|
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.hotKeyNextKeyCode" options:0 context:nil];
|
2013-10-04 11:16:09 +00:00
|
|
|
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self
|
|
|
|
forKeyPath:@"values.hotKeySpamKeyCode" options:0 context:nil];
|
2006-09-17 18:11:29 +00:00
|
|
|
|
2007-02-25 02:43:56 +00:00
|
|
|
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.remoteEnabled" options:0 context:nil];
|
|
|
|
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.remoteOnlyOnActive" options:0 context:nil];
|
2006-09-02 16:09:20 +00:00
|
|
|
}
|
|
|
|
|
2006-09-10 21:27:20 +00:00
|
|
|
- (void) observeValueForKeyPath:(NSString *)keyPath
|
|
|
|
ofObject:(id)object
|
|
|
|
change:(NSDictionary *)change
|
|
|
|
context:(void *)context
|
2006-09-02 16:09:20 +00:00
|
|
|
{
|
2006-09-10 21:27:20 +00:00
|
|
|
if ([keyPath isEqualToString:@"values.hotKeyPlayKeyCode"]) {
|
|
|
|
[self registerHotKeys];
|
2006-09-02 16:09:20 +00:00
|
|
|
}
|
2006-09-10 21:27:20 +00:00
|
|
|
else if ([keyPath isEqualToString:@"values.hotKeyPreviousKeyCode"]) {
|
|
|
|
[self registerHotKeys];
|
2006-09-02 16:09:20 +00:00
|
|
|
}
|
2006-09-10 21:27:20 +00:00
|
|
|
else if ([keyPath isEqualToString:@"values.hotKeyNextKeyCode"]) {
|
|
|
|
[self registerHotKeys];
|
2006-09-02 16:09:20 +00:00
|
|
|
}
|
2013-10-04 11:16:09 +00:00
|
|
|
else if ([keyPath isEqualToString:@"values.hotKeySpamKeyCode"]) {
|
|
|
|
[self registerHotKeys];
|
|
|
|
}
|
2007-02-25 02:43:56 +00:00
|
|
|
else if ([keyPath isEqualToString:@"values.remoteEnabled"] || [keyPath isEqualToString:@"values.remoteOnlyOnActive"]) {
|
|
|
|
if([[NSUserDefaults standardUserDefaults] boolForKey:@"remoteEnabled"]) {
|
|
|
|
BOOL onlyOnActive = [[NSUserDefaults standardUserDefaults] boolForKey:@"remoteOnlyOnActive"];
|
|
|
|
if (!onlyOnActive || [NSApp isActive]) {
|
|
|
|
[remote startListening: self];
|
|
|
|
}
|
|
|
|
if (onlyOnActive && ![NSApp isActive]) { //Setting a preference without being active? *shrugs*
|
|
|
|
[remote stopListening: self];
|
|
|
|
}
|
2007-02-19 00:42:12 +00:00
|
|
|
}
|
2007-02-25 02:43:56 +00:00
|
|
|
else {
|
2007-02-19 00:42:12 +00:00
|
|
|
[remote stopListening: self];
|
|
|
|
}
|
|
|
|
}
|
2006-09-02 16:09:20 +00:00
|
|
|
}
|
|
|
|
|
2006-09-10 21:27:20 +00:00
|
|
|
- (void)registerHotKeys
|
2006-09-02 16:09:20 +00:00
|
|
|
{
|
2006-09-10 21:27:20 +00:00
|
|
|
[playHotKey release];
|
2013-10-04 11:16:09 +00:00
|
|
|
if ([[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"hotKeyPlayKeyCode"] intValue]) {
|
2006-09-10 21:27:20 +00:00
|
|
|
playHotKey = [[NDHotKeyEvent alloc]
|
|
|
|
initWithKeyCode: [[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"hotKeyPlayKeyCode"] intValue]
|
|
|
|
modifierFlags: [[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"hotKeyPlayModifiers"] intValue]
|
|
|
|
];
|
2013-10-04 11:16:09 +00:00
|
|
|
[playHotKey setTarget:self selector:@selector(clickPlay)];
|
|
|
|
[playHotKey setEnabled:YES];
|
|
|
|
}
|
2006-09-10 21:27:20 +00:00
|
|
|
|
|
|
|
[prevHotKey release];
|
2013-10-04 11:16:09 +00:00
|
|
|
if ([[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"hotKeyPreviousKeyCode"] intValue]) {
|
2006-09-10 21:27:20 +00:00
|
|
|
prevHotKey = [[NDHotKeyEvent alloc]
|
2007-02-17 19:33:31 +00:00
|
|
|
initWithKeyCode: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeyPreviousKeyCode"]
|
2006-09-10 21:27:20 +00:00
|
|
|
modifierFlags: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeyPreviousModifiers"]
|
|
|
|
];
|
2013-10-04 11:16:09 +00:00
|
|
|
[prevHotKey setTarget:self selector:@selector(clickPrev)];
|
|
|
|
[prevHotKey setEnabled:YES];
|
|
|
|
}
|
2006-09-10 21:27:20 +00:00
|
|
|
|
|
|
|
[nextHotKey release];
|
2013-10-04 11:16:09 +00:00
|
|
|
if ([[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"hotKeyNextKeyCode"] intValue]) {
|
2006-09-10 21:27:20 +00:00
|
|
|
nextHotKey = [[NDHotKeyEvent alloc]
|
|
|
|
initWithKeyCode: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeyNextKeyCode"]
|
|
|
|
modifierFlags: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeyNextModifiers"]
|
|
|
|
];
|
2013-10-04 11:16:09 +00:00
|
|
|
[nextHotKey setTarget:self selector:@selector(clickNext)];
|
|
|
|
[nextHotKey setEnabled:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
[spamHotKey release];
|
|
|
|
if ([[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"hotKeySpamKeyCode"] intValue]) {
|
|
|
|
spamHotKey = [[NDHotKeyEvent alloc]
|
|
|
|
initWithKeyCode: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeySpamKeyCode"]
|
|
|
|
modifierFlags: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeySpamModifiers"]
|
|
|
|
];
|
|
|
|
[spamHotKey setTarget:self selector:@selector(clickSpam)];
|
|
|
|
[spamHotKey setEnabled:YES];
|
|
|
|
}
|
2006-09-02 16:09:20 +00:00
|
|
|
}
|
|
|
|
|
2013-10-11 10:39:57 +00:00
|
|
|
- (void)windowDidEnterFullScreen:(NSNotification *)notification
|
2013-10-11 09:09:26 +00:00
|
|
|
{
|
2013-10-11 12:03:55 +00:00
|
|
|
DLog(@"Entering fullscreen");
|
2013-10-11 09:09:26 +00:00
|
|
|
if (nil == nowPlaying)
|
|
|
|
{
|
|
|
|
nowPlaying = [[NowPlayingBarController alloc] init];
|
|
|
|
[nowPlaying retain];
|
|
|
|
|
|
|
|
NSView *contentView = [mainWindow contentView];
|
|
|
|
NSRect contentRect = [contentView frame];
|
|
|
|
const NSSize windowSize = [contentView convertSize:[mainWindow frame].size fromView: nil];
|
|
|
|
|
|
|
|
NSRect nowPlayingFrame = [[nowPlaying view] frame];
|
|
|
|
nowPlayingFrame.size.width = windowSize.width;
|
|
|
|
[[nowPlaying view] setFrame: nowPlayingFrame];
|
|
|
|
|
|
|
|
[contentView addSubview: [nowPlaying view]];
|
|
|
|
[[nowPlaying view] setFrameOrigin: NSMakePoint(0.0, NSMaxY(contentRect) - nowPlayingFrame.size.height)];
|
|
|
|
|
|
|
|
NSRect mainViewFrame = [mainView frame];
|
|
|
|
mainViewFrame.size.height -= nowPlayingFrame.size.height;
|
|
|
|
[mainView setFrame:mainViewFrame];
|
|
|
|
|
|
|
|
[[nowPlaying text] bind:@"value" toObject:currentEntryController withKeyPath:@"content.display" options:nil];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-11 10:39:57 +00:00
|
|
|
- (void)windowDidExitFullScreen:(NSNotification *)notification
|
2013-10-11 09:09:26 +00:00
|
|
|
{
|
2013-10-11 12:03:55 +00:00
|
|
|
DLog(@"Exiting fullscreen");
|
2013-10-11 09:09:26 +00:00
|
|
|
if (nowPlaying)
|
|
|
|
{
|
|
|
|
NSRect nowPlayingFrame = [[nowPlaying view] frame];
|
|
|
|
NSRect mainViewFrame = [mainView frame];
|
|
|
|
mainViewFrame.size.height += nowPlayingFrame.size.height;
|
|
|
|
[mainView setFrame:mainViewFrame];
|
|
|
|
// [mainView setFrameOrigin:NSMakePoint(0.0, 0.0)];
|
|
|
|
|
|
|
|
[[nowPlaying view] removeFromSuperview];
|
|
|
|
[nowPlaying release];
|
|
|
|
nowPlaying = nil;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-02 16:09:20 +00:00
|
|
|
- (void)clickPlay
|
|
|
|
{
|
2008-01-23 03:03:46 +00:00
|
|
|
[playbackController playPauseResume:self];
|
2006-09-02 16:09:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)clickPrev
|
|
|
|
{
|
2008-01-23 03:03:46 +00:00
|
|
|
[playbackController prev:nil];
|
2006-09-02 16:09:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)clickNext
|
|
|
|
{
|
2008-01-23 03:03:46 +00:00
|
|
|
[playbackController next:nil];
|
2006-09-02 16:09:20 +00:00
|
|
|
}
|
|
|
|
|
2013-10-04 11:16:09 +00:00
|
|
|
- (void)clickSpam
|
|
|
|
{
|
|
|
|
[playbackController spam];
|
|
|
|
}
|
|
|
|
|
2008-02-15 15:27:34 +00:00
|
|
|
- (void)changeFontSize:(float)size
|
|
|
|
{
|
2008-02-18 00:11:38 +00:00
|
|
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
|
|
float fCurrentSize = [defaults floatForKey:@"fontSize"];
|
|
|
|
NSNumber *newSize = [NSNumber numberWithFloat:(fCurrentSize + size)];
|
|
|
|
[defaults setObject:newSize forKey:@"fontSize"];
|
2008-02-15 15:27:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)increaseFontSize:(id)sender
|
|
|
|
{
|
|
|
|
[self changeFontSize:1];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)decreaseFontSize:(id)sender
|
|
|
|
{
|
|
|
|
[self changeFontSize:-1];
|
|
|
|
|
|
|
|
}
|
2008-03-01 18:29:14 +00:00
|
|
|
|
2013-10-11 19:02:05 +00:00
|
|
|
- (IBAction)toggleMiniMode:(id)sender
|
|
|
|
{
|
|
|
|
[self setMiniMode:(!miniMode)];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)miniMode
|
|
|
|
{
|
|
|
|
return miniMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setMiniMode:(BOOL)newMiniMode
|
|
|
|
{
|
|
|
|
miniMode = newMiniMode;
|
|
|
|
[[NSUserDefaults standardUserDefaults] setBool:miniMode forKey:@"miniMode"];
|
|
|
|
|
|
|
|
NSWindow *windowToShow = miniMode ? miniWindow : mainWindow;
|
|
|
|
NSWindow *windowToHide = miniMode ? mainWindow : miniWindow;
|
|
|
|
[windowToHide close];
|
|
|
|
[windowToShow makeKeyAndOrderFront:self];
|
|
|
|
}
|
|
|
|
|
2005-06-02 18:16:43 +00:00
|
|
|
@end
|