"Show in Finder" feature for track files (right-click menu).

CQTexperiment
sryegkahl 2006-05-23 15:12:24 +00:00
parent 48e4187b88
commit a430aff269
9 changed files with 77 additions and 10 deletions

View File

@ -84,7 +84,11 @@
SUPERCLASS = NSObject;
},
{
ACTIONS = {takeRepeatFromObject = id; takeShuffleFromObject = id; };
ACTIONS = {
showFileInFinder = id;
takeRepeatFromObject = id;
takeShuffleFromObject = id;
};
CLASS = PlaylistController;
LANGUAGE = ObjC;
SUPERCLASS = DNDArrayController;

View File

@ -3,15 +3,17 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>-18 96 617 240 0 0 1024 746 </string>
<string>-9 67 617 240 0 0 1280 1002 </string>
<key>IBEditorPositions</key>
<dict>
<key>1063</key>
<string>0 312 189 49 0 0 1280 1002 </string>
<key>29</key>
<string>98 651 409 44 0 0 1024 746 </string>
<string>139 888 409 44 0 0 1280 1002 </string>
<key>463</key>
<string>358 426 308 187 0 0 1024 746 </string>
<string>486 586 308 187 0 0 1280 1002 </string>
<key>513</key>
<string>639 190 125 137 0 0 1024 746 </string>
<string>821 270 125 137 0 0 1280 1002 </string>
</dict>
<key>IBFramework Version</key>
<string>443.0</string>
@ -28,11 +30,12 @@
<integer>3</integer>
<key>IBOpenObjects</key>
<array>
<integer>1063</integer>
<integer>513</integer>
<integer>21</integer>
<integer>463</integer>
<integer>823</integer>
<integer>29</integer>
<integer>21</integer>
<integer>513</integer>
</array>
<key>IBSystem Version</key>
<string>8I127</string>

Binary file not shown.

View File

@ -89,7 +89,11 @@
SUPERCLASS = NSObject;
},
{
ACTIONS = {takeRepeatFromObject = id; takeShuffleFromObject = id; };
ACTIONS = {
showFileInFinder = id;
takeRepeatFromObject = id;
takeShuffleFromObject = id;
};
CLASS = PlaylistController;
LANGUAGE = ObjC;
SUPERCLASS = DNDArrayController;
@ -105,7 +109,6 @@
};
SUPERCLASS = NSTableView;
},
{CLASS = SeekSlider; LANGUAGE = ObjC; SUPERCLASS = NSSlider; },
{
ACTIONS = {
changeVolume = id;

View File

@ -12,6 +12,8 @@
<string>486 586 308 187 0 0 1280 1002 </string>
<key>513</key>
<string>689 788 166 137 0 0 1280 1002 </string>
<key>760</key>
<string>465 451 189 49 0 0 1280 1002 </string>
</dict>
<key>IBFramework Version</key>
<string>443.0</string>
@ -22,7 +24,7 @@
<key>IBOpenObjects</key>
<array>
<integer>21</integer>
<integer>463</integer>
<integer>760</integer>
</array>
<key>IBSystem Version</key>
<string>8I127</string>

Binary file not shown.

View File

@ -23,6 +23,8 @@
BOOL shuffle;
BOOL repeat;
int selectedRow;
}
//All these return the number of things actually added
@ -73,4 +75,7 @@
- (void)setPlaylistFilename:(NSString *)pf;
- (NSArray *)acceptablePlaylistTypes;
- (IBAction)showFileInFinder:(id)sender;
- (void)setSelectedRow:(int)row;
- (int)selectedRow;
@end

View File

@ -696,4 +696,24 @@
playlistFilename = pf;
}
- (IBAction)showFileInFinder:(id)sender
{
NSWorkspace* ws = [NSWorkspace sharedWorkspace];
if (selectedRow < 0)
return;
PlaylistEntry* curr = [self entryAtIndex:selectedRow];
[ws selectFile:[curr filename] inFileViewerRootedAtPath:[curr filename]];
}
- (void)setSelectedRow:(int)row
{
selectedRow = row;
}
- (int)selectedRow
{
return selectedRow;
}
@end

View File

@ -59,6 +59,36 @@
}
}
// enables right-click selection for "Show in Finder" contextual menu
-(NSMenu*)menuForEvent:(NSEvent*)event
{
//Find which row is under the cursor
[[self window] makeFirstResponder:self];
NSPoint menuPoint = [self convertPoint:[event locationInWindow] fromView:nil];
int row = [self rowAtPoint:menuPoint];
/* Update the table selection before showing menu
Preserves the selection if the row under the mouse is selected (to allow for
multiple items to be selected), otherwise selects the row under the mouse */
BOOL currentRowIsSelected = [[self selectedRowIndexes] containsIndex:row];
if (!currentRowIsSelected)
[self selectRow:row byExtendingSelection:NO];
[playlistController setSelectedRow:[self selectedRow]];
if ([self numberOfSelectedRows] <=0)
{
//No rows are selected, so the table should be displayed with all items disabled
NSMenu* tableViewMenu = [[self menu] copy];
int i;
for (i=0;i<[tableViewMenu numberOfItems];i++)
[[tableViewMenu itemAtIndex:i] setEnabled:NO];
return [tableViewMenu autorelease];
}
else
return [self menu];
}
- (void)keyDown:(NSEvent *)e
{