Commit 002c526b authored by David Fuhrmann's avatar David Fuhrmann

macosx: Improve menu item validation for delete, selectAll, play

This affects main menu and playlist context menu items. Also
removes dead code from the PlaylistView class.
parent c5369f03
......@@ -345,7 +345,7 @@
<menuItem title="Delete" id="5084">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="delete:" target="-1" id="5085"/>
<action selector="deleteItem:" target="-1" id="9EK-NF-Zy9"/>
</connections>
</menuItem>
<menuItem title="Select All" keyEquivalent="a" id="198">
......
......@@ -329,7 +329,7 @@
[_cutItem setTitle: _NS("Cut")];
[_mcopyItem setTitle: _NS("Copy")];
[_pasteItem setTitle: _NS("Paste")];
[_clearItem setTitle: _NS("Clear")];
[_clearItem setTitle: _NS("Delete")];
[_select_all setTitle: _NS("Select All")];
[_viewMenu setTitle: _NS("View")];
......
......@@ -506,6 +506,13 @@
return NO;
if (![[NSFileManager defaultManager] fileExistsAtPath:[url path]])
return NO;
} else if ([item action] == @selector(deleteItem:)) {
return [_outlineView numberOfSelectedRows] > 0 && _model.editAllowed;
} else if ([item action] == @selector(selectAll:)) {
return [_outlineView numberOfRows] >= 0;
} else if ([item action] == @selector(playItem:)) {
return [_outlineView numberOfSelectedRows] > 0;
}
return YES;
......@@ -733,9 +740,7 @@
playlist_t *p_playlist = pl_Get(getIntf());
bool b_del_allowed = [[self model] editAllowed];
[_playPlaylistMenuItem setEnabled: b_item_sel];
[_deletePlaylistMenuItem setEnabled: b_item_sel && b_del_allowed];
[_selectAllPlaylistMenuItem setEnabled: b_rows];
// TODO move other items to menu validation protocol
[_infoPlaylistMenuItem setEnabled: b_item_sel];
[_preparsePlaylistMenuItem setEnabled: b_item_sel];
[_recursiveExpandPlaylistMenuItem setEnabled: b_item_sel];
......
......@@ -60,14 +60,6 @@
}
}
- (BOOL)validateMenuItem:(NSMenuItem *)item
{
if (([self numberOfSelectedRows] >= 1 && [item action] == @selector(delete:)) || [item action] == @selector(selectAll:))
return YES;
return NO;
}
- (BOOL)acceptsFirstResponder
{
return YES;
......@@ -85,9 +77,4 @@
return YES;
}
- (IBAction)delete:(id)sender
{
[[[VLCMain sharedInstance] playlist] deleteItem: sender];
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment