Total playlist time displayed in title (simon savary)
parent
9377d8647e
commit
3597e03585
|
@ -32,11 +32,13 @@
|
|||
|
||||
- (IBAction)donate:(id)sender;
|
||||
|
||||
- (void)updateTotalTime;
|
||||
|
||||
- (IBAction)toggleInfoDrawer:(id)sender;
|
||||
- (void)drawerDidOpen:(NSNotification *)notification;
|
||||
- (void)drawerDidClose:(NSNotification *)notification;
|
||||
|
||||
//Fun stuff
|
||||
//Fun stuff
|
||||
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag;
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename;
|
||||
- (void)application:(NSApplication *)theApplication openFiles:(NSArray *)filenames;
|
||||
|
|
|
@ -12,11 +12,12 @@
|
|||
[p setAllowsMultipleSelection:YES];
|
||||
|
||||
// [p beginSheetForDirectory:nil file:nil types:[`listController acceptableFileTypes] modalForWindow:mainWindow modalDelegate:self didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:) contextInfo:NULL];
|
||||
// [p beginForDirectory:nil file:nil types:[playlistController acceptableFileTypes] modelessDelegate:self didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:) contextInfo:nil];
|
||||
// [p beginForDirectory:nil file:nil types:[playlistController acceptableFileTypes] modelessDelegate:self didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:) contextInfo:nil];
|
||||
|
||||
if ([p runModalForTypes:[playlistController acceptableFileTypes]] == NSOKButton)
|
||||
{
|
||||
[playlistController addPaths:[p filenames] sort:NO];
|
||||
[self updateTotalTime];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,6 +35,7 @@
|
|||
- (IBAction)delEntries:(id)sender
|
||||
{
|
||||
[playlistController remove:self];
|
||||
[self updateTotalTime];
|
||||
}
|
||||
|
||||
- (PlaylistEntry *)currentEntry
|
||||
|
@ -43,13 +45,13 @@
|
|||
|
||||
- (BOOL)application:(NSApplication *)sender delegateHandlesKey:(NSString *)key
|
||||
{
|
||||
// DBLog(@"W00t");
|
||||
// DBLog(@"W00t");
|
||||
return [key isEqualToString:@"currentEntry"];
|
||||
}
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
// DBLog(@"AWAKe");
|
||||
// DBLog(@"AWAKe");
|
||||
|
||||
[playButton setToolTip:NSLocalizedString(@"PlayButtonTooltip", @"")];
|
||||
[stopButton setToolTip:NSLocalizedString(@"StopButtonTooltip", @"")];
|
||||
|
@ -63,11 +65,13 @@
|
|||
|
||||
NSString *filename = @"~/Library/Application Support/Cog/Default.playlist";
|
||||
[playlistController loadPlaylist:[filename stringByExpandingTildeInPath]];
|
||||
|
||||
[self updateTotalTime];
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(NSNotification *)aNotification
|
||||
{
|
||||
// DBLog(@"QUITTING");
|
||||
// DBLog(@"QUITTING");
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSString *folder = @"~/Library/Application Support/Cog/";
|
||||
|
||||
|
@ -120,6 +124,8 @@
|
|||
[playlistController setPlaylistFilename:[p filename]];
|
||||
|
||||
[playlistController loadPlaylist:[p filename]];
|
||||
|
||||
[self updateTotalTime];
|
||||
}
|
||||
|
||||
[mainWindow makeKeyAndOrderFront:self];
|
||||
|
@ -172,4 +178,21 @@
|
|||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://sourceforge.net/project/project_donations.php?group_id=140003"]];
|
||||
}
|
||||
|
||||
- (void)updateTotalTime
|
||||
{
|
||||
double tt=0;
|
||||
NSArray* entries = [playlistController arrangedObjects];
|
||||
|
||||
NSEnumerator *enumerator = [entries objectEnumerator];
|
||||
PlaylistEntry* pe;
|
||||
|
||||
while (pe = [enumerator nextObject]) {
|
||||
tt += [pe length];
|
||||
}
|
||||
|
||||
int sec = (int)(tt/1000.0);
|
||||
NSString* ttstring = [NSString stringWithFormat:@"Cog - %i:%02i",sec/60, sec%60];
|
||||
[mainWindow setTitle:ttstring];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -94,6 +94,7 @@
|
|||
CLASS = PlaylistView;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {
|
||||
appController = AppController;
|
||||
playbackController = PlaybackController;
|
||||
playlistController = PlaylistController;
|
||||
};
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IBDocumentLocation</key>
|
||||
<string>91 411 617 240 0 0 1024 746 </string>
|
||||
<string>69 473 617 240 0 0 1024 746 </string>
|
||||
<key>IBEditorPositions</key>
|
||||
<dict>
|
||||
<key>29</key>
|
||||
|
@ -28,12 +28,12 @@
|
|||
<integer>3</integer>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>463</integer>
|
||||
<integer>29</integer>
|
||||
<integer>21</integer>
|
||||
<integer>513</integer>
|
||||
<integer>463</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>8H14</string>
|
||||
<string>8I127</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
Binary file not shown.
|
@ -94,6 +94,7 @@
|
|||
CLASS = PlaylistView;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {
|
||||
appController = AppController;
|
||||
playbackController = PlaybackController;
|
||||
playlistController = PlaylistController;
|
||||
};
|
||||
|
|
|
@ -25,6 +25,6 @@
|
|||
<integer>513</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>8H14</string>
|
||||
<string>8I127</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
Binary file not shown.
|
@ -8,11 +8,13 @@
|
|||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "AppController.h"
|
||||
#import "PlaybackController.h"
|
||||
#import "PlaylistController.h"
|
||||
|
||||
@interface PlaylistView : NSTableView {
|
||||
|
||||
IBOutlet AppController *appController; //needed to update the total time in the main window title
|
||||
IBOutlet PlaybackController *playbackController;
|
||||
IBOutlet PlaylistController *playlistController;
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
if (c == NSDeleteCharacter)
|
||||
{
|
||||
[playlistController remove:self];
|
||||
[appController updateTotalTime];
|
||||
}
|
||||
else if (c == ' ')
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue