]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/controls.m
* include/vlc_keys.h: added StringToKey()
[vlc] / modules / gui / macosx / controls.m
index fe786efe08c25f47fb56fec5b78f5010d3cd9e4f..8c385ac28b5f0a4d977f97a483ecdaf3fcb42c89 100644 (file)
@@ -2,7 +2,7 @@
  * controls.m: MacOS X interface plugin
  *****************************************************************************
  * Copyright (C) 2002-2003 VideoLAN
- * $Id: controls.m,v 1.44 2003/07/09 01:30:41 hartman Exp $
+ * $Id: controls.m,v 1.53 2003/11/11 23:50:41 hartman Exp $
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *          Christophe Massiot <massiot@via.ecp.fr>
@@ -34,6 +34,7 @@
 #include "vout.h"
 #include "open.h"
 #include "controls.h"
+#include <osd.h>
 
 /*****************************************************************************
  * VLCControls implementation 
@@ -53,6 +54,7 @@
 
     if( playlist_IsPlaying( p_playlist ) )
     {
+        vout_OSDMessage( (vlc_object_t *)p_intf, _( "Pause" ) );
         playlist_Pause( p_playlist );
         vlc_object_release( p_playlist );
     }
@@ -61,6 +63,7 @@
         if( !playlist_IsEmpty( p_playlist ) )
         {
             playlist_Play( p_playlist );
+            vout_OSDMessage( (vlc_object_t *)p_intf, _( "Play" ) );
             vlc_object_release( p_playlist );
         }
         else
 - (IBAction)stop:(id)sender
 {
     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 )
+    if( p_playlist != NULL )
     {
-        return;
+        vout_OSDMessage( (vlc_object_t *)p_intf, _( "Stop" ) );
+        playlist_Stop( p_playlist );
+        vlc_object_release( p_playlist );
     }
-
-    playlist_Stop( p_playlist );
-    vlc_object_release( p_playlist );
 }
 
 - (IBAction)faster:(id)sender
 {
     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 )
-    {
-        return;
-    }
-
-    vlc_mutex_lock( &p_playlist->object_lock );
-    if( p_playlist->p_input != NULL )
+    if( p_input != NULL )
     {
-        input_SetStatus( p_playlist->p_input, INPUT_STATUS_FASTER );
-    } 
-    vlc_mutex_unlock( &p_playlist->object_lock );
+        vlc_value_t val; val.b_bool = VLC_TRUE;
 
-    vlc_object_release( p_playlist );
+        var_Set( p_input, "rate-faster", val );
+        vout_OSDMessage( (vlc_object_t *)p_intf, _( "Faster" ) );
+        vlc_object_release( p_input );
+    }
 }
 
 - (IBAction)slower:(id)sender
 {
     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 )
+    if( p_input != NULL )
     {
-        return;
-    }
+        vlc_value_t val; val.b_bool = VLC_TRUE;
 
-    vlc_mutex_lock( &p_playlist->object_lock );
-    if( p_playlist->p_input != NULL )
-    {
-        input_SetStatus( p_playlist->p_input, INPUT_STATUS_SLOWER );
+        var_Set( p_input, "rate-slower", val );
+        vout_OSDMessage( (vlc_object_t *)p_intf, _( "Slower" ) );
+        vlc_object_release( p_input );
     }
-    vlc_mutex_unlock( &p_playlist->object_lock );
-
-    vlc_object_release( p_playlist );
 }
 
 - (IBAction)prev:(id)sender
     }
 
     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 );
-        vlc_mutex_unlock( &p_playlist->object_lock );
-        var_Get( p_playlist->p_input, "prev-chapter", &val );
         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 );
-        vlc_mutex_unlock( &p_playlist->object_lock );
-        var_Get( p_playlist->p_input, "prev-title", &val );
         var_Set( p_playlist->p_input, "prev-title", val );
+        vlc_mutex_unlock( &p_playlist->object_lock );
     }
     else
     {
 #undef p_area
 
     vlc_object_release( p_playlist );
+    vout_OSDMessage( (vlc_object_t *)p_intf, _( "Previous" ) );
 }
 
 - (IBAction)next:(id)sender
     }
 
     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 && p_area->i_part_nb > 1 )
+    if( p_area->i_part < p_area->i_part_nb - 1 && p_area->i_part_nb > 1 )
     {
-    NSLog(@"next-chapter: %d, all: %d", p_area->i_part, p_area->i_part_nb);
         vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
-        vlc_mutex_unlock( &p_playlist->object_lock );
-        var_Get( p_playlist->p_input, "next-chapter", &val );
         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 )
     {
-    NSLog(@"next-title: %d, all: %d", p_area->i_id, p_playlist->p_input->stream.i_area_nb );
         vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
-        vlc_mutex_unlock( &p_playlist->object_lock );
-        var_Get( p_playlist->p_input, "next-title", &val );
         var_Set( p_playlist->p_input, "next-title", val );
+        vlc_mutex_unlock( &p_playlist->object_lock );
     }
     else
     {
-    NSLog(@"next-item");
         vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
         vlc_mutex_unlock( &p_playlist->object_lock );
         playlist_Next( p_playlist );
 #undef p_area
 
     vlc_object_release( p_playlist );
+    vout_OSDMessage( (vlc_object_t *)p_intf, _( "Next" ) );
 }
 
-- (IBAction)loop:(id)sender
+- (IBAction)random:(id)sender
 {
     intf_thread_t * p_intf = [NSApp getIntf];
-
+    vlc_value_t val;
     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                        FIND_ANYWHERE );
     if( p_playlist == NULL )
         return;
     }
 
-    config_PutInt( p_playlist, "loop",
-                   !config_GetInt( p_playlist, "loop" ) );
+    var_Get( p_playlist, "random", &val );
+    val.b_bool = !val.b_bool;
+    var_Set( p_playlist, "random", val );
+    if( val.b_bool )
+    {
+        vout_OSDMessage( (vlc_object_t *)p_intf, _( "Shuffle On" ) );
+    }
+    else
+    {
+        vout_OSDMessage( (vlc_object_t *)p_intf, _( "Shuffle Off" ) );
+    }    
 
     vlc_object_release( p_playlist );
 }
 
-- (IBAction)forward:(id)sender
+- (IBAction)repeat:(id)sender
 {
     intf_thread_t * p_intf = [NSApp getIntf];
+    vlc_value_t val;
     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                        FIND_ANYWHERE );
-    if( p_playlist == NULL || p_playlist->p_input == NULL )
+    if( p_playlist == NULL )
     {
-        if ( p_playlist != NULL ) vlc_object_release( p_playlist );
         return;
     }
 
-    input_Seek( p_playlist->p_input, 5, INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
+    var_Get( p_playlist, "repeat", &val );
+    val.b_bool = !val.b_bool;
+    var_Set( p_playlist, "repeat", val );
+    if( val.b_bool )
+    {
+        vout_OSDMessage( (vlc_object_t *)p_intf, _( "Repeat On" ) );
+    }
+    else
+    {
+        vout_OSDMessage( (vlc_object_t *)p_intf, _( "Repeat Off" ) );
+    }    
+
     vlc_object_release( p_playlist );
 }
 
-- (IBAction)backward:(id)sender
+- (IBAction)loop:(id)sender
 {
     intf_thread_t * p_intf = [NSApp getIntf];
+    vlc_value_t val;
     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                        FIND_ANYWHERE );
-    if( p_playlist == NULL || p_playlist->p_input == NULL )
+    if( p_playlist == NULL )
     {
-        if ( p_playlist != NULL ) vlc_object_release( p_playlist );
         return;
     }
 
-    input_Seek( p_playlist->p_input, -5, INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
+    var_Get( p_playlist, "loop", &val );
+    val.b_bool = !val.b_bool;
+    var_Set( p_playlist, "loop", val );
+    if( val.b_bool )
+    {
+        vout_OSDMessage( (vlc_object_t *)p_intf, _( "Loop On" ) );
+    }
+    else
+    {
+        vout_OSDMessage( (vlc_object_t *)p_intf, _( "Loop Off" ) );
+    }    
+
     vlc_object_release( p_playlist );
 }
 
+- (IBAction)forward:(id)sender
+{
+    intf_thread_t * p_intf = [NSApp getIntf];
+    input_thread_t * p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT,
+                                                       FIND_ANYWHERE );
+    if( p_input != NULL )
+    {
+        vlc_value_t time;
+        time.i_time = 10 * 1000000;
+        var_Set( p_input, "time-offset", time );
+        vlc_object_release( p_input );
+    }
+}
+
+- (IBAction)backward:(id)sender
+{
+    intf_thread_t * p_intf = [NSApp getIntf];
+    input_thread_t * p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT,
+                                                       FIND_ANYWHERE );
+    if( p_input != NULL )
+    {
+        vlc_value_t time;
+        time.i_time = -10 * 1000000;
+        var_Set( p_input, "time-offset", time );
+        vlc_object_release( p_input );
+    }
+}
+
 - (IBAction)volumeUp:(id)sender
 {
     intf_thread_t * p_intf = [NSApp getIntf];
 {
     intf_thread_t * p_intf = [NSApp getIntf];
     audio_volume_t i_volume;
+    char string[9];
 
     aout_VolumeGet( p_intf, &i_volume );
 
-    [o_volumeslider setFloatValue: (float)(i_volume / AOUT_VOLUME_STEP)]; 
+    [o_volumeslider setFloatValue: (float)(i_volume / AOUT_VOLUME_STEP)];
+
+    sprintf( string, "Vol %d%%", i_volume*100/AOUT_VOLUME_MAX );
+    vout_OSDMessage( (vlc_object_t *)p_intf, string );
 }
 
 - (IBAction)windowAction:(id)sender
                     if( ![o_window isZoomed] )
                         [o_window performZoom:self];
                 }
+                break;
             }
         }
         vlc_object_release( (vlc_object_t *)p_vout );
 - (BOOL)validateMenuItem:(NSMenuItem *)o_mi
 {
     BOOL bEnabled = TRUE;
+    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 );
 
             }
         }
     }
-    else if( [[o_mi title] isEqualToString: _NS("Loop")] )
+    else if( [[o_mi title] isEqualToString: _NS("Shuffle")] )
     {
-        int i_state = config_GetInt( p_playlist, "loop" ) ?
-                      NSOnState : NSOffState;
-
+        int i_state;
+        var_Get( p_playlist, "random", &val );
+        i_state = val.b_bool ? NSOnState : NSOffState;
+        [o_mi setState: i_state];
+    }
+    else if( [[o_mi title] isEqualToString: _NS("Repeat Item")] )
+    {
+        int i_state;
+        var_Get( p_playlist, "repeat", &val );
+        i_state = val.b_bool ? NSOnState : NSOffState;
+        [o_mi setState: i_state];
+    }
+    else if( [[o_mi title] isEqualToString: _NS("Repeat Playlist")] )
+    {
+        int i_state;
+        var_Get( p_playlist, "loop", &val );
+        i_state = val.b_bool ? NSOnState : NSOffState;
         [o_mi setState: i_state];
     }
     else if( [[o_mi title] isEqualToString: _NS("Step Forward")] ||