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 /* UGLY UGLY UGLY FIXME FIXME FIXME. Need solution for b_can_pace_control.
43 * Put it public ? Is it needed here ?*/
44 #include "../../../src/input/input_internal.h"
46 /*****************************************************************************
47 * VLCControls implementation
48 *****************************************************************************/
49 @implementation VLCControls
54 o_fs_panel = [[VLCFSPanel alloc] init];
60 [o_specificTime_mi setTitle: _NS("Jump To Time")];
61 [o_specificTime_cancel_btn setTitle: _NS("Cancel")];
62 [o_specificTime_ok_btn setTitle: _NS("OK")];
63 [o_specificTime_sec_lbl setStringValue: _NS("sec.")];
64 [o_specificTime_goTo_lbl setStringValue: _NS("Jump to time")];
67 - (IBAction)play:(id)sender
70 intf_thread_t * p_intf = VLCIntf;
71 playlist_t * p_playlist = pl_Yield( p_intf );
73 vlc_mutex_lock( &p_playlist->object_lock );
74 if( playlist_IsEmpty( p_playlist ) )
76 vlc_mutex_unlock( &p_playlist->object_lock );
77 vlc_object_release( p_playlist );
78 [o_main intfOpenFileGeneric: (id)sender];
82 vlc_mutex_unlock( &p_playlist->object_lock );
83 vlc_object_release( p_playlist );
86 val.i_int = config_GetInt( p_intf, "key-play-pause" );
87 var_Set( p_intf->p_libvlc, "key-pressed", val );
90 /* Small helper method */
96 id o_embedded_vout_list = [[VLCMain sharedInstance] getEmbeddedList];
97 NSEnumerator *o_enumerator = [[NSApp orderedWindows] objectEnumerator];
98 while( !o_vout_view && ( o_window = [o_enumerator nextObject] ) )
100 /* We have an embedded vout */
101 if( [o_embedded_vout_list windowContainsEmbedded: o_window] )
103 o_vout_view = [o_embedded_vout_list getViewForWindow: o_window];
105 /* We have a detached vout */
106 else if( [[o_window className] isEqualToString: @"VLCWindow"] )
108 msg_Dbg( VLCIntf, "detached vout controls.m call getVoutView" );
109 o_vout_view = [o_window getVoutView];
116 - (IBAction)stop:(id)sender
119 intf_thread_t * p_intf = VLCIntf;
120 val.i_int = config_GetInt( p_intf, "key-stop" );
121 var_Set( p_intf->p_libvlc, "key-pressed", val );
124 - (IBAction)faster:(id)sender
127 intf_thread_t * p_intf = VLCIntf;
128 val.i_int = config_GetInt( p_intf, "key-faster" );
129 var_Set( p_intf->p_libvlc, "key-pressed", val );
132 - (IBAction)slower:(id)sender
135 intf_thread_t * p_intf = VLCIntf;
136 val.i_int = config_GetInt( p_intf, "key-slower" );
137 var_Set( p_intf->p_libvlc, "key-pressed", val );
140 - (IBAction)prev:(id)sender
143 intf_thread_t * p_intf = VLCIntf;
144 val.i_int = config_GetInt( p_intf, "key-prev" );
145 var_Set( p_intf->p_libvlc, "key-pressed", val );
148 - (IBAction)next:(id)sender
151 intf_thread_t * p_intf = VLCIntf;
152 val.i_int = config_GetInt( p_intf, "key-next" );
153 var_Set( p_intf->p_libvlc, "key-pressed", val );
156 - (IBAction)random:(id)sender
159 intf_thread_t * p_intf = VLCIntf;
160 playlist_t * p_playlist = pl_Yield( p_intf );
162 var_Get( p_playlist, "random", &val );
163 val.b_bool = !val.b_bool;
164 var_Set( p_playlist, "random", val );
167 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Random On" ) );
168 config_PutInt( p_playlist, "random", 1 );
172 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Random Off" ) );
173 config_PutInt( p_playlist, "random", 0 );
176 p_intf->p_sys->b_playmode_update = VLC_TRUE;
177 p_intf->p_sys->b_intf_update = VLC_TRUE;
178 vlc_object_release( p_playlist );
181 /* three little ugly helpers */
184 [o_btn_repeat setImage: [NSImage imageNamed:@"repeat_single_embedded_blue"]];
185 [o_btn_repeat setAlternateImage: [NSImage imageNamed:@"repeat_embedded_blue"]];
189 [o_btn_repeat setImage: [NSImage imageNamed:@"repeat_embedded_blue"]];
190 [o_btn_repeat setAlternateImage: [NSImage imageNamed:@"repeat_embedded"]];
194 [o_btn_repeat setImage: [NSImage imageNamed:@"repeat_embedded"]];
195 [o_btn_repeat setAlternateImage: [NSImage imageNamed:@"repeat_single_embedded_blue"]];
200 playlist_t *p_playlist = pl_Yield( VLCIntf );
201 var_Get( p_playlist, "random", &val );
202 [o_btn_shuffle setState: val.b_bool];
203 vlc_object_release( p_playlist );
206 - (IBAction)repeatButtonAction:(id)sender
208 vlc_value_t looping,repeating;
209 intf_thread_t * p_intf = VLCIntf;
210 playlist_t * p_playlist = pl_Yield( p_intf );
212 var_Get( p_playlist, "repeat", &repeating );
213 var_Get( p_playlist, "loop", &looping );
215 if( !repeating.b_bool && !looping.b_bool )
217 /* was: no repeating at all, switching to Repeat One */
219 /* set our button's look */
222 /* prepare core communication */
223 repeating.b_bool = VLC_TRUE;
224 looping.b_bool = VLC_FALSE;
225 config_PutInt( p_playlist, "repeat", 1 );
226 config_PutInt( p_playlist, "loop", 0 );
228 /* show the change */
229 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
231 else if( repeating.b_bool && !looping.b_bool )
233 /* was: Repeat One, switching to Repeat All */
235 /* set our button's look */
238 /* prepare core communication */
239 repeating.b_bool = VLC_FALSE;
240 looping.b_bool = VLC_TRUE;
241 config_PutInt( p_playlist, "repeat", 0 );
242 config_PutInt( p_playlist, "loop", 1 );
244 /* show the change */
245 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
249 /* was: Repeat All or bug in VLC, switching to Repeat Off */
251 /* set our button's look */
254 /* prepare core communication */
255 repeating.b_bool = VLC_FALSE;
256 looping.b_bool = VLC_FALSE;
257 config_PutInt( p_playlist, "repeat", 0 );
258 config_PutInt( p_playlist, "loop", 0 );
260 /* show the change */
261 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
264 /* communicate with core and the main intf loop */
265 var_Set( p_playlist, "repeat", repeating );
266 var_Set( p_playlist, "loop", looping );
267 p_intf->p_sys->b_playmode_update = VLC_TRUE;
268 p_intf->p_sys->b_intf_update = VLC_TRUE;
270 vlc_object_release( p_playlist );
274 - (IBAction)repeat:(id)sender
277 intf_thread_t * p_intf = VLCIntf;
278 playlist_t * p_playlist = pl_Yield( p_intf );
280 var_Get( p_playlist, "repeat", &val );
283 var_Set( p_playlist, "loop", val );
285 val.b_bool = !val.b_bool;
286 var_Set( p_playlist, "repeat", val );
289 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
290 config_PutInt( p_playlist, "repeat", 1 );
294 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
295 config_PutInt( p_playlist, "repeat", 0 );
298 p_intf->p_sys->b_playmode_update = VLC_TRUE;
299 p_intf->p_sys->b_intf_update = VLC_TRUE;
300 vlc_object_release( p_playlist );
303 - (IBAction)loop:(id)sender
306 intf_thread_t * p_intf = VLCIntf;
307 playlist_t * p_playlist = pl_Yield( p_intf );
309 var_Get( p_playlist, "loop", &val );
312 var_Set( p_playlist, "repeat", val );
314 val.b_bool = !val.b_bool;
315 var_Set( p_playlist, "loop", val );
318 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
319 config_PutInt( p_playlist, "loop", 1 );
323 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
324 config_PutInt( p_playlist, "loop", 0 );
327 p_intf->p_sys->b_playmode_update = VLC_TRUE;
328 p_intf->p_sys->b_intf_update = VLC_TRUE;
329 vlc_object_release( p_playlist );
332 - (IBAction)forward:(id)sender
335 intf_thread_t * p_intf = VLCIntf;
336 val.i_int = config_GetInt( p_intf, "key-jump+short" );
337 var_Set( p_intf->p_libvlc, "key-pressed", val );
340 - (IBAction)backward:(id)sender
343 intf_thread_t * p_intf = VLCIntf;
344 val.i_int = config_GetInt( p_intf, "key-jump-short" );
345 var_Set( p_intf->p_libvlc, "key-pressed", val );
349 - (IBAction)volumeUp:(id)sender
352 intf_thread_t * p_intf = VLCIntf;
353 val.i_int = config_GetInt( p_intf, "key-vol-up" );
354 var_Set( p_intf->p_libvlc, "key-pressed", val );
355 /* Manage volume status */
356 [o_main manageVolumeSlider];
359 - (IBAction)volumeDown:(id)sender
362 intf_thread_t * p_intf = VLCIntf;
363 val.i_int = config_GetInt( p_intf, "key-vol-down" );
364 var_Set( p_intf->p_libvlc, "key-pressed", val );
365 /* Manage volume status */
366 [o_main manageVolumeSlider];
369 - (IBAction)mute:(id)sender
372 intf_thread_t * p_intf = VLCIntf;
373 val.i_int = config_GetInt( p_intf, "key-vol-mute" );
374 var_Set( p_intf->p_libvlc, "key-pressed", val );
375 /* Manage volume status */
376 [o_main manageVolumeSlider];
379 - (IBAction)volumeSliderUpdated:(id)sender
381 intf_thread_t * p_intf = VLCIntf;
382 audio_volume_t i_volume = (audio_volume_t)[sender intValue];
383 int i_volume_step = 0;
384 i_volume_step = config_GetInt( p_intf->p_libvlc, "volume-step" );
385 aout_VolumeSet( p_intf, i_volume * i_volume_step );
386 /* Manage volume status */
387 [o_main manageVolumeSlider];
390 - (IBAction)windowAction:(id)sender
392 NSString *o_title = [sender title];
394 vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
398 id o_vout_view = [self getVoutView];
401 if( [o_title isEqualToString: _NS("Half Size") ] )
402 [o_vout_view scaleWindowWithFactor: 0.5];
403 else if( [o_title isEqualToString: _NS("Normal Size") ] )
404 [o_vout_view scaleWindowWithFactor: 1.0];
405 else if( [o_title isEqualToString: _NS("Double Size") ] )
406 [o_vout_view scaleWindowWithFactor: 2.0];
407 else if( [o_title isEqualToString: _NS("Float on Top") ] )
408 [o_vout_view toggleFloatOnTop];
409 else if( [o_title isEqualToString: _NS("Fit to Screen") ] )
411 id o_window = [o_vout_view getWindow];
412 if( ![o_window isZoomed] )
413 [o_window performZoom:self];
415 else if( [o_title isEqualToString: _NS("Snapshot") ] )
417 [o_vout_view snapshot];
421 [o_vout_view toggleFullscreen];
424 vlc_object_release( (vlc_object_t *)p_vout );
428 playlist_t * p_playlist = pl_Yield( VLCIntf );
430 if( [o_title isEqualToString: _NS("Fullscreen")] ||
431 [sender isKindOfClass:[NSButton class]] )
434 var_Get( p_playlist, "fullscreen", &val );
435 var_Set( p_playlist, "fullscreen", (vlc_value_t)!val.b_bool );
438 vlc_object_release( p_playlist );
443 - (BOOL)keyEvent:(NSEvent *)o_event
445 BOOL eventHandled = NO;
446 unichar key = [[o_event charactersIgnoringModifiers] characterAtIndex: 0];
450 vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
455 if( key == (unichar) 0x1b )
457 id o_vout_view = [self getVoutView];
458 if( o_vout_view && [o_vout_view isFullscreen] )
460 [o_vout_view toggleFullscreen];
464 else if( key == ' ' )
469 vlc_object_release( (vlc_object_t *)p_vout );
475 - (void)setupVarMenuItem:(NSMenuItem *)o_mi
476 target:(vlc_object_t *)p_object
477 var:(const char *)psz_variable
478 selector:(SEL)pf_callback
480 vlc_value_t val, text;
481 int i_type = var_Type( p_object, psz_variable );
483 switch( i_type & VLC_VAR_TYPE )
487 case VLC_VAR_VARIABLE:
489 case VLC_VAR_INTEGER:
492 /* Variable doesn't exist or isn't handled */
496 /* Make sure we want to display the variable */
497 if( i_type & VLC_VAR_HASCHOICE )
499 var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
500 if( val.i_int == 0 ) return;
501 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
505 /* Get the descriptive name of the variable */
506 var_Change( p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL );
507 [o_mi setTitle: [[VLCMain sharedInstance] localizedString: text.psz_string ?
508 text.psz_string : strdup( psz_variable ) ]];
510 var_Get( p_object, psz_variable, &val );
511 if( i_type & VLC_VAR_HASCHOICE )
513 NSMenu *o_menu = [o_mi submenu];
515 [self setupVarMenu: o_menu forMenuItem: o_mi target:p_object
516 var:psz_variable selector:pf_callback];
518 if( text.psz_string ) free( text.psz_string );
523 switch( i_type & VLC_VAR_TYPE )
526 o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
527 Value: val ofType: i_type];
528 [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
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]]];
535 if( !( i_type & VLC_VAR_ISCOMMAND ) )
536 [o_mi setState: val.b_bool ? TRUE : FALSE ];
540 if( text.psz_string ) free( text.psz_string );
544 if( ( i_type & VLC_VAR_TYPE ) == VLC_VAR_STRING ) free( val.psz_string );
545 if( text.psz_string ) free( text.psz_string );
549 - (void)setupVarMenu:(NSMenu *)o_menu
550 forMenuItem: (NSMenuItem *)o_parent
551 target:(vlc_object_t *)p_object
552 var:(const char *)psz_variable
553 selector:(SEL)pf_callback
555 vlc_value_t val, val_list, text_list;
556 int i_type, i, i_nb_items;
558 /* remove previous items */
559 i_nb_items = [o_menu numberOfItems];
560 for( i = 0; i < i_nb_items; i++ )
562 [o_menu removeItemAtIndex: 0];
565 /* Check the type of the object variable */
566 i_type = var_Type( p_object, psz_variable );
568 /* Make sure we want to display the variable */
569 if( i_type & VLC_VAR_HASCHOICE )
571 var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
572 if( val.i_int == 0 ) return;
573 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
581 switch( i_type & VLC_VAR_TYPE )
585 case VLC_VAR_VARIABLE:
587 case VLC_VAR_INTEGER:
590 /* Variable doesn't exist or isn't handled */
594 if( var_Get( p_object, psz_variable, &val ) < 0 )
599 if( var_Change( p_object, psz_variable, VLC_VAR_GETLIST,
600 &val_list, &text_list ) < 0 )
602 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
606 /* make (un)sensitive */
607 [o_parent setEnabled: ( val_list.p_list->i_count > 1 )];
609 for( i = 0; i < val_list.p_list->i_count; i++ )
611 vlc_value_t another_val;
613 NSString *o_title = @"";
616 switch( i_type & VLC_VAR_TYPE )
619 another_val.psz_string =
620 strdup(val_list.p_list->p_values[i].psz_string);
622 o_title = [[VLCMain sharedInstance] localizedString: text_list.p_list->p_values[i].psz_string ?
623 text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string ];
625 o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
626 o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
627 Value: another_val ofType: i_type];
628 [o_lmi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
629 [o_lmi setTarget: self];
631 if( !strcmp( val.psz_string, val_list.p_list->p_values[i].psz_string ) && !( i_type & VLC_VAR_ISCOMMAND ) )
632 [o_lmi setState: TRUE ];
636 case VLC_VAR_INTEGER:
638 o_title = text_list.p_list->p_values[i].psz_string ?
639 [[VLCMain sharedInstance] localizedString: strdup( text_list.p_list->p_values[i].psz_string )] :
640 [NSString stringWithFormat: @"%d",
641 val_list.p_list->p_values[i].i_int];
643 o_lmi = [[o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""] retain ];
644 o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
645 Value: val_list.p_list->p_values[i] ofType: i_type];
646 [o_lmi setRepresentedObject: [NSValue valueWithPointer:[ o_data retain]]];
647 [o_lmi setTarget: self];
649 if( val_list.p_list->p_values[i].i_int == val.i_int && !( i_type & VLC_VAR_ISCOMMAND ) )
650 [o_lmi setState: TRUE ];
658 /* clean up everything */
659 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
660 var_Change( p_object, psz_variable, VLC_VAR_FREELIST, &val_list, &text_list );
663 - (IBAction)toggleVar:(id)sender
665 NSMenuItem *o_mi = (NSMenuItem *)sender;
666 VLCMenuExt *o_data = [[o_mi representedObject] pointerValue];
667 [NSThread detachNewThreadSelector: @selector(toggleVarThread:)
668 toTarget: self withObject: o_data];
673 - (int)toggleVarThread: (id)_o_data
675 vlc_object_t *p_object;
676 NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
677 VLCMenuExt *o_data = (VLCMenuExt *)_o_data;
679 vlc_thread_set_priority( VLCIntf , VLC_THREAD_PRIORITY_LOW );
681 p_object = (vlc_object_t *)vlc_object_get( VLCIntf,
684 if( p_object != NULL )
686 var_Set( p_object, strdup([o_data name]), [o_data value] );
687 vlc_object_release( p_object );
695 - (IBAction)goToSpecificTime:(id)sender
697 if( sender == o_specificTime_cancel_btn )
699 [NSApp endSheet: o_specificTime_win];
700 [o_specificTime_win close];
702 else if( sender == o_specificTime_ok_btn )
704 input_thread_t * p_input = (input_thread_t *)vlc_object_find( VLCIntf, \
705 VLC_OBJECT_INPUT, FIND_ANYWHERE );
708 unsigned int timeInSec = 0;
709 NSString * fieldContent = [o_specificTime_enter_fld stringValue];
710 if( [[fieldContent componentsSeparatedByString: @":"] count] > 1 &&
711 [[fieldContent componentsSeparatedByString: @":"] count] <= 3 )
713 NSArray * ourTempArray = \
714 [fieldContent componentsSeparatedByString: @":"];
716 if( [[fieldContent componentsSeparatedByString: @":"] count] == 3 )
718 timeInSec += ([[ourTempArray objectAtIndex: 0] intValue] * 3600); //h
719 timeInSec += ([[ourTempArray objectAtIndex: 1] intValue] * 60); //m
720 timeInSec += [[ourTempArray objectAtIndex: 2] intValue]; //s
724 timeInSec += ([[ourTempArray objectAtIndex: 0] intValue] * 60); //m
725 timeInSec += [[ourTempArray objectAtIndex: 1] intValue]; //s
729 timeInSec = [fieldContent intValue];
731 input_Control( p_input, INPUT_SET_TIME, (int64_t)(timeInSec * 1000000));
732 vlc_object_release( p_input );
735 [NSApp endSheet: o_specificTime_win];
736 [o_specificTime_win close];
740 input_thread_t * p_input = (input_thread_t *)vlc_object_find( VLCIntf, \
741 VLC_OBJECT_INPUT, FIND_ANYWHERE );
744 /* we can obviously only do that if an input is available */
745 vlc_value_t pos, length;
746 var_Get( p_input, "time", &pos );
747 [o_specificTime_enter_fld setIntValue: (pos.i_time / 1000000)];
748 var_Get( p_input, "length", &length );
749 [o_specificTime_stepper setMaxValue: (length.i_time / 1000000)];
751 [NSApp beginSheet: o_specificTime_win modalForWindow: \
752 [NSApp mainWindow] modalDelegate: self didEndSelector: nil \
754 [o_specificTime_win makeKeyWindow];
755 vlc_object_release( p_input );
766 msg_Err( VLCIntf, "FSPanel is nil" );
773 @implementation VLCControls (NSMenuValidation)
775 - (BOOL)validateMenuItem:(NSMenuItem *)o_mi
777 BOOL bEnabled = TRUE;
779 intf_thread_t * p_intf = VLCIntf;
780 playlist_t * p_playlist = pl_Yield( p_intf );
782 vlc_mutex_lock( &p_playlist->object_lock );
784 #define p_input p_playlist->p_input
786 if( [[o_mi title] isEqualToString: _NS("Faster")] ||
787 [[o_mi title] isEqualToString: _NS("Slower")] )
789 if( p_input != NULL )
791 bEnabled = p_input->p->input.b_can_pace_control;
798 else if( [[o_mi title] isEqualToString: _NS("Stop")] )
800 if( p_input == NULL )
804 [o_main setupMenus]; /* Make sure input menu is up to date */
806 else if( [[o_mi title] isEqualToString: _NS("Previous")] ||
807 [[o_mi title] isEqualToString: _NS("Next")] )
809 /** \todo fix i_size use */
810 bEnabled = p_playlist->items.i_size > 1;
812 else if( [[o_mi title] isEqualToString: _NS("Random")] )
815 var_Get( p_playlist, "random", &val );
816 i_state = val.b_bool ? NSOnState : NSOffState;
817 [o_mi setState: i_state];
819 else if( [[o_mi title] isEqualToString: _NS("Repeat One")] )
822 var_Get( p_playlist, "repeat", &val );
823 i_state = val.b_bool ? NSOnState : NSOffState;
824 [o_mi setState: i_state];
826 else if( [[o_mi title] isEqualToString: _NS("Repeat All")] )
829 var_Get( p_playlist, "loop", &val );
830 i_state = val.b_bool ? NSOnState : NSOffState;
831 [o_mi setState: i_state];
833 else if( [[o_mi title] isEqualToString: _NS("Step Forward")] ||
834 [[o_mi title] isEqualToString: _NS("Step Backward")] ||
835 [[o_mi title] isEqualToString: _NS("Jump To Time")])
837 if( p_input != NULL )
839 var_Get( p_input, "seekable", &val);
840 bEnabled = val.b_bool;
842 else bEnabled = FALSE;
844 else if( [[o_mi title] isEqualToString: _NS("Mute")] )
846 [o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState];
847 [o_main setupMenus]; /* Make sure audio menu is up to date */
849 else if( [[o_mi title] isEqualToString: _NS("Half Size")] ||
850 [[o_mi title] isEqualToString: _NS("Normal Size")] ||
851 [[o_mi title] isEqualToString: _NS("Double Size")] ||
852 [[o_mi title] isEqualToString: _NS("Fit to Screen")] ||
853 [[o_mi title] isEqualToString: _NS("Snapshot")] ||
854 [[o_mi title] isEqualToString: _NS("Fullscreen")] ||
855 [[o_mi title] isEqualToString: _NS("Float on Top")] )
858 NSArray *o_windows = [NSApp orderedWindows];
859 NSEnumerator *o_enumerator = [o_windows objectEnumerator];
862 vout_thread_t *p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
866 if( [[o_mi title] isEqualToString: _NS("Float on Top")] )
868 var_Get( p_vout, "video-on-top", &val );
869 [o_mi setState: val.b_bool ? NSOnState : NSOffState];
872 while( (o_window = [o_enumerator nextObject]))
874 if( [[o_window className] isEqualToString: @"VLCWindow"] ||
875 [[[VLCMain sharedInstance] getEmbeddedList]
876 windowContainsEmbedded: o_window])
882 vlc_object_release( (vlc_object_t *)p_vout );
884 else if( [[o_mi title] isEqualToString: _NS("Fullscreen")] )
886 var_Get( p_playlist, "fullscreen", &val );
887 [o_mi setState: val.b_bool];
890 [o_main setupMenus]; /* Make sure video menu is up to date */
893 vlc_mutex_unlock( &p_playlist->object_lock );
894 vlc_object_release( p_playlist );
901 /*****************************************************************************
902 * VLCMenuExt implementation
903 *****************************************************************************
904 * Object connected to a playlistitem which remembers the data belonging to
905 * the variable of the autogenerated menu
906 *****************************************************************************/
907 @implementation VLCMenuExt
909 - (id)initWithVar: (const char *)_psz_name Object: (int)i_id
910 Value: (vlc_value_t)val ofType: (int)_i_type
916 psz_name = strdup( _psz_name );
954 /*****************************************************************************
955 * VLCTimeField implementation
956 *****************************************************************************
957 * we need this to catch our click-event in the controller window
958 *****************************************************************************/
960 @implementation VLCTimeField
961 - (void)mouseDown: (NSEvent *)ourEvent
963 if( [ourEvent clickCount] > 1 )
964 [[[VLCMain sharedInstance] getControls] goToSpecificTime: nil];