/*****************************************************************************
- * controls.m: MacOS X interface plugin
+ * controls.m: MacOS X interface module
*****************************************************************************
* Copyright (C) 2002-2003 VideoLAN
- * $Id: controls.m,v 1.47 2003/07/29 21:14:10 gbazin Exp $
+ * $Id$
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Christophe Massiot <massiot@via.ecp.fr>
- * Derk-Jan Hartman <thedj@users.sourceforge.net>
+ * Derk-Jan Hartman <hartman at videolan dot org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "vout.h"
#include "open.h"
#include "controls.h"
+#include <osd.h>
/*****************************************************************************
* VLCControls implementation
- (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 )
{
- playlist_Pause( p_playlist );
- vlc_object_release( p_playlist );
+ vout_OSDMessage( p_intf, _( "Pause" ) );
+ val.i_int = PAUSE_S;
+ var_Set( p_input, "state", val );
}
else
{
- if( !playlist_IsEmpty( p_playlist ) )
- {
- playlist_Play( p_playlist );
- vlc_object_release( p_playlist );
- }
- else
+ p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ if( p_playlist )
{
- 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( 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
{
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( 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 )
+ if( p_input != NULL )
{
- return;
+ vlc_value_t val; val.b_bool = VLC_TRUE;
+
+ var_Set( p_input, "rate-faster", val );
+ vout_OSDMessage( p_intf, _( "Faster" ) );
+ vlc_object_release( p_input );
}
+}
- vlc_mutex_lock( &p_playlist->object_lock );
- if( p_playlist->p_input != NULL )
+- (IBAction)slower:(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 )
{
- 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-slower", val );
+ vout_OSDMessage( p_intf, _( "Slower" ) );
+ vlc_object_release( p_input );
+ }
}
-- (IBAction)slower:(id)sender
+- (IBAction)prev:(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 )
{
- return;
+ playlist_Prev( p_playlist );
+ vlc_object_release( p_playlist );
+ vout_OSDMessage( p_intf, _( "Previous" ) );
}
+}
- vlc_mutex_lock( &p_playlist->object_lock );
- if( p_playlist->p_input != NULL )
+- (IBAction)next:(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 )
{
- input_SetStatus( p_playlist->p_input, INPUT_STATUS_SLOWER );
+ playlist_Next( p_playlist );
+ vlc_object_release( p_playlist );
+ vout_OSDMessage( p_intf, _( "Next" ) );
}
- vlc_mutex_unlock( &p_playlist->object_lock );
-
- vlc_object_release( p_playlist );
}
-- (IBAction)prev:(id)sender
+- (IBAction)random:(id)sender
{
- vlc_value_t val;
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;
}
- 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)
+ var_Get( p_playlist, "random", &val );
+ val.b_bool = !val.b_bool;
+ var_Set( p_playlist, "random", val );
+ if( val.b_bool )
{
- 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 );
+ vout_OSDMessage( p_intf, _( "Random On" ) );
}
else
{
- vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
- vlc_mutex_unlock( &p_playlist->object_lock );
- playlist_Prev( p_playlist );
- }
-#undef p_area
+ vout_OSDMessage( p_intf, _( "Random Off" ) );
+ }
+ p_intf->p_sys->b_playlist_update = VLC_TRUE;
+ p_intf->p_sys->b_intf_update = VLC_TRUE;
vlc_object_release( p_playlist );
}
-- (IBAction)next:(id)sender
+- (IBAction)repeat:(id)sender
{
- vlc_value_t val;
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;
}
-
- 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 )
- {
- 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 )
+ var_Get( p_playlist, "repeat", &val );
+ if (!val.b_bool)
+ {
+ var_Set( p_playlist, "loop", val );
+ }
+ val.b_bool = !val.b_bool;
+ var_Set( p_playlist, "repeat", val );
+ if( val.b_bool )
{
- 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 );
+ vout_OSDMessage( p_intf, _( "Repeat All" ) );
}
else
{
- vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
- vlc_mutex_unlock( &p_playlist->object_lock );
- playlist_Next( p_playlist );
+ vout_OSDMessage( p_intf, _( "Repeat Off" ) );
}
-#undef p_area
+ p_intf->p_sys->b_playlist_update = VLC_TRUE;
+ p_intf->p_sys->b_intf_update = VLC_TRUE;
vlc_object_release( p_playlist );
}
- (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 )
return;
}
- config_PutInt( p_playlist, "loop",
- !config_GetInt( p_playlist, "loop" ) );
+ var_Get( p_playlist, "loop", &val );
+ if (!val.b_bool)
+ {
+ var_Set( p_playlist, "repeat", val );
+ }
+ val.b_bool = !val.b_bool;
+ var_Set( p_playlist, "loop", val );
+ if( val.b_bool )
+ {
+ vout_OSDMessage( p_intf, _( "Repeat One" ) );
+ }
+ else
+ {
+ vout_OSDMessage( 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 );
}
- (IBAction)forward:(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 || p_playlist->p_input == NULL )
+ if( p_input != NULL )
{
- if ( p_playlist != NULL ) vlc_object_release( p_playlist );
- return;
+ vlc_value_t time;
+ time.i_time = 10 * 1000000;
+ var_Set( p_input, "time-offset", time );
+ vout_OSDMessage( p_intf, _( "Jump +10 Seconds" ) );
+ vlc_object_release( p_input );
}
+}
- playlist_Play( p_playlist );
- input_Seek( p_playlist->p_input, 5, INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
- vlc_object_release( p_playlist );
+- (IBAction)forward1Min:(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 = 60 * 1000000;
+ var_Set( p_input, "time-offset", time );
+ vout_OSDMessage( p_intf, _( "Jump +1 Minute" ) );
+ vlc_object_release( p_input );
+ }
+}
+
+- (IBAction)forward5Min:(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 = 300 * 1000000;
+ var_Set( p_input, "time-offset", time );
+ vout_OSDMessage( p_intf, _( "Jump +5 Minutes" ) );
+ vlc_object_release( p_input );
+ }
}
- (IBAction)backward:(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 || p_playlist->p_input == NULL )
+ if( p_input != NULL )
{
- if ( p_playlist != NULL ) vlc_object_release( p_playlist );
- return;
+ vlc_value_t time;
+ time.i_time = -10 * 1000000;
+ var_Set( p_input, "time-offset", time );
+ vout_OSDMessage( p_intf, _( "Jump -10 Seconds" ) );
+ vlc_object_release( p_input );
}
+}
- playlist_Play( p_playlist );
- input_Seek( p_playlist->p_input, -5, INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
- vlc_object_release( p_playlist );
+- (IBAction)backward1Min:(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 = -60 * 1000000;
+ var_Set( p_input, "time-offset", time );
+ vout_OSDMessage( p_intf, _( "Jump -1 Minute" ) );
+ vlc_object_release( p_input );
+ }
+}
+
+- (IBAction)backward5Min:(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 = -300 * 1000000;
+ var_Set( p_input, "time-offset", time );
+ vout_OSDMessage( p_intf, _( "Jump -5 Minutes" ) );
+ vlc_object_release( p_input );
+ }
}
- (IBAction)volumeUp:(id)sender
aout_VolumeGet( p_intf, &i_volume );
- [o_volumeslider setFloatValue: (float)(i_volume / AOUT_VOLUME_STEP)];
+ [o_volumeslider setFloatValue: (float)(i_volume / AOUT_VOLUME_STEP)];
+
+ vout_OSDMessage( p_intf, "Vol %d%%", i_volume*100/AOUT_VOLUME_MAX );
}
- (IBAction)windowAction:(id)sender
{
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];
else if( [o_title isEqualToString: _NS("Double Size") ] )
[o_window scaleWindowWithFactor: 2.0];
- else if( [o_title isEqualToString: _NS("Float On Top") ] )
+ else if( [o_title isEqualToString: _NS("Float on Top") ] )
[o_window toggleFloatOnTop];
- else if( [o_title isEqualToString: _NS("Fit To Screen") ] )
+ else if( [o_title isEqualToString: _NS("Fit to Screen") ] )
{
if( ![o_window isZoomed] )
[o_window performZoom:self];
}
+ else
+ {
+ [o_window toggleFullscreen];
+ }
+ 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("Random")] )
{
- 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 One")] )
+ {
+ 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 All")] )
+ {
+ 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")] ||
[[o_mi title] isEqualToString: _NS("Half Size")] ||
[[o_mi title] isEqualToString: _NS("Normal Size")] ||
[[o_mi title] isEqualToString: _NS("Double Size")] ||
- [[o_mi title] isEqualToString: _NS("Fit To Screen")] ||
- [[o_mi title] isEqualToString: _NS("Float On Top")] )
+ [[o_mi title] isEqualToString: _NS("Fit to Screen")] ||
+ [[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")] )
+ 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];
}