Total playlist time displayed in title (simon savary)

CQTexperiment
vspader 2006-04-13 03:20:31 +00:00
parent 9377d8647e
commit 3597e03585
10 changed files with 46 additions and 16 deletions

View File

@ -32,6 +32,8 @@
- (IBAction)donate:(id)sender;
- (void)updateTotalTime;
- (IBAction)toggleInfoDrawer:(id)sender;
- (void)drawerDidOpen:(NSNotification *)notification;
- (void)drawerDidClose:(NSNotification *)notification;

View File

@ -17,6 +17,7 @@
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
@ -63,6 +65,8 @@
NSString *filename = @"~/Library/Application Support/Cog/Default.playlist";
[playlistController loadPlaylist:[filename stringByExpandingTildeInPath]];
[self updateTotalTime];
}
- (void)applicationWillTerminate:(NSNotification *)aNotification
@ -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

View File

@ -94,6 +94,7 @@
CLASS = PlaylistView;
LANGUAGE = ObjC;
OUTLETS = {
appController = AppController;
playbackController = PlaybackController;
playlistController = PlaylistController;
};

View File

@ -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.

View File

@ -94,6 +94,7 @@
CLASS = PlaylistView;
LANGUAGE = ObjC;
OUTLETS = {
appController = AppController;
playbackController = PlaybackController;
playlistController = PlaylistController;
};

View File

@ -25,6 +25,6 @@
<integer>513</integer>
</array>
<key>IBSystem Version</key>
<string>8H14</string>
<string>8I127</string>
</dict>
</plist>

Binary file not shown.

View File

@ -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;

View File

@ -54,6 +54,7 @@
if (c == NSDeleteCharacter)
{
[playlistController remove:self];
[appController updateTotalTime];
}
else if (c == ' ')
{