]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/controls.m
Fix for the fullscreen button state (it is only enabled if a vout is present)
[vlc] / modules / gui / macosx / controls.m
index 8c385ac28b5f0a4d977f97a483ecdaf3fcb42c89..06018f682498d178d78761e530e09dea6544cee9 100644 (file)
@@ -2,7 +2,7 @@
  * controls.m: MacOS X interface plugin
  *****************************************************************************
  * Copyright (C) 2002-2003 VideoLAN
- * $Id: controls.m,v 1.53 2003/11/11 23:50:41 hartman Exp $
+ * $Id: controls.m,v 1.59 2003/12/15 19:25:56 bigben Exp $
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *          Christophe Massiot <massiot@via.ecp.fr>
 
 - (IBAction)play:(id)sender
 {
+    vlc_value_t val;
+    playlist_t * p_playlist;
     intf_thread_t * p_intf = [NSApp getIntf];
-
-    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+    input_thread_t * p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT,
                                                        FIND_ANYWHERE );
-    if( p_playlist == NULL )
+
+    val.i_int = PLAYING_S;
+    if( p_input )
     {
-        return;
+        var_Get( p_input, "state", &val );
     }
-
-    if( playlist_IsPlaying( p_playlist ) )
+    if( p_input && val.i_int != PAUSE_S )
     {
-        vout_OSDMessage( (vlc_object_t *)p_intf, _( "Pause" ) );
-        playlist_Pause( p_playlist );
-        vlc_object_release( p_playlist );
+        vout_OSDMessage( VLC_OBJECT(p_intf), _( "Pause" ) );
+        val.i_int = PAUSE_S;
+        var_Set( p_input, "state", val );
     }
     else
     {
-        if( !playlist_IsEmpty( p_playlist ) )
+        p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+                                        FIND_ANYWHERE );
+        if( p_playlist )
         {
-            playlist_Play( p_playlist );
-            vout_OSDMessage( (vlc_object_t *)p_intf, _( "Play" ) );
-            vlc_object_release( p_playlist );
-        }
-        else
-        {
-            vlc_object_release( p_playlist );
-            [o_open openFileGeneric: nil];
+            vlc_mutex_lock( &p_playlist->object_lock );
+            if( p_playlist->i_size )
+            {
+                vlc_mutex_unlock( &p_playlist->object_lock );
+                vout_OSDMessage( VLC_OBJECT(p_intf), _( "Play" ) );
+                playlist_Play( p_playlist );
+                vlc_object_release( p_playlist );
+            }
+            else
+            {
+                vlc_mutex_unlock( &p_playlist->object_lock );
+                vlc_object_release( p_playlist );
+                [o_open openFileGeneric: nil];
+            }
         }
     }
+    if( p_input ) vlc_object_release( p_input );
 }
 
 - (IBAction)stop:(id)sender
 
 - (IBAction)prev:(id)sender
 {
-    vlc_value_t val;
     intf_thread_t * p_intf = [NSApp getIntf];
-
     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                        FIND_ANYWHERE );
-    if( p_playlist == NULL )
-    {
-        return;
-    }
-
-    vlc_mutex_lock( &p_playlist->object_lock );
-
-    if( p_playlist->p_input == NULL )
-    {
-        vlc_mutex_unlock( &p_playlist->object_lock );
-        vlc_object_release( p_playlist );  
-        return;
-    }
-
-    vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
-    val.b_bool = VLC_TRUE;
-
-#define p_area p_playlist->p_input->stream.p_selected_area
-    if( p_area->i_part > 0 && p_area->i_part_nb > 1)
-    {
-        vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
-        var_Set( p_playlist->p_input, "prev-chapter", val );
-        vlc_mutex_unlock( &p_playlist->object_lock );
-    }
-    else if( p_area->i_id > 1 )
-    {
-        vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
-        var_Set( p_playlist->p_input, "prev-title", val );
-        vlc_mutex_unlock( &p_playlist->object_lock );
-    }
-    else
+    if( p_playlist )
     {
-        vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
-        vlc_mutex_unlock( &p_playlist->object_lock );
         playlist_Prev( p_playlist );
+        vlc_object_release( p_playlist );
+        vout_OSDMessage( (vlc_object_t *)p_intf, _( "Previous" ) );
     }
-#undef p_area
-
-    vlc_object_release( p_playlist );
-    vout_OSDMessage( (vlc_object_t *)p_intf, _( "Previous" ) );
 }
 
 - (IBAction)next:(id)sender
 {
-    vlc_value_t val;
     intf_thread_t * p_intf = [NSApp getIntf];
-
     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                        FIND_ANYWHERE );
-    if( p_playlist == NULL )
-    {
-        return;
-    }
-    
-    vlc_mutex_lock( &p_playlist->object_lock );
-
-    if( p_playlist->p_input == NULL )
-    {
-        vlc_mutex_unlock( &p_playlist->object_lock );
-        vlc_object_release( p_playlist );  
-        return;
-    }
-
-    vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
-    val.b_bool = VLC_TRUE;
-
-#define p_area p_playlist->p_input->stream.p_selected_area
-    if( p_area->i_part < p_area->i_part_nb - 1 && p_area->i_part_nb > 1 )
+    if( p_playlist )
     {
-        vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
-        var_Set( p_playlist->p_input, "next-chapter", val );
-        vlc_mutex_unlock( &p_playlist->object_lock );
-    }
-    else if( p_area->i_id < p_playlist->p_input->stream.i_area_nb && p_playlist->p_input->stream.i_area_nb > 1 )
-    {
-        vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
-        var_Set( p_playlist->p_input, "next-title", val );
-        vlc_mutex_unlock( &p_playlist->object_lock );
-    }
-    else
-    {
-        vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
-        vlc_mutex_unlock( &p_playlist->object_lock );
         playlist_Next( p_playlist );
+        vlc_object_release( p_playlist );
+        vout_OSDMessage( (vlc_object_t *)p_intf, _( "Next" ) );
     }
-#undef p_area
-
-    vlc_object_release( p_playlist );
-    vout_OSDMessage( (vlc_object_t *)p_intf, _( "Next" ) );
 }
 
 - (IBAction)random:(id)sender
         vout_OSDMessage( (vlc_object_t *)p_intf, _( "Shuffle Off" ) );
     }    
 
+    p_intf->p_sys->b_playlist_update = VLC_TRUE;
+    p_intf->p_sys->b_intf_update = VLC_TRUE;
     vlc_object_release( p_playlist );
 }
 
     else
     {
         vout_OSDMessage( (vlc_object_t *)p_intf, _( "Repeat Off" ) );
-    }    
+    }
 
+    p_intf->p_sys->b_playlist_update = VLC_TRUE;    
+    p_intf->p_sys->b_intf_update = VLC_TRUE;
     vlc_object_release( p_playlist );
 }
 
         vout_OSDMessage( (vlc_object_t *)p_intf, _( "Loop Off" ) );
     }    
 
+    p_intf->p_sys->b_playlist_update = VLC_TRUE;
+    p_intf->p_sys->b_intf_update = VLC_TRUE;
     vlc_object_release( p_playlist );
 }
 
 {
     id o_window = [NSApp keyWindow];
     NSString *o_title = [sender title];
-    NSArray *o_windows = [NSApp windows];
+    NSArray *o_windows = [NSApp orderedWindows];
     NSEnumerator *o_enumerator = [o_windows objectEnumerator];
     vout_thread_t   *p_vout = vlc_object_find( [NSApp getIntf], VLC_OBJECT_VOUT,
                                               FIND_ANYWHERE );
         {
             if( [[o_window className] isEqualToString: @"VLCWindow"] )
             {
-                if( [o_title isEqualToString: _NS("Fullscreen") ] )
-                    [o_window toggleFullscreen];
-                else if( [o_title isEqualToString: _NS("Half Size") ] )
+                if( [o_title isEqualToString: _NS("Half Size") ] )
                     [o_window scaleWindowWithFactor: 0.5];
                 else if( [o_title isEqualToString: _NS("Normal Size") ] )
                     [o_window scaleWindowWithFactor: 1.0];
                     if( ![o_window isZoomed] )
                         [o_window performZoom:self];
                 }
+                else
+                {
+                    [o_window toggleFullscreen];
+                }
                 break;
             }
         }
                 [[o_mi title] isEqualToString: _NS("Float On Top")] )
     {
         id o_window;
-        NSArray *o_windows = [NSApp windows];
+        NSArray *o_windows = [NSApp orderedWindows];
         NSEnumerator *o_enumerator = [o_windows objectEnumerator];
         bEnabled = FALSE;
         
         if ( [[o_mi title] isEqualToString: _NS("Float On Top")] )
         {
-            int i_state = config_GetInt( p_playlist, "macosx-float" ) ?
+            int i_state = config_GetInt( p_playlist, "video-on-top" ) ?
                       NSOnState : NSOffState;
             [o_mi setState: i_state];
         }