[vlc-commits] macosx: Fix revealInFinder for main menu item and popup menu
David Fuhrmann
git at videolan.org
Wed Jan 6 17:38:47 CET 2016
vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Wed Jan 6 15:41:59 2016 +0100| [6d1da70de79e36ca984c464ede972eaf60ba1dd0] | committer: David Fuhrmann
macosx: Fix revealInFinder for main menu item and popup menu
Implementation is the same for both menu items. Menu validation
is used to check before if an item is a local file and existing.
Action is passed from main menu via responder chain to playlist.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6d1da70de79e36ca984c464ede972eaf60ba1dd0
---
.../macosx/Resources/English.lproj/MainMenu.xib | 6 +--
.../Resources/English.lproj/PlaylistMenu.xib | 10 ++--
modules/gui/macosx/MainMenu.h | 1 -
modules/gui/macosx/MainMenu.m | 5 --
modules/gui/macosx/MainWindow.m | 1 +
modules/gui/macosx/VLCPlaylist.h | 2 +-
modules/gui/macosx/VLCPlaylist.m | 54 +++++++++++++++-----
7 files changed, 50 insertions(+), 29 deletions(-)
diff --git a/extras/package/macosx/Resources/English.lproj/MainMenu.xib b/extras/package/macosx/Resources/English.lproj/MainMenu.xib
index 74c921d..58aba3c 100644
--- a/extras/package/macosx/Resources/English.lproj/MainMenu.xib
+++ b/extras/package/macosx/Resources/English.lproj/MainMenu.xib
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14F25a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment version="1070" identifier="macosx"/>
<development version="5100" identifier="xcode"/>
- <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="VLCMainMenu">
@@ -302,7 +302,7 @@
</menuItem>
<menuItem title="Reveal in Finder" keyEquivalent="R" id="3945">
<connections>
- <action selector="revealItemInFinder:" target="-2" id="s3X-xq-zrn"/>
+ <action selector="revealItemInFinder:" target="-1" id="SHl-6e-1ro"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="79">
diff --git a/extras/package/macosx/Resources/English.lproj/PlaylistMenu.xib b/extras/package/macosx/Resources/English.lproj/PlaylistMenu.xib
index 21f80c9..f78eae6 100644
--- a/extras/package/macosx/Resources/English.lproj/PlaylistMenu.xib
+++ b/extras/package/macosx/Resources/English.lproj/PlaylistMenu.xib
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="8152.3" systemVersion="14F6a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment version="1070" identifier="macosx"/>
<development version="5100" identifier="xcode"/>
- <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="8152.3"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="VLCPlaylist">
@@ -22,8 +22,8 @@
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
- <customObject id="-3" userLabel="Application"/>
- <menu title="Menu" autoenablesItems="NO" id="1" userLabel="PlaylistMenu">
+ <customObject id="-3" userLabel="Application" customClass="NSObject"/>
+ <menu title="Menu" id="1" userLabel="PlaylistMenu">
<items>
<menuItem title="Play" id="12">
<connections>
@@ -81,7 +81,7 @@
</menuItem>
<menuItem title="Reveal in Finder" id="3">
<connections>
- <action selector="revealItemInFinder:" target="-2" id="35"/>
+ <action selector="revealItemInFinder:" target="-2" id="4WU-rm-69M"/>
</connections>
</menuItem>
</items>
diff --git a/modules/gui/macosx/MainMenu.h b/modules/gui/macosx/MainMenu.h
index 1c9fbba..935bb05 100644
--- a/modules/gui/macosx/MainMenu.h
+++ b/modules/gui/macosx/MainMenu.h
@@ -221,7 +221,6 @@
- (IBAction)intfOpenNet:(id)sender;
- (IBAction)intfOpenCapture:(id)sender;
- (IBAction)savePlaylist:(id)sender;
-- (IBAction)revealItemInFinder:(id)sender;
- (IBAction)toggleEffectsButton:(id)sender;
- (IBAction)toggleJumpButtons:(id)sender;
diff --git a/modules/gui/macosx/MainMenu.m b/modules/gui/macosx/MainMenu.m
index 03d896f..c699740 100644
--- a/modules/gui/macosx/MainMenu.m
+++ b/modules/gui/macosx/MainMenu.m
@@ -1228,11 +1228,6 @@
}
}
-- (IBAction)revealItemInFinder:(id)sender
-{
- [[[VLCMain sharedInstance] playlist] revealItemInFinder:sender];
-}
-
- (IBAction)showConvertAndSave:(id)sender
{
[[[VLCMain sharedInstance] convertAndSaveWindow] showWindow:self];
diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m
index 6d8c294..438644e 100644
--- a/modules/gui/macosx/MainWindow.m
+++ b/modules/gui/macosx/MainWindow.m
@@ -166,6 +166,7 @@ static const float f_min_window_height = 307.;
VLCPlaylist *playlist = [[VLCMain sharedInstance] playlist];
[playlist setOutlineView:(VLCPlaylistView *)_outlineView];
[playlist setPlaylistHeaderView:_outlineView.headerView];
+ [self setNextResponder:playlist];
// (Re)load sidebar for the first time and select first item
[self reloadSidebar];
diff --git a/modules/gui/macosx/VLCPlaylist.h b/modules/gui/macosx/VLCPlaylist.h
index ebf259b..3c21d11 100644
--- a/modules/gui/macosx/VLCPlaylist.h
+++ b/modules/gui/macosx/VLCPlaylist.h
@@ -27,7 +27,7 @@
#import "PLModel.h"
#import "VLCPlaylistView.h"
- at interface VLCPlaylist : NSObject<NSOutlineViewDelegate>
+ at interface VLCPlaylist : NSResponder<NSOutlineViewDelegate>
@property (readwrite, weak) IBOutlet NSMenu *playlistMenu;
@property (readwrite, weak) IBOutlet NSMenuItem *playPlaylistMenuItem;
diff --git a/modules/gui/macosx/VLCPlaylist.m b/modules/gui/macosx/VLCPlaylist.m
index 2bc33f3..da5cfa3 100644
--- a/modules/gui/macosx/VLCPlaylist.m
+++ b/modules/gui/macosx/VLCPlaylist.m
@@ -291,6 +291,9 @@
[_outlineView selectRowIndexes: [NSIndexSet indexSetWithIndex: itemIndex] byExtendingSelection: NO];
}
+#pragma mark -
+#pragma mark Playlist actions
+
/* When called retrieves the selected outlineview row and plays that node or item */
- (IBAction)playItem:(id)sender
{
@@ -317,23 +320,21 @@
- (IBAction)revealItemInFinder:(id)sender
{
NSIndexSet *selectedRows = [_outlineView selectedRowIndexes];
- [selectedRows enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
-
- PLItem *o_item = [_outlineView itemAtRow:idx];
+ if (selectedRows.count < 1)
+ return;
- /* perform some checks whether it is a file and if it is local at all... */
- char *psz_url = input_item_GetURI([o_item input]);
- NSURL *url = [NSURL URLWithString:toNSStr(psz_url)];
- free(psz_url);
- if (![url isFileURL])
- return;
- if (![[NSFileManager defaultManager] fileExistsAtPath:[url path]])
- return;
+ PLItem *o_item = [_outlineView itemAtRow:selectedRows.firstIndex];
- msg_Dbg(VLCIntf, "Reveal url %s in finder", [[url path] UTF8String]);
- [[NSWorkspace sharedWorkspace] selectFile: [url path] inFileViewerRootedAtPath: [url path]];
- }];
+ char *psz_url = input_item_GetURI([o_item input]);
+ if (!psz_url)
+ return;
+ char *psz_path = vlc_uri2path(psz_url);
+ NSString *path = toNSStr(psz_path);
+ free(psz_url);
+ free(psz_path);
+ msg_Dbg(VLCIntf, "Reveal url %s in finder", [path UTF8String]);
+ [[NSWorkspace sharedWorkspace] selectFile: path inFileViewerRootedAtPath: path];
}
/* When called retrieves the selected outlineview row and plays that node or item */
@@ -438,6 +439,31 @@
// [self playlistUpdated];
}
+- (BOOL)validateMenuItem:(NSMenuItem *)item
+{
+ if ([item action] == @selector(revealItemInFinder:)) {
+ NSIndexSet *selectedRows = [_outlineView selectedRowIndexes];
+ if (selectedRows.count != 1)
+ return NO;
+
+ PLItem *o_item = [_outlineView itemAtRow:selectedRows.firstIndex];
+
+ // Check if item exists in file system
+ char *psz_url = input_item_GetURI([o_item input]);
+ NSURL *url = [NSURL URLWithString:toNSStr(psz_url)];
+ free(psz_url);
+ if (![url isFileURL])
+ return NO;
+ if (![[NSFileManager defaultManager] fileExistsAtPath:[url path]])
+ return NO;
+ }
+
+ return YES;
+}
+
+#pragma mark -
+#pragma mark Item helpers
+
- (input_item_t *)createItem:(NSDictionary *)itemToCreateDict
{
intf_thread_t *p_intf = VLCIntf;
More information about the vlc-commits
mailing list