]> git.sesse.net Git - vlc/blob - modules/gui/macosx/MainWindowTitle.m
macosx: fixed conditionals for the different OS X release by adapting to the newly...
[vlc] / modules / gui / macosx / MainWindowTitle.m
1 /*****************************************************************************
2  * MainWindowTitle.m: MacOS X interface module
3  *****************************************************************************
4  * Copyright (C) 2011-2012 Felix Paul Kühne
5  * $Id$
6  *
7  * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #import <vlc_common.h>
25 #import "intf.h"
26 #import "MainWindowTitle.h"
27 #import "CoreInteraction.h"
28 #import "CompatibilityFixes.h"
29 #import <SystemConfiguration/SystemConfiguration.h> // for the revealInFinder clone
30
31 /*****************************************************************************
32  * VLCMainWindowTitleView
33  *
34  * this is our title bar, which can do anything a title should do
35  * it relies on the VLCWindowButtonCell to display the correct traffic light
36  * states, since we can't capture the mouse-moved events here correctly
37  *****************************************************************************/
38
39 @implementation VLCMainWindowTitleView
40 - (id)init
41 {
42     o_window_title_attributes_dict = [[NSDictionary dictionaryWithObjectsAndKeys: [NSColor whiteColor], NSForegroundColorAttributeName, [NSFont titleBarFontOfSize:12.0], NSFontAttributeName, nil] retain];
43
44     return [super init];
45 }
46
47 - (void)dealloc
48 {
49     [[NSNotificationCenter defaultCenter] removeObserver: self];
50
51     [o_red_img release];
52     [o_red_over_img release];
53     [o_red_on_img release];
54     [o_yellow_img release];
55     [o_yellow_over_img release];
56     [o_yellow_on_img release];
57     [o_green_img release];
58     [o_green_over_img release];
59     [o_green_on_img release];
60
61     [o_window_title_shadow release];
62     [o_window_title_attributes_dict release];
63
64     [super dealloc];
65 }
66
67 - (void)awakeFromNib
68 {
69     [self setAutoresizesSubviews: YES];
70     [self setImagesLeft:[NSImage imageNamed:@"topbar-dark-left"] middle: [NSImage imageNamed:@"topbar-dark-center-fill"] right:[NSImage imageNamed:@"topbar-dark-right"]];
71
72     [self loadButtonIcons];
73     [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(controlTintChanged:) name: NSControlTintDidChangeNotification object: nil];
74
75     [o_red_btn setImage: o_red_img];
76     [o_red_btn setAlternateImage: o_red_on_img];
77     [[o_red_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
78     [[o_red_btn cell] setTag: 0];
79     [o_yellow_btn setImage: o_yellow_img];
80     [o_yellow_btn setAlternateImage: o_yellow_on_img];
81     [[o_yellow_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
82     [[o_yellow_btn cell] setTag: 1];
83     [o_green_btn setImage: o_green_img];
84     [o_green_btn setAlternateImage: o_green_on_img];
85     [[o_green_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
86     [[o_green_btn cell] setTag: 2];
87     [o_fullscreen_btn setImage: [NSImage imageNamed:@"window-fullscreen"]];
88     [o_fullscreen_btn setAlternateImage: [NSImage imageNamed:@"window-fullscreen-on"]];
89     [[o_fullscreen_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
90     [[o_fullscreen_btn cell] setTag: 3];
91 }
92
93 - (void)controlTintChanged:(NSNotification *)notification
94 {
95     [o_red_img release];
96     [o_red_over_img release];
97     [o_red_on_img release];
98     [o_yellow_img release];
99     [o_yellow_over_img release];
100     [o_yellow_on_img release];
101     [o_green_img release];
102     [o_green_over_img release];
103     [o_green_on_img release];
104
105     [self loadButtonIcons];
106
107     [o_red_btn setNeedsDisplay];
108     [o_yellow_btn setNeedsDisplay];
109     [o_green_btn setNeedsDisplay];
110 }
111
112 - (void)loadButtonIcons
113 {
114     if (!OSX_SNOW_LEOPARD)
115     {
116         if( [NSColor currentControlTint] == NSBlueControlTint )
117         {
118             o_red_img = [[NSImage imageNamed:@"lion-window-close"] retain];
119             o_red_over_img = [[NSImage imageNamed:@"lion-window-close-over"] retain];
120             o_red_on_img = [[NSImage imageNamed:@"lion-window-close-on"] retain];
121             o_yellow_img = [[NSImage imageNamed:@"lion-window-minimize"] retain];
122             o_yellow_over_img = [[NSImage imageNamed:@"lion-window-minimize-over"] retain];
123             o_yellow_on_img = [[NSImage imageNamed:@"lion-window-minimize-on"] retain];
124             o_green_img = [[NSImage imageNamed:@"lion-window-zoom"] retain];
125             o_green_over_img = [[NSImage imageNamed:@"lion-window-zoom-over"] retain];
126             o_green_on_img = [[NSImage imageNamed:@"lion-window-zoom-on"] retain];
127         } else {
128             o_red_img = [[NSImage imageNamed:@"lion-window-close-graphite"] retain];
129             o_red_over_img = [[NSImage imageNamed:@"lion-window-close-over-graphite"] retain];
130             o_red_on_img = [[NSImage imageNamed:@"lion-window-close-on-graphite"] retain];
131             o_yellow_img = [[NSImage imageNamed:@"lion-window-minimize-graphite"] retain];
132             o_yellow_over_img = [[NSImage imageNamed:@"lion-window-minimize-over-graphite"] retain];
133             o_yellow_on_img = [[NSImage imageNamed:@"lion-window-minimize-on-graphite"] retain];
134             o_green_img = [[NSImage imageNamed:@"lion-window-zoom-graphite"] retain];
135             o_green_over_img = [[NSImage imageNamed:@"lion-window-zoom-over-graphite"] retain];
136             o_green_on_img = [[NSImage imageNamed:@"lion-window-zoom-on-graphite"] retain];
137         }
138     } else {
139         if( [NSColor currentControlTint] == NSBlueControlTint )
140         {
141             o_red_img = [[NSImage imageNamed:@"snowleo-window-close"] retain];
142             o_red_over_img = [[NSImage imageNamed:@"snowleo-window-close-over"] retain];
143             o_red_on_img = [[NSImage imageNamed:@"snowleo-window-close-on"] retain];
144             o_yellow_img = [[NSImage imageNamed:@"snowleo-window-minimize"] retain];
145             o_yellow_over_img = [[NSImage imageNamed:@"snowleo-window-minimize-over"] retain];
146             o_yellow_on_img = [[NSImage imageNamed:@"snowleo-window-minimize-on"] retain];
147             o_green_img = [[NSImage imageNamed:@"snowleo-window-zoom"] retain];
148             o_green_over_img = [[NSImage imageNamed:@"snowleo-window-zoom-over"] retain];
149             o_green_on_img = [[NSImage imageNamed:@"snowleo-window-zoom-on"] retain];
150         } else {
151             o_red_img = [[NSImage imageNamed:@"snowleo-window-close-graphite"] retain];
152             o_red_over_img = [[NSImage imageNamed:@"snowleo-window-close-over-graphite"] retain];
153             o_red_on_img = [[NSImage imageNamed:@"snowleo-window-close-on-graphite"] retain];
154             o_yellow_img = [[NSImage imageNamed:@"snowleo-window-minimize-graphite"] retain];
155             o_yellow_over_img = [[NSImage imageNamed:@"snowleo-window-minimize-over-graphite"] retain];
156             o_yellow_on_img = [[NSImage imageNamed:@"snowleo-window-minimize-on-graphite"] retain];
157             o_green_img = [[NSImage imageNamed:@"snowleo-window-zoom-graphite"] retain];
158             o_green_over_img = [[NSImage imageNamed:@"snowleo-window-zoom-over-graphite"] retain];
159             o_green_on_img = [[NSImage imageNamed:@"snowleo-window-zoom-on-graphite"] retain];
160         }
161     }
162 }
163
164 - (BOOL)mouseDownCanMoveWindow
165 {
166     return YES;
167 }
168
169 - (IBAction)buttonAction:(id)sender
170 {
171     if (sender == o_red_btn)
172         [[self window] performClose: sender];
173     else if (sender == o_yellow_btn)
174         [[self window] miniaturize: sender];
175     else if (sender == o_green_btn)
176         [[self window] performZoom: sender];
177     else if (sender == o_fullscreen_btn)
178     {
179         // set fs directly to true, as the vars can be already true in some configs
180         var_SetBool( pl_Get( VLCIntf ), "fullscreen", true );
181
182         vout_thread_t *p_vout = getVout();
183         if( p_vout )
184         {
185             var_SetBool( p_vout, "fullscreen", true );
186             vlc_object_release( p_vout );
187         }
188     }
189     else
190         msg_Err( VLCIntf, "unknown button action sender" );
191
192     [self setWindowButtonOver: NO];
193     [self setWindowFullscreenButtonOver: NO];
194 }
195
196 - (void)setWindowTitle:(NSString *)title
197 {
198     if (!o_window_title_shadow)
199     {
200         o_window_title_shadow = [[NSShadow alloc] init];
201         [o_window_title_shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.5]];
202         [o_window_title_shadow setShadowOffset:NSMakeSize(0.0, -1.5)];
203         [o_window_title_shadow setShadowBlurRadius:0.5];
204         [o_window_title_shadow retain];
205     }
206
207     NSMutableAttributedString *o_attributed_title = [[NSMutableAttributedString alloc] initWithString:title attributes: o_window_title_attributes_dict];
208     NSUInteger i_titleLength = [title length];
209
210     [o_attributed_title addAttribute:NSShadowAttributeName value:o_window_title_shadow range:NSMakeRange(0, i_titleLength)];
211     [o_attributed_title setAlignment: NSCenterTextAlignment range:NSMakeRange(0, i_titleLength)];
212     [o_title_lbl setAttributedStringValue:o_attributed_title];
213     [o_attributed_title release];
214 }
215
216 - (void)setFullscreenButtonHidden:(BOOL)b_value
217 {
218     [o_fullscreen_btn setHidden: b_value];
219 }
220
221 - (void)setWindowButtonOver:(BOOL)b_value
222 {
223     if( b_value )
224     {
225         [o_red_btn setImage: o_red_over_img];
226         [o_yellow_btn setImage: o_yellow_over_img];
227         [o_green_btn setImage: o_green_over_img];
228     }
229     else
230     {
231         [o_red_btn setImage: o_red_img];
232         [o_yellow_btn setImage: o_yellow_img];
233         [o_green_btn setImage: o_green_img];
234     }
235 }
236
237 - (void)setWindowFullscreenButtonOver:(BOOL)b_value
238 {
239     if (b_value)
240         [o_fullscreen_btn setImage: [NSImage imageNamed:@"window-fullscreen-over"]];
241     else
242         [o_fullscreen_btn setImage: [NSImage imageNamed:@"window-fullscreen"]];
243 }
244
245 - (void)mouseDown:(NSEvent *)event
246 {
247     NSPoint ml = [self convertPoint: [event locationInWindow] fromView: self];
248     if( ([[self window] frame].size.height - ml.y) <= 22. && [event clickCount] == 2) {
249         //Get settings from "System Preferences" >  "Appearance" > "Double-click on windows title bar to minimize"
250         NSString *const MDAppleMiniaturizeOnDoubleClickKey = @"AppleMiniaturizeOnDoubleClick";
251         NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
252         [userDefaults addSuiteNamed:NSGlobalDomain];
253
254         if ([[userDefaults objectForKey:MDAppleMiniaturizeOnDoubleClickKey] boolValue])
255             [[self window] miniaturize:self];
256     }
257
258     [super mouseDown: event];
259 }
260
261 - (NSButton*)closeButton
262 {
263     return o_red_btn;
264 }
265
266 - (NSButton*)minimizeButton
267 {
268     return o_yellow_btn;
269 }
270
271 - (NSButton*)zoomButton
272 {
273     return o_green_btn;
274 }
275
276 @end
277
278 /*****************************************************************************
279  * VLCWindowButtonCell
280  *
281  * since the title bar cannot fetch these mouse events (the more top-level
282  * NSButton is unable fetch them as well), we are using a subclass of the
283  * button cell to do so. It's set in the nib for the respective objects.
284  *****************************************************************************/
285
286 @implementation VLCWindowButtonCell
287
288 - (void)mouseEntered:(NSEvent *)theEvent
289 {
290     if ([self tag] == 3)
291         [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowFullscreenButtonOver: YES];
292     else
293         [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowButtonOver: YES];
294 }
295
296 - (void)mouseExited:(NSEvent *)theEvent
297 {
298     if ([self tag] == 3)
299         [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowFullscreenButtonOver: NO];
300     else
301         [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowButtonOver: NO];
302 }
303
304 /* accessibility stuff */
305 - (NSArray*)accessibilityAttributeNames {
306     NSArray *theAttributeNames = [super accessibilityAttributeNames];
307     id theControlView = [self controlView];
308     return ([theControlView respondsToSelector: @selector(extendedAccessibilityAttributeNames:)] ? [theControlView extendedAccessibilityAttributeNames: theAttributeNames] : theAttributeNames); // ask the cell's control view (i.e., the button) for additional attribute values
309 }
310
311 - (id)accessibilityAttributeValue: (NSString*)theAttributeName {
312     id theControlView = [self controlView];
313     if ([theControlView respondsToSelector: @selector(extendedAccessibilityAttributeValue:)]) {
314         id theValue = [theControlView extendedAccessibilityAttributeValue: theAttributeName];
315         if (theValue) {
316             return theValue; // if this is an extended attribute value we added, return that -- otherwise, fall back to super's implementation
317         }
318     }
319     return [super accessibilityAttributeValue: theAttributeName];
320 }
321
322 - (BOOL)accessibilityIsAttributeSettable: (NSString*)theAttributeName {
323     id theControlView = [self controlView];
324     if ([theControlView respondsToSelector: @selector(extendedAccessibilityIsAttributeSettable:)]) {
325         NSNumber *theValue = [theControlView extendedAccessibilityIsAttributeSettable: theAttributeName];
326         if (theValue) {
327             return [theValue boolValue]; // same basic strategy we use in -accessibilityAttributeValue:
328         }
329     }
330     return [super accessibilityIsAttributeSettable: theAttributeName];
331 }
332
333 @end
334
335
336 /*****************************************************************************
337  * VLCResizeControl
338  *
339  * For Leopard and Snow Leopard, we need to emulate the resize control on the
340  * bottom right of the window, since it is gone by using the borderless window
341  * mask. A proper fix would be Lion-only.
342  *****************************************************************************/
343
344 @implementation VLCResizeControl
345
346 - (void)mouseDown:(NSEvent *)theEvent {
347     BOOL keepOn = YES;
348
349     while (keepOn) {
350         theEvent = [[self window] nextEventMatchingMask: NSLeftMouseUpMask |
351                     NSLeftMouseDraggedMask];
352
353         switch ([theEvent type]) {
354             case NSLeftMouseDragged:
355             {
356                 NSRect windowFrame = [[self window] frame];
357                 CGFloat deltaX, deltaY, oldOriginY;
358                 deltaX = [theEvent deltaX];
359                 deltaY = [theEvent deltaY];
360                 oldOriginY = windowFrame.origin.y;
361
362                 windowFrame.origin.y = (oldOriginY + windowFrame.size.height) - (windowFrame.size.height + deltaY);
363                 windowFrame.size.width += deltaX;
364                 windowFrame.size.height += deltaY;
365
366                 NSSize winMinSize = [self window].minSize;
367                 if (windowFrame.size.width < winMinSize.width)
368                     windowFrame.size.width = winMinSize.width;
369
370                 if (windowFrame.size.height < winMinSize.height)
371                 {
372                     windowFrame.size.height = winMinSize.height;
373                     windowFrame.origin.y = oldOriginY;
374                 }
375
376                 [[self window] setFrame: windowFrame display: YES animate: NO];
377                 break;
378             }
379                 break;
380             case NSLeftMouseUp:
381                 keepOn = NO;
382                 break;
383             default:
384                 /* Ignore any other kind of event. */
385                 break;
386         }
387
388     };
389
390     return;
391 }
392
393 @end
394
395 /*****************************************************************************
396  * VLCColorView
397  *
398  * since we are using a clear window color when using the black window
399  * style, some filling is needed behind the video and some other elements
400  *****************************************************************************/
401
402 @implementation VLCColorView
403
404 - (void)drawRect:(NSRect)rect {
405     [[NSColor blackColor] setFill];
406     NSRectFill(rect);
407 }
408
409 @end
410
411 /*****************************************************************************
412  * custom window buttons to support the accessibility stuff
413  *****************************************************************************/
414
415 @implementation VLCCustomWindowButtonPrototype
416 + (Class)cellClass {
417     return [VLCWindowButtonCell class];
418 }
419
420 - (NSArray*)extendedAccessibilityAttributeNames: (NSArray*)theAttributeNames {
421     return ([theAttributeNames containsObject: NSAccessibilitySubroleAttribute] ? theAttributeNames : [theAttributeNames arrayByAddingObject: NSAccessibilitySubroleAttribute]); // run-of-the-mill button cells don't usually have a Subrole attribute, so we add that attribute
422 }
423
424 - (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName {
425     return nil;
426 }
427
428 - (NSNumber*)extendedAccessibilityIsAttributeSettable: (NSString*)theAttributeName {
429     return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? [NSNumber numberWithBool: NO] : nil); // make the Subrole attribute we added non-settable
430 }
431
432 - (void)accessibilityPerformAction: (NSString*)theActionName {
433     if ([theActionName isEqualToString: NSAccessibilityPressAction]) {
434         if ([self isEnabled]) {
435             [self performClick: nil];
436         }
437     } else {
438         [super accessibilityPerformAction: theActionName];
439     }
440 }
441
442 @end
443
444 @implementation VLCCustomWindowCloseButton
445 - (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName {
446     return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? NSAccessibilityCloseButtonAttribute : nil);
447 }
448
449 @end
450
451
452 @implementation VLCCustomWindowMinimizeButton
453 - (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName {
454     return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? NSAccessibilityMinimizeButtonAttribute : nil);
455 }
456
457 @end
458
459
460 @implementation VLCCustomWindowZoomButton
461 - (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName {
462     return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? NSAccessibilityZoomButtonAttribute : nil);
463 }
464
465 @end
466
467
468 @implementation VLCCustomWindowFullscreenButton
469 #ifdef MAC_OS_X_VERSION_10_7
470 - (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName {
471     return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? NSAccessibilityFullScreenButtonAttribute : nil);
472 }
473 #endif
474
475 @end
476
477
478 @implementation VLCWindowTitleTextField
479
480 - (void)dealloc
481 {
482     if (contextMenu)
483         [contextMenu release];
484
485     [super dealloc];
486 }
487
488 - (void)showRightClickMenuWithEvent:(NSEvent *)o_event
489 {
490     if (contextMenu)
491         [contextMenu release];
492
493     NSURL * representedURL = [[self window] representedURL];
494     if (! representedURL)
495         return;
496
497     NSArray * pathComponents;
498     pathComponents = [representedURL pathComponents];
499
500     if (!pathComponents)
501         return;
502
503     contextMenu = [[NSMenu alloc] initWithTitle: [[NSFileManager defaultManager] displayNameAtPath: [representedURL path]]];
504
505     NSUInteger count = [pathComponents count];
506     NSImage * icon;
507     NSMenuItem * currentItem;
508     NSMutableString * currentPath;
509     NSSize iconSize = NSMakeSize( 16., 16. );
510     for (NSUInteger i = count - 1; i > 0; i--) {
511         currentPath = [NSMutableString stringWithCapacity:1024];
512         for (NSUInteger y = 0; y < i; y++)
513             [currentPath appendFormat: @"/%@", [pathComponents objectAtIndex:y + 1]];
514
515         [contextMenu addItemWithTitle: [[NSFileManager defaultManager] displayNameAtPath: currentPath] action:@selector(revealInFinder:) keyEquivalent:@""];
516         currentItem = [contextMenu itemAtIndex:[contextMenu numberOfItems] - 1];
517         [currentItem setTarget: self];
518
519         icon = [[NSWorkspace sharedWorkspace] iconForFile:currentPath];
520         [icon setSize: iconSize];
521         [currentItem setImage: icon];
522     }
523
524     if ([[pathComponents objectAtIndex: 1] isEqualToString:@"Volumes"]) {
525         /* we don't want to show the Volumes item, since the Cocoa does it neither */
526         currentItem = [contextMenu itemWithTitle:[[NSFileManager defaultManager] displayNameAtPath: @"/Volumes"]];
527         if (currentItem)
528             [contextMenu removeItem: currentItem];
529     } else {
530         /* we're on the boot drive, so add it since it isn't part of the components */
531         [contextMenu addItemWithTitle: [[NSFileManager defaultManager] displayNameAtPath:@"/"] action:@selector(revealInFinder:) keyEquivalent:@""];
532         currentItem = [contextMenu itemAtIndex: [contextMenu numberOfItems] - 1];
533         icon = [[NSWorkspace sharedWorkspace] iconForFile:@"/"];
534         [icon setSize: iconSize];
535         [currentItem setImage: icon];
536         [currentItem setTarget: self];
537     }
538
539     /* add the computer item */
540     [contextMenu addItemWithTitle: [(NSString*)SCDynamicStoreCopyComputerName(NULL, NULL) autorelease] action:@selector(revealInFinder:) keyEquivalent:@""];
541     currentItem = [contextMenu itemAtIndex: [contextMenu numberOfItems] - 1];
542     icon = [NSImage imageNamed: NSImageNameComputer];
543     [icon setSize: iconSize];
544     [currentItem setImage: icon];
545     [currentItem setTarget: self];
546
547     [NSMenu popUpContextMenu: contextMenu withEvent: o_event forView: [self superview]];
548 }
549
550 - (IBAction)revealInFinder:(id)sender
551 {
552     NSUInteger count = [contextMenu numberOfItems];
553     NSUInteger selectedItem = [contextMenu indexOfItem: sender];
554
555     if (selectedItem == count - 1)  // the fake computer item
556     {
557         [[NSWorkspace sharedWorkspace] selectFile: @"/" inFileViewerRootedAtPath: @""];
558         return;
559     }
560
561     NSURL * representedURL = [[self window] representedURL];
562     if (! representedURL)
563         return;
564
565     if (selectedItem == 0) // the actual file, let's save time
566     {
567         [[NSWorkspace sharedWorkspace] selectFile: [representedURL path] inFileViewerRootedAtPath: [representedURL path]];
568         return;
569     }
570
571     NSArray * pathComponents;
572     pathComponents = [representedURL pathComponents];
573     if (!pathComponents)
574         return;
575
576     NSMutableString * currentPath;
577     currentPath = [NSMutableString stringWithCapacity:1024];
578     selectedItem = count - selectedItem;
579
580     /* fix for non-startup volumes */
581     if ([[pathComponents objectAtIndex:1] isEqualToString:@"Volumes"])
582         selectedItem += 1;
583
584     for (NSUInteger y = 1; y < selectedItem; y++)
585         [currentPath appendFormat: @"/%@", [pathComponents objectAtIndex:y]];
586
587     [[NSWorkspace sharedWorkspace] selectFile: currentPath inFileViewerRootedAtPath: currentPath];
588 }
589
590 - (void)rightMouseDown:(NSEvent *)o_event
591 {
592     if( [o_event type] == NSRightMouseDown )
593         [self showRightClickMenuWithEvent:o_event];
594
595     [super mouseDown: o_event];
596 }
597
598 @end