/*****************************************************************************
* controls.m: MacOS X interface module
*****************************************************************************
- * Copyright (C) 2002-2005 the VideoLAN team
+ * Copyright (C) 2002-2006 the VideoLAN team
* $Id$
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Christophe Massiot <massiot@via.ecp.fr>
* Derk-Jan Hartman <hartman at videolan dot org>
* Benjamin Pracht <bigben at videolan doit org>
+ * Felix K\9fhne <fkuehne 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 <sys/param.h> /* for MAXPATHLEN */
#include <string.h>
-#include "intf.h"
-#include "vout.h"
-#include "open.h"
-#include "controls.h"
+#import "intf.h"
+#import "vout.h"
+#import "open.h"
+#import "controls.h"
+#import "playlist.h"
#include <vlc_osd.h>
{
vlc_value_t val;
intf_thread_t * p_intf = VLCIntf;
- playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
- if( p_playlist )
- {
- vlc_mutex_lock( &p_playlist->object_lock );
- if( p_playlist->i_size <= 0 )
- {
- vlc_mutex_unlock( &p_playlist->object_lock );
- vlc_object_release( p_playlist );
- [o_main intfOpenFileGeneric: (id)sender];
- }
- else
- {
- vlc_mutex_unlock( &p_playlist->object_lock );
- vlc_object_release( p_playlist );
- }
+ playlist_t * p_playlist = pl_Yield( p_intf );
+ vlc_mutex_lock( &p_playlist->object_lock );
+ if( playlist_IsEmpty( p_playlist ) )
+ {
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ vlc_object_release( p_playlist );
+ [o_main intfOpenFileGeneric: (id)sender];
}
+ else
+ {
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ vlc_object_release( p_playlist );
+ }
+
val.i_int = config_GetInt( p_intf, "key-play-pause" );
var_Set( p_intf->p_libvlc, "key-pressed", val );
}
{
vlc_value_t val;
intf_thread_t * p_intf = VLCIntf;
- playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
- if( p_playlist == NULL )
- {
- return;
- }
+ playlist_t * p_playlist = pl_Yield( p_intf );
var_Get( p_playlist, "random", &val );
val.b_bool = !val.b_bool;
vlc_object_release( p_playlist );
}
-- (IBAction)repeat:(id)sender
+/* three little ugly helpers */
+- (void)repeatOne
+{
+ [o_btn_repeat setImage: [[NSImage alloc] initWithContentsOfFile:
+ [[NSBundle mainBundle] pathForImageResource:@"repeat_single_embedded_blue.png"]]];
+ [o_btn_repeat setAlternateImage: [[NSImage alloc] initWithContentsOfFile:
+ [[NSBundle mainBundle] pathForImageResource:@"repeat_embedded_blue.png"]]];
+}
+- (void)repeatAll
+{
+ [o_btn_repeat setImage: [[NSImage alloc] initWithContentsOfFile:
+ [[NSBundle mainBundle] pathForImageResource:@"repeat_embedded_blue.png"]]];
+ [o_btn_repeat setAlternateImage: [[NSImage alloc] initWithContentsOfFile:
+ [[NSBundle mainBundle] pathForImageResource:@"repeat_embedded.png"]]];
+}
+- (void)repeatOff
+{
+ [o_btn_repeat setImage: [[NSImage alloc] initWithContentsOfFile:
+ [[NSBundle mainBundle] pathForImageResource:@"repeat_embedded.png"]]];
+ [o_btn_repeat setAlternateImage: [[NSImage alloc] initWithContentsOfFile:
+ [[NSBundle mainBundle] pathForImageResource:@"repeat_single_embedded_blue.png"]]];
+}
+- (void)shuffle
{
vlc_value_t val;
+ playlist_t *p_playlist = pl_Yield( VLCIntf );
+ var_Get( p_playlist, "random", &val );
+ [o_btn_shuffle setState: val.b_bool];
+ vlc_object_release( p_playlist );
+}
+
+- (IBAction)repeatButtonAction:(id)sender
+{
+ vlc_value_t looping,repeating;
intf_thread_t * p_intf = VLCIntf;
- playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
- if( p_playlist == NULL )
+ playlist_t * p_playlist = pl_Yield( p_intf );
+
+ var_Get( p_playlist, "repeat", &repeating );
+ var_Get( p_playlist, "loop", &looping );
+
+ [[o_btn_repeat image] release];
+ [[o_btn_repeat alternateImage] release];
+
+ if( !repeating.b_bool && !looping.b_bool )
{
- return;
+ /* was: no repeating at all, switching to Repeat One */
+
+ /* set our button's look */
+ [self repeatOne];
+
+ /* prepare core communication */
+ repeating.b_bool = VLC_TRUE;
+ looping.b_bool = VLC_FALSE;
+ config_PutInt( p_playlist, "repeat", 1 );
+ config_PutInt( p_playlist, "loop", 0 );
+
+ /* show the change */
+ vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
}
+ else if( repeating.b_bool && !looping.b_bool )
+ {
+ /* was: Repeat One, switching to Repeat All */
+
+ /* set our button's look */
+ [self repeatAll];
+
+ /* prepare core communication */
+ repeating.b_bool = VLC_FALSE;
+ looping.b_bool = VLC_TRUE;
+ config_PutInt( p_playlist, "repeat", 0 );
+ config_PutInt( p_playlist, "loop", 1 );
+
+ /* show the change */
+ vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
+ }
+ else
+ {
+ /* was: Repeat All or bug in VLC, switching to Repeat Off */
+
+ /* set our button's look */
+ [self repeatOff];
+
+ /* prepare core communication */
+ repeating.b_bool = VLC_FALSE;
+ looping.b_bool = VLC_FALSE;
+ config_PutInt( p_playlist, "repeat", 0 );
+ config_PutInt( p_playlist, "loop", 0 );
+
+ /* show the change */
+ vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
+ }
+
+ /* communicate with core and the main intf loop */
+ var_Set( p_playlist, "repeat", repeating );
+ var_Set( p_playlist, "loop", looping );
+ p_intf->p_sys->b_playmode_update = VLC_TRUE;
+ p_intf->p_sys->b_intf_update = VLC_TRUE;
+
+ vlc_object_release( p_playlist );
+}
+
+
+- (IBAction)repeat:(id)sender
+{
+ vlc_value_t val;
+ intf_thread_t * p_intf = VLCIntf;
+ playlist_t * p_playlist = pl_Yield( p_intf );
var_Get( p_playlist, "repeat", &val );
if (!val.b_bool)
{
vlc_value_t val;
intf_thread_t * p_intf = VLCIntf;
- playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
- if( p_playlist == NULL )
- {
- return;
- }
+ playlist_t * p_playlist = pl_Yield( p_intf );
var_Get( p_playlist, "loop", &val );
if (!val.b_bool)
}
else
{
- playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
+ playlist_t * p_playlist = pl_Yield( VLCIntf );
- if( p_playlist && ( [o_title isEqualToString: _NS("Fullscreen")] ||
- [sender isKindOfClass:[NSButton class]] ) )
+ if( [o_title isEqualToString: _NS("Fullscreen")] ||
+ [sender isKindOfClass:[NSButton class]] )
{
vlc_value_t val;
var_Get( p_playlist, "fullscreen", &val );
var_Set( p_playlist, "fullscreen", (vlc_value_t)!val.b_bool );
}
- if( p_playlist ) vlc_object_release( (vlc_object_t *)p_playlist );
+
+ vlc_object_release( p_playlist );
}
}
BOOL bEnabled = TRUE;
vlc_value_t val;
intf_thread_t * p_intf = VLCIntf;
- playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
+ playlist_t * p_playlist = pl_Yield( p_intf );
- if( p_playlist != NULL )
- {
- vlc_mutex_lock( &p_playlist->object_lock );
- }
- else return FALSE;
+ vlc_mutex_lock( &p_playlist->object_lock );
#define p_input p_playlist->p_input
else if( [[o_mi title] isEqualToString: _NS("Previous")] ||
[[o_mi title] isEqualToString: _NS("Next")] )
{
- bEnabled = p_playlist->i_size > 1;
+ /** \todo fix i_size use */
+ bEnabled = p_playlist->items.i_size > 1;
}
else if( [[o_mi title] isEqualToString: _NS("Random")] )
{