1 /*****************************************************************************
2 * controls.m: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2002-2006 the VideoLAN team
7 * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8 * Christophe Massiot <massiot@via.ecp.fr>
9 * Derk-Jan Hartman <hartman at videolan dot org>
10 * Benjamin Pracht <bigben at videolan doit org>
11 * Felix K
\9fhne <fkuehne at videolan dot org>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26 *****************************************************************************/
28 /*****************************************************************************
30 *****************************************************************************/
31 #include <stdlib.h> /* malloc(), free() */
32 #include <sys/param.h> /* for MAXPATHLEN */
42 /*****************************************************************************
43 * VLCControls implementation
44 *****************************************************************************/
45 @implementation VLCControls
50 o_fs_panel = [[VLCFSPanel alloc] init];
56 [o_specificTime_mi setTitle: _NS("Jump To Time")];
57 [o_specificTime_cancel_btn setTitle: _NS("Cancel")];
58 [o_specificTime_ok_btn setTitle: _NS("OK")];
59 [o_specificTime_sec_lbl setStringValue: _NS("sec.")];
60 [o_specificTime_goTo_lbl setStringValue: _NS("Jump to time")];
63 - (IBAction)play:(id)sender
66 intf_thread_t * p_intf = VLCIntf;
67 playlist_t * p_playlist = pl_Yield( p_intf );
69 vlc_mutex_lock( &p_playlist->object_lock );
70 if( playlist_IsEmpty( p_playlist ) )
72 vlc_mutex_unlock( &p_playlist->object_lock );
73 vlc_object_release( p_playlist );
74 [o_main intfOpenFileGeneric: (id)sender];
78 vlc_mutex_unlock( &p_playlist->object_lock );
79 vlc_object_release( p_playlist );
82 val.i_int = config_GetInt( p_intf, "key-play-pause" );
83 var_Set( p_intf->p_libvlc, "key-pressed", val );
86 /* Small helper method */
92 id o_embedded_vout_list = [[VLCMain sharedInstance] getEmbeddedList];
93 NSEnumerator *o_enumerator = [[NSApp orderedWindows] objectEnumerator];
94 while( !o_vout_view && ( o_window = [o_enumerator nextObject] ) )
96 /* We have an embedded vout */
97 if( [o_embedded_vout_list windowContainsEmbedded: o_window] )
99 o_vout_view = [o_embedded_vout_list getViewForWindow: o_window];
101 /* We have a detached vout */
102 else if( [[o_window className] isEqualToString: @"VLCWindow"] )
104 msg_Dbg( VLCIntf, "detached vout controls.m call getVoutView" );
105 o_vout_view = [o_window getVoutView];
112 - (IBAction)stop:(id)sender
115 intf_thread_t * p_intf = VLCIntf;
116 val.i_int = config_GetInt( p_intf, "key-stop" );
117 var_Set( p_intf->p_libvlc, "key-pressed", val );
120 - (IBAction)faster:(id)sender
123 intf_thread_t * p_intf = VLCIntf;
124 val.i_int = config_GetInt( p_intf, "key-faster" );
125 var_Set( p_intf->p_libvlc, "key-pressed", val );
128 - (IBAction)slower:(id)sender
131 intf_thread_t * p_intf = VLCIntf;
132 val.i_int = config_GetInt( p_intf, "key-slower" );
133 var_Set( p_intf->p_libvlc, "key-pressed", val );
136 - (IBAction)prev:(id)sender
139 intf_thread_t * p_intf = VLCIntf;
140 val.i_int = config_GetInt( p_intf, "key-prev" );
141 var_Set( p_intf->p_libvlc, "key-pressed", val );
144 - (IBAction)next:(id)sender
147 intf_thread_t * p_intf = VLCIntf;
148 val.i_int = config_GetInt( p_intf, "key-next" );
149 var_Set( p_intf->p_libvlc, "key-pressed", val );
152 - (IBAction)random:(id)sender
155 intf_thread_t * p_intf = VLCIntf;
156 playlist_t * p_playlist = pl_Yield( p_intf );
158 var_Get( p_playlist, "random", &val );
159 val.b_bool = !val.b_bool;
160 var_Set( p_playlist, "random", val );
163 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Random On" ) );
164 config_PutInt( p_playlist, "random", 1 );
168 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Random Off" ) );
169 config_PutInt( p_playlist, "random", 0 );
172 p_intf->p_sys->b_playmode_update = VLC_TRUE;
173 p_intf->p_sys->b_intf_update = VLC_TRUE;
174 vlc_object_release( p_playlist );
177 /* three little ugly helpers */
180 [o_btn_repeat setImage: [NSImage imageNamed:@"repeat_single_embedded_blue"]];
181 [o_btn_repeat setAlternateImage: [NSImage imageNamed:@"repeat_embedded_blue"]];
185 [o_btn_repeat setImage: [NSImage imageNamed:@"repeat_embedded_blue"]];
186 [o_btn_repeat setAlternateImage: [NSImage imageNamed:@"repeat_embedded"]];
190 [o_btn_repeat setImage: [NSImage imageNamed:@"repeat_embedded"]];
191 [o_btn_repeat setAlternateImage: [NSImage imageNamed:@"repeat_single_embedded_blue"]];
196 playlist_t *p_playlist = pl_Yield( VLCIntf );
197 var_Get( p_playlist, "random", &val );
198 [o_btn_shuffle setState: val.b_bool];
199 vlc_object_release( p_playlist );
202 - (IBAction)repeatButtonAction:(id)sender
204 vlc_value_t looping,repeating;
205 intf_thread_t * p_intf = VLCIntf;
206 playlist_t * p_playlist = pl_Yield( p_intf );
208 var_Get( p_playlist, "repeat", &repeating );
209 var_Get( p_playlist, "loop", &looping );
211 if( !repeating.b_bool && !looping.b_bool )
213 /* was: no repeating at all, switching to Repeat One */
215 /* set our button's look */
218 /* prepare core communication */
219 repeating.b_bool = VLC_TRUE;
220 looping.b_bool = VLC_FALSE;
221 config_PutInt( p_playlist, "repeat", 1 );
222 config_PutInt( p_playlist, "loop", 0 );
224 /* show the change */
225 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
227 else if( repeating.b_bool && !looping.b_bool )
229 /* was: Repeat One, switching to Repeat All */
231 /* set our button's look */
234 /* prepare core communication */
235 repeating.b_bool = VLC_FALSE;
236 looping.b_bool = VLC_TRUE;
237 config_PutInt( p_playlist, "repeat", 0 );
238 config_PutInt( p_playlist, "loop", 1 );
240 /* show the change */
241 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
245 /* was: Repeat All or bug in VLC, switching to Repeat Off */
247 /* set our button's look */
250 /* prepare core communication */
251 repeating.b_bool = VLC_FALSE;
252 looping.b_bool = VLC_FALSE;
253 config_PutInt( p_playlist, "repeat", 0 );
254 config_PutInt( p_playlist, "loop", 0 );
256 /* show the change */
257 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
260 /* communicate with core and the main intf loop */
261 var_Set( p_playlist, "repeat", repeating );
262 var_Set( p_playlist, "loop", looping );
263 p_intf->p_sys->b_playmode_update = VLC_TRUE;
264 p_intf->p_sys->b_intf_update = VLC_TRUE;
266 vlc_object_release( p_playlist );
270 - (IBAction)repeat:(id)sender
273 intf_thread_t * p_intf = VLCIntf;
274 playlist_t * p_playlist = pl_Yield( p_intf );
276 var_Get( p_playlist, "repeat", &val );
279 var_Set( p_playlist, "loop", val );
281 val.b_bool = !val.b_bool;
282 var_Set( p_playlist, "repeat", val );
285 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
286 config_PutInt( p_playlist, "repeat", 1 );
290 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
291 config_PutInt( p_playlist, "repeat", 0 );
294 p_intf->p_sys->b_playmode_update = VLC_TRUE;
295 p_intf->p_sys->b_intf_update = VLC_TRUE;
296 vlc_object_release( p_playlist );
299 - (IBAction)loop:(id)sender
302 intf_thread_t * p_intf = VLCIntf;
303 playlist_t * p_playlist = pl_Yield( p_intf );
305 var_Get( p_playlist, "loop", &val );
308 var_Set( p_playlist, "repeat", val );
310 val.b_bool = !val.b_bool;
311 var_Set( p_playlist, "loop", val );
314 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
315 config_PutInt( p_playlist, "loop", 1 );
319 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
320 config_PutInt( p_playlist, "loop", 0 );
323 p_intf->p_sys->b_playmode_update = VLC_TRUE;
324 p_intf->p_sys->b_intf_update = VLC_TRUE;
325 vlc_object_release( p_playlist );
328 - (IBAction)forward:(id)sender
331 intf_thread_t * p_intf = VLCIntf;
332 val.i_int = config_GetInt( p_intf, "key-jump+short" );
333 var_Set( p_intf->p_libvlc, "key-pressed", val );
336 - (IBAction)backward:(id)sender
339 intf_thread_t * p_intf = VLCIntf;
340 val.i_int = config_GetInt( p_intf, "key-jump-short" );
341 var_Set( p_intf->p_libvlc, "key-pressed", val );
345 - (IBAction)volumeUp:(id)sender
348 intf_thread_t * p_intf = VLCIntf;
349 val.i_int = config_GetInt( p_intf, "key-vol-up" );
350 var_Set( p_intf->p_libvlc, "key-pressed", val );
351 /* Manage volume status */
352 [o_main manageVolumeSlider];
355 - (IBAction)volumeDown:(id)sender
358 intf_thread_t * p_intf = VLCIntf;
359 val.i_int = config_GetInt( p_intf, "key-vol-down" );
360 var_Set( p_intf->p_libvlc, "key-pressed", val );
361 /* Manage volume status */
362 [o_main manageVolumeSlider];
365 - (IBAction)mute:(id)sender
368 intf_thread_t * p_intf = VLCIntf;
369 val.i_int = config_GetInt( p_intf, "key-vol-mute" );
370 var_Set( p_intf->p_libvlc, "key-pressed", val );
371 /* Manage volume status */
372 [o_main manageVolumeSlider];
375 - (IBAction)volumeSliderUpdated:(id)sender
377 intf_thread_t * p_intf = VLCIntf;
378 audio_volume_t i_volume = (audio_volume_t)[sender intValue];
379 int i_volume_step = 0;
380 i_volume_step = config_GetInt( p_intf->p_libvlc, "volume-step" );
381 aout_VolumeSet( p_intf, i_volume * i_volume_step );
382 /* Manage volume status */
383 [o_main manageVolumeSlider];
386 - (IBAction)showPosition: (id)sender
388 vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
393 intf_thread_t * p_intf = VLCIntf;
394 val.i_int = config_GetInt( p_intf, "key-position" );
395 var_Set( p_intf, "key-pressed", val );
399 - (IBAction)toogleFullscreen:(id)sender {
400 NSMenuItem *o_mi = [[NSMenuItem alloc] initWithTitle: _NS("Fullscreen") action: nil keyEquivalent:@""];
401 [self windowAction: [o_mi autorelease]];
404 - (BOOL) isFullscreen {
405 id o_vout_view = [self getVoutView];
408 return [o_vout_view isFullscreen];
413 - (IBAction)windowAction:(id)sender
415 NSString *o_title = [sender title];
417 vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
421 id o_vout_view = [self getVoutView];
424 if( [o_title isEqualToString: _NS("Half Size") ] )
425 [o_vout_view scaleWindowWithFactor: 0.5 animate: YES];
426 else if( [o_title isEqualToString: _NS("Normal Size") ] )
427 [o_vout_view scaleWindowWithFactor: 1.0 animate: YES];
428 else if( [o_title isEqualToString: _NS("Double Size") ] )
429 [o_vout_view scaleWindowWithFactor: 2.0 animate: YES];
430 else if( [o_title isEqualToString: _NS("Float on Top") ] )
431 [o_vout_view toggleFloatOnTop];
432 else if( [o_title isEqualToString: _NS("Fit to Screen") ] )
434 id o_window = [o_vout_view getWindow];
435 if( ![o_window isZoomed] )
436 [o_window performZoom:self];
438 else if( [o_title isEqualToString: _NS("Snapshot") ] )
440 [o_vout_view snapshot];
444 [o_vout_view toggleFullscreen];
447 vlc_object_release( (vlc_object_t *)p_vout );
451 playlist_t * p_playlist = pl_Yield( VLCIntf );
453 if( [o_title isEqualToString: _NS("Fullscreen")] ||
454 [sender isKindOfClass:[NSButton class]] )
457 var_Get( p_playlist, "fullscreen", &val );
458 var_Set( p_playlist, "fullscreen", (vlc_value_t)!val.b_bool );
461 vlc_object_release( p_playlist );
466 - (BOOL)keyEvent:(NSEvent *)o_event
468 BOOL eventHandled = NO;
469 unichar key = [[o_event charactersIgnoringModifiers] characterAtIndex: 0];
473 vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
478 if( key == (unichar) 0x1b )
480 id o_vout_view = [self getVoutView];
481 if( o_vout_view && [o_vout_view isFullscreen] )
483 [o_vout_view toggleFullscreen];
487 else if( key == ' ' )
492 vlc_object_release( (vlc_object_t *)p_vout );
498 - (void)setupVarMenuItem:(NSMenuItem *)o_mi
499 target:(vlc_object_t *)p_object
500 var:(const char *)psz_variable
501 selector:(SEL)pf_callback
503 vlc_value_t val, text;
504 int i_type = var_Type( p_object, psz_variable );
506 switch( i_type & VLC_VAR_TYPE )
510 case VLC_VAR_VARIABLE:
512 case VLC_VAR_INTEGER:
515 /* Variable doesn't exist or isn't handled */
519 /* Make sure we want to display the variable */
520 if( i_type & VLC_VAR_HASCHOICE )
522 var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
523 if( val.i_int == 0 ) return;
524 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
528 /* Get the descriptive name of the variable */
529 var_Change( p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL );
530 [o_mi setTitle: [[VLCMain sharedInstance] localizedString: text.psz_string ?
531 text.psz_string : strdup( psz_variable ) ]];
533 var_Get( p_object, psz_variable, &val );
534 if( i_type & VLC_VAR_HASCHOICE )
536 NSMenu *o_menu = [o_mi submenu];
538 [self setupVarMenu: o_menu forMenuItem: o_mi target:p_object
539 var:psz_variable selector:pf_callback];
541 if( text.psz_string ) free( text.psz_string );
546 switch( i_type & VLC_VAR_TYPE )
549 o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
550 Value: val ofType: i_type];
551 [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
555 o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
556 Value: val ofType: i_type];
557 [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
558 if( !( i_type & VLC_VAR_ISCOMMAND ) )
559 [o_mi setState: val.b_bool ? TRUE : FALSE ];
563 if( text.psz_string ) free( text.psz_string );
567 if( ( i_type & VLC_VAR_TYPE ) == VLC_VAR_STRING ) free( val.psz_string );
568 if( text.psz_string ) free( text.psz_string );
572 - (void)setupVarMenu:(NSMenu *)o_menu
573 forMenuItem: (NSMenuItem *)o_parent
574 target:(vlc_object_t *)p_object
575 var:(const char *)psz_variable
576 selector:(SEL)pf_callback
578 vlc_value_t val, val_list, text_list;
579 int i_type, i, i_nb_items;
581 /* remove previous items */
582 i_nb_items = [o_menu numberOfItems];
583 for( i = 0; i < i_nb_items; i++ )
585 [o_menu removeItemAtIndex: 0];
588 /* Check the type of the object variable */
589 i_type = var_Type( p_object, psz_variable );
591 /* Make sure we want to display the variable */
592 if( i_type & VLC_VAR_HASCHOICE )
594 var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
595 if( val.i_int == 0 ) return;
596 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
604 switch( i_type & VLC_VAR_TYPE )
608 case VLC_VAR_VARIABLE:
610 case VLC_VAR_INTEGER:
613 /* Variable doesn't exist or isn't handled */
617 if( var_Get( p_object, psz_variable, &val ) < 0 )
622 if( var_Change( p_object, psz_variable, VLC_VAR_GETLIST,
623 &val_list, &text_list ) < 0 )
625 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
629 /* make (un)sensitive */
630 [o_parent setEnabled: ( val_list.p_list->i_count > 1 )];
632 for( i = 0; i < val_list.p_list->i_count; i++ )
634 vlc_value_t another_val;
636 NSString *o_title = @"";
639 switch( i_type & VLC_VAR_TYPE )
642 another_val.psz_string =
643 strdup(val_list.p_list->p_values[i].psz_string);
645 o_title = [[VLCMain sharedInstance] localizedString: text_list.p_list->p_values[i].psz_string ?
646 text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string ];
648 o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
649 o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
650 Value: another_val ofType: i_type];
651 [o_lmi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
652 [o_lmi setTarget: self];
654 if( !strcmp( val.psz_string, val_list.p_list->p_values[i].psz_string ) && !( i_type & VLC_VAR_ISCOMMAND ) )
655 [o_lmi setState: TRUE ];
659 case VLC_VAR_INTEGER:
661 o_title = text_list.p_list->p_values[i].psz_string ?
662 [[VLCMain sharedInstance] localizedString: strdup( text_list.p_list->p_values[i].psz_string )] :
663 [NSString stringWithFormat: @"%d",
664 val_list.p_list->p_values[i].i_int];
666 o_lmi = [[o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""] retain ];
667 o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
668 Value: val_list.p_list->p_values[i] ofType: i_type];
669 [o_lmi setRepresentedObject: [NSValue valueWithPointer:[ o_data retain]]];
670 [o_lmi setTarget: self];
672 if( val_list.p_list->p_values[i].i_int == val.i_int && !( i_type & VLC_VAR_ISCOMMAND ) )
673 [o_lmi setState: TRUE ];
681 /* clean up everything */
682 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
683 var_Change( p_object, psz_variable, VLC_VAR_FREELIST, &val_list, &text_list );
686 - (IBAction)toggleVar:(id)sender
688 NSMenuItem *o_mi = (NSMenuItem *)sender;
689 VLCMenuExt *o_data = [[o_mi representedObject] pointerValue];
690 [NSThread detachNewThreadSelector: @selector(toggleVarThread:)
691 toTarget: self withObject: o_data];
696 - (int)toggleVarThread: (id)_o_data
698 vlc_object_t *p_object;
699 NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
700 VLCMenuExt *o_data = (VLCMenuExt *)_o_data;
702 vlc_thread_set_priority( VLCIntf , VLC_THREAD_PRIORITY_LOW );
704 p_object = (vlc_object_t *)vlc_object_get( VLCIntf,
707 if( p_object != NULL )
709 var_Set( p_object, strdup([o_data name]), [o_data value] );
710 vlc_object_release( p_object );
718 - (IBAction)goToSpecificTime:(id)sender
720 if( sender == o_specificTime_cancel_btn )
722 [NSApp endSheet: o_specificTime_win];
723 [o_specificTime_win close];
725 else if( sender == o_specificTime_ok_btn )
727 input_thread_t * p_input = (input_thread_t *)vlc_object_find( VLCIntf, \
728 VLC_OBJECT_INPUT, FIND_ANYWHERE );
731 unsigned int timeInSec = 0;
732 NSString * fieldContent = [o_specificTime_enter_fld stringValue];
733 if( [[fieldContent componentsSeparatedByString: @":"] count] > 1 &&
734 [[fieldContent componentsSeparatedByString: @":"] count] <= 3 )
736 NSArray * ourTempArray = \
737 [fieldContent componentsSeparatedByString: @":"];
739 if( [[fieldContent componentsSeparatedByString: @":"] count] == 3 )
741 timeInSec += ([[ourTempArray objectAtIndex: 0] intValue] * 3600); //h
742 timeInSec += ([[ourTempArray objectAtIndex: 1] intValue] * 60); //m
743 timeInSec += [[ourTempArray objectAtIndex: 2] intValue]; //s
747 timeInSec += ([[ourTempArray objectAtIndex: 0] intValue] * 60); //m
748 timeInSec += [[ourTempArray objectAtIndex: 1] intValue]; //s
752 timeInSec = [fieldContent intValue];
754 input_Control( p_input, INPUT_SET_TIME, (int64_t)(timeInSec * 1000000));
755 vlc_object_release( p_input );
758 [NSApp endSheet: o_specificTime_win];
759 [o_specificTime_win close];
763 input_thread_t * p_input = (input_thread_t *)vlc_object_find( VLCIntf, \
764 VLC_OBJECT_INPUT, FIND_ANYWHERE );
767 /* we can obviously only do that if an input is available */
768 vlc_value_t pos, length;
769 var_Get( p_input, "time", &pos );
770 [o_specificTime_enter_fld setIntValue: (pos.i_time / 1000000)];
771 var_Get( p_input, "length", &length );
772 [o_specificTime_stepper setMaxValue: (length.i_time / 1000000)];
774 [NSApp beginSheet: o_specificTime_win modalForWindow: \
775 [NSApp mainWindow] modalDelegate: self didEndSelector: nil \
777 [o_specificTime_win makeKeyWindow];
778 vlc_object_release( p_input );
789 msg_Err( VLCIntf, "FSPanel is nil" );
796 @implementation VLCControls (NSMenuValidation)
798 - (BOOL)validateMenuItem:(NSMenuItem *)o_mi
800 BOOL bEnabled = TRUE;
802 intf_thread_t * p_intf = VLCIntf;
803 playlist_t * p_playlist = pl_Yield( p_intf );
805 vlc_mutex_lock( &p_playlist->object_lock );
807 #define p_input p_playlist->p_input
809 if( [[o_mi title] isEqualToString: _NS("Faster")] ||
810 [[o_mi title] isEqualToString: _NS("Slower")] )
812 if( p_input != NULL )
814 bEnabled = p_input->b_can_pace_control;
821 else if( [[o_mi title] isEqualToString: _NS("Stop")] )
823 if( p_input == NULL )
827 [o_main setupMenus]; /* Make sure input menu is up to date */
829 else if( [[o_mi title] isEqualToString: _NS("Previous")] ||
830 [[o_mi title] isEqualToString: _NS("Next")] )
832 /** \todo fix i_size use */
833 bEnabled = p_playlist->items.i_size > 1;
835 else if( [[o_mi title] isEqualToString: _NS("Random")] )
838 var_Get( p_playlist, "random", &val );
839 i_state = val.b_bool ? NSOnState : NSOffState;
840 [o_mi setState: i_state];
842 else if( [[o_mi title] isEqualToString: _NS("Repeat One")] )
845 var_Get( p_playlist, "repeat", &val );
846 i_state = val.b_bool ? NSOnState : NSOffState;
847 [o_mi setState: i_state];
849 else if( [[o_mi title] isEqualToString: _NS("Repeat All")] )
852 var_Get( p_playlist, "loop", &val );
853 i_state = val.b_bool ? NSOnState : NSOffState;
854 [o_mi setState: i_state];
856 else if( [[o_mi title] isEqualToString: _NS("Step Forward")] ||
857 [[o_mi title] isEqualToString: _NS("Step Backward")] ||
858 [[o_mi title] isEqualToString: _NS("Jump To Time")])
860 if( p_input != NULL )
862 var_Get( p_input, "seekable", &val);
863 bEnabled = val.b_bool;
865 else bEnabled = FALSE;
867 else if( [[o_mi title] isEqualToString: _NS("Mute")] )
869 [o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState];
870 [o_main setupMenus]; /* Make sure audio menu is up to date */
872 else if( [[o_mi title] isEqualToString: _NS("Half Size")] ||
873 [[o_mi title] isEqualToString: _NS("Normal Size")] ||
874 [[o_mi title] isEqualToString: _NS("Double Size")] ||
875 [[o_mi title] isEqualToString: _NS("Fit to Screen")] ||
876 [[o_mi title] isEqualToString: _NS("Snapshot")] ||
877 [[o_mi title] isEqualToString: _NS("Fullscreen")] ||
878 [[o_mi title] isEqualToString: _NS("Float on Top")] )
881 NSArray *o_windows = [NSApp orderedWindows];
882 NSEnumerator *o_enumerator = [o_windows objectEnumerator];
885 vout_thread_t *p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
889 if( [[o_mi title] isEqualToString: _NS("Float on Top")] )
891 var_Get( p_vout, "video-on-top", &val );
892 [o_mi setState: val.b_bool ? NSOnState : NSOffState];
895 while( (o_window = [o_enumerator nextObject]))
897 if( [[o_window className] isEqualToString: @"VLCWindow"] ||
898 [[[VLCMain sharedInstance] getEmbeddedList]
899 windowContainsEmbedded: o_window])
905 vlc_object_release( (vlc_object_t *)p_vout );
907 else if( [[o_mi title] isEqualToString: _NS("Fullscreen")] )
909 var_Get( p_playlist, "fullscreen", &val );
910 [o_mi setState: val.b_bool];
913 [o_main setupMenus]; /* Make sure video menu is up to date */
916 vlc_mutex_unlock( &p_playlist->object_lock );
917 vlc_object_release( p_playlist );
924 /*****************************************************************************
925 * VLCMenuExt implementation
926 *****************************************************************************
927 * Object connected to a playlistitem which remembers the data belonging to
928 * the variable of the autogenerated menu
929 *****************************************************************************/
930 @implementation VLCMenuExt
932 - (id)initWithVar: (const char *)_psz_name Object: (int)i_id
933 Value: (vlc_value_t)val ofType: (int)_i_type
939 psz_name = strdup( _psz_name );
977 /*****************************************************************************
978 * VLCTimeField implementation
979 *****************************************************************************
980 * we need this to catch our click-event in the controller window
981 *****************************************************************************/
983 @implementation VLCTimeField
984 - (void)mouseDown: (NSEvent *)ourEvent
986 if( [ourEvent clickCount] > 1 )
987 [[[VLCMain sharedInstance] getControls] goToSpecificTime: nil];