]> git.sesse.net Git - vlc/commitdiff
macosx: clean Dudiak's code a bit
authorFelix Paul Kühne <fkuehne@videolan.org>
Thu, 21 May 2009 21:02:08 +0000 (23:02 +0200)
committerFelix Paul Kühne <fkuehne@videolan.org>
Thu, 21 May 2009 21:02:08 +0000 (23:02 +0200)
modules/gui/macosx/controls.m
modules/gui/macosx/embeddedwindow.m
modules/gui/macosx/playlist.m

index b0aea74328193724cc1ea00ed15ccd8cb341bd40..21df06159241620f424d65c101fd19fb24d9e8ad 100644 (file)
 
 - (IBAction)showPosition: (id)sender
 {
-    vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
-                                             FIND_ANYWHERE );
+    vout_thread_t *p_vout = input_GetVout( pl_CurrentInput( VLCIntf ));
     if( p_vout != NULL )
     {
-        intf_thread_t * p_intf = VLCIntf;
-        var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_POSITION );
+        var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_POSITION );
         vlc_object_release( (vlc_object_t *)p_vout );
     }
 }
 {
     NSString *o_title = [sender title];
 
-    vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
-                                              FIND_ANYWHERE );
+    vout_thread_t *p_vout = input_GetVout( pl_CurrentInput( VLCIntf ));
     if( p_vout != NULL )
     {
         id o_vout_view = [self voutView];
 
     if( key )
     {
-        vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
-                                              FIND_ANYWHERE );
+        vout_thread_t *p_vout = input_GetVout( pl_CurrentInput( VLCIntf ));
+
         if( p_vout != NULL )
         {
             /* Escape */
         NSEnumerator *o_enumerator = [o_windows objectEnumerator];
         bEnabled = FALSE;
  
-        vout_thread_t   *p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
-                                              FIND_ANYWHERE );
+        vout_thread_t   *p_vout = input_GetVout( pl_CurrentInput( VLCIntf ));
         if( p_vout != NULL )
         {
             if( [[o_mi title] isEqualToString: _NS("Float on Top")] )
index 3392fd1f256bdf0cec08d2479605e724de2c2c36..5ddb8656182915e596f7d7d1bb95c73f7daa721b 100644 (file)
@@ -26,9 +26,6 @@
  * Preamble
  *****************************************************************************/
 
-/* DisableScreenUpdates, SetSystemUIMode, ... */
-#import <QuickTime/QuickTime.h>
-
 #import "intf.h"
 #import "controls.h"
 #import "vout.h"
@@ -36,6 +33,9 @@
 #import "fspanel.h"
 #import "playlist.h"
 
+/* SetSystemUIMode, ... */
+#import <Carbon/Carbon.h>
+
 /*****************************************************************************
  * extension to NSWindow's interface to fix compilation warnings
  * and let us access this functions properly
 
 @implementation VLCEmbeddedWindow
 
+- (id)initWithContentRect:(NSRect)contentRect styleMask: (NSUInteger)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
+{
+    BOOL b_useTextured = YES;
+    if( [[NSWindow class] instancesRespondToSelector:@selector(setContentBorderThickness:forEdge:)] )
+    {
+        b_useTextured = NO;
+        windowStyle ^= NSTexturedBackgroundWindowMask;
+    }
+    self = [super initWithContentRect:contentRect styleMask:windowStyle backing:bufferingType defer:deferCreation];
+    if(! b_useTextured )
+    {
+        [self setContentBorderThickness:28.0 forEdge:NSMinYEdge];
+    }
+    return self;
+}
+
 - (void)awakeFromNib
 {
     [self setDelegate: self];
     [o_btn_playlist setToolTip: _NS("Playlist")];
     [self setTitle: _NS("VLC media player")];
 
-    if(MACOS_VERSION < 10.5f) {
-        o_img_play = [NSImage imageNamed: @"play"];
-        o_img_pause = [NSImage imageNamed: @"pause"];
-        [o_btn_play setImage: [NSImage imageNamed: @"play"]];
-    }
-    else {
-        o_img_play = [NSImage imageNamed: @"play_big"];
-        o_img_pause = [NSImage imageNamed: @"pause_big"];
-    }
+    o_img_play = [NSImage imageNamed: @"play_big"];
+    o_img_pause = [NSImage imageNamed: @"pause_big"];
+
     [self controlTintChanged];
     [[NSNotificationCenter defaultCenter] addObserver: self
                                              selector: @selector( controlTintChanged )
     if( [o_btn_play alternateImage] == o_img_play_pressed )
         b_playing = YES;
     
-    if (MACOS_VERSION < 10.5f) {
-        /* System is running Tiger and should use aqua buttons */
-        [o_btn_backward setImage: [NSImage imageNamed: @"skip_previous_active"]];
-        [o_btn_forward setImage: [NSImage imageNamed: @"skip_forward_active"]];
-        if( [NSColor currentControlTint] == NSGraphiteControlTint )
-        {
-            o_img_play_pressed = [NSImage imageNamed: @"play_graphite"];
-            o_img_pause_pressed = [NSImage imageNamed: @"pause_graphite"];
-            [o_btn_backward setAlternateImage: [NSImage imageNamed: @"skip_previous_graphite"]];
-            [o_btn_forward setAlternateImage: [NSImage imageNamed: @"skip_forward_graphite"]];
-        }
-        else
-        {
-            o_img_play_pressed = [NSImage imageNamed: @"play_blue"];
-            o_img_pause_pressed = [NSImage imageNamed: @"pause_blue"];
-            [o_btn_backward setAlternateImage: [NSImage imageNamed: @"skip_previous_blue"]];
-            [o_btn_forward setAlternateImage: [NSImage imageNamed: @"skip_forward_blue"]];
-        }
-    }
-    else{
-        /* System is running Leopard or later and should use metal buttons */
-        o_img_play_pressed = [NSImage imageNamed: @"play_big_down"];
-        o_img_pause_pressed = [NSImage imageNamed: @"pause_big_down"];
-    }
+    o_img_play_pressed = [NSImage imageNamed: @"play_big_down"];
+    o_img_pause_pressed = [NSImage imageNamed: @"pause_big_down"];
     
     if( b_playing )
         [o_btn_play setAlternateImage: o_img_play_pressed];
         [o_fullscreen_window setBackgroundColor: [NSColor blackColor]];
         [o_fullscreen_window setCanBecomeKeyWindow: YES];
 
-        if (![self isVisible] || [self alphaValue] == 0.0 || MACOS_VERSION < 10.4f)
+        if (![self isVisible] || [self alphaValue] == 0.0)
         {
-            /* We don't animate if we are not visible or if we are running on
-             * Mac OS X <10.4 which doesn't support NSAnimation, instead we
+            /* We don't animate if we are not visible, instead we
              * simply fade the display */
             CGDisplayFadeReservationToken token;
  
         }
  
         /* Make sure we don't see the o_view disappearing of the screen during this operation */
-        DisableScreenUpdates();
+        NSDisableScreenUpdates();
         [[self contentView] replaceSubview:o_view with:o_temp_view];
         [o_temp_view setFrame:[o_view frame]];
         [o_fullscreen_window setContentView:o_view];
         [o_fullscreen_window makeKeyAndOrderFront:self];
-        EnableScreenUpdates();
-    }
-
-    if (MACOS_VERSION < 10.4f)
-    {
-        /* We were already fullscreen nothing to do when NSAnimation
-         * is not supported */
-        [self unlockFullscreenAnimation];
-        return;
+        NSEnableScreenUpdates();
     }
 
     /* We are in fullscreen (and no animation is running) */
         return;
     }
 
-    if (fadeout || MACOS_VERSION < 10.4f)
+    if (fadeout)
     {
-        /* We don't animate if we are not visible or if we are running on
-        * Mac OS X <10.4 which doesn't support NSAnimation, instead we
+        /* We don't animate if we are not visible, instead we
         * simply fade the display */
         CGDisplayFadeReservationToken token;
 
 {
     /* This function is private and should be only triggered at the end of the fullscreen change animation */
     /* Make sure we don't see the o_view disappearing of the screen during this operation */
-    DisableScreenUpdates();
+    NSDisableScreenUpdates();
     [o_view retain];
     [o_view removeFromSuperviewWithoutNeedingDisplay];
     [[self contentView] replaceSubview:o_temp_view with:o_view];
     if ([self isVisible])
         [super makeKeyAndOrderFront:self]; /* our version contains a workaround */
     [o_fullscreen_window orderOut: self];
-    EnableScreenUpdates();
+    NSEnableScreenUpdates();
 
     [o_fullscreen_window release];
     o_fullscreen_window = nil;
index 54f548ac9b68ca09ed86c16b852f4e45196b857d..1cb0f8906891c3043dceefbfb8adf8b29ef853a5 100644 (file)
     playlist_t *p_playlist = pl_Hold( VLCIntf );
     
     id o_playing_item;
-    
+
+    PL_LOCK;
     o_playing_item = [o_outline_dict objectForKey:
                       [NSString stringWithFormat:@"%p",  playlist_CurrentPlayingItem( p_playlist )]];
-    
+    PL_UNLOCK;
+
     pl_Release( VLCIntf );
     
     return o_playing_item;