]> git.sesse.net Git - vlc/blob - modules/gui/macosx/MainWindowTitle.m
macosx: unify and modernize coding style
[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         if ([NSColor currentControlTint] == NSBlueControlTint)
116         {
117             o_red_img = [[NSImage imageNamed:@"lion-window-close"] retain];
118             o_red_over_img = [[NSImage imageNamed:@"lion-window-close-over"] retain];
119             o_red_on_img = [[NSImage imageNamed:@"lion-window-close-on"] retain];
120             o_yellow_img = [[NSImage imageNamed:@"lion-window-minimize"] retain];
121             o_yellow_over_img = [[NSImage imageNamed:@"lion-window-minimize-over"] retain];
122             o_yellow_on_img = [[NSImage imageNamed:@"lion-window-minimize-on"] retain];
123             o_green_img = [[NSImage imageNamed:@"lion-window-zoom"] retain];
124             o_green_over_img = [[NSImage imageNamed:@"lion-window-zoom-over"] retain];
125             o_green_on_img = [[NSImage imageNamed:@"lion-window-zoom-on"] retain];
126         } else {
127             o_red_img = [[NSImage imageNamed:@"lion-window-close-graphite"] retain];
128             o_red_over_img = [[NSImage imageNamed:@"lion-window-close-over-graphite"] retain];
129             o_red_on_img = [[NSImage imageNamed:@"lion-window-close-on-graphite"] retain];
130             o_yellow_img = [[NSImage imageNamed:@"lion-window-minimize-graphite"] retain];
131             o_yellow_over_img = [[NSImage imageNamed:@"lion-window-minimize-over-graphite"] retain];
132             o_yellow_on_img = [[NSImage imageNamed:@"lion-window-minimize-on-graphite"] retain];
133             o_green_img = [[NSImage imageNamed:@"lion-window-zoom-graphite"] retain];
134             o_green_over_img = [[NSImage imageNamed:@"lion-window-zoom-over-graphite"] retain];
135             o_green_on_img = [[NSImage imageNamed:@"lion-window-zoom-on-graphite"] retain];
136         }
137     } else {
138         if ([NSColor currentControlTint] == NSBlueControlTint)
139         {
140             o_red_img = [[NSImage imageNamed:@"snowleo-window-close"] retain];
141             o_red_over_img = [[NSImage imageNamed:@"snowleo-window-close-over"] retain];
142             o_red_on_img = [[NSImage imageNamed:@"snowleo-window-close-on"] retain];
143             o_yellow_img = [[NSImage imageNamed:@"snowleo-window-minimize"] retain];
144             o_yellow_over_img = [[NSImage imageNamed:@"snowleo-window-minimize-over"] retain];
145             o_yellow_on_img = [[NSImage imageNamed:@"snowleo-window-minimize-on"] retain];
146             o_green_img = [[NSImage imageNamed:@"snowleo-window-zoom"] retain];
147             o_green_over_img = [[NSImage imageNamed:@"snowleo-window-zoom-over"] retain];
148             o_green_on_img = [[NSImage imageNamed:@"snowleo-window-zoom-on"] retain];
149         } else {
150             o_red_img = [[NSImage imageNamed:@"snowleo-window-close-graphite"] retain];
151             o_red_over_img = [[NSImage imageNamed:@"snowleo-window-close-over-graphite"] retain];
152             o_red_on_img = [[NSImage imageNamed:@"snowleo-window-close-on-graphite"] retain];
153             o_yellow_img = [[NSImage imageNamed:@"snowleo-window-minimize-graphite"] retain];
154             o_yellow_over_img = [[NSImage imageNamed:@"snowleo-window-minimize-over-graphite"] retain];
155             o_yellow_on_img = [[NSImage imageNamed:@"snowleo-window-minimize-on-graphite"] retain];
156             o_green_img = [[NSImage imageNamed:@"snowleo-window-zoom-graphite"] retain];
157             o_green_over_img = [[NSImage imageNamed:@"snowleo-window-zoom-over-graphite"] retain];
158             o_green_on_img = [[NSImage imageNamed:@"snowleo-window-zoom-on-graphite"] retain];
159         }
160     }
161 }
162
163 - (BOOL)mouseDownCanMoveWindow
164 {
165     return YES;
166 }
167
168 - (IBAction)buttonAction:(id)sender
169 {
170     if (sender == o_red_btn)
171         [[self window] performClose: sender];
172     else if (sender == o_yellow_btn)
173         [[self window] miniaturize: sender];
174     else if (sender == o_green_btn)
175         [[self window] performZoom: sender];
176     else if (sender == o_fullscreen_btn) {
177         // set fs directly to true, as the vars can be already true in some configs
178         var_SetBool(pl_Get(VLCIntf), "fullscreen", true);
179
180         vout_thread_t *p_vout = getVout();
181         if (p_vout) {
182             var_SetBool(p_vout, "fullscreen", true);
183             vlc_object_release(p_vout);
184         }
185     } else
186         msg_Err(VLCIntf, "unknown button action sender");
187
188     [self setWindowButtonOver: NO];
189     [self setWindowFullscreenButtonOver: NO];
190 }
191
192 - (void)setWindowTitle:(NSString *)title
193 {
194     if (!o_window_title_shadow) {
195         o_window_title_shadow = [[NSShadow alloc] init];
196         [o_window_title_shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.5]];
197         [o_window_title_shadow setShadowOffset:NSMakeSize(0.0, -1.5)];
198         [o_window_title_shadow setShadowBlurRadius:0.5];
199         [o_window_title_shadow retain];
200     }
201
202     NSMutableAttributedString *o_attributed_title = [[NSMutableAttributedString alloc] initWithString:title attributes: o_window_title_attributes_dict];
203     NSUInteger i_titleLength = [title length];
204
205     [o_attributed_title addAttribute:NSShadowAttributeName value:o_window_title_shadow range:NSMakeRange(0, i_titleLength)];
206     [o_attributed_title setAlignment: NSCenterTextAlignment range:NSMakeRange(0, i_titleLength)];
207     [o_title_lbl setAttributedStringValue:o_attributed_title];
208     [o_attributed_title release];
209 }
210
211 - (void)setFullscreenButtonHidden:(BOOL)b_value
212 {
213     [o_fullscreen_btn setHidden: b_value];
214 }
215
216 - (void)setWindowButtonOver:(BOOL)b_value
217 {
218     if (b_value) {
219         [o_red_btn setImage: o_red_over_img];
220         [o_yellow_btn setImage: o_yellow_over_img];
221         [o_green_btn setImage: o_green_over_img];
222     } else {
223         [o_red_btn setImage: o_red_img];
224         [o_yellow_btn setImage: o_yellow_img];
225         [o_green_btn setImage: o_green_img];
226     }
227 }
228
229 - (void)setWindowFullscreenButtonOver:(BOOL)b_value
230 {
231     if (b_value)
232         [o_fullscreen_btn setImage: [NSImage imageNamed:@"window-fullscreen-over"]];
233     else
234         [o_fullscreen_btn setImage: [NSImage imageNamed:@"window-fullscreen"]];
235 }
236
237 - (void)mouseDown:(NSEvent *)event
238 {
239     NSPoint ml = [self convertPoint: [event locationInWindow] fromView: self];
240     if (([[self window] frame].size.height - ml.y) <= 22. && [event clickCount] == 2) {
241         //Get settings from "System Preferences" >  "Appearance" > "Double-click on windows title bar to minimize"
242         NSString *const MDAppleMiniaturizeOnDoubleClickKey = @"AppleMiniaturizeOnDoubleClick";
243         NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
244         [userDefaults addSuiteNamed:NSGlobalDomain];
245
246         if ([[userDefaults objectForKey:MDAppleMiniaturizeOnDoubleClickKey] boolValue])
247             [[self window] miniaturize:self];
248     }
249
250     [super mouseDown: event];
251 }
252
253 - (NSButton*)closeButton
254 {
255     return o_red_btn;
256 }
257
258 - (NSButton*)minimizeButton
259 {
260     return o_yellow_btn;
261 }
262
263 - (NSButton*)zoomButton
264 {
265     return o_green_btn;
266 }
267
268 @end
269
270 /*****************************************************************************
271  * VLCWindowButtonCell
272  *
273  * since the title bar cannot fetch these mouse events (the more top-level
274  * NSButton is unable fetch them as well), we are using a subclass of the
275  * button cell to do so. It's set in the nib for the respective objects.
276  *****************************************************************************/
277
278 @implementation VLCWindowButtonCell
279
280 - (void)mouseEntered:(NSEvent *)theEvent
281 {
282     if ([self tag] == 3)
283         [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowFullscreenButtonOver: YES];
284     else
285         [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowButtonOver: YES];
286 }
287
288 - (void)mouseExited:(NSEvent *)theEvent
289 {
290     if ([self tag] == 3)
291         [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowFullscreenButtonOver: NO];
292     else
293         [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowButtonOver: NO];
294 }
295
296 /* accessibility stuff */
297 - (NSArray*)accessibilityAttributeNames {
298     NSArray *theAttributeNames = [super accessibilityAttributeNames];
299     id theControlView = [self controlView];
300     return ([theControlView respondsToSelector: @selector(extendedAccessibilityAttributeNames:)] ? [theControlView extendedAccessibilityAttributeNames: theAttributeNames] : theAttributeNames); // ask the cell's control view (i.e., the button) for additional attribute values
301 }
302
303 - (id)accessibilityAttributeValue: (NSString*)theAttributeName {
304     id theControlView = [self controlView];
305     if ([theControlView respondsToSelector: @selector(extendedAccessibilityAttributeValue:)]) {
306         id theValue = [theControlView extendedAccessibilityAttributeValue: theAttributeName];
307         if (theValue) {
308             return theValue; // if this is an extended attribute value we added, return that -- otherwise, fall back to super's implementation
309         }
310     }
311     return [super accessibilityAttributeValue: theAttributeName];
312 }
313
314 - (BOOL)accessibilityIsAttributeSettable: (NSString*)theAttributeName {
315     id theControlView = [self controlView];
316     if ([theControlView respondsToSelector: @selector(extendedAccessibilityIsAttributeSettable:)]) {
317         NSNumber *theValue = [theControlView extendedAccessibilityIsAttributeSettable: theAttributeName];
318         if (theValue)
319             return [theValue boolValue]; // same basic strategy we use in -accessibilityAttributeValue:
320     }
321     return [super accessibilityIsAttributeSettable: theAttributeName];
322 }
323
324 @end
325
326
327 /*****************************************************************************
328  * VLCResizeControl
329  *
330  * For Leopard and Snow Leopard, we need to emulate the resize control on the
331  * bottom right of the window, since it is gone by using the borderless window
332  * mask. A proper fix would be Lion-only.
333  *****************************************************************************/
334
335 @implementation VLCResizeControl
336
337 - (void)mouseDown:(NSEvent *)theEvent {
338     BOOL keepOn = YES;
339
340     while (keepOn) {
341         theEvent = [[self window] nextEventMatchingMask: NSLeftMouseUpMask |
342                     NSLeftMouseDraggedMask];
343
344         switch ([theEvent type]) {
345             case NSLeftMouseDragged:
346             {
347                 NSRect windowFrame = [[self window] frame];
348                 CGFloat deltaX, deltaY, oldOriginY;
349                 deltaX = [theEvent deltaX];
350                 deltaY = [theEvent deltaY];
351                 oldOriginY = windowFrame.origin.y;
352
353                 windowFrame.origin.y = (oldOriginY + windowFrame.size.height) - (windowFrame.size.height + deltaY);
354                 windowFrame.size.width += deltaX;
355                 windowFrame.size.height += deltaY;
356
357                 NSSize winMinSize = [self window].minSize;
358                 if (windowFrame.size.width < winMinSize.width)
359                     windowFrame.size.width = winMinSize.width;
360
361                 if (windowFrame.size.height < winMinSize.height) {
362                     windowFrame.size.height = winMinSize.height;
363                     windowFrame.origin.y = oldOriginY;
364                 }
365
366                 [[self window] setFrame: windowFrame display: YES animate: NO];
367                 break;
368             }
369                 break;
370             case NSLeftMouseUp:
371                 keepOn = NO;
372                 break;
373             default:
374                 /* Ignore any other kind of event. */
375                 break;
376         }
377
378     };
379
380     return;
381 }
382
383 @end
384
385 /*****************************************************************************
386  * VLCColorView
387  *
388  * since we are using a clear window color when using the black window
389  * style, some filling is needed behind the video and some other elements
390  *****************************************************************************/
391
392 @implementation VLCColorView
393
394 - (void)drawRect:(NSRect)rect {
395     [[NSColor blackColor] setFill];
396     NSRectFill(rect);
397 }
398
399 @end
400
401 /*****************************************************************************
402  * custom window buttons to support the accessibility stuff
403  *****************************************************************************/
404
405 @implementation VLCCustomWindowButtonPrototype
406 + (Class)cellClass {
407     return [VLCWindowButtonCell class];
408 }
409
410 - (NSArray*)extendedAccessibilityAttributeNames: (NSArray*)theAttributeNames {
411     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
412 }
413
414 - (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName {
415     return nil;
416 }
417
418 - (NSNumber*)extendedAccessibilityIsAttributeSettable: (NSString*)theAttributeName {
419     return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? [NSNumber numberWithBool: NO] : nil); // make the Subrole attribute we added non-settable
420 }
421
422 - (void)accessibilityPerformAction: (NSString*)theActionName {
423     if ([theActionName isEqualToString: NSAccessibilityPressAction]) {
424         if ([self isEnabled])
425             [self performClick: nil];
426     } else
427         [super accessibilityPerformAction: theActionName];
428 }
429
430 @end
431
432 @implementation VLCCustomWindowCloseButton
433 - (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName {
434     return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? NSAccessibilityCloseButtonAttribute : nil);
435 }
436
437 @end
438
439
440 @implementation VLCCustomWindowMinimizeButton
441 - (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName {
442     return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? NSAccessibilityMinimizeButtonAttribute : nil);
443 }
444
445 @end
446
447
448 @implementation VLCCustomWindowZoomButton
449 - (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName {
450     return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? NSAccessibilityZoomButtonAttribute : nil);
451 }
452
453 @end
454
455
456 @implementation VLCCustomWindowFullscreenButton
457 #ifdef MAC_OS_X_VERSION_10_7
458 - (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName {
459     return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? NSAccessibilityFullScreenButtonAttribute : nil);
460 }
461 #endif
462
463 @end
464
465
466 @implementation VLCWindowTitleTextField
467
468 - (void)dealloc
469 {
470     if (contextMenu)
471         [contextMenu release];
472
473     [super dealloc];
474 }
475
476 - (void)showRightClickMenuWithEvent:(NSEvent *)o_event
477 {
478     if (contextMenu)
479         [contextMenu release];
480
481     NSURL * representedURL = [[self window] representedURL];
482     if (! representedURL)
483         return;
484
485     NSArray * pathComponents;
486     pathComponents = [representedURL pathComponents];
487
488     if (!pathComponents)
489         return;
490
491     contextMenu = [[NSMenu alloc] initWithTitle: [[NSFileManager defaultManager] displayNameAtPath: [representedURL path]]];
492
493     NSUInteger count = [pathComponents count];
494     NSImage * icon;
495     NSMenuItem * currentItem;
496     NSMutableString * currentPath;
497     NSSize iconSize = NSMakeSize(16., 16.);
498     for (NSUInteger i = count - 1; i > 0; i--) {
499         currentPath = [NSMutableString stringWithCapacity:1024];
500         for (NSUInteger y = 0; y < i; y++)
501             [currentPath appendFormat: @"/%@", [pathComponents objectAtIndex:y + 1]];
502
503         [contextMenu addItemWithTitle: [[NSFileManager defaultManager] displayNameAtPath: currentPath] action:@selector(revealInFinder:) keyEquivalent:@""];
504         currentItem = [contextMenu itemAtIndex:[contextMenu numberOfItems] - 1];
505         [currentItem setTarget: self];
506
507         icon = [[NSWorkspace sharedWorkspace] iconForFile:currentPath];
508         [icon setSize: iconSize];
509         [currentItem setImage: icon];
510     }
511
512     if ([[pathComponents objectAtIndex: 1] isEqualToString:@"Volumes"]) {
513         /* we don't want to show the Volumes item, since the Cocoa does it neither */
514         currentItem = [contextMenu itemWithTitle:[[NSFileManager defaultManager] displayNameAtPath: @"/Volumes"]];
515         if (currentItem)
516             [contextMenu removeItem: currentItem];
517     } else {
518         /* we're on the boot drive, so add it since it isn't part of the components */
519         [contextMenu addItemWithTitle: [[NSFileManager defaultManager] displayNameAtPath:@"/"] action:@selector(revealInFinder:) keyEquivalent:@""];
520         currentItem = [contextMenu itemAtIndex: [contextMenu numberOfItems] - 1];
521         icon = [[NSWorkspace sharedWorkspace] iconForFile:@"/"];
522         [icon setSize: iconSize];
523         [currentItem setImage: icon];
524         [currentItem setTarget: self];
525     }
526
527     /* add the computer item */
528     [contextMenu addItemWithTitle: [(NSString*)SCDynamicStoreCopyComputerName(NULL, NULL) autorelease] action:@selector(revealInFinder:) keyEquivalent:@""];
529     currentItem = [contextMenu itemAtIndex: [contextMenu numberOfItems] - 1];
530     icon = [NSImage imageNamed: NSImageNameComputer];
531     [icon setSize: iconSize];
532     [currentItem setImage: icon];
533     [currentItem setTarget: self];
534
535     [NSMenu popUpContextMenu: contextMenu withEvent: o_event forView: [self superview]];
536 }
537
538 - (IBAction)revealInFinder:(id)sender
539 {
540     NSUInteger count = [contextMenu numberOfItems];
541     NSUInteger selectedItem = [contextMenu indexOfItem: sender];
542
543     if (selectedItem == count - 1) { // the fake computer item
544         [[NSWorkspace sharedWorkspace] selectFile: @"/" inFileViewerRootedAtPath: @""];
545         return;
546     }
547
548     NSURL * representedURL = [[self window] representedURL];
549     if (! representedURL)
550         return;
551
552     if (selectedItem == 0) { // the actual file, let's save time
553         [[NSWorkspace sharedWorkspace] selectFile: [representedURL path] inFileViewerRootedAtPath: [representedURL path]];
554         return;
555     }
556
557     NSArray * pathComponents;
558     pathComponents = [representedURL pathComponents];
559     if (!pathComponents)
560         return;
561
562     NSMutableString * currentPath;
563     currentPath = [NSMutableString stringWithCapacity:1024];
564     selectedItem = count - selectedItem;
565
566     /* fix for non-startup volumes */
567     if ([[pathComponents objectAtIndex:1] isEqualToString:@"Volumes"])
568         selectedItem += 1;
569
570     for (NSUInteger y = 1; y < selectedItem; y++)
571         [currentPath appendFormat: @"/%@", [pathComponents objectAtIndex:y]];
572
573     [[NSWorkspace sharedWorkspace] selectFile: currentPath inFileViewerRootedAtPath: currentPath];
574 }
575
576 - (void)rightMouseDown:(NSEvent *)o_event
577 {
578     if ([o_event type] == NSRightMouseDown)
579         [self showRightClickMenuWithEvent:o_event];
580
581     [super mouseDown: o_event];
582 }
583
584 @end