Total time display is now a binding
This commit is contained in:
parent
53d9869e02
commit
5465ec09d9
8 changed files with 40 additions and 30 deletions
|
@ -32,8 +32,6 @@
|
||||||
|
|
||||||
- (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;
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
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];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,7 +34,6 @@
|
||||||
- (IBAction)delEntries:(id)sender
|
- (IBAction)delEntries:(id)sender
|
||||||
{
|
{
|
||||||
[playlistController remove:self];
|
[playlistController remove:self];
|
||||||
[self updateTotalTime];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (PlaylistEntry *)currentEntry
|
- (PlaylistEntry *)currentEntry
|
||||||
|
@ -65,8 +63,6 @@
|
||||||
|
|
||||||
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
|
||||||
|
@ -124,8 +120,6 @@
|
||||||
[playlistController setPlaylistFilename:[p filename]];
|
[playlistController setPlaylistFilename:[p filename]];
|
||||||
|
|
||||||
[playlistController loadPlaylist:[p filename]];
|
[playlistController loadPlaylist:[p filename]];
|
||||||
|
|
||||||
[self updateTotalTime];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[mainWindow makeKeyAndOrderFront:self];
|
[mainWindow makeKeyAndOrderFront:self];
|
||||||
|
@ -178,21 +172,4 @@
|
||||||
[[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
|
||||||
|
|
2
English.lproj/MainMenu.nib/info.nib
generated
2
English.lproj/MainMenu.nib/info.nib
generated
|
@ -29,9 +29,9 @@
|
||||||
<key>IBOpenObjects</key>
|
<key>IBOpenObjects</key>
|
||||||
<array>
|
<array>
|
||||||
<integer>29</integer>
|
<integer>29</integer>
|
||||||
<integer>21</integer>
|
|
||||||
<integer>513</integer>
|
<integer>513</integer>
|
||||||
<integer>463</integer>
|
<integer>463</integer>
|
||||||
|
<integer>21</integer>
|
||||||
</array>
|
</array>
|
||||||
<key>IBSystem Version</key>
|
<key>IBSystem Version</key>
|
||||||
<string>8I127</string>
|
<string>8I127</string>
|
||||||
|
|
BIN
English.lproj/MainMenu.nib/keyedobjects.nib
generated
BIN
English.lproj/MainMenu.nib/keyedobjects.nib
generated
Binary file not shown.
|
@ -15,6 +15,7 @@
|
||||||
NSArray *acceptablePlaylistTypes;
|
NSArray *acceptablePlaylistTypes;
|
||||||
|
|
||||||
NSString *playlistFilename;
|
NSString *playlistFilename;
|
||||||
|
NSString *totalTimeDisplay;
|
||||||
|
|
||||||
NSMutableArray *shuffleList;
|
NSMutableArray *shuffleList;
|
||||||
|
|
||||||
|
@ -33,6 +34,8 @@
|
||||||
- (int)insertFile:(NSString *)filename atIndex:(int)index;
|
- (int)insertFile:(NSString *)filename atIndex:(int)index;
|
||||||
- (int)addFile:(NSString *)filename;
|
- (int)addFile:(NSString *)filename;
|
||||||
- (void)updateIndexesFromRow:(int) row;
|
- (void)updateIndexesFromRow:(int) row;
|
||||||
|
- (void)updateTotalTime;
|
||||||
|
|
||||||
|
|
||||||
//PUBLIC METHODS
|
//PUBLIC METHODS
|
||||||
- (int)addPaths:(NSArray *)paths sort:(BOOL)sort;
|
- (int)addPaths:(NSArray *)paths sort:(BOOL)sort;
|
||||||
|
@ -48,6 +51,9 @@
|
||||||
- (IBAction)takeShuffleFromObject:(id)sender;
|
- (IBAction)takeShuffleFromObject:(id)sender;
|
||||||
- (IBAction)takeRepeatFromObject:(id)sender;
|
- (IBAction)takeRepeatFromObject:(id)sender;
|
||||||
|
|
||||||
|
- (void)setTotalTimeDisplay:(NSString *)ttd;
|
||||||
|
- (NSString *)totalTimeDisplay;
|
||||||
|
|
||||||
//FUN PLAYLIST MANAGEMENT STUFF!
|
//FUN PLAYLIST MANAGEMENT STUFF!
|
||||||
- (id)currentEntry;
|
- (id)currentEntry;
|
||||||
- (void)setCurrentEntry:(PlaylistEntry *)pe;
|
- (void)setCurrentEntry:(PlaylistEntry *)pe;
|
||||||
|
|
|
@ -134,6 +134,7 @@
|
||||||
|
|
||||||
|
|
||||||
[self setSelectionIndex:index];
|
[self setSelectionIndex:index];
|
||||||
|
[self updateTotalTime];
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
@ -193,13 +194,42 @@
|
||||||
[self insertPaths:files atIndex:row sort:YES];
|
[self insertPaths:files atIndex:row sort:YES];
|
||||||
|
|
||||||
[self updateIndexesFromRow:row];
|
[self updateIndexesFromRow:row];
|
||||||
|
[self updateTotalTime];
|
||||||
|
|
||||||
if (shuffle == YES)
|
if (shuffle == YES)
|
||||||
[self resetShuffleList];
|
[self resetShuffleList];
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)updateTotalTime
|
||||||
|
{
|
||||||
|
double tt=0;
|
||||||
|
|
||||||
|
NSEnumerator *enumerator = [[self arrangedObjects] objectEnumerator];
|
||||||
|
PlaylistEntry* pe;
|
||||||
|
|
||||||
|
while (pe = [enumerator nextObject]) {
|
||||||
|
tt += [pe length];
|
||||||
|
}
|
||||||
|
|
||||||
|
int sec = (int)(tt/1000.0);
|
||||||
|
[self setTotalTimeDisplay:[NSString stringWithFormat:@"%i:%02i",sec/60, sec%60]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setTotalTimeDisplay:(NSString *)ttd
|
||||||
|
{
|
||||||
|
[ttd retain];
|
||||||
|
[totalTimeDisplay release];
|
||||||
|
totalTimeDisplay = ttd;
|
||||||
|
NSLog(@"Displaying: %@", ttd);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)totalTimeDisplay;
|
||||||
|
{
|
||||||
|
return totalTimeDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)updateIndexesFromRow:(int) row
|
- (void)updateIndexesFromRow:(int) row
|
||||||
{
|
{
|
||||||
// DBLog(@"UPDATE INDEXES: %i", row);
|
// DBLog(@"UPDATE INDEXES: %i", row);
|
||||||
|
@ -236,7 +266,8 @@
|
||||||
|
|
||||||
[super removeObjectsAtArrangedObjectIndexes:indexes];
|
[super removeObjectsAtArrangedObjectIndexes:indexes];
|
||||||
[self updateIndexesFromRow:[indexes firstIndex]];
|
[self updateIndexesFromRow:[indexes firstIndex]];
|
||||||
|
[self updateTotalTime];
|
||||||
|
|
||||||
if (shuffle == YES)
|
if (shuffle == YES)
|
||||||
[self resetShuffleList];
|
[self resetShuffleList];
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
@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;
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,6 @@
|
||||||
if (c == NSDeleteCharacter)
|
if (c == NSDeleteCharacter)
|
||||||
{
|
{
|
||||||
[playlistController remove:self];
|
[playlistController remove:self];
|
||||||
[appController updateTotalTime];
|
|
||||||
}
|
}
|
||||||
else if (c == ' ')
|
else if (c == ' ')
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue