1 /*****************************************************************************
2 * controls.m: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2002-2005 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>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
27 /*****************************************************************************
29 *****************************************************************************/
30 #include <stdlib.h> /* malloc(), free() */
31 #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( p_playlist->i_size <= 0 )
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 alloc] initWithContentsOfFile:
181 [[NSBundle mainBundle] pathForImageResource:@"repeat_single_embedded_blue.png"]]];
182 [o_btn_repeat setAlternateImage: [[NSImage alloc] initWithContentsOfFile:
183 [[NSBundle mainBundle] pathForImageResource:@"repeat_embedded_blue.png"]]];
187 [o_btn_repeat setImage: [[NSImage alloc] initWithContentsOfFile:
188 [[NSBundle mainBundle] pathForImageResource:@"repeat_embedded_blue.png"]]];
189 [o_btn_repeat setAlternateImage: [[NSImage alloc] initWithContentsOfFile:
190 [[NSBundle mainBundle] pathForImageResource:@"repeat_embedded.png"]]];
194 [o_btn_repeat setImage: [[NSImage alloc] initWithContentsOfFile:
195 [[NSBundle mainBundle] pathForImageResource:@"repeat_embedded.png"]]];
196 [o_btn_repeat setAlternateImage: [[NSImage alloc] initWithContentsOfFile:
197 [[NSBundle mainBundle] pathForImageResource:@"repeat_single_embedded_blue.png"]]];
202 playlist_t *p_playlist = pl_Yield( VLCIntf );
203 var_Get( p_playlist, "random", &val );
204 [o_btn_shuffle setState: val.b_bool];
205 vlc_object_release( p_playlist );
208 - (IBAction)repeatButtonAction:(id)sender
210 vlc_value_t looping,repeating;
211 intf_thread_t * p_intf = VLCIntf;
212 playlist_t * p_playlist = pl_Yield( p_intf );
214 var_Get( p_playlist, "repeat", &repeating );
215 var_Get( p_playlist, "loop", &looping );
217 [[o_btn_repeat image] release];
218 [[o_btn_repeat alternateImage] release];
220 if( !repeating.b_bool && !looping.b_bool )
222 /* was: no repeating at all, switching to Repeat One */
224 /* set our button's look */
227 /* prepare core communication */
228 repeating.b_bool = VLC_TRUE;
229 looping.b_bool = VLC_FALSE;
230 config_PutInt( p_playlist, "repeat", 1 );
231 config_PutInt( p_playlist, "loop", 0 );
233 /* show the change */
234 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
236 else if( repeating.b_bool && !looping.b_bool )
238 /* was: Repeat One, switching to Repeat All */
240 /* set our button's look */
243 /* prepare core communication */
244 repeating.b_bool = VLC_FALSE;
245 looping.b_bool = VLC_TRUE;
246 config_PutInt( p_playlist, "repeat", 0 );
247 config_PutInt( p_playlist, "loop", 1 );
249 /* show the change */
250 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
254 /* was: Repeat All or bug in VLC, switching to Repeat Off */
256 /* set our button's look */
259 /* prepare core communication */
260 repeating.b_bool = VLC_FALSE;
261 looping.b_bool = VLC_FALSE;
262 config_PutInt( p_playlist, "repeat", 0 );
263 config_PutInt( p_playlist, "loop", 0 );
265 /* show the change */
266 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
269 /* communicate with core and the main intf loop */
270 var_Set( p_playlist, "repeat", repeating );
271 var_Set( p_playlist, "loop", looping );
272 p_intf->p_sys->b_playmode_update = VLC_TRUE;
273 p_intf->p_sys->b_intf_update = VLC_TRUE;
275 vlc_object_release( p_playlist );
279 - (IBAction)repeat:(id)sender
282 intf_thread_t * p_intf = VLCIntf;
283 playlist_t * p_playlist = pl_Yield( p_intf );
285 var_Get( p_playlist, "repeat", &val );
288 var_Set( p_playlist, "loop", val );
290 val.b_bool = !val.b_bool;
291 var_Set( p_playlist, "repeat", val );
294 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
295 config_PutInt( p_playlist, "repeat", 1 );
299 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
300 config_PutInt( p_playlist, "repeat", 0 );
303 p_intf->p_sys->b_playmode_update = VLC_TRUE;
304 p_intf->p_sys->b_intf_update = VLC_TRUE;
305 vlc_object_release( p_playlist );
308 - (IBAction)loop:(id)sender
311 intf_thread_t * p_intf = VLCIntf;
312 playlist_t * p_playlist = pl_Yield( p_intf );
314 var_Get( p_playlist, "loop", &val );
317 var_Set( p_playlist, "repeat", val );
319 val.b_bool = !val.b_bool;
320 var_Set( p_playlist, "loop", val );
323 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
324 config_PutInt( p_playlist, "loop", 1 );
328 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
329 config_PutInt( p_playlist, "loop", 0 );
332 p_intf->p_sys->b_playmode_update = VLC_TRUE;
333 p_intf->p_sys->b_intf_update = VLC_TRUE;
334 vlc_object_release( p_playlist );
337 - (IBAction)forward:(id)sender
340 intf_thread_t * p_intf = VLCIntf;
341 val.i_int = config_GetInt( p_intf, "key-jump+short" );
342 var_Set( p_intf->p_libvlc, "key-pressed", val );
345 - (IBAction)backward:(id)sender
348 intf_thread_t * p_intf = VLCIntf;
349 val.i_int = config_GetInt( p_intf, "key-jump-short" );
350 var_Set( p_intf->p_libvlc, "key-pressed", val );
354 - (IBAction)volumeUp:(id)sender
357 intf_thread_t * p_intf = VLCIntf;
358 val.i_int = config_GetInt( p_intf, "key-vol-up" );
359 var_Set( p_intf->p_libvlc, "key-pressed", val );
360 /* Manage volume status */
361 [o_main manageVolumeSlider];
364 - (IBAction)volumeDown:(id)sender
367 intf_thread_t * p_intf = VLCIntf;
368 val.i_int = config_GetInt( p_intf, "key-vol-down" );
369 var_Set( p_intf->p_libvlc, "key-pressed", val );
370 /* Manage volume status */
371 [o_main manageVolumeSlider];
374 - (IBAction)mute:(id)sender
377 intf_thread_t * p_intf = VLCIntf;
378 val.i_int = config_GetInt( p_intf, "key-vol-mute" );
379 var_Set( p_intf->p_libvlc, "key-pressed", val );
380 /* Manage volume status */
381 [o_main manageVolumeSlider];
384 - (IBAction)volumeSliderUpdated:(id)sender
386 intf_thread_t * p_intf = VLCIntf;
387 audio_volume_t i_volume = (audio_volume_t)[sender intValue];
388 int i_volume_step = 0;
389 i_volume_step = config_GetInt( p_intf->p_libvlc, "volume-step" );
390 aout_VolumeSet( p_intf, i_volume * i_volume_step );
391 /* Manage volume status */
392 [o_main manageVolumeSlider];
395 - (IBAction)windowAction:(id)sender
397 NSString *o_title = [sender title];
399 vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
403 id o_vout_view = [self getVoutView];
406 if( [o_title isEqualToString: _NS("Half Size") ] )
407 [o_vout_view scaleWindowWithFactor: 0.5];
408 else if( [o_title isEqualToString: _NS("Normal Size") ] )
409 [o_vout_view scaleWindowWithFactor: 1.0];
410 else if( [o_title isEqualToString: _NS("Double Size") ] )
411 [o_vout_view scaleWindowWithFactor: 2.0];
412 else if( [o_title isEqualToString: _NS("Float on Top") ] )
413 [o_vout_view toggleFloatOnTop];
414 else if( [o_title isEqualToString: _NS("Fit to Screen") ] )
416 id o_window = [o_vout_view getWindow];
417 if( ![o_window isZoomed] )
418 [o_window performZoom:self];
420 else if( [o_title isEqualToString: _NS("Snapshot") ] )
422 [o_vout_view snapshot];
426 [o_vout_view toggleFullscreen];
429 vlc_object_release( (vlc_object_t *)p_vout );
433 playlist_t * p_playlist = pl_Yield( VLCIntf );
435 if( [o_title isEqualToString: _NS("Fullscreen")] ||
436 [sender isKindOfClass:[NSButton class]] )
439 var_Get( p_playlist, "fullscreen", &val );
440 var_Set( p_playlist, "fullscreen", (vlc_value_t)!val.b_bool );
443 vlc_object_release( p_playlist );
448 - (BOOL)keyEvent:(NSEvent *)o_event
450 BOOL eventHandled = NO;
451 unichar key = [[o_event charactersIgnoringModifiers] characterAtIndex: 0];
455 vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
460 if( key == (unichar) 0x1b )
462 id o_vout_view = [self getVoutView];
463 if( o_vout_view && [o_vout_view isFullscreen] )
465 [o_vout_view toggleFullscreen];
469 else if( key == ' ' )
474 vlc_object_release( (vlc_object_t *)p_vout );
480 - (void)setupVarMenuItem:(NSMenuItem *)o_mi
481 target:(vlc_object_t *)p_object
482 var:(const char *)psz_variable
483 selector:(SEL)pf_callback
485 vlc_value_t val, text;
486 int i_type = var_Type( p_object, psz_variable );
488 switch( i_type & VLC_VAR_TYPE )
492 case VLC_VAR_VARIABLE:
494 case VLC_VAR_INTEGER:
497 /* Variable doesn't exist or isn't handled */
501 /* Make sure we want to display the variable */
502 if( i_type & VLC_VAR_HASCHOICE )
504 var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
505 if( val.i_int == 0 ) return;
506 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
510 /* Get the descriptive name of the variable */
511 var_Change( p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL );
512 [o_mi setTitle: [[VLCMain sharedInstance] localizedString: text.psz_string ?
513 text.psz_string : strdup( psz_variable ) ]];
515 var_Get( p_object, psz_variable, &val );
516 if( i_type & VLC_VAR_HASCHOICE )
518 NSMenu *o_menu = [o_mi submenu];
520 [self setupVarMenu: o_menu forMenuItem: o_mi target:p_object
521 var:psz_variable selector:pf_callback];
523 if( text.psz_string ) free( text.psz_string );
528 switch( i_type & VLC_VAR_TYPE )
531 o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
532 Value: val ofType: i_type];
533 [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
537 o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
538 Value: val ofType: i_type];
539 [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
540 if( !( i_type & VLC_VAR_ISCOMMAND ) )
541 [o_mi setState: val.b_bool ? TRUE : FALSE ];
545 if( text.psz_string ) free( text.psz_string );
549 if( ( i_type & VLC_VAR_TYPE ) == VLC_VAR_STRING ) free( val.psz_string );
550 if( text.psz_string ) free( text.psz_string );
554 - (void)setupVarMenu:(NSMenu *)o_menu
555 forMenuItem: (NSMenuItem *)o_parent
556 target:(vlc_object_t *)p_object
557 var:(const char *)psz_variable
558 selector:(SEL)pf_callback
560 vlc_value_t val, val_list, text_list;
561 int i_type, i, i_nb_items;
563 /* remove previous items */
564 i_nb_items = [o_menu numberOfItems];
565 for( i = 0; i < i_nb_items; i++ )
567 [o_menu removeItemAtIndex: 0];
570 /* Check the type of the object variable */
571 i_type = var_Type( p_object, psz_variable );
573 /* Make sure we want to display the variable */
574 if( i_type & VLC_VAR_HASCHOICE )
576 var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
577 if( val.i_int == 0 ) return;
578 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
586 switch( i_type & VLC_VAR_TYPE )
590 case VLC_VAR_VARIABLE:
592 case VLC_VAR_INTEGER:
595 /* Variable doesn't exist or isn't handled */
599 if( var_Get( p_object, psz_variable, &val ) < 0 )
604 if( var_Change( p_object, psz_variable, VLC_VAR_GETLIST,
605 &val_list, &text_list ) < 0 )
607 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
611 /* make (un)sensitive */
612 [o_parent setEnabled: ( val_list.p_list->i_count > 1 )];
614 for( i = 0; i < val_list.p_list->i_count; i++ )
616 vlc_value_t another_val;
618 NSString *o_title = @"";
621 switch( i_type & VLC_VAR_TYPE )
624 another_val.psz_string =
625 strdup(val_list.p_list->p_values[i].psz_string);
627 o_title = [[VLCMain sharedInstance] localizedString: text_list.p_list->p_values[i].psz_string ?
628 text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string ];
630 o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
631 o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
632 Value: another_val ofType: i_type];
633 [o_lmi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
634 [o_lmi setTarget: self];
636 if( !strcmp( val.psz_string, val_list.p_list->p_values[i].psz_string ) && !( i_type & VLC_VAR_ISCOMMAND ) )
637 [o_lmi setState: TRUE ];
641 case VLC_VAR_INTEGER:
643 o_title = text_list.p_list->p_values[i].psz_string ?
644 [[VLCMain sharedInstance] localizedString: strdup( text_list.p_list->p_values[i].psz_string )] :
645 [NSString stringWithFormat: @"%d",
646 val_list.p_list->p_values[i].i_int];
648 o_lmi = [[o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""] retain ];
649 o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
650 Value: val_list.p_list->p_values[i] ofType: i_type];
651 [o_lmi setRepresentedObject: [NSValue valueWithPointer:[ o_data retain]]];
652 [o_lmi setTarget: self];
654 if( val_list.p_list->p_values[i].i_int == val.i_int && !( i_type & VLC_VAR_ISCOMMAND ) )
655 [o_lmi setState: TRUE ];
663 /* clean up everything */
664 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
665 var_Change( p_object, psz_variable, VLC_VAR_FREELIST, &val_list, &text_list );
668 - (IBAction)toggleVar:(id)sender
670 NSMenuItem *o_mi = (NSMenuItem *)sender;
671 VLCMenuExt *o_data = [[o_mi representedObject] pointerValue];
672 [NSThread detachNewThreadSelector: @selector(toggleVarThread:)
673 toTarget: self withObject: o_data];
678 - (int)toggleVarThread: (id)_o_data
680 vlc_object_t *p_object;
681 NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
682 VLCMenuExt *o_data = (VLCMenuExt *)_o_data;
684 vlc_thread_set_priority( VLCIntf , VLC_THREAD_PRIORITY_LOW );
686 p_object = (vlc_object_t *)vlc_object_get( VLCIntf,
689 if( p_object != NULL )
691 var_Set( p_object, strdup([o_data name]), [o_data value] );
692 vlc_object_release( p_object );
700 - (IBAction)goToSpecificTime:(id)sender
702 if( sender == o_specificTime_cancel_btn )
704 [NSApp endSheet: o_specificTime_win];
705 [o_specificTime_win close];
707 else if( sender == o_specificTime_ok_btn )
709 input_thread_t * p_input = (input_thread_t *)vlc_object_find( VLCIntf, \
710 VLC_OBJECT_INPUT, FIND_ANYWHERE );
713 unsigned int timeInSec = 0;
714 NSString * fieldContent = [o_specificTime_enter_fld stringValue];
715 if( [[fieldContent componentsSeparatedByString: @":"] count] > 1 &&
716 [[fieldContent componentsSeparatedByString: @":"] count] <= 3 )
718 NSArray * ourTempArray = \
719 [fieldContent componentsSeparatedByString: @":"];
721 if( [[fieldContent componentsSeparatedByString: @":"] count] == 3 )
723 timeInSec += ([[ourTempArray objectAtIndex: 0] intValue] * 3600); //h
724 timeInSec += ([[ourTempArray objectAtIndex: 1] intValue] * 60); //m
725 timeInSec += [[ourTempArray objectAtIndex: 2] intValue]; //s
729 timeInSec += ([[ourTempArray objectAtIndex: 0] intValue] * 60); //m
730 timeInSec += [[ourTempArray objectAtIndex: 1] intValue]; //s
734 timeInSec = [fieldContent intValue];
736 input_Control( p_input, INPUT_SET_TIME, (int64_t)(timeInSec * 1000000));
737 vlc_object_release( p_input );
740 [NSApp endSheet: o_specificTime_win];
741 [o_specificTime_win close];
745 input_thread_t * p_input = (input_thread_t *)vlc_object_find( VLCIntf, \
746 VLC_OBJECT_INPUT, FIND_ANYWHERE );
749 /* we can obviously only do that if an input is available */
750 vlc_value_t pos, length;
751 var_Get( p_input, "time", &pos );
752 [o_specificTime_enter_fld setIntValue: (pos.i_time / 1000000)];
753 var_Get( p_input, "length", &length );
754 [o_specificTime_stepper setMaxValue: (length.i_time / 1000000)];
756 [NSApp beginSheet: o_specificTime_win modalForWindow: \
757 [NSApp mainWindow] modalDelegate: self didEndSelector: nil \
759 [o_specificTime_win makeKeyWindow];
760 vlc_object_release( p_input );
771 msg_Err( VLCIntf, "FSPanel is nil" );
778 @implementation VLCControls (NSMenuValidation)
780 - (BOOL)validateMenuItem:(NSMenuItem *)o_mi
782 BOOL bEnabled = TRUE;
784 intf_thread_t * p_intf = VLCIntf;
785 playlist_t * p_playlist = pl_Yield( p_intf );
787 vlc_mutex_lock( &p_playlist->object_lock );
789 #define p_input p_playlist->p_input
791 if( [[o_mi title] isEqualToString: _NS("Faster")] ||
792 [[o_mi title] isEqualToString: _NS("Slower")] )
794 if( p_input != NULL )
796 bEnabled = p_input->input.b_can_pace_control;
803 else if( [[o_mi title] isEqualToString: _NS("Stop")] )
805 if( p_input == NULL )
809 [o_main setupMenus]; /* Make sure input menu is up to date */
811 else if( [[o_mi title] isEqualToString: _NS("Previous")] ||
812 [[o_mi title] isEqualToString: _NS("Next")] )
814 bEnabled = p_playlist->i_size > 1;
816 else if( [[o_mi title] isEqualToString: _NS("Random")] )
819 var_Get( p_playlist, "random", &val );
820 i_state = val.b_bool ? NSOnState : NSOffState;
821 [o_mi setState: i_state];
823 else if( [[o_mi title] isEqualToString: _NS("Repeat One")] )
826 var_Get( p_playlist, "repeat", &val );
827 i_state = val.b_bool ? NSOnState : NSOffState;
828 [o_mi setState: i_state];
830 else if( [[o_mi title] isEqualToString: _NS("Repeat All")] )
833 var_Get( p_playlist, "loop", &val );
834 i_state = val.b_bool ? NSOnState : NSOffState;
835 [o_mi setState: i_state];
837 else if( [[o_mi title] isEqualToString: _NS("Step Forward")] ||
838 [[o_mi title] isEqualToString: _NS("Step Backward")] ||
839 [[o_mi title] isEqualToString: _NS("Jump To Time")])
841 if( p_input != NULL )
843 var_Get( p_input, "seekable", &val);
844 bEnabled = val.b_bool;
846 else bEnabled = FALSE;
848 else if( [[o_mi title] isEqualToString: _NS("Mute")] )
850 [o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState];
851 [o_main setupMenus]; /* Make sure audio menu is up to date */
853 else if( [[o_mi title] isEqualToString: _NS("Half Size")] ||
854 [[o_mi title] isEqualToString: _NS("Normal Size")] ||
855 [[o_mi title] isEqualToString: _NS("Double Size")] ||
856 [[o_mi title] isEqualToString: _NS("Fit to Screen")] ||
857 [[o_mi title] isEqualToString: _NS("Snapshot")] ||
858 [[o_mi title] isEqualToString: _NS("Fullscreen")] ||
859 [[o_mi title] isEqualToString: _NS("Float on Top")] )
862 NSArray *o_windows = [NSApp orderedWindows];
863 NSEnumerator *o_enumerator = [o_windows objectEnumerator];
866 vout_thread_t *p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
870 if( [[o_mi title] isEqualToString: _NS("Float on Top")] )
872 var_Get( p_vout, "video-on-top", &val );
873 [o_mi setState: val.b_bool ? NSOnState : NSOffState];
876 while( (o_window = [o_enumerator nextObject]))
878 if( [[o_window className] isEqualToString: @"VLCWindow"] ||
879 [[[VLCMain sharedInstance] getEmbeddedList]
880 windowContainsEmbedded: o_window])
886 vlc_object_release( (vlc_object_t *)p_vout );
888 else if( [[o_mi title] isEqualToString: _NS("Fullscreen")] )
890 var_Get( p_playlist, "fullscreen", &val );
891 [o_mi setState: val.b_bool];
894 [o_main setupMenus]; /* Make sure video menu is up to date */
897 vlc_mutex_unlock( &p_playlist->object_lock );
898 vlc_object_release( p_playlist );
905 /*****************************************************************************
906 * VLCMenuExt implementation
907 *****************************************************************************
908 * Object connected to a playlistitem which remembers the data belonging to
909 * the variable of the autogenerated menu
910 *****************************************************************************/
911 @implementation VLCMenuExt
913 - (id)initWithVar: (const char *)_psz_name Object: (int)i_id
914 Value: (vlc_value_t)val ofType: (int)_i_type
920 psz_name = strdup( _psz_name );
958 /*****************************************************************************
959 * VLCTimeField implementation
960 *****************************************************************************
961 * we need this to catch our click-event in the controller window
962 *****************************************************************************/
964 @implementation VLCTimeField
965 - (void)mouseDown: (NSEvent *)ourEvent
967 if( [ourEvent clickCount] > 1 )
968 [[[VLCMain sharedInstance] getControls] goToSpecificTime: nil];