[vlc-commits] macosx: Improve menu item validation for delete, selectAll, play

David Fuhrmann git at videolan.org
Sat Jan 9 14:55:19 CET 2016


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sat Jan  9 14:52:07 2016 +0100| [002c526bdf3fb97ed54c4c640a2922014a1dc683] | committer: 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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=002c526bdf3fb97ed54c4c640a2922014a1dc683
---

 .../package/macosx/Resources/English.lproj/MainMenu.xib   |    2 +-
 modules/gui/macosx/MainMenu.m                             |    2 +-
 modules/gui/macosx/VLCPlaylist.m                          |   11 ++++++++---
 modules/gui/macosx/VLCPlaylistView.m                      |   13 -------------
 4 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/extras/package/macosx/Resources/English.lproj/MainMenu.xib b/extras/package/macosx/Resources/English.lproj/MainMenu.xib
index 58aba3c..03770a6 100644
--- a/extras/package/macosx/Resources/English.lproj/MainMenu.xib
+++ b/extras/package/macosx/Resources/English.lproj/MainMenu.xib
@@ -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">
diff --git a/modules/gui/macosx/MainMenu.m b/modules/gui/macosx/MainMenu.m
index a7d1044..2ebcc8d 100644
--- a/modules/gui/macosx/MainMenu.m
+++ b/modules/gui/macosx/MainMenu.m
@@ -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")];
diff --git a/modules/gui/macosx/VLCPlaylist.m b/modules/gui/macosx/VLCPlaylist.m
index 1e78962..e34f80f 100644
--- a/modules/gui/macosx/VLCPlaylist.m
+++ b/modules/gui/macosx/VLCPlaylist.m
@@ -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];
diff --git a/modules/gui/macosx/VLCPlaylistView.m b/modules/gui/macosx/VLCPlaylistView.m
index 132d86f..013ae08 100644
--- a/modules/gui/macosx/VLCPlaylistView.m
+++ b/modules/gui/macosx/VLCPlaylistView.m
@@ -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



More information about the vlc-commits mailing list