Commit ce2b23f7 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: reimplemented the right-click Reveal-in-Finder feature on the window...

macosx: reimplemented the right-click Reveal-in-Finder feature on the window title when using the dark interface style
parent 46a8f555
......@@ -3731,7 +3731,7 @@ then
VLC_ADD_OBJCFLAGS([macosx minimal_macosx], [-fobjc-exceptions] )
VLC_ADD_PLUGIN([macosx minimal_macosx])
VLC_ADD_LIBS([macosx], [-Wl,-framework,QTKit -Wl,-framework,IOKit -Wl,-framework,AddressBook -Wl,-framework,WebKit -Wl,-framework,CoreAudio])
VLC_ADD_LIBS([macosx], [-Wl,-framework,QTKit -Wl,-framework,IOKit -Wl,-framework,AddressBook -Wl,-framework,WebKit -Wl,-framework,CoreAudio -Wl,-framework,SystemConfiguration])
if test ! -d ${CONTRIB_DIR}/Sparkle.framework
then
......
......@@ -2,7 +2,7 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">11E53</string>
<string key="IBDocument.SystemVersion">11G15</string>
<string key="IBDocument.InterfaceBuilderVersion">851</string>
<string key="IBDocument.AppKitVersion">1138.47</string>
<string key="IBDocument.HIToolboxVersion">569.00</string>
......@@ -21,16 +21,16 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="915"/>
<integer value="2770"/>
<integer value="4722"/>
<integer value="4596"/>
<integer value="4850"/>
<integer value="915"/>
<integer value="5100"/>
<integer value="1617"/>
<integer value="4596"/>
<integer value="4948"/>
<integer value="2730"/>
<integer value="4756"/>
<integer value="2770"/>
<integer value="1617"/>
<integer value="4722"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
......@@ -11859,6 +11859,7 @@ LCAuLi4</string>
<string>4898.CustomClassName</string>
<string>4898.IBPluginDependency</string>
<string>4898.IBViewBoundsToFrameTransform</string>
<string>4899.CustomClassName</string>
<string>4899.IBPluginDependency</string>
<string>4899.IBViewBoundsToFrameTransform</string>
<string>4900.IBPluginDependency</string>
......@@ -12773,6 +12774,7 @@ LCAuLi4</string>
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAABDv4AAwYAAAA</bytes>
</object>
<string>VLCWindowTitleTextField</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAABCggAAwZAAAA</bytes>
......@@ -18054,6 +18056,11 @@ LCAuLi4</string>
<string key="superclassName">NSButtonCell</string>
<reference key="sourceIdentifier" ref="672431580"/>
</object>
<object class="IBPartialClassDescription">
<string key="className">VLCWindowTitleTextField</string>
<string key="superclassName">NSTextField</string>
<reference key="sourceIdentifier" ref="672431580"/>
</object>
</object>
<object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
<bool key="EncodedWithXMLCoder">YES</bool>
......
......@@ -75,6 +75,10 @@ extern OSErr UpdateSystemActivity(UInt8 activity);
- (void)setPresentationOptions:(NSApplicationPresentationOptions)newOptions;
- (NSApplicationPresentationOptions)currentSystemPresentationOptions;
@end
@interface NSURL (IntroducedInSnowLeopard)
- (NSArray *)pathComponents;
@end
#endif
#pragma mark -
......
......@@ -103,3 +103,10 @@
{
}
@end
@interface VLCWindowTitleTextField : NSTextField
{
NSMenu * contextMenu;
}
@end
......@@ -26,6 +26,7 @@
#import "MainWindowTitle.h"
#import "CoreInteraction.h"
#import "CompatibilityFixes.h"
#import <SystemConfiguration/SystemConfiguration.h> // for the revealInFinder clone
/*****************************************************************************
* VLCMainWindowTitleView
......@@ -453,3 +454,123 @@
#endif
@end
@implementation VLCWindowTitleTextField
- (void)dealloc
{
if (contextMenu)
[contextMenu release];
[super dealloc];
}
- (void)showRightClickMenuWithEvent:(NSEvent *)o_event
{
if (contextMenu)
[contextMenu release];
NSURL * representedURL = [[self window] representedURL];
if (! representedURL)
return;
NSArray * pathComponents;
if (OSX_SNOW_LEOPARD || OSX_LION)
pathComponents = [representedURL pathComponents];
else
pathComponents = [[representedURL path] pathComponents];
if (!pathComponents)
return;
contextMenu = [[NSMenu alloc] initWithTitle: [[NSFileManager defaultManager] displayNameAtPath: [representedURL path]]];
NSUInteger count = [pathComponents count];
NSImage * icon;
NSMenuItem * currentItem;
NSMutableString * currentPath;
NSSize iconSize = NSMakeSize( 16., 16. );
for (NSUInteger i = count - 1; i > 0; i--) {
currentPath = [NSMutableString stringWithCapacity:1024];
for (NSUInteger y = 0; y < i; y++)
[currentPath appendFormat: @"/%@", [pathComponents objectAtIndex:y + 1]];
[contextMenu addItemWithTitle: [[NSFileManager defaultManager] displayNameAtPath: currentPath] action:@selector(revealInFinder:) keyEquivalent:@""];
currentItem = [contextMenu itemAtIndex:[contextMenu numberOfItems] - 1];
[currentItem setTarget: self];
icon = [[NSWorkspace sharedWorkspace] iconForFile:currentPath];
[icon setSize: iconSize];
[currentItem setImage: icon];
}
if ([[pathComponents objectAtIndex: 1] isEqualToString:@"Users"]) {
/* we're on the boot drive, so add it is since it isn't part of the components */
[contextMenu addItemWithTitle: [[NSFileManager defaultManager] displayNameAtPath:@"/"] action:@selector(revealInFinder:) keyEquivalent:@""];
currentItem = [contextMenu itemAtIndex: [contextMenu numberOfItems] - 1];
icon = [[NSWorkspace sharedWorkspace] iconForFile:@"/"];
[icon setSize: iconSize];
[currentItem setImage: icon];
[currentItem setTarget: self];
}
/* add the computer item */
[contextMenu addItemWithTitle: [(NSString*)SCDynamicStoreCopyComputerName(NULL, NULL) autorelease] action:@selector(revealInFinder:) keyEquivalent:@""];
currentItem = [contextMenu itemAtIndex: [contextMenu numberOfItems] - 1];
icon = [NSImage imageNamed: NSImageNameComputer];
[icon setSize: iconSize];
[currentItem setImage: icon];
[currentItem setTarget: self];
[NSMenu popUpContextMenu: contextMenu withEvent: o_event forView: [self superview]];
}
- (IBAction)revealInFinder:(id)sender
{
NSUInteger count = [contextMenu numberOfItems];
NSUInteger selectedItem = [contextMenu indexOfItem: sender];
if (selectedItem == count - 1) // the fake computer item
{
[[NSWorkspace sharedWorkspace] selectFile: @"/" inFileViewerRootedAtPath: @""];
return;
}
NSURL * representedURL = [[self window] representedURL];
if (! representedURL)
return;
if (selectedItem == 0) // the actual file, let's save time
{
[[NSWorkspace sharedWorkspace] selectFile: [representedURL path] inFileViewerRootedAtPath: [representedURL path]];
return;
}
NSArray * pathComponents;
if (OSX_SNOW_LEOPARD || OSX_LION)
pathComponents = [representedURL pathComponents];
else
pathComponents = [[representedURL path] pathComponents];
if (!pathComponents)
return;
NSMutableString * currentPath;
currentPath = [NSMutableString stringWithCapacity:1024];
selectedItem = count - selectedItem;
for (NSUInteger y = 1; y < selectedItem; y++)
[currentPath appendFormat: @"/%@", [pathComponents objectAtIndex:y]];
[[NSWorkspace sharedWorkspace] selectFile: currentPath inFileViewerRootedAtPath: currentPath];
}
- (void)rightMouseDown:(NSEvent *)o_event
{
if( [o_event type] == NSRightMouseDown )
[self showRightClickMenuWithEvent:o_event];
[super mouseDown: o_event];
}
@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