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; - (IBAction)donate:(id)sender;
- (void)updateTotalTime;
- (IBAction)toggleInfoDrawer:(id)sender; - (IBAction)toggleInfoDrawer:(id)sender;
- (void)drawerDidOpen:(NSNotification *)notification; - (void)drawerDidOpen:(NSNotification *)notification;
- (void)drawerDidClose:(NSNotification *)notification; - (void)drawerDidClose:(NSNotification *)notification;

View File

@ -17,6 +17,7 @@
if ([p runModalForTypes:[playlistController acceptableFileTypes]] == NSOKButton) if ([p runModalForTypes:[playlistController acceptableFileTypes]] == NSOKButton)
{ {
[playlistController addPaths:[p filenames] sort:NO]; [playlistController addPaths:[p filenames] sort:NO];
[self updateTotalTime];
} }
} }
@ -34,6 +35,7 @@
- (IBAction)delEntries:(id)sender - (IBAction)delEntries:(id)sender
{ {
[playlistController remove:self]; [playlistController remove:self];
[self updateTotalTime];
} }
- (PlaylistEntry *)currentEntry - (PlaylistEntry *)currentEntry
@ -63,6 +65,8 @@
NSString *filename = @"~/Library/Application Support/Cog/Default.playlist"; NSString *filename = @"~/Library/Application Support/Cog/Default.playlist";
[playlistController loadPlaylist:[filename stringByExpandingTildeInPath]]; [playlistController loadPlaylist:[filename stringByExpandingTildeInPath]];
[self updateTotalTime];
} }
- (void)applicationWillTerminate:(NSNotification *)aNotification - (void)applicationWillTerminate:(NSNotification *)aNotification
@ -120,6 +124,8 @@
[playlistController setPlaylistFilename:[p filename]]; [playlistController setPlaylistFilename:[p filename]];
[playlistController loadPlaylist:[p filename]]; [playlistController loadPlaylist:[p filename]];
[self updateTotalTime];
} }
[mainWindow makeKeyAndOrderFront:self]; [mainWindow makeKeyAndOrderFront:self];
@ -172,4 +178,21 @@
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://sourceforge.net/project/project_donations.php?group_id=140003"]]; [[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 @end

View File

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

View File

@ -3,7 +3,7 @@
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>IBDocumentLocation</key> <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> <key>IBEditorPositions</key>
<dict> <dict>
<key>29</key> <key>29</key>
@ -28,12 +28,12 @@
<integer>3</integer> <integer>3</integer>
<key>IBOpenObjects</key> <key>IBOpenObjects</key>
<array> <array>
<integer>463</integer>
<integer>29</integer> <integer>29</integer>
<integer>21</integer> <integer>21</integer>
<integer>513</integer> <integer>513</integer>
<integer>463</integer>
</array> </array>
<key>IBSystem Version</key> <key>IBSystem Version</key>
<string>8H14</string> <string>8I127</string>
</dict> </dict>
</plist> </plist>

Binary file not shown.

View File

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

View File

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

Binary file not shown.

View File

@ -8,11 +8,13 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "AppController.h"
#import "PlaybackController.h" #import "PlaybackController.h"
#import "PlaylistController.h" #import "PlaylistController.h"
@interface PlaylistView : NSTableView { @interface PlaylistView : NSTableView {
IBOutlet AppController *appController; //needed to update the total time in the main window title
IBOutlet PlaybackController *playbackController; IBOutlet PlaybackController *playbackController;
IBOutlet PlaylistController *playlistController; IBOutlet PlaylistController *playlistController;

View File

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