1 /*****************************************************************************
2 * controls.m: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2002-2006 the VideoLAN team
7 * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8 * Christophe Massiot <massiot@via.ecp.fr>
9 * Derk-Jan Hartman <hartman at videolan dot org>
10 * Benjamin Pracht <bigben at videolan doit org>
11 * Felix K
\9fhne <fkuehne at videolan dot org>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26 *****************************************************************************/
28 /*****************************************************************************
30 *****************************************************************************/
31 #include <stdlib.h> /* malloc(), free() */
32 #include <sys/param.h> /* for MAXPATHLEN */
42 /*****************************************************************************
43 * VLCControls implementation
44 *****************************************************************************/
45 @implementation VLCControls
50 o_fs_panel = [[VLCFSPanel alloc] init];
56 [o_specificTime_mi setTitle: _NS("Jump To Time")];
57 [o_specificTime_cancel_btn setTitle: _NS("Cancel")];
58 [o_specificTime_ok_btn setTitle: _NS("OK")];
59 [o_specificTime_sec_lbl setStringValue: _NS("sec.")];
60 [o_specificTime_goTo_lbl setStringValue: _NS("Jump to time")];
63 - (IBAction)play:(id)sender
66 intf_thread_t * p_intf = VLCIntf;
67 playlist_t * p_playlist = pl_Yield( p_intf );
69 vlc_mutex_lock( &p_playlist->object_lock );
70 if( playlist_IsEmpty( p_playlist ) )
72 vlc_mutex_unlock( &p_playlist->object_lock );
73 vlc_object_release( p_playlist );
74 [o_main intfOpenFileGeneric: (id)sender];
78 vlc_mutex_unlock( &p_playlist->object_lock );
79 vlc_object_release( p_playlist );
82 val.i_int = config_GetInt( p_intf, "key-play-pause" );
83 var_Set( p_intf->p_libvlc, "key-pressed", val );
86 /* Small helper method */
92 id o_embedded_vout_list = [[VLCMain sharedInstance] getEmbeddedList];
93 NSEnumerator *o_enumerator = [[NSApp orderedWindows] objectEnumerator];
94 while( !o_vout_view && ( o_window = [o_enumerator nextObject] ) )
96 /* We have an embedded vout */
97 if( [o_embedded_vout_list windowContainsEmbedded: o_window] )
99 o_vout_view = [o_embedded_vout_list getViewForWindow: o_window];
101 /* We have a detached vout */
102 else if( [[o_window className] isEqualToString: @"VLCWindow"] )
104 msg_Dbg( VLCIntf, "detached vout controls.m call getVoutView" );
105 o_vout_view = [o_window getVoutView];
112 - (IBAction)stop:(id)sender
115 intf_thread_t * p_intf = VLCIntf;
116 val.i_int = config_GetInt( p_intf, "key-stop" );
117 var_Set( p_intf->p_libvlc, "key-pressed", val );
120 - (IBAction)faster:(id)sender
123 intf_thread_t * p_intf = VLCIntf;
124 val.i_int = config_GetInt( p_intf, "key-faster" );
125 var_Set( p_intf->p_libvlc, "key-pressed", val );
128 - (IBAction)slower:(id)sender
131 intf_thread_t * p_intf = VLCIntf;
132 val.i_int = config_GetInt( p_intf, "key-slower" );
133 var_Set( p_intf->p_libvlc, "key-pressed", val );
136 - (IBAction)prev:(id)sender
139 intf_thread_t * p_intf = VLCIntf;
140 val.i_int = config_GetInt( p_intf, "key-prev" );
141 var_Set( p_intf->p_libvlc, "key-pressed", val );
144 - (IBAction)next:(id)sender
147 intf_thread_t * p_intf = VLCIntf;
148 val.i_int = config_GetInt( p_intf, "key-next" );
149 var_Set( p_intf->p_libvlc, "key-pressed", val );
152 - (IBAction)random:(id)sender
155 intf_thread_t * p_intf = VLCIntf;
156 playlist_t * p_playlist = pl_Yield( p_intf );
158 var_Get( p_playlist, "random", &val );
159 val.b_bool = !val.b_bool;
160 var_Set( p_playlist, "random", val );
163 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Random On" ) );
164 config_PutInt( p_playlist, "random", 1 );
168 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Random Off" ) );
169 config_PutInt( p_playlist, "random", 0 );
172 p_intf->p_sys->b_playmode_update = VLC_TRUE;
173 p_intf->p_sys->b_intf_update = VLC_TRUE;
174 vlc_object_release( p_playlist );
177 /* three little ugly helpers */
180 [o_btn_repeat setImage: [NSImage imageNamed:@"repeat_single_embedded_blue"]];
181 [o_btn_repeat setAlternateImage: [NSImage imageNamed:@"repeat_embedded_blue"]];
185 [o_btn_repeat setImage: [NSImage imageNamed:@"repeat_embedded_blue"]];
186 [o_btn_repeat setAlternateImage: [NSImage imageNamed:@"repeat_embedded"]];
190 [o_btn_repeat setImage: [NSImage imageNamed:@"repeat_embedded"]];
191 [o_btn_repeat setAlternateImage: [NSImage imageNamed:@"repeat_single_embedded_blue"]];
196 playlist_t *p_playlist = pl_Yield( VLCIntf );
197 var_Get( p_playlist, "random", &val );
198 [o_btn_shuffle setState: val.b_bool];
199 vlc_object_release( p_playlist );
202 - (IBAction)repeatButtonAction:(id)sender
204 vlc_value_t looping,repeating;
205 intf_thread_t * p_intf = VLCIntf;
206 playlist_t * p_playlist = pl_Yield( p_intf );
208 var_Get( p_playlist, "repeat", &repeating );
209 var_Get( p_playlist, "loop", &looping );
211 if( !repeating.b_bool && !looping.b_bool )
213 /* was: no repeating at all, switching to Repeat One */
215 /* set our button's look */
218 /* prepare core communication */
219 repeating.b_bool = VLC_TRUE;
220 looping.b_bool = VLC_FALSE;
221 config_PutInt( p_playlist, "repeat", 1 );
222 config_PutInt( p_playlist, "loop", 0 );
224 /* show the change */
225 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
227 else if( repeating.b_bool && !looping.b_bool )
229 /* was: Repeat One, switching to Repeat All */
231 /* set our button's look */
234 /* prepare core communication */
235 repeating.b_bool = VLC_FALSE;
236 looping.b_bool = VLC_TRUE;
237 config_PutInt( p_playlist, "repeat", 0 );
238 config_PutInt( p_playlist, "loop", 1 );
240 /* show the change */
241 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
245 /* was: Repeat All or bug in VLC, switching to Repeat Off */
247 /* set our button's look */
250 /* prepare core communication */
251 repeating.b_bool = VLC_FALSE;
252 looping.b_bool = VLC_FALSE;
253 config_PutInt( p_playlist, "repeat", 0 );
254 config_PutInt( p_playlist, "loop", 0 );
256 /* show the change */
257 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
260 /* communicate with core and the main intf loop */
261 var_Set( p_playlist, "repeat", repeating );
262 var_Set( p_playlist, "loop", looping );
263 p_intf->p_sys->b_playmode_update = VLC_TRUE;
264 p_intf->p_sys->b_intf_update = VLC_TRUE;
266 vlc_object_release( p_playlist );
270 - (IBAction)repeat:(id)sender
273 intf_thread_t * p_intf = VLCIntf;
274 playlist_t * p_playlist = pl_Yield( p_intf );
276 var_Get( p_playlist, "repeat", &val );
279 var_Set( p_playlist, "loop", val );
281 val.b_bool = !val.b_bool;
282 var_Set( p_playlist, "repeat", val );
285 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
286 config_PutInt( p_playlist, "repeat", 1 );
290 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
291 config_PutInt( p_playlist, "repeat", 0 );
294 p_intf->p_sys->b_playmode_update = VLC_TRUE;
295 p_intf->p_sys->b_intf_update = VLC_TRUE;
296 vlc_object_release( p_playlist );
299 - (IBAction)loop:(id)sender
302 intf_thread_t * p_intf = VLCIntf;
303 playlist_t * p_playlist = pl_Yield( p_intf );
305 var_Get( p_playlist, "loop", &val );
308 var_Set( p_playlist, "repeat", val );
310 val.b_bool = !val.b_bool;
311 var_Set( p_playlist, "loop", val );
314 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
315 config_PutInt( p_playlist, "loop", 1 );
319 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
320 config_PutInt( p_playlist, "loop", 0 );
323 p_intf->p_sys->b_playmode_update = VLC_TRUE;
324 p_intf->p_sys->b_intf_update = VLC_TRUE;
325 vlc_object_release( p_playlist );
328 - (IBAction)forward:(id)sender
331 intf_thread_t * p_intf = VLCIntf;
332 val.i_int = config_GetInt( p_intf, "key-jump+short" );
333 var_Set( p_intf->p_libvlc, "key-pressed", val );
336 - (IBAction)backward:(id)sender
339 intf_thread_t * p_intf = VLCIntf;
340 val.i_int = config_GetInt( p_intf, "key-jump-short" );
341 var_Set( p_intf->p_libvlc, "key-pressed", val );
345 - (IBAction)volumeUp:(id)sender
348 intf_thread_t * p_intf = VLCIntf;
349 val.i_int = config_GetInt( p_intf, "key-vol-up" );
350 var_Set( p_intf->p_libvlc, "key-pressed", val );
351 /* Manage volume status */
352 [o_main manageVolumeSlider];
355 - (IBAction)volumeDown:(id)sender
358 intf_thread_t * p_intf = VLCIntf;
359 val.i_int = config_GetInt( p_intf, "key-vol-down" );
360 var_Set( p_intf->p_libvlc, "key-pressed", val );
361 /* Manage volume status */
362 [o_main manageVolumeSlider];
365 - (IBAction)mute:(id)sender
368 intf_thread_t * p_intf = VLCIntf;
369 val.i_int = config_GetInt( p_intf, "key-vol-mute" );
370 var_Set( p_intf->p_libvlc, "key-pressed", val );
371 /* Manage volume status */
372 [o_main manageVolumeSlider];
375 - (IBAction)volumeSliderUpdated:(id)sender
377 intf_thread_t * p_intf = VLCIntf;
378 audio_volume_t i_volume = (audio_volume_t)[sender intValue];
379 int i_volume_step = 0;
380 i_volume_step = config_GetInt( p_intf->p_libvlc, "volume-step" );
381 aout_VolumeSet( p_intf, i_volume * i_volume_step );
382 /* Manage volume status */
383 [o_main manageVolumeSlider];
386 - (IBAction)windowAction:(id)sender
388 NSString *o_title = [sender title];
390 vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
394 id o_vout_view = [self getVoutView];
397 if( [o_title isEqualToString: _NS("Half Size") ] )
398 [o_vout_view scaleWindowWithFactor: 0.5];
399 else if( [o_title isEqualToString: _NS("Normal Size") ] )
400 [o_vout_view scaleWindowWithFactor: 1.0];
401 else if( [o_title isEqualToString: _NS("Double Size") ] )
402 [o_vout_view scaleWindowWithFactor: 2.0];
403 else if( [o_title isEqualToString: _NS("Float on Top") ] )
404 [o_vout_view toggleFloatOnTop];
405 else if( [o_title isEqualToString: _NS("Fit to Screen") ] )
407 id o_window = [o_vout_view getWindow];
408 if( ![o_window isZoomed] )
409 [o_window performZoom:self];
411 else if( [o_title isEqualToString: _NS("Snapshot") ] )
413 [o_vout_view snapshot];
417 [o_vout_view toggleFullscreen];
420 vlc_object_release( (vlc_object_t *)p_vout );
424 playlist_t * p_playlist = pl_Yield( VLCIntf );
426 if( [o_title isEqualToString: _NS("Fullscreen")] ||
427 [sender isKindOfClass:[NSButton class]] )
430 var_Get( p_playlist, "fullscreen", &val );
431 var_Set( p_playlist, "fullscreen", (vlc_value_t)!val.b_bool );
434 vlc_object_release( p_playlist );
439 - (BOOL)keyEvent:(NSEvent *)o_event
441 BOOL eventHandled = NO;
442 unichar key = [[o_event charactersIgnoringModifiers] characterAtIndex: 0];
446 vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
451 if( key == (unichar) 0x1b )
453 id o_vout_view = [self getVoutView];
454 if( o_vout_view && [o_vout_view isFullscreen] )
456 [o_vout_view toggleFullscreen];
460 else if( key == ' ' )
465 vlc_object_release( (vlc_object_t *)p_vout );
471 - (void)setupVarMenuItem:(NSMenuItem *)o_mi
472 target:(vlc_object_t *)p_object
473 var:(const char *)psz_variable
474 selector:(SEL)pf_callback
476 vlc_value_t val, text;
477 int i_type = var_Type( p_object, psz_variable );
479 switch( i_type & VLC_VAR_TYPE )
483 case VLC_VAR_VARIABLE:
485 case VLC_VAR_INTEGER:
488 /* Variable doesn't exist or isn't handled */
492 /* Make sure we want to display the variable */
493 if( i_type & VLC_VAR_HASCHOICE )
495 var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
496 if( val.i_int == 0 ) return;
497 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
501 /* Get the descriptive name of the variable */
502 var_Change( p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL );
503 [o_mi setTitle: [[VLCMain sharedInstance] localizedString: text.psz_string ?
504 text.psz_string : strdup( psz_variable ) ]];
506 var_Get( p_object, psz_variable, &val );
507 if( i_type & VLC_VAR_HASCHOICE )
509 NSMenu *o_menu = [o_mi submenu];
511 [self setupVarMenu: o_menu forMenuItem: o_mi target:p_object
512 var:psz_variable selector:pf_callback];
514 if( text.psz_string ) free( text.psz_string );
519 switch( i_type & VLC_VAR_TYPE )
522 o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
523 Value: val ofType: i_type];
524 [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
528 o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
529 Value: val ofType: i_type];
530 [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
531 if( !( i_type & VLC_VAR_ISCOMMAND ) )
532 [o_mi setState: val.b_bool ? TRUE : FALSE ];
536 if( text.psz_string ) free( text.psz_string );
540 if( ( i_type & VLC_VAR_TYPE ) == VLC_VAR_STRING ) free( val.psz_string );
541 if( text.psz_string ) free( text.psz_string );
545 - (void)setupVarMenu:(NSMenu *)o_menu
546 forMenuItem: (NSMenuItem *)o_parent
547 target:(vlc_object_t *)p_object
548 var:(const char *)psz_variable
549 selector:(SEL)pf_callback
551 vlc_value_t val, val_list, text_list;
552 int i_type, i, i_nb_items;
554 /* remove previous items */
555 i_nb_items = [o_menu numberOfItems];
556 for( i = 0; i < i_nb_items; i++ )
558 [o_menu removeItemAtIndex: 0];
561 /* Check the type of the object variable */
562 i_type = var_Type( p_object, psz_variable );
564 /* Make sure we want to display the variable */
565 if( i_type & VLC_VAR_HASCHOICE )
567 var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
568 if( val.i_int == 0 ) return;
569 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
577 switch( i_type & VLC_VAR_TYPE )
581 case VLC_VAR_VARIABLE:
583 case VLC_VAR_INTEGER:
586 /* Variable doesn't exist or isn't handled */
590 if( var_Get( p_object, psz_variable, &val ) < 0 )
595 if( var_Change( p_object, psz_variable, VLC_VAR_GETLIST,
596 &val_list, &text_list ) < 0 )
598 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
602 /* make (un)sensitive */
603 [o_parent setEnabled: ( val_list.p_list->i_count > 1 )];
605 for( i = 0; i < val_list.p_list->i_count; i++ )
607 vlc_value_t another_val;
609 NSString *o_title = @"";
612 switch( i_type & VLC_VAR_TYPE )
615 another_val.psz_string =
616 strdup(val_list.p_list->p_values[i].psz_string);
618 o_title = [[VLCMain sharedInstance] localizedString: text_list.p_list->p_values[i].psz_string ?
619 text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string ];
621 o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
622 o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
623 Value: another_val ofType: i_type];
624 [o_lmi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
625 [o_lmi setTarget: self];
627 if( !strcmp( val.psz_string, val_list.p_list->p_values[i].psz_string ) && !( i_type & VLC_VAR_ISCOMMAND ) )
628 [o_lmi setState: TRUE ];
632 case VLC_VAR_INTEGER:
634 o_title = text_list.p_list->p_values[i].psz_string ?
635 [[VLCMain sharedInstance] localizedString: strdup( text_list.p_list->p_values[i].psz_string )] :
636 [NSString stringWithFormat: @"%d",
637 val_list.p_list->p_values[i].i_int];
639 o_lmi = [[o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""] retain ];
640 o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
641 Value: val_list.p_list->p_values[i] ofType: i_type];
642 [o_lmi setRepresentedObject: [NSValue valueWithPointer:[ o_data retain]]];
643 [o_lmi setTarget: self];
645 if( val_list.p_list->p_values[i].i_int == val.i_int && !( i_type & VLC_VAR_ISCOMMAND ) )
646 [o_lmi setState: TRUE ];
654 /* clean up everything */
655 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
656 var_Change( p_object, psz_variable, VLC_VAR_FREELIST, &val_list, &text_list );
659 - (IBAction)toggleVar:(id)sender
661 NSMenuItem *o_mi = (NSMenuItem *)sender;
662 VLCMenuExt *o_data = [[o_mi representedObject] pointerValue];
663 [NSThread detachNewThreadSelector: @selector(toggleVarThread:)
664 toTarget: self withObject: o_data];
669 - (int)toggleVarThread: (id)_o_data
671 vlc_object_t *p_object;
672 NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
673 VLCMenuExt *o_data = (VLCMenuExt *)_o_data;
675 vlc_thread_set_priority( VLCIntf , VLC_THREAD_PRIORITY_LOW );
677 p_object = (vlc_object_t *)vlc_object_get( VLCIntf,
680 if( p_object != NULL )
682 var_Set( p_object, strdup([o_data name]), [o_data value] );
683 vlc_object_release( p_object );
691 - (IBAction)goToSpecificTime:(id)sender
693 if( sender == o_specificTime_cancel_btn )
695 [NSApp endSheet: o_specificTime_win];
696 [o_specificTime_win close];
698 else if( sender == o_specificTime_ok_btn )
700 input_thread_t * p_input = (input_thread_t *)vlc_object_find( VLCIntf, \
701 VLC_OBJECT_INPUT, FIND_ANYWHERE );
704 unsigned int timeInSec = 0;
705 NSString * fieldContent = [o_specificTime_enter_fld stringValue];
706 if( [[fieldContent componentsSeparatedByString: @":"] count] > 1 &&
707 [[fieldContent componentsSeparatedByString: @":"] count] <= 3 )
709 NSArray * ourTempArray = \
710 [fieldContent componentsSeparatedByString: @":"];
712 if( [[fieldContent componentsSeparatedByString: @":"] count] == 3 )
714 timeInSec += ([[ourTempArray objectAtIndex: 0] intValue] * 3600); //h
715 timeInSec += ([[ourTempArray objectAtIndex: 1] intValue] * 60); //m
716 timeInSec += [[ourTempArray objectAtIndex: 2] intValue]; //s
720 timeInSec += ([[ourTempArray objectAtIndex: 0] intValue] * 60); //m
721 timeInSec += [[ourTempArray objectAtIndex: 1] intValue]; //s
725 timeInSec = [fieldContent intValue];
727 input_Control( p_input, INPUT_SET_TIME, (int64_t)(timeInSec * 1000000));
728 vlc_object_release( p_input );
731 [NSApp endSheet: o_specificTime_win];
732 [o_specificTime_win close];
736 input_thread_t * p_input = (input_thread_t *)vlc_object_find( VLCIntf, \
737 VLC_OBJECT_INPUT, FIND_ANYWHERE );
740 /* we can obviously only do that if an input is available */
741 vlc_value_t pos, length;
742 var_Get( p_input, "time", &pos );
743 [o_specificTime_enter_fld setIntValue: (pos.i_time / 1000000)];
744 var_Get( p_input, "length", &length );
745 [o_specificTime_stepper setMaxValue: (length.i_time / 1000000)];
747 [NSApp beginSheet: o_specificTime_win modalForWindow: \
748 [NSApp mainWindow] modalDelegate: self didEndSelector: nil \
750 [o_specificTime_win makeKeyWindow];
751 vlc_object_release( p_input );
762 msg_Err( VLCIntf, "FSPanel is nil" );
769 @implementation VLCControls (NSMenuValidation)
771 - (BOOL)validateMenuItem:(NSMenuItem *)o_mi
773 BOOL bEnabled = TRUE;
775 intf_thread_t * p_intf = VLCIntf;
776 playlist_t * p_playlist = pl_Yield( p_intf );
778 vlc_mutex_lock( &p_playlist->object_lock );
780 #define p_input p_playlist->p_input
782 if( [[o_mi title] isEqualToString: _NS("Faster")] ||
783 [[o_mi title] isEqualToString: _NS("Slower")] )
785 if( p_input != NULL )
787 bEnabled = p_input->b_can_pace_control;
794 else if( [[o_mi title] isEqualToString: _NS("Stop")] )
796 if( p_input == NULL )
800 [o_main setupMenus]; /* Make sure input menu is up to date */
802 else if( [[o_mi title] isEqualToString: _NS("Previous")] ||
803 [[o_mi title] isEqualToString: _NS("Next")] )
805 /** \todo fix i_size use */
806 bEnabled = p_playlist->items.i_size > 1;
808 else if( [[o_mi title] isEqualToString: _NS("Random")] )
811 var_Get( p_playlist, "random", &val );
812 i_state = val.b_bool ? NSOnState : NSOffState;
813 [o_mi setState: i_state];
815 else if( [[o_mi title] isEqualToString: _NS("Repeat One")] )
818 var_Get( p_playlist, "repeat", &val );
819 i_state = val.b_bool ? NSOnState : NSOffState;
820 [o_mi setState: i_state];
822 else if( [[o_mi title] isEqualToString: _NS("Repeat All")] )
825 var_Get( p_playlist, "loop", &val );
826 i_state = val.b_bool ? NSOnState : NSOffState;
827 [o_mi setState: i_state];
829 else if( [[o_mi title] isEqualToString: _NS("Step Forward")] ||
830 [[o_mi title] isEqualToString: _NS("Step Backward")] ||
831 [[o_mi title] isEqualToString: _NS("Jump To Time")])
833 if( p_input != NULL )
835 var_Get( p_input, "seekable", &val);
836 bEnabled = val.b_bool;
838 else bEnabled = FALSE;
840 else if( [[o_mi title] isEqualToString: _NS("Mute")] )
842 [o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState];
843 [o_main setupMenus]; /* Make sure audio menu is up to date */
845 else if( [[o_mi title] isEqualToString: _NS("Half Size")] ||
846 [[o_mi title] isEqualToString: _NS("Normal Size")] ||
847 [[o_mi title] isEqualToString: _NS("Double Size")] ||
848 [[o_mi title] isEqualToString: _NS("Fit to Screen")] ||
849 [[o_mi title] isEqualToString: _NS("Snapshot")] ||
850 [[o_mi title] isEqualToString: _NS("Fullscreen")] ||
851 [[o_mi title] isEqualToString: _NS("Float on Top")] )
854 NSArray *o_windows = [NSApp orderedWindows];
855 NSEnumerator *o_enumerator = [o_windows objectEnumerator];
858 vout_thread_t *p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
862 if( [[o_mi title] isEqualToString: _NS("Float on Top")] )
864 var_Get( p_vout, "video-on-top", &val );
865 [o_mi setState: val.b_bool ? NSOnState : NSOffState];
868 while( (o_window = [o_enumerator nextObject]))
870 if( [[o_window className] isEqualToString: @"VLCWindow"] ||
871 [[[VLCMain sharedInstance] getEmbeddedList]
872 windowContainsEmbedded: o_window])
878 vlc_object_release( (vlc_object_t *)p_vout );
880 else if( [[o_mi title] isEqualToString: _NS("Fullscreen")] )
882 var_Get( p_playlist, "fullscreen", &val );
883 [o_mi setState: val.b_bool];
886 [o_main setupMenus]; /* Make sure video menu is up to date */
889 vlc_mutex_unlock( &p_playlist->object_lock );
890 vlc_object_release( p_playlist );
897 /*****************************************************************************
898 * VLCMenuExt implementation
899 *****************************************************************************
900 * Object connected to a playlistitem which remembers the data belonging to
901 * the variable of the autogenerated menu
902 *****************************************************************************/
903 @implementation VLCMenuExt
905 - (id)initWithVar: (const char *)_psz_name Object: (int)i_id
906 Value: (vlc_value_t)val ofType: (int)_i_type
912 psz_name = strdup( _psz_name );
950 /*****************************************************************************
951 * VLCTimeField implementation
952 *****************************************************************************
953 * we need this to catch our click-event in the controller window
954 *****************************************************************************/
956 @implementation VLCTimeField
957 - (void)mouseDown: (NSEvent *)ourEvent
959 if( [ourEvent clickCount] > 1 )
960 [[[VLCMain sharedInstance] getControls] goToSpecificTime: nil];