Hide/Show table columns through menu selection.
parent
838dd31a64
commit
2884273ff7
|
@ -3,6 +3,8 @@
|
|||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "PlaylistController.h"
|
||||
#import "PlaylistView.h"
|
||||
|
||||
#import "FileTreeController.h"
|
||||
#import "NDHotKeyEvent.h"
|
||||
|
||||
|
@ -10,10 +12,10 @@
|
|||
@interface AppController : NSObject
|
||||
{
|
||||
IBOutlet PlaylistController *playlistController;
|
||||
|
||||
IBOutlet NSPanel *mainWindow;
|
||||
|
||||
IBOutlet NSButton *playButton;
|
||||
IBOutlet NSButton *stopButton;
|
||||
IBOutlet NSButton *prevButton;
|
||||
IBOutlet NSButton *nextButton;
|
||||
IBOutlet NSButton *addButton;
|
||||
|
@ -28,6 +30,17 @@
|
|||
|
||||
IBOutlet FileTreeController *fileTreeController;
|
||||
|
||||
IBOutlet PlaylistView *playlistView;
|
||||
|
||||
IBOutlet NSMenuItem *showIndexColumn;
|
||||
IBOutlet NSMenuItem *showTitleColumn;
|
||||
IBOutlet NSMenuItem *showArtistColumn;
|
||||
IBOutlet NSMenuItem *showAlbumColumn;
|
||||
IBOutlet NSMenuItem *showGenreColumn;
|
||||
IBOutlet NSMenuItem *showLengthColumn;
|
||||
IBOutlet NSMenuItem *showTrackColumn;
|
||||
IBOutlet NSMenuItem *showYearColumn;
|
||||
|
||||
NDHotKeyEvent *playHotKey;
|
||||
NDHotKeyEvent *prevHotKey;
|
||||
NDHotKeyEvent *nextHotKey;
|
||||
|
|
|
@ -73,13 +73,33 @@
|
|||
return [key isEqualToString:@"currentEntry"];
|
||||
}
|
||||
|
||||
- (void)initShowColumn:(NSMenuItem *)showColumn withIdentifier:(NSString *)identifier
|
||||
{
|
||||
id tc = [playlistView tableColumnWithIdentifier:identifier];
|
||||
|
||||
NSArray *visibleColumnIdentifiers = [[NSUserDefaults standardUserDefaults] objectForKey:[playlistView columnVisibilitySaveName]];
|
||||
if (visibleColumnIdentifiers) {
|
||||
NSEnumerator *enumerator = [visibleColumnIdentifiers objectEnumerator];
|
||||
id column;
|
||||
while (column = [enumerator nextObject]) {
|
||||
if ([visibleColumnIdentifiers containsObject:identifier]) {
|
||||
[showColumn setState:NSOnState];
|
||||
}
|
||||
else {
|
||||
[showColumn setState:NSOffState];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[showColumn setRepresentedObject: tc];
|
||||
}
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
// [self initDefaults];
|
||||
|
||||
// DBLog(@"AWAKe");
|
||||
[playButton setToolTip:NSLocalizedString(@"PlayButtonTooltip", @"")];
|
||||
[stopButton setToolTip:NSLocalizedString(@"StopButtonTooltip", @"")];
|
||||
[prevButton setToolTip:NSLocalizedString(@"PrevButtonTooltip", @"")];
|
||||
[nextButton setToolTip:NSLocalizedString(@"NextButtonTooltip", @"")];
|
||||
[addButton setToolTip:NSLocalizedString(@"AddButtonTooltip", @"")];
|
||||
|
@ -88,6 +108,15 @@
|
|||
[shuffleButton setToolTip:NSLocalizedString(@"ShuffleButtonTooltip", @"")];
|
||||
[repeatButton setToolTip:NSLocalizedString(@"RepeatButtonTooltip", @"")];
|
||||
|
||||
[self initShowColumn: showIndexColumn withIdentifier: @"index"];
|
||||
[self initShowColumn: showTitleColumn withIdentifier: @"title"];
|
||||
[self initShowColumn: showArtistColumn withIdentifier: @"artist"];
|
||||
[self initShowColumn: showAlbumColumn withIdentifier: @"album"];
|
||||
[self initShowColumn: showGenreColumn withIdentifier: @"genre"];
|
||||
[self initShowColumn: showLengthColumn withIdentifier: @"length"];
|
||||
[self initShowColumn: showTrackColumn withIdentifier: @"track"];
|
||||
[self initShowColumn: showYearColumn withIdentifier: @"year"];
|
||||
|
||||
[self registerHotKeys];
|
||||
|
||||
NSString *filename = @"~/Library/Application Support/Cog/Default.playlist";
|
||||
|
@ -274,7 +303,7 @@
|
|||
|
||||
[prevHotKey release];
|
||||
prevHotKey = [[NDHotKeyEvent alloc]
|
||||
initWithKeyCode: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeyPreviousKeyCode"]
|
||||
initWithKeyCode: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeyPreviousKeyCode"]
|
||||
character: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeyPreviousCharacter"]
|
||||
modifierFlags: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeyPreviousModifiers"]
|
||||
];
|
||||
|
@ -312,10 +341,5 @@
|
|||
[nextButton performClick:nil];
|
||||
}
|
||||
|
||||
- (void)clickStop
|
||||
{
|
||||
[stopButton performClick:nil];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -37,11 +37,19 @@
|
|||
nextButton = NSButton;
|
||||
playButton = NSButton;
|
||||
playlistController = PlaylistController;
|
||||
playlistView = PlaylistView;
|
||||
prevButton = NSButton;
|
||||
remButton = NSButton;
|
||||
repeatButton = NSButton;
|
||||
showAlbumColumn = NSMenuItem;
|
||||
showArtistColumn = NSMenuItem;
|
||||
showGenreColumn = NSMenuItem;
|
||||
showIndexColumn = NSMenuItem;
|
||||
showLengthColumn = NSMenuItem;
|
||||
showTitleColumn = NSMenuItem;
|
||||
showTrackColumn = NSMenuItem;
|
||||
showYearColumn = NSMenuItem;
|
||||
shuffleButton = NSButton;
|
||||
stopButton = NSButton;
|
||||
};
|
||||
SUPERCLASS = NSObject;
|
||||
},
|
||||
|
@ -118,18 +126,7 @@
|
|||
},
|
||||
{CLASS = PlaylistEntry; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
|
||||
{
|
||||
ACTIONS = {
|
||||
shufflePlaylist = id;
|
||||
sortByPath = id;
|
||||
toggleColumnForAlbum = id;
|
||||
toggleColumnForArtist = id;
|
||||
toggleColumnForGenre = id;
|
||||
toggleColumnForIndex = id;
|
||||
toggleColumnForLength = id;
|
||||
toggleColumnForTitle = id;
|
||||
toggleColumnForTrack = id;
|
||||
toggleColumnForYear = id;
|
||||
};
|
||||
ACTIONS = {shufflePlaylist = id; sortByPath = id; toggleColumn = id; };
|
||||
CLASS = PlaylistView;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IBDocumentLocation</key>
|
||||
<string>38 327 639 388 0 0 1024 746 </string>
|
||||
<string>66 -65 639 388 0 0 1024 746 </string>
|
||||
<key>IBEditorPositions</key>
|
||||
<dict>
|
||||
<key>1063</key>
|
||||
|
@ -11,7 +11,7 @@
|
|||
<key>1156</key>
|
||||
<string>233 341 241 366 0 0 1024 746 </string>
|
||||
<key>29</key>
|
||||
<string>73 702 383 44 0 0 1024 746 </string>
|
||||
<string>85 683 383 44 0 0 1024 746 </string>
|
||||
<key>463</key>
|
||||
<string>358 380 308 279 0 0 1024 746 </string>
|
||||
<key>513</key>
|
||||
|
|
Binary file not shown.
|
@ -8,7 +8,6 @@
|
|||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "AppController.h"
|
||||
#import "PlaybackController.h"
|
||||
#import "PlaylistController.h"
|
||||
|
||||
|
@ -23,14 +22,7 @@
|
|||
- (IBAction)sortByPath:(id)sender;
|
||||
- (IBAction)shufflePlaylist:(id)sender;
|
||||
|
||||
- (IBAction)toggleColumnForIndex:(id)sender;
|
||||
- (IBAction)toggleColumnForTitle:(id)sender;
|
||||
- (IBAction)toggleColumnForArtist:(id)sender;
|
||||
- (IBAction)toggleColumnForAlbum:(id)sender;
|
||||
- (IBAction)toggleColumnForLength:(id)sender;
|
||||
- (IBAction)toggleColumnForYear:(id)sender;
|
||||
- (IBAction)toggleColumnForGenre:(id)sender;
|
||||
- (IBAction)toggleColumnForTrack:(id)sender;
|
||||
- (IBAction)toggleColumn:(id)sender;
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -45,9 +45,9 @@
|
|||
}
|
||||
|
||||
|
||||
- (void)toggleColumn:(id)sender withIdentifier:(NSString *)identifier
|
||||
- (IBAction)toggleColumn:(id)sender
|
||||
{
|
||||
NSTableColumn *tc = [super tableColumnWithIdentifier:identifier];
|
||||
id tc = [sender representedObject];
|
||||
|
||||
if ([sender state] == NSOffState)
|
||||
{
|
||||
|
@ -62,47 +62,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (IBAction)toggleColumnForIndex:(id)sender
|
||||
{
|
||||
[self toggleColumn:sender withIdentifier:@"index"];
|
||||
}
|
||||
|
||||
- (IBAction)toggleColumnForTitle:(id)sender
|
||||
{
|
||||
[self toggleColumn:sender withIdentifier:@"title"];
|
||||
}
|
||||
|
||||
- (IBAction)toggleColumnForArtist:(id)sender
|
||||
{
|
||||
[self toggleColumn:sender withIdentifier:@"artist"];
|
||||
}
|
||||
|
||||
- (IBAction)toggleColumnForAlbum:(id)sender
|
||||
{
|
||||
[self toggleColumn:sender withIdentifier:@"album"];
|
||||
}
|
||||
|
||||
- (IBAction)toggleColumnForLength:(id)sender
|
||||
{
|
||||
[self toggleColumn:sender withIdentifier:@"length"];
|
||||
}
|
||||
|
||||
- (IBAction)toggleColumnForYear:(id)sender
|
||||
{
|
||||
[self toggleColumn:sender withIdentifier:@"year"];
|
||||
}
|
||||
|
||||
- (IBAction)toggleColumnForGenre:(id)sender
|
||||
{
|
||||
[self toggleColumn:sender withIdentifier:@"genre"];
|
||||
}
|
||||
|
||||
- (IBAction)toggleColumnForTrack:(id)sender
|
||||
{
|
||||
[self toggleColumn:sender withIdentifier:@"track"];
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)acceptsFirstResponder
|
||||
{
|
||||
return YES;
|
||||
|
|
Loading…
Reference in New Issue