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: @"VLCVoutWindow"] )
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 );
396 vlc_object_release( (vlc_object_t *)p_vout );
400 - (IBAction)toogleFullscreen:(id)sender {
401 NSMenuItem *o_mi = [[NSMenuItem alloc] initWithTitle: _NS("Fullscreen") action: nil keyEquivalent:@""];
402 [self windowAction: [o_mi autorelease]];
405 - (BOOL) isFullscreen {
406 id o_vout_view = [self getVoutView];
409 return [o_vout_view isFullscreen];
414 - (IBAction)windowAction:(id)sender
416 NSString *o_title = [sender title];
418 vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
422 id o_vout_view = [self getVoutView];
425 if( [o_title isEqualToString: _NS("Half Size") ] )
426 [o_vout_view scaleWindowWithFactor: 0.5 animate: YES];
427 else if( [o_title isEqualToString: _NS("Normal Size") ] )
428 [o_vout_view scaleWindowWithFactor: 1.0 animate: YES];
429 else if( [o_title isEqualToString: _NS("Double Size") ] )
430 [o_vout_view scaleWindowWithFactor: 2.0 animate: YES];
431 else if( [o_title isEqualToString: _NS("Float on Top") ] )
432 [o_vout_view toggleFloatOnTop];
433 else if( [o_title isEqualToString: _NS("Fit to Screen") ] )
435 id o_window = [o_vout_view getWindow];
436 if( ![o_window isZoomed] )
437 [o_window performZoom:self];
439 else if( [o_title isEqualToString: _NS("Snapshot") ] )
441 [o_vout_view snapshot];
445 [o_vout_view toggleFullscreen];
448 vlc_object_release( (vlc_object_t *)p_vout );
452 playlist_t * p_playlist = pl_Yield( VLCIntf );
454 if( [o_title isEqualToString: _NS("Fullscreen")] ||
455 [sender isKindOfClass:[NSButton class]] )
458 var_Get( p_playlist, "fullscreen", &val );
459 var_Set( p_playlist, "fullscreen", (vlc_value_t)!val.b_bool );
462 vlc_object_release( p_playlist );
467 - (BOOL)keyEvent:(NSEvent *)o_event
469 BOOL eventHandled = NO;
470 unichar key = [[o_event charactersIgnoringModifiers] characterAtIndex: 0];
474 vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
479 if( key == (unichar) 0x1b )
481 id o_vout_view = [self getVoutView];
482 if( o_vout_view && [o_vout_view isFullscreen] )
484 [o_vout_view toggleFullscreen];
488 else if( key == ' ' )
493 vlc_object_release( (vlc_object_t *)p_vout );
499 - (void)setupVarMenuItem:(NSMenuItem *)o_mi
500 target:(vlc_object_t *)p_object
501 var:(const char *)psz_variable
502 selector:(SEL)pf_callback
504 vlc_value_t val, text;
505 int i_type = var_Type( p_object, psz_variable );
507 switch( i_type & VLC_VAR_TYPE )
511 case VLC_VAR_VARIABLE:
513 case VLC_VAR_INTEGER:
516 /* Variable doesn't exist or isn't handled */
520 /* Make sure we want to display the variable */
521 if( i_type & VLC_VAR_HASCHOICE )
523 var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
524 if( val.i_int == 0 ) return;
525 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
529 /* Get the descriptive name of the variable */
530 var_Change( p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL );
531 [o_mi setTitle: [[VLCMain sharedInstance] localizedString: text.psz_string ?
532 text.psz_string : strdup( psz_variable ) ]];
534 var_Get( p_object, psz_variable, &val );
535 if( i_type & VLC_VAR_HASCHOICE )
537 NSMenu *o_menu = [o_mi submenu];
539 [self setupVarMenu: o_menu forMenuItem: o_mi target:p_object
540 var:psz_variable selector:pf_callback];
542 if( text.psz_string ) free( text.psz_string );
547 switch( i_type & VLC_VAR_TYPE )
550 o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
551 Value: val ofType: i_type];
552 [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
556 o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
557 Value: val ofType: i_type];
558 [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
559 if( !( i_type & VLC_VAR_ISCOMMAND ) )
560 [o_mi setState: val.b_bool ? TRUE : FALSE ];
564 if( text.psz_string ) free( text.psz_string );
568 if( ( i_type & VLC_VAR_TYPE ) == VLC_VAR_STRING ) free( val.psz_string );
569 if( text.psz_string ) free( text.psz_string );
573 - (void)setupVarMenu:(NSMenu *)o_menu
574 forMenuItem: (NSMenuItem *)o_parent
575 target:(vlc_object_t *)p_object
576 var:(const char *)psz_variable
577 selector:(SEL)pf_callback
579 vlc_value_t val, val_list, text_list;
580 int i_type, i, i_nb_items;
582 /* remove previous items */
583 i_nb_items = [o_menu numberOfItems];
584 for( i = 0; i < i_nb_items; i++ )
586 [o_menu removeItemAtIndex: 0];
589 /* Check the type of the object variable */
590 i_type = var_Type( p_object, psz_variable );
592 /* Make sure we want to display the variable */
593 if( i_type & VLC_VAR_HASCHOICE )
595 var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
596 if( val.i_int == 0 ) return;
597 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
605 switch( i_type & VLC_VAR_TYPE )
609 case VLC_VAR_VARIABLE:
611 case VLC_VAR_INTEGER:
614 /* Variable doesn't exist or isn't handled */
618 if( var_Get( p_object, psz_variable, &val ) < 0 )
623 if( var_Change( p_object, psz_variable, VLC_VAR_GETLIST,
624 &val_list, &text_list ) < 0 )
626 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
630 /* make (un)sensitive */
631 [o_parent setEnabled: ( val_list.p_list->i_count > 1 )];
633 for( i = 0; i < val_list.p_list->i_count; i++ )
635 vlc_value_t another_val;
637 NSString *o_title = @"";
640 switch( i_type & VLC_VAR_TYPE )
643 another_val.psz_string =
644 strdup(val_list.p_list->p_values[i].psz_string);
646 o_title = [[VLCMain sharedInstance] localizedString: text_list.p_list->p_values[i].psz_string ?
647 text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string ];
649 o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
650 o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
651 Value: another_val ofType: i_type];
652 [o_lmi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
653 [o_lmi setTarget: self];
655 if( !strcmp( val.psz_string, val_list.p_list->p_values[i].psz_string ) && !( i_type & VLC_VAR_ISCOMMAND ) )
656 [o_lmi setState: TRUE ];
660 case VLC_VAR_INTEGER:
662 o_title = text_list.p_list->p_values[i].psz_string ?
663 [[VLCMain sharedInstance] localizedString: strdup( text_list.p_list->p_values[i].psz_string )] :
664 [NSString stringWithFormat: @"%d",
665 val_list.p_list->p_values[i].i_int];
667 o_lmi = [[o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""] retain ];
668 o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
669 Value: val_list.p_list->p_values[i] ofType: i_type];
670 [o_lmi setRepresentedObject: [NSValue valueWithPointer:[ o_data retain]]];
671 [o_lmi setTarget: self];
673 if( val_list.p_list->p_values[i].i_int == val.i_int && !( i_type & VLC_VAR_ISCOMMAND ) )
674 [o_lmi setState: TRUE ];
682 /* clean up everything */
683 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
684 var_Change( p_object, psz_variable, VLC_VAR_FREELIST, &val_list, &text_list );
687 - (IBAction)toggleVar:(id)sender
689 NSMenuItem *o_mi = (NSMenuItem *)sender;
690 VLCMenuExt *o_data = [[o_mi representedObject] pointerValue];
691 [NSThread detachNewThreadSelector: @selector(toggleVarThread:)
692 toTarget: self withObject: o_data];
697 - (int)toggleVarThread: (id)_o_data
699 vlc_object_t *p_object;
700 NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
701 VLCMenuExt *o_data = (VLCMenuExt *)_o_data;
703 vlc_thread_set_priority( VLCIntf , VLC_THREAD_PRIORITY_LOW );
705 p_object = (vlc_object_t *)vlc_object_get( VLCIntf,
708 if( p_object != NULL )
710 var_Set( p_object, strdup([o_data name]), [o_data value] );
711 vlc_object_release( p_object );
719 - (IBAction)goToSpecificTime:(id)sender
721 if( sender == o_specificTime_cancel_btn )
723 [NSApp endSheet: o_specificTime_win];
724 [o_specificTime_win close];
726 else if( sender == o_specificTime_ok_btn )
728 input_thread_t * p_input = (input_thread_t *)vlc_object_find( VLCIntf, \
729 VLC_OBJECT_INPUT, FIND_ANYWHERE );
732 unsigned int timeInSec = 0;
733 NSString * fieldContent = [o_specificTime_enter_fld stringValue];
734 if( [[fieldContent componentsSeparatedByString: @":"] count] > 1 &&
735 [[fieldContent componentsSeparatedByString: @":"] count] <= 3 )
737 NSArray * ourTempArray = \
738 [fieldContent componentsSeparatedByString: @":"];
740 if( [[fieldContent componentsSeparatedByString: @":"] count] == 3 )
742 timeInSec += ([[ourTempArray objectAtIndex: 0] intValue] * 3600); //h
743 timeInSec += ([[ourTempArray objectAtIndex: 1] intValue] * 60); //m
744 timeInSec += [[ourTempArray objectAtIndex: 2] intValue]; //s
748 timeInSec += ([[ourTempArray objectAtIndex: 0] intValue] * 60); //m
749 timeInSec += [[ourTempArray objectAtIndex: 1] intValue]; //s
753 timeInSec = [fieldContent intValue];
755 input_Control( p_input, INPUT_SET_TIME, (int64_t)(timeInSec * 1000000));
756 vlc_object_release( p_input );
759 [NSApp endSheet: o_specificTime_win];
760 [o_specificTime_win close];
764 input_thread_t * p_input = (input_thread_t *)vlc_object_find( VLCIntf, \
765 VLC_OBJECT_INPUT, FIND_ANYWHERE );
768 /* we can obviously only do that if an input is available */
769 vlc_value_t pos, length;
770 var_Get( p_input, "time", &pos );
771 [o_specificTime_enter_fld setIntValue: (pos.i_time / 1000000)];
772 var_Get( p_input, "length", &length );
773 [o_specificTime_stepper setMaxValue: (length.i_time / 1000000)];
775 [NSApp beginSheet: o_specificTime_win modalForWindow: \
776 [NSApp mainWindow] modalDelegate: self didEndSelector: nil \
778 [o_specificTime_win makeKeyWindow];
779 vlc_object_release( p_input );
790 msg_Err( VLCIntf, "FSPanel is nil" );
797 @implementation VLCControls (NSMenuValidation)
799 - (BOOL)validateMenuItem:(NSMenuItem *)o_mi
801 BOOL bEnabled = TRUE;
803 intf_thread_t * p_intf = VLCIntf;
804 playlist_t * p_playlist = pl_Yield( p_intf );
806 vlc_mutex_lock( &p_playlist->object_lock );
808 #define p_input p_playlist->p_input
810 if( [[o_mi title] isEqualToString: _NS("Faster")] ||
811 [[o_mi title] isEqualToString: _NS("Slower")] )
813 if( p_input != NULL )
815 bEnabled = p_input->b_can_pace_control;
822 else if( [[o_mi title] isEqualToString: _NS("Stop")] )
824 if( p_input == NULL )
828 [o_main setupMenus]; /* Make sure input menu is up to date */
830 else if( [[o_mi title] isEqualToString: _NS("Previous")] ||
831 [[o_mi title] isEqualToString: _NS("Next")] )
833 /** \todo fix i_size use */
834 bEnabled = p_playlist->items.i_size > 1;
836 else if( [[o_mi title] isEqualToString: _NS("Random")] )
839 var_Get( p_playlist, "random", &val );
840 i_state = val.b_bool ? NSOnState : NSOffState;
841 [o_mi setState: i_state];
843 else if( [[o_mi title] isEqualToString: _NS("Repeat One")] )
846 var_Get( p_playlist, "repeat", &val );
847 i_state = val.b_bool ? NSOnState : NSOffState;
848 [o_mi setState: i_state];
850 else if( [[o_mi title] isEqualToString: _NS("Repeat All")] )
853 var_Get( p_playlist, "loop", &val );
854 i_state = val.b_bool ? NSOnState : NSOffState;
855 [o_mi setState: i_state];
857 else if( [[o_mi title] isEqualToString: _NS("Step Forward")] ||
858 [[o_mi title] isEqualToString: _NS("Step Backward")] ||
859 [[o_mi title] isEqualToString: _NS("Jump To Time")])
861 if( p_input != NULL )
863 var_Get( p_input, "seekable", &val);
864 bEnabled = val.b_bool;
866 else bEnabled = FALSE;
868 else if( [[o_mi title] isEqualToString: _NS("Mute")] )
870 [o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState];
871 [o_main setupMenus]; /* Make sure audio menu is up to date */
873 else if( [[o_mi title] isEqualToString: _NS("Half Size")] ||
874 [[o_mi title] isEqualToString: _NS("Normal Size")] ||
875 [[o_mi title] isEqualToString: _NS("Double Size")] ||
876 [[o_mi title] isEqualToString: _NS("Fit to Screen")] ||
877 [[o_mi title] isEqualToString: _NS("Snapshot")] ||
878 [[o_mi title] isEqualToString: _NS("Fullscreen")] ||
879 [[o_mi title] isEqualToString: _NS("Float on Top")] )
882 NSArray *o_windows = [NSApp orderedWindows];
883 NSEnumerator *o_enumerator = [o_windows objectEnumerator];
886 vout_thread_t *p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
890 if( [[o_mi title] isEqualToString: _NS("Float on Top")] )
892 var_Get( p_vout, "video-on-top", &val );
893 [o_mi setState: val.b_bool ? NSOnState : NSOffState];
896 while( (o_window = [o_enumerator nextObject]))
898 if( [[o_window className] isEqualToString: @"VLCVoutWindow"] ||
899 [[[VLCMain sharedInstance] getEmbeddedList]
900 windowContainsEmbedded: o_window])
906 vlc_object_release( (vlc_object_t *)p_vout );
908 else if( [[o_mi title] isEqualToString: _NS("Fullscreen")] )
910 var_Get( p_playlist, "fullscreen", &val );
911 [o_mi setState: val.b_bool];
914 [o_main setupMenus]; /* Make sure video menu is up to date */
917 vlc_mutex_unlock( &p_playlist->object_lock );
918 vlc_object_release( p_playlist );
925 /*****************************************************************************
926 * VLCMenuExt implementation
927 *****************************************************************************
928 * Object connected to a playlistitem which remembers the data belonging to
929 * the variable of the autogenerated menu
930 *****************************************************************************/
931 @implementation VLCMenuExt
933 - (id)initWithVar: (const char *)_psz_name Object: (int)i_id
934 Value: (vlc_value_t)val ofType: (int)_i_type
940 psz_name = strdup( _psz_name );
978 /*****************************************************************************
979 * VLCTimeField implementation
980 *****************************************************************************
981 * we need this to catch our click-event in the controller window
982 *****************************************************************************/
984 @implementation VLCTimeField
985 - (void)mouseDown: (NSEvent *)ourEvent
987 if( [ourEvent clickCount] > 1 )
988 [[[VLCMain sharedInstance] getControls] goToSpecificTime: nil];