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 */
43 /*****************************************************************************
44 * VLCControls implementation
45 *****************************************************************************/
46 @implementation VLCControls
51 o_fs_panel = [[VLCFSPanel alloc] init];
57 [o_specificTime_mi setTitle: _NS("Jump To Time")];
58 [o_specificTime_cancel_btn setTitle: _NS("Cancel")];
59 [o_specificTime_ok_btn setTitle: _NS("OK")];
60 [o_specificTime_sec_lbl setStringValue: _NS("sec.")];
61 [o_specificTime_goTo_lbl setStringValue: _NS("Jump to time")];
64 - (IBAction)play:(id)sender
67 intf_thread_t * p_intf = VLCIntf;
68 playlist_t * p_playlist = pl_Yield( p_intf );
70 vlc_mutex_lock( &p_playlist->object_lock );
71 if( p_playlist->i_size <= 0 )
73 vlc_mutex_unlock( &p_playlist->object_lock );
74 vlc_object_release( p_playlist );
75 [o_main intfOpenFileGeneric: (id)sender];
79 vlc_mutex_unlock( &p_playlist->object_lock );
80 vlc_object_release( p_playlist );
83 val.i_int = config_GetInt( p_intf, "key-play-pause" );
84 var_Set( p_intf->p_libvlc, "key-pressed", val );
87 /* Small helper method */
93 id o_embedded_vout_list = [[VLCMain sharedInstance] getEmbeddedList];
94 NSEnumerator *o_enumerator = [[NSApp orderedWindows] objectEnumerator];
95 while( !o_vout_view && ( o_window = [o_enumerator nextObject] ) )
97 /* We have an embedded vout */
98 if( [o_embedded_vout_list windowContainsEmbedded: o_window] )
100 o_vout_view = [o_embedded_vout_list getViewForWindow: o_window];
102 /* We have a detached vout */
103 else if( [[o_window className] isEqualToString: @"VLCWindow"] )
105 msg_Dbg( VLCIntf, "detached vout controls.m call getVoutView" );
106 o_vout_view = [o_window getVoutView];
113 - (IBAction)stop:(id)sender
116 intf_thread_t * p_intf = VLCIntf;
117 val.i_int = config_GetInt( p_intf, "key-stop" );
118 var_Set( p_intf->p_libvlc, "key-pressed", val );
121 - (IBAction)faster:(id)sender
124 intf_thread_t * p_intf = VLCIntf;
125 val.i_int = config_GetInt( p_intf, "key-faster" );
126 var_Set( p_intf->p_libvlc, "key-pressed", val );
129 - (IBAction)slower:(id)sender
132 intf_thread_t * p_intf = VLCIntf;
133 val.i_int = config_GetInt( p_intf, "key-slower" );
134 var_Set( p_intf->p_libvlc, "key-pressed", val );
137 - (IBAction)prev:(id)sender
140 intf_thread_t * p_intf = VLCIntf;
141 val.i_int = config_GetInt( p_intf, "key-prev" );
142 var_Set( p_intf->p_libvlc, "key-pressed", val );
145 - (IBAction)next:(id)sender
148 intf_thread_t * p_intf = VLCIntf;
149 val.i_int = config_GetInt( p_intf, "key-next" );
150 var_Set( p_intf->p_libvlc, "key-pressed", val );
153 - (IBAction)random:(id)sender
156 intf_thread_t * p_intf = VLCIntf;
157 playlist_t * p_playlist = pl_Yield( p_intf );
159 var_Get( p_playlist, "random", &val );
160 val.b_bool = !val.b_bool;
161 var_Set( p_playlist, "random", val );
164 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Random On" ) );
165 config_PutInt( p_playlist, "random", 1 );
169 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Random Off" ) );
170 config_PutInt( p_playlist, "random", 0 );
173 p_intf->p_sys->b_playmode_update = VLC_TRUE;
174 p_intf->p_sys->b_intf_update = VLC_TRUE;
175 vlc_object_release( p_playlist );
178 /* three little ugly helpers */
181 [o_btn_repeat setImage: [[NSImage alloc] initWithContentsOfFile:
182 [[NSBundle mainBundle] pathForImageResource:@"repeat_single_embedded_blue.png"]]];
183 [o_btn_repeat setAlternateImage: [[NSImage alloc] initWithContentsOfFile:
184 [[NSBundle mainBundle] pathForImageResource:@"repeat_embedded_blue.png"]]];
188 [o_btn_repeat setImage: [[NSImage alloc] initWithContentsOfFile:
189 [[NSBundle mainBundle] pathForImageResource:@"repeat_embedded_blue.png"]]];
190 [o_btn_repeat setAlternateImage: [[NSImage alloc] initWithContentsOfFile:
191 [[NSBundle mainBundle] pathForImageResource:@"repeat_embedded.png"]]];
195 [o_btn_repeat setImage: [[NSImage alloc] initWithContentsOfFile:
196 [[NSBundle mainBundle] pathForImageResource:@"repeat_embedded.png"]]];
197 [o_btn_repeat setAlternateImage: [[NSImage alloc] initWithContentsOfFile:
198 [[NSBundle mainBundle] pathForImageResource:@"repeat_single_embedded_blue.png"]]];
203 playlist_t *p_playlist = pl_Yield( VLCIntf );
204 var_Get( p_playlist, "random", &val );
205 [o_btn_shuffle setState: val.b_bool];
206 vlc_object_release( p_playlist );
209 - (IBAction)repeatButtonAction:(id)sender
211 vlc_value_t looping,repeating;
212 intf_thread_t * p_intf = VLCIntf;
213 playlist_t * p_playlist = pl_Yield( p_intf );
215 var_Get( p_playlist, "repeat", &repeating );
216 var_Get( p_playlist, "loop", &looping );
218 [[o_btn_repeat image] release];
219 [[o_btn_repeat alternateImage] release];
221 if( !repeating.b_bool && !looping.b_bool )
223 /* was: no repeating at all, switching to Repeat One */
225 /* set our button's look */
228 /* prepare core communication */
229 repeating.b_bool = VLC_TRUE;
230 looping.b_bool = VLC_FALSE;
231 config_PutInt( p_playlist, "repeat", 1 );
232 config_PutInt( p_playlist, "loop", 0 );
234 /* show the change */
235 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
237 else if( repeating.b_bool && !looping.b_bool )
239 /* was: Repeat One, switching to Repeat All */
241 /* set our button's look */
244 /* prepare core communication */
245 repeating.b_bool = VLC_FALSE;
246 looping.b_bool = VLC_TRUE;
247 config_PutInt( p_playlist, "repeat", 0 );
248 config_PutInt( p_playlist, "loop", 1 );
250 /* show the change */
251 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
255 /* was: Repeat All or bug in VLC, switching to Repeat Off */
257 /* set our button's look */
260 /* prepare core communication */
261 repeating.b_bool = VLC_FALSE;
262 looping.b_bool = VLC_FALSE;
263 config_PutInt( p_playlist, "repeat", 0 );
264 config_PutInt( p_playlist, "loop", 0 );
266 /* show the change */
267 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
270 /* communicate with core and the main intf loop */
271 var_Set( p_playlist, "repeat", repeating );
272 var_Set( p_playlist, "loop", looping );
273 p_intf->p_sys->b_playmode_update = VLC_TRUE;
274 p_intf->p_sys->b_intf_update = VLC_TRUE;
276 vlc_object_release( p_playlist );
280 - (IBAction)repeat:(id)sender
283 intf_thread_t * p_intf = VLCIntf;
284 playlist_t * p_playlist = pl_Yield( p_intf );
286 var_Get( p_playlist, "repeat", &val );
289 var_Set( p_playlist, "loop", val );
291 val.b_bool = !val.b_bool;
292 var_Set( p_playlist, "repeat", val );
295 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
296 config_PutInt( p_playlist, "repeat", 1 );
300 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
301 config_PutInt( p_playlist, "repeat", 0 );
304 p_intf->p_sys->b_playmode_update = VLC_TRUE;
305 p_intf->p_sys->b_intf_update = VLC_TRUE;
306 vlc_object_release( p_playlist );
309 - (IBAction)loop:(id)sender
312 intf_thread_t * p_intf = VLCIntf;
313 playlist_t * p_playlist = pl_Yield( p_intf );
315 var_Get( p_playlist, "loop", &val );
318 var_Set( p_playlist, "repeat", val );
320 val.b_bool = !val.b_bool;
321 var_Set( p_playlist, "loop", val );
324 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
325 config_PutInt( p_playlist, "loop", 1 );
329 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
330 config_PutInt( p_playlist, "loop", 0 );
333 p_intf->p_sys->b_playmode_update = VLC_TRUE;
334 p_intf->p_sys->b_intf_update = VLC_TRUE;
335 vlc_object_release( p_playlist );
338 - (IBAction)forward:(id)sender
341 intf_thread_t * p_intf = VLCIntf;
342 val.i_int = config_GetInt( p_intf, "key-jump+short" );
343 var_Set( p_intf->p_libvlc, "key-pressed", val );
346 - (IBAction)backward:(id)sender
349 intf_thread_t * p_intf = VLCIntf;
350 val.i_int = config_GetInt( p_intf, "key-jump-short" );
351 var_Set( p_intf->p_libvlc, "key-pressed", val );
355 - (IBAction)volumeUp:(id)sender
358 intf_thread_t * p_intf = VLCIntf;
359 val.i_int = config_GetInt( p_intf, "key-vol-up" );
360 var_Set( p_intf->p_libvlc, "key-pressed", val );
361 /* Manage volume status */
362 [o_main manageVolumeSlider];
365 - (IBAction)volumeDown:(id)sender
368 intf_thread_t * p_intf = VLCIntf;
369 val.i_int = config_GetInt( p_intf, "key-vol-down" );
370 var_Set( p_intf->p_libvlc, "key-pressed", val );
371 /* Manage volume status */
372 [o_main manageVolumeSlider];
375 - (IBAction)mute:(id)sender
378 intf_thread_t * p_intf = VLCIntf;
379 val.i_int = config_GetInt( p_intf, "key-vol-mute" );
380 var_Set( p_intf->p_libvlc, "key-pressed", val );
381 /* Manage volume status */
382 [o_main manageVolumeSlider];
385 - (IBAction)volumeSliderUpdated:(id)sender
387 intf_thread_t * p_intf = VLCIntf;
388 audio_volume_t i_volume = (audio_volume_t)[sender intValue];
389 int i_volume_step = 0;
390 i_volume_step = config_GetInt( p_intf->p_libvlc, "volume-step" );
391 aout_VolumeSet( p_intf, i_volume * i_volume_step );
392 /* Manage volume status */
393 [o_main manageVolumeSlider];
396 - (IBAction)windowAction:(id)sender
398 NSString *o_title = [sender title];
400 vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
404 id o_vout_view = [self getVoutView];
407 if( [o_title isEqualToString: _NS("Half Size") ] )
408 [o_vout_view scaleWindowWithFactor: 0.5];
409 else if( [o_title isEqualToString: _NS("Normal Size") ] )
410 [o_vout_view scaleWindowWithFactor: 1.0];
411 else if( [o_title isEqualToString: _NS("Double Size") ] )
412 [o_vout_view scaleWindowWithFactor: 2.0];
413 else if( [o_title isEqualToString: _NS("Float on Top") ] )
414 [o_vout_view toggleFloatOnTop];
415 else if( [o_title isEqualToString: _NS("Fit to Screen") ] )
417 id o_window = [o_vout_view getWindow];
418 if( ![o_window isZoomed] )
419 [o_window performZoom:self];
421 else if( [o_title isEqualToString: _NS("Snapshot") ] )
423 [o_vout_view snapshot];
427 [o_vout_view toggleFullscreen];
430 vlc_object_release( (vlc_object_t *)p_vout );
434 playlist_t * p_playlist = pl_Yield( VLCIntf );
436 if( [o_title isEqualToString: _NS("Fullscreen")] ||
437 [sender isKindOfClass:[NSButton class]] )
440 var_Get( p_playlist, "fullscreen", &val );
441 var_Set( p_playlist, "fullscreen", (vlc_value_t)!val.b_bool );
444 vlc_object_release( p_playlist );
449 - (BOOL)keyEvent:(NSEvent *)o_event
451 BOOL eventHandled = NO;
452 unichar key = [[o_event charactersIgnoringModifiers] characterAtIndex: 0];
456 vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
461 if( key == (unichar) 0x1b )
463 id o_vout_view = [self getVoutView];
464 if( o_vout_view && [o_vout_view isFullscreen] )
466 [o_vout_view toggleFullscreen];
470 else if( key == ' ' )
475 vlc_object_release( (vlc_object_t *)p_vout );
481 - (void)setupVarMenuItem:(NSMenuItem *)o_mi
482 target:(vlc_object_t *)p_object
483 var:(const char *)psz_variable
484 selector:(SEL)pf_callback
486 vlc_value_t val, text;
487 int i_type = var_Type( p_object, psz_variable );
489 switch( i_type & VLC_VAR_TYPE )
493 case VLC_VAR_VARIABLE:
495 case VLC_VAR_INTEGER:
498 /* Variable doesn't exist or isn't handled */
502 /* Make sure we want to display the variable */
503 if( i_type & VLC_VAR_HASCHOICE )
505 var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
506 if( val.i_int == 0 ) return;
507 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
511 /* Get the descriptive name of the variable */
512 var_Change( p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL );
513 [o_mi setTitle: [[VLCMain sharedInstance] localizedString: text.psz_string ?
514 text.psz_string : strdup( psz_variable ) ]];
516 var_Get( p_object, psz_variable, &val );
517 if( i_type & VLC_VAR_HASCHOICE )
519 NSMenu *o_menu = [o_mi submenu];
521 [self setupVarMenu: o_menu forMenuItem: o_mi target:p_object
522 var:psz_variable selector:pf_callback];
524 if( text.psz_string ) free( text.psz_string );
529 switch( i_type & VLC_VAR_TYPE )
532 o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
533 Value: val ofType: i_type];
534 [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
538 o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
539 Value: val ofType: i_type];
540 [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
541 if( !( i_type & VLC_VAR_ISCOMMAND ) )
542 [o_mi setState: val.b_bool ? TRUE : FALSE ];
546 if( text.psz_string ) free( text.psz_string );
550 if( ( i_type & VLC_VAR_TYPE ) == VLC_VAR_STRING ) free( val.psz_string );
551 if( text.psz_string ) free( text.psz_string );
555 - (void)setupVarMenu:(NSMenu *)o_menu
556 forMenuItem: (NSMenuItem *)o_parent
557 target:(vlc_object_t *)p_object
558 var:(const char *)psz_variable
559 selector:(SEL)pf_callback
561 vlc_value_t val, val_list, text_list;
562 int i_type, i, i_nb_items;
564 /* remove previous items */
565 i_nb_items = [o_menu numberOfItems];
566 for( i = 0; i < i_nb_items; i++ )
568 [o_menu removeItemAtIndex: 0];
571 /* Check the type of the object variable */
572 i_type = var_Type( p_object, psz_variable );
574 /* Make sure we want to display the variable */
575 if( i_type & VLC_VAR_HASCHOICE )
577 var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
578 if( val.i_int == 0 ) return;
579 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
587 switch( i_type & VLC_VAR_TYPE )
591 case VLC_VAR_VARIABLE:
593 case VLC_VAR_INTEGER:
596 /* Variable doesn't exist or isn't handled */
600 if( var_Get( p_object, psz_variable, &val ) < 0 )
605 if( var_Change( p_object, psz_variable, VLC_VAR_GETLIST,
606 &val_list, &text_list ) < 0 )
608 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
612 /* make (un)sensitive */
613 [o_parent setEnabled: ( val_list.p_list->i_count > 1 )];
615 for( i = 0; i < val_list.p_list->i_count; i++ )
617 vlc_value_t another_val;
619 NSString *o_title = @"";
622 switch( i_type & VLC_VAR_TYPE )
625 another_val.psz_string =
626 strdup(val_list.p_list->p_values[i].psz_string);
628 o_title = [[VLCMain sharedInstance] localizedString: text_list.p_list->p_values[i].psz_string ?
629 text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string ];
631 o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
632 o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
633 Value: another_val ofType: i_type];
634 [o_lmi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
635 [o_lmi setTarget: self];
637 if( !strcmp( val.psz_string, val_list.p_list->p_values[i].psz_string ) && !( i_type & VLC_VAR_ISCOMMAND ) )
638 [o_lmi setState: TRUE ];
642 case VLC_VAR_INTEGER:
644 o_title = text_list.p_list->p_values[i].psz_string ?
645 [[VLCMain sharedInstance] localizedString: strdup( text_list.p_list->p_values[i].psz_string )] :
646 [NSString stringWithFormat: @"%d",
647 val_list.p_list->p_values[i].i_int];
649 o_lmi = [[o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""] retain ];
650 o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
651 Value: val_list.p_list->p_values[i] ofType: i_type];
652 [o_lmi setRepresentedObject: [NSValue valueWithPointer:[ o_data retain]]];
653 [o_lmi setTarget: self];
655 if( val_list.p_list->p_values[i].i_int == val.i_int && !( i_type & VLC_VAR_ISCOMMAND ) )
656 [o_lmi setState: TRUE ];
664 /* clean up everything */
665 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
666 var_Change( p_object, psz_variable, VLC_VAR_FREELIST, &val_list, &text_list );
669 - (IBAction)toggleVar:(id)sender
671 NSMenuItem *o_mi = (NSMenuItem *)sender;
672 VLCMenuExt *o_data = [[o_mi representedObject] pointerValue];
673 [NSThread detachNewThreadSelector: @selector(toggleVarThread:)
674 toTarget: self withObject: o_data];
679 - (int)toggleVarThread: (id)_o_data
681 vlc_object_t *p_object;
682 NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
683 VLCMenuExt *o_data = (VLCMenuExt *)_o_data;
685 vlc_thread_set_priority( VLCIntf , VLC_THREAD_PRIORITY_LOW );
687 p_object = (vlc_object_t *)vlc_object_get( VLCIntf,
690 if( p_object != NULL )
692 var_Set( p_object, strdup([o_data name]), [o_data value] );
693 vlc_object_release( p_object );
701 - (IBAction)goToSpecificTime:(id)sender
703 if( sender == o_specificTime_cancel_btn )
705 [NSApp endSheet: o_specificTime_win];
706 [o_specificTime_win close];
708 else if( sender == o_specificTime_ok_btn )
710 input_thread_t * p_input = (input_thread_t *)vlc_object_find( VLCIntf, \
711 VLC_OBJECT_INPUT, FIND_ANYWHERE );
714 unsigned int timeInSec = 0;
715 NSString * fieldContent = [o_specificTime_enter_fld stringValue];
716 if( [[fieldContent componentsSeparatedByString: @":"] count] > 1 &&
717 [[fieldContent componentsSeparatedByString: @":"] count] <= 3 )
719 NSArray * ourTempArray = \
720 [fieldContent componentsSeparatedByString: @":"];
722 if( [[fieldContent componentsSeparatedByString: @":"] count] == 3 )
724 timeInSec += ([[ourTempArray objectAtIndex: 0] intValue] * 3600); //h
725 timeInSec += ([[ourTempArray objectAtIndex: 1] intValue] * 60); //m
726 timeInSec += [[ourTempArray objectAtIndex: 2] intValue]; //s
730 timeInSec += ([[ourTempArray objectAtIndex: 0] intValue] * 60); //m
731 timeInSec += [[ourTempArray objectAtIndex: 1] intValue]; //s
735 timeInSec = [fieldContent intValue];
737 input_Control( p_input, INPUT_SET_TIME, (int64_t)(timeInSec * 1000000));
738 vlc_object_release( p_input );
741 [NSApp endSheet: o_specificTime_win];
742 [o_specificTime_win close];
746 input_thread_t * p_input = (input_thread_t *)vlc_object_find( VLCIntf, \
747 VLC_OBJECT_INPUT, FIND_ANYWHERE );
750 /* we can obviously only do that if an input is available */
751 vlc_value_t pos, length;
752 var_Get( p_input, "time", &pos );
753 [o_specificTime_enter_fld setIntValue: (pos.i_time / 1000000)];
754 var_Get( p_input, "length", &length );
755 [o_specificTime_stepper setMaxValue: (length.i_time / 1000000)];
757 [NSApp beginSheet: o_specificTime_win modalForWindow: \
758 [NSApp mainWindow] modalDelegate: self didEndSelector: nil \
760 [o_specificTime_win makeKeyWindow];
761 vlc_object_release( p_input );
772 msg_Err( VLCIntf, "FSPanel is nil" );
779 @implementation VLCControls (NSMenuValidation)
781 - (BOOL)validateMenuItem:(NSMenuItem *)o_mi
783 BOOL bEnabled = TRUE;
785 intf_thread_t * p_intf = VLCIntf;
786 playlist_t * p_playlist = pl_Yield( p_intf );
788 vlc_mutex_lock( &p_playlist->object_lock );
790 #define p_input p_playlist->p_input
792 if( [[o_mi title] isEqualToString: _NS("Faster")] ||
793 [[o_mi title] isEqualToString: _NS("Slower")] )
795 if( p_input != NULL )
797 bEnabled = p_input->input.b_can_pace_control;
804 else if( [[o_mi title] isEqualToString: _NS("Stop")] )
806 if( p_input == NULL )
810 [o_main setupMenus]; /* Make sure input menu is up to date */
812 else if( [[o_mi title] isEqualToString: _NS("Previous")] ||
813 [[o_mi title] isEqualToString: _NS("Next")] )
815 bEnabled = p_playlist->i_size > 1;
817 else if( [[o_mi title] isEqualToString: _NS("Random")] )
820 var_Get( p_playlist, "random", &val );
821 i_state = val.b_bool ? NSOnState : NSOffState;
822 [o_mi setState: i_state];
824 else if( [[o_mi title] isEqualToString: _NS("Repeat One")] )
827 var_Get( p_playlist, "repeat", &val );
828 i_state = val.b_bool ? NSOnState : NSOffState;
829 [o_mi setState: i_state];
831 else if( [[o_mi title] isEqualToString: _NS("Repeat All")] )
834 var_Get( p_playlist, "loop", &val );
835 i_state = val.b_bool ? NSOnState : NSOffState;
836 [o_mi setState: i_state];
838 else if( [[o_mi title] isEqualToString: _NS("Step Forward")] ||
839 [[o_mi title] isEqualToString: _NS("Step Backward")] ||
840 [[o_mi title] isEqualToString: _NS("Jump To Time")])
842 if( p_input != NULL )
844 var_Get( p_input, "seekable", &val);
845 bEnabled = val.b_bool;
847 else bEnabled = FALSE;
849 else if( [[o_mi title] isEqualToString: _NS("Mute")] )
851 [o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState];
852 [o_main setupMenus]; /* Make sure audio menu is up to date */
854 else if( [[o_mi title] isEqualToString: _NS("Half Size")] ||
855 [[o_mi title] isEqualToString: _NS("Normal Size")] ||
856 [[o_mi title] isEqualToString: _NS("Double Size")] ||
857 [[o_mi title] isEqualToString: _NS("Fit to Screen")] ||
858 [[o_mi title] isEqualToString: _NS("Snapshot")] ||
859 [[o_mi title] isEqualToString: _NS("Fullscreen")] ||
860 [[o_mi title] isEqualToString: _NS("Float on Top")] )
863 NSArray *o_windows = [NSApp orderedWindows];
864 NSEnumerator *o_enumerator = [o_windows objectEnumerator];
867 vout_thread_t *p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
871 if( [[o_mi title] isEqualToString: _NS("Float on Top")] )
873 var_Get( p_vout, "video-on-top", &val );
874 [o_mi setState: val.b_bool ? NSOnState : NSOffState];
877 while( (o_window = [o_enumerator nextObject]))
879 if( [[o_window className] isEqualToString: @"VLCWindow"] ||
880 [[[VLCMain sharedInstance] getEmbeddedList]
881 windowContainsEmbedded: o_window])
887 vlc_object_release( (vlc_object_t *)p_vout );
889 else if( [[o_mi title] isEqualToString: _NS("Fullscreen")] )
891 var_Get( p_playlist, "fullscreen", &val );
892 [o_mi setState: val.b_bool];
895 [o_main setupMenus]; /* Make sure video menu is up to date */
898 vlc_mutex_unlock( &p_playlist->object_lock );
899 vlc_object_release( p_playlist );
906 /*****************************************************************************
907 * VLCMenuExt implementation
908 *****************************************************************************
909 * Object connected to a playlistitem which remembers the data belonging to
910 * the variable of the autogenerated menu
911 *****************************************************************************/
912 @implementation VLCMenuExt
914 - (id)initWithVar: (const char *)_psz_name Object: (int)i_id
915 Value: (vlc_value_t)val ofType: (int)_i_type
921 psz_name = strdup( _psz_name );
959 /*****************************************************************************
960 * VLCTimeField implementation
961 *****************************************************************************
962 * we need this to catch our click-event in the controller window
963 *****************************************************************************/
965 @implementation VLCTimeField
966 - (void)mouseDown: (NSEvent *)ourEvent
968 if( [ourEvent clickCount] > 1 )
969 [[[VLCMain sharedInstance] getControls] goToSpecificTime: nil];