diff --git a/AppController.h b/AppController.h
index c8d9193d3..aa4009917 100644
--- a/AppController.h
+++ b/AppController.h
@@ -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;
diff --git a/AppController.m b/AppController.m
index 0f654b222..52ed537c7 100644
--- a/AppController.m
+++ b/AppController.m
@@ -12,13 +12,14 @@
[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];
}
-
+
}
- (void)openPanelDidEnd:(NSOpenPanel *)panel returnCode:(int)returnCode contextInfo:(void *)contextInfo
@@ -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", @"")];
@@ -60,14 +62,16 @@
[infoButton setToolTip:NSLocalizedString(@"InfoButtonTooltip", @"")];
[shuffleButton setToolTip:NSLocalizedString(@"ShuffleButtonTooltip", @"")];
[repeatButton setToolTip:NSLocalizedString(@"RepeatButtonTooltip", @"")];
-
+
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/";
@@ -79,9 +83,9 @@
}
NSString *fileName = @"Default.playlist";
-
+
[playlistController savePlaylist:[folder stringByAppendingPathComponent: fileName]];
-
+
}
- (IBAction)savePlaylist:(id)sender
@@ -102,7 +106,7 @@
if ([p runModalForDirectory:nil file:[[playlistController playlistFilename] lastPathComponent]] == NSOKButton)
{
[playlistController setPlaylistFilename:[p filename]];
-
+
[playlistController savePlaylist:[p filename]];
}
}
@@ -120,6 +124,8 @@
[playlistController setPlaylistFilename:[p filename]];
[playlistController loadPlaylist:[p filename]];
+
+ [self updateTotalTime];
}
[mainWindow makeKeyAndOrderFront:self];
@@ -145,7 +151,7 @@
- (void)application:(NSApplication *)theApplication openFiles:(NSArray *)filenames
{
DBLog(@"Adding paths: %@", filenames);
-
+
[playlistController addPaths:filenames sort:YES];
[theApplication replyToOpenOrPrint:NSApplicationDelegateReplySuccess];
}
@@ -153,7 +159,7 @@
- (IBAction)toggleInfoDrawer:(id)sender
{
[mainWindow makeKeyAndOrderFront:self];
-
+
[infoDrawer toggle: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
diff --git a/English.lproj/MainMenu.nib/classes.nib b/English.lproj/MainMenu.nib/classes.nib
index 3e7ff796e..dbbe04f51 100644
--- a/English.lproj/MainMenu.nib/classes.nib
+++ b/English.lproj/MainMenu.nib/classes.nib
@@ -94,6 +94,7 @@
CLASS = PlaylistView;
LANGUAGE = ObjC;
OUTLETS = {
+ appController = AppController;
playbackController = PlaybackController;
playlistController = PlaylistController;
};
diff --git a/English.lproj/MainMenu.nib/info.nib b/English.lproj/MainMenu.nib/info.nib
index 9b92f27e8..819b6c605 100644
--- a/English.lproj/MainMenu.nib/info.nib
+++ b/English.lproj/MainMenu.nib/info.nib
@@ -3,7 +3,7 @@
IBDocumentLocation
- 91 411 617 240 0 0 1024 746
+ 69 473 617 240 0 0 1024 746
IBEditorPositions
29
@@ -28,12 +28,12 @@
3
IBOpenObjects
- 463
29
21
513
+ 463
IBSystem Version
- 8H14
+ 8I127
diff --git a/English.lproj/MainMenu.nib/keyedobjects.nib b/English.lproj/MainMenu.nib/keyedobjects.nib
index 4f8c02aeb..a0b007a1e 100644
Binary files a/English.lproj/MainMenu.nib/keyedobjects.nib and b/English.lproj/MainMenu.nib/keyedobjects.nib differ
diff --git a/French.lproj/MainMenu.nib/classes.nib b/French.lproj/MainMenu.nib/classes.nib
index 3e7ff796e..dbbe04f51 100644
--- a/French.lproj/MainMenu.nib/classes.nib
+++ b/French.lproj/MainMenu.nib/classes.nib
@@ -94,6 +94,7 @@
CLASS = PlaylistView;
LANGUAGE = ObjC;
OUTLETS = {
+ appController = AppController;
playbackController = PlaybackController;
playlistController = PlaylistController;
};
diff --git a/French.lproj/MainMenu.nib/info.nib b/French.lproj/MainMenu.nib/info.nib
index 4f19caf32..52efcff31 100644
--- a/French.lproj/MainMenu.nib/info.nib
+++ b/French.lproj/MainMenu.nib/info.nib
@@ -25,6 +25,6 @@
513
IBSystem Version
- 8H14
+ 8I127
diff --git a/French.lproj/MainMenu.nib/keyedobjects.nib b/French.lproj/MainMenu.nib/keyedobjects.nib
index 50f610665..f21f2bbf4 100644
Binary files a/French.lproj/MainMenu.nib/keyedobjects.nib and b/French.lproj/MainMenu.nib/keyedobjects.nib differ
diff --git a/Playlist/PlaylistView.h b/Playlist/PlaylistView.h
index e4149967b..b53ab6247 100644
--- a/Playlist/PlaylistView.h
+++ b/Playlist/PlaylistView.h
@@ -8,11 +8,13 @@
#import
+#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;
diff --git a/Playlist/PlaylistView.m b/Playlist/PlaylistView.m
index 1bb6d5b27..0af980437 100644
--- a/Playlist/PlaylistView.m
+++ b/Playlist/PlaylistView.m
@@ -54,6 +54,7 @@
if (c == NSDeleteCharacter)
{
[playlistController remove:self];
+ [appController updateTotalTime];
}
else if (c == ' ')
{