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( playlist_IsEmpty( p_playlist ) )
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: @"VLCVoutWindow"] )
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 imageNamed:@"repeat_single_embedded_blue"]];
182 [o_btn_repeat setAlternateImage: [NSImage imageNamed:@"repeat_embedded_blue"]];
186 [o_btn_repeat setImage: [NSImage imageNamed:@"repeat_embedded_blue"]];
187 [o_btn_repeat setAlternateImage: [NSImage imageNamed:@"repeat_embedded"]];
191 [o_btn_repeat setImage: [NSImage imageNamed:@"repeat_embedded"]];
192 [o_btn_repeat setAlternateImage: [NSImage imageNamed:@"repeat_single_embedded_blue"]];
197 playlist_t *p_playlist = pl_Yield( VLCIntf );
198 var_Get( p_playlist, "random", &val );
199 [o_btn_shuffle setState: val.b_bool];
200 vlc_object_release( p_playlist );
203 - (IBAction)repeatButtonAction:(id)sender
205 vlc_value_t looping,repeating;
206 intf_thread_t * p_intf = VLCIntf;
207 playlist_t * p_playlist = pl_Yield( p_intf );
209 var_Get( p_playlist, "repeat", &repeating );
210 var_Get( p_playlist, "loop", &looping );
212 if( !repeating.b_bool && !looping.b_bool )
214 /* was: no repeating at all, switching to Repeat One */
216 /* set our button's look */
219 /* prepare core communication */
220 repeating.b_bool = VLC_TRUE;
221 looping.b_bool = VLC_FALSE;
222 config_PutInt( p_playlist, "repeat", 1 );
223 config_PutInt( p_playlist, "loop", 0 );
225 /* show the change */
226 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
228 else if( repeating.b_bool && !looping.b_bool )
230 /* was: Repeat One, switching to Repeat All */
232 /* set our button's look */
235 /* prepare core communication */
236 repeating.b_bool = VLC_FALSE;
237 looping.b_bool = VLC_TRUE;
238 config_PutInt( p_playlist, "repeat", 0 );
239 config_PutInt( p_playlist, "loop", 1 );
241 /* show the change */
242 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
246 /* was: Repeat All or bug in VLC, switching to Repeat Off */
248 /* set our button's look */
251 /* prepare core communication */
252 repeating.b_bool = VLC_FALSE;
253 looping.b_bool = VLC_FALSE;
254 config_PutInt( p_playlist, "repeat", 0 );
255 config_PutInt( p_playlist, "loop", 0 );
257 /* show the change */
258 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
261 /* communicate with core and the main intf loop */
262 var_Set( p_playlist, "repeat", repeating );
263 var_Set( p_playlist, "loop", looping );
264 p_intf->p_sys->b_playmode_update = VLC_TRUE;
265 p_intf->p_sys->b_intf_update = VLC_TRUE;
267 vlc_object_release( p_playlist );
271 - (IBAction)repeat:(id)sender
274 intf_thread_t * p_intf = VLCIntf;
275 playlist_t * p_playlist = pl_Yield( p_intf );
277 var_Get( p_playlist, "repeat", &val );
280 var_Set( p_playlist, "loop", val );
282 val.b_bool = !val.b_bool;
283 var_Set( p_playlist, "repeat", val );
286 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
287 config_PutInt( p_playlist, "repeat", 1 );
291 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
292 config_PutInt( p_playlist, "repeat", 0 );
295 p_intf->p_sys->b_playmode_update = VLC_TRUE;
296 p_intf->p_sys->b_intf_update = VLC_TRUE;
297 vlc_object_release( p_playlist );
300 - (IBAction)loop:(id)sender
303 intf_thread_t * p_intf = VLCIntf;
304 playlist_t * p_playlist = pl_Yield( p_intf );
306 var_Get( p_playlist, "loop", &val );
309 var_Set( p_playlist, "repeat", val );
311 val.b_bool = !val.b_bool;
312 var_Set( p_playlist, "loop", val );
315 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
316 config_PutInt( p_playlist, "loop", 1 );
320 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
321 config_PutInt( p_playlist, "loop", 0 );
324 p_intf->p_sys->b_playmode_update = VLC_TRUE;
325 p_intf->p_sys->b_intf_update = VLC_TRUE;
326 vlc_object_release( p_playlist );
329 - (IBAction)forward:(id)sender
332 intf_thread_t * p_intf = VLCIntf;
333 val.i_int = config_GetInt( p_intf, "key-jump+short" );
334 var_Set( p_intf->p_libvlc, "key-pressed", val );
337 - (IBAction)backward:(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 );
346 - (IBAction)volumeUp:(id)sender
349 intf_thread_t * p_intf = VLCIntf;
350 val.i_int = config_GetInt( p_intf, "key-vol-up" );
351 var_Set( p_intf->p_libvlc, "key-pressed", val );
352 /* Manage volume status */
353 [o_main manageVolumeSlider];
356 - (IBAction)volumeDown:(id)sender
359 intf_thread_t * p_intf = VLCIntf;
360 val.i_int = config_GetInt( p_intf, "key-vol-down" );
361 var_Set( p_intf->p_libvlc, "key-pressed", val );
362 /* Manage volume status */
363 [o_main manageVolumeSlider];
366 - (IBAction)mute:(id)sender
369 intf_thread_t * p_intf = VLCIntf;
370 val.i_int = config_GetInt( p_intf, "key-vol-mute" );
371 var_Set( p_intf->p_libvlc, "key-pressed", val );
372 /* Manage volume status */
373 [o_main manageVolumeSlider];
376 - (IBAction)volumeSliderUpdated:(id)sender
378 intf_thread_t * p_intf = VLCIntf;
379 audio_volume_t i_volume = (audio_volume_t)[sender intValue];
380 int i_volume_step = 0;
381 i_volume_step = config_GetInt( p_intf->p_libvlc, "volume-step" );
382 aout_VolumeSet( p_intf, i_volume * i_volume_step );
383 /* Manage volume status */
384 [o_main manageVolumeSlider];
387 - (IBAction)showPosition: (id)sender
389 vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
394 intf_thread_t * p_intf = VLCIntf;
395 val.i_int = config_GetInt( p_intf, "key-position" );
396 var_Set( p_intf, "key-pressed", val );
397 vlc_object_release( (vlc_object_t *)p_vout );
401 - (IBAction)toogleFullscreen:(id)sender {
402 NSMenuItem *o_mi = [[NSMenuItem alloc] initWithTitle: _NS("Fullscreen") action: nil keyEquivalent:@""];
403 [self windowAction: [o_mi autorelease]];
406 - (BOOL) isFullscreen {
407 id o_vout_view = [self getVoutView];
410 return [o_vout_view isFullscreen];
415 - (IBAction)windowAction:(id)sender
417 NSString *o_title = [sender title];
419 vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
423 id o_vout_view = [self getVoutView];
426 if( [o_title isEqualToString: _NS("Half Size") ] )
427 [o_vout_view scaleWindowWithFactor: 0.5 animate: YES];
428 else if( [o_title isEqualToString: _NS("Normal Size") ] )
429 [o_vout_view scaleWindowWithFactor: 1.0 animate: YES];
430 else if( [o_title isEqualToString: _NS("Double Size") ] )
431 [o_vout_view scaleWindowWithFactor: 2.0 animate: YES];
432 else if( [o_title isEqualToString: _NS("Float on Top") ] )
433 [o_vout_view toggleFloatOnTop];
434 else if( [o_title isEqualToString: _NS("Fit to Screen") ] )
436 id o_window = [o_vout_view getWindow];
437 if( ![o_window isZoomed] )
438 [o_window performZoom:self];
440 else if( [o_title isEqualToString: _NS("Snapshot") ] )
442 [o_vout_view snapshot];
446 [o_vout_view toggleFullscreen];
449 vlc_object_release( (vlc_object_t *)p_vout );
453 playlist_t * p_playlist = pl_Yield( VLCIntf );
455 if( [o_title isEqualToString: _NS("Fullscreen")] ||
456 [sender isKindOfClass:[NSButton class]] )
459 var_Get( p_playlist, "fullscreen", &val );
460 var_Set( p_playlist, "fullscreen", (vlc_value_t)!val.b_bool );
463 vlc_object_release( p_playlist );
468 - (void)scrollWheel:(NSEvent *)theEvent
470 intf_thread_t * p_intf = VLCIntf;
471 float f_absvalue = [theEvent deltaY] > 0.0f ? [theEvent deltaY] : -[theEvent deltaY];
474 f_absvalue = f_absvalue/2.0f + 1.0f;
476 if ([theEvent deltaY] < 0.0f)
477 i_vlckey = KEY_MOUSEWHEELDOWN;
479 i_vlckey = KEY_MOUSEWHEELUP;
481 /* Send multiple key event, depending on the intensity of the event */
482 for (i = 0; i < (int)f_absvalue; i++)
483 var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlckey );
486 - (BOOL)keyEvent:(NSEvent *)o_event
488 BOOL eventHandled = NO;
489 unichar key = [[o_event charactersIgnoringModifiers] characterAtIndex: 0];
493 vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
498 if( key == (unichar) 0x1b )
500 id o_vout_view = [self getVoutView];
501 if( o_vout_view && [o_vout_view isFullscreen] )
503 [o_vout_view toggleFullscreen];
507 else if( key == ' ' )
512 vlc_object_release( (vlc_object_t *)p_vout );
518 - (void)setupVarMenuItem:(NSMenuItem *)o_mi
519 target:(vlc_object_t *)p_object
520 var:(const char *)psz_variable
521 selector:(SEL)pf_callback
523 vlc_value_t val, text;
524 int i_type = var_Type( p_object, psz_variable );
526 switch( i_type & VLC_VAR_TYPE )
530 case VLC_VAR_VARIABLE:
532 case VLC_VAR_INTEGER:
535 /* Variable doesn't exist or isn't handled */
539 /* Make sure we want to display the variable */
540 if( i_type & VLC_VAR_HASCHOICE )
542 var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
543 if( val.i_int == 0 ) return;
544 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
548 /* Get the descriptive name of the variable */
549 var_Change( p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL );
550 [o_mi setTitle: [[VLCMain sharedInstance] localizedString: text.psz_string ?
551 text.psz_string : strdup( psz_variable ) ]];
553 var_Get( p_object, psz_variable, &val );
554 if( i_type & VLC_VAR_HASCHOICE )
556 NSMenu *o_menu = [o_mi submenu];
558 [self setupVarMenu: o_menu forMenuItem: o_mi target:p_object
559 var:psz_variable selector:pf_callback];
561 if( text.psz_string ) free( text.psz_string );
566 switch( i_type & VLC_VAR_TYPE )
569 o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
570 Value: val ofType: i_type];
571 [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
575 o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
576 Value: val ofType: i_type];
577 [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
578 if( !( i_type & VLC_VAR_ISCOMMAND ) )
579 [o_mi setState: val.b_bool ? TRUE : FALSE ];
583 if( text.psz_string ) free( text.psz_string );
587 if( ( i_type & VLC_VAR_TYPE ) == VLC_VAR_STRING ) free( val.psz_string );
588 if( text.psz_string ) free( text.psz_string );
592 - (void)setupVarMenu:(NSMenu *)o_menu
593 forMenuItem: (NSMenuItem *)o_parent
594 target:(vlc_object_t *)p_object
595 var:(const char *)psz_variable
596 selector:(SEL)pf_callback
598 vlc_value_t val, val_list, text_list;
599 int i_type, i, i_nb_items;
601 /* remove previous items */
602 i_nb_items = [o_menu numberOfItems];
603 for( i = 0; i < i_nb_items; i++ )
605 [o_menu removeItemAtIndex: 0];
608 /* Check the type of the object variable */
609 i_type = var_Type( p_object, psz_variable );
611 /* Make sure we want to display the variable */
612 if( i_type & VLC_VAR_HASCHOICE )
614 var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
615 if( val.i_int == 0 ) return;
616 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
624 switch( i_type & VLC_VAR_TYPE )
628 case VLC_VAR_VARIABLE:
630 case VLC_VAR_INTEGER:
633 /* Variable doesn't exist or isn't handled */
637 if( var_Get( p_object, psz_variable, &val ) < 0 )
642 if( var_Change( p_object, psz_variable, VLC_VAR_GETLIST,
643 &val_list, &text_list ) < 0 )
645 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
649 /* make (un)sensitive */
650 [o_parent setEnabled: ( val_list.p_list->i_count > 1 )];
652 for( i = 0; i < val_list.p_list->i_count; i++ )
654 vlc_value_t another_val;
656 NSString *o_title = @"";
659 switch( i_type & VLC_VAR_TYPE )
662 another_val.psz_string =
663 strdup(val_list.p_list->p_values[i].psz_string);
665 o_title = [[VLCMain sharedInstance] localizedString: text_list.p_list->p_values[i].psz_string ?
666 text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string ];
668 o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
669 o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
670 Value: another_val ofType: i_type];
671 [o_lmi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
672 [o_lmi setTarget: self];
674 if( !strcmp( val.psz_string, val_list.p_list->p_values[i].psz_string ) && !( i_type & VLC_VAR_ISCOMMAND ) )
675 [o_lmi setState: TRUE ];
679 case VLC_VAR_INTEGER:
681 o_title = text_list.p_list->p_values[i].psz_string ?
682 [[VLCMain sharedInstance] localizedString: strdup( text_list.p_list->p_values[i].psz_string )] :
683 [NSString stringWithFormat: @"%d",
684 val_list.p_list->p_values[i].i_int];
686 o_lmi = [[o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""] retain ];
687 o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
688 Value: val_list.p_list->p_values[i] ofType: i_type];
689 [o_lmi setRepresentedObject: [NSValue valueWithPointer:[ o_data retain]]];
690 [o_lmi setTarget: self];
692 if( val_list.p_list->p_values[i].i_int == val.i_int && !( i_type & VLC_VAR_ISCOMMAND ) )
693 [o_lmi setState: TRUE ];
701 /* clean up everything */
702 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
703 var_Change( p_object, psz_variable, VLC_VAR_FREELIST, &val_list, &text_list );
706 - (IBAction)toggleVar:(id)sender
708 NSMenuItem *o_mi = (NSMenuItem *)sender;
709 VLCMenuExt *o_data = [[o_mi representedObject] pointerValue];
710 [NSThread detachNewThreadSelector: @selector(toggleVarThread:)
711 toTarget: self withObject: o_data];
716 - (int)toggleVarThread: (id)_o_data
718 vlc_object_t *p_object;
719 NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
720 VLCMenuExt *o_data = (VLCMenuExt *)_o_data;
722 vlc_thread_set_priority( VLCIntf , VLC_THREAD_PRIORITY_LOW );
724 p_object = (vlc_object_t *)vlc_object_get( VLCIntf,
727 if( p_object != NULL )
729 var_Set( p_object, strdup([o_data name]), [o_data value] );
730 vlc_object_release( p_object );
738 - (IBAction)goToSpecificTime:(id)sender
740 if( sender == o_specificTime_cancel_btn )
742 [NSApp endSheet: o_specificTime_win];
743 [o_specificTime_win close];
745 else if( sender == o_specificTime_ok_btn )
747 input_thread_t * p_input = (input_thread_t *)vlc_object_find( VLCIntf, \
748 VLC_OBJECT_INPUT, FIND_ANYWHERE );
751 unsigned int timeInSec = 0;
752 NSString * fieldContent = [o_specificTime_enter_fld stringValue];
753 if( [[fieldContent componentsSeparatedByString: @":"] count] > 1 &&
754 [[fieldContent componentsSeparatedByString: @":"] count] <= 3 )
756 NSArray * ourTempArray = \
757 [fieldContent componentsSeparatedByString: @":"];
759 if( [[fieldContent componentsSeparatedByString: @":"] count] == 3 )
761 timeInSec += ([[ourTempArray objectAtIndex: 0] intValue] * 3600); //h
762 timeInSec += ([[ourTempArray objectAtIndex: 1] intValue] * 60); //m
763 timeInSec += [[ourTempArray objectAtIndex: 2] intValue]; //s
767 timeInSec += ([[ourTempArray objectAtIndex: 0] intValue] * 60); //m
768 timeInSec += [[ourTempArray objectAtIndex: 1] intValue]; //s
772 timeInSec = [fieldContent intValue];
774 input_Control( p_input, INPUT_SET_TIME, (int64_t)(timeInSec * 1000000));
775 vlc_object_release( p_input );
778 [NSApp endSheet: o_specificTime_win];
779 [o_specificTime_win close];
783 input_thread_t * p_input = (input_thread_t *)vlc_object_find( VLCIntf, \
784 VLC_OBJECT_INPUT, FIND_ANYWHERE );
787 /* we can obviously only do that if an input is available */
788 vlc_value_t pos, length;
789 var_Get( p_input, "time", &pos );
790 [o_specificTime_enter_fld setIntValue: (pos.i_time / 1000000)];
791 var_Get( p_input, "length", &length );
792 [o_specificTime_stepper setMaxValue: (length.i_time / 1000000)];
794 [NSApp beginSheet: o_specificTime_win modalForWindow: \
795 [NSApp mainWindow] modalDelegate: self didEndSelector: nil \
797 [o_specificTime_win makeKeyWindow];
798 vlc_object_release( p_input );
809 msg_Err( VLCIntf, "FSPanel is nil" );
816 @implementation VLCControls (NSMenuValidation)
818 - (BOOL)validateMenuItem:(NSMenuItem *)o_mi
820 BOOL bEnabled = TRUE;
822 intf_thread_t * p_intf = VLCIntf;
823 playlist_t * p_playlist = pl_Yield( p_intf );
825 vlc_mutex_lock( &p_playlist->object_lock );
827 #define p_input p_playlist->p_input
829 if( [[o_mi title] isEqualToString: _NS("Faster")] ||
830 [[o_mi title] isEqualToString: _NS("Slower")] )
832 if( p_input != NULL )
834 bEnabled = p_input->b_can_pace_control;
841 else if( [[o_mi title] isEqualToString: _NS("Stop")] )
843 if( p_input == NULL )
847 [o_main setupMenus]; /* Make sure input menu is up to date */
849 else if( [[o_mi title] isEqualToString: _NS("Previous")] ||
850 [[o_mi title] isEqualToString: _NS("Next")] )
852 /** \todo fix i_size use */
853 bEnabled = p_playlist->items.i_size > 1;
855 else if( [[o_mi title] isEqualToString: _NS("Random")] )
858 var_Get( p_playlist, "random", &val );
859 i_state = val.b_bool ? NSOnState : NSOffState;
860 [o_mi setState: i_state];
862 else if( [[o_mi title] isEqualToString: _NS("Repeat One")] )
865 var_Get( p_playlist, "repeat", &val );
866 i_state = val.b_bool ? NSOnState : NSOffState;
867 [o_mi setState: i_state];
869 else if( [[o_mi title] isEqualToString: _NS("Repeat All")] )
872 var_Get( p_playlist, "loop", &val );
873 i_state = val.b_bool ? NSOnState : NSOffState;
874 [o_mi setState: i_state];
876 else if( [[o_mi title] isEqualToString: _NS("Step Forward")] ||
877 [[o_mi title] isEqualToString: _NS("Step Backward")] ||
878 [[o_mi title] isEqualToString: _NS("Jump To Time")])
880 if( p_input != NULL )
882 var_Get( p_input, "seekable", &val);
883 bEnabled = val.b_bool;
885 else bEnabled = FALSE;
887 else if( [[o_mi title] isEqualToString: _NS("Mute")] )
889 [o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState];
890 [o_main setupMenus]; /* Make sure audio menu is up to date */
892 else if( [[o_mi title] isEqualToString: _NS("Half Size")] ||
893 [[o_mi title] isEqualToString: _NS("Normal Size")] ||
894 [[o_mi title] isEqualToString: _NS("Double Size")] ||
895 [[o_mi title] isEqualToString: _NS("Fit to Screen")] ||
896 [[o_mi title] isEqualToString: _NS("Snapshot")] ||
897 [[o_mi title] isEqualToString: _NS("Fullscreen")] ||
898 [[o_mi title] isEqualToString: _NS("Float on Top")] )
901 NSArray *o_windows = [NSApp orderedWindows];
902 NSEnumerator *o_enumerator = [o_windows objectEnumerator];
905 vout_thread_t *p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
909 if( [[o_mi title] isEqualToString: _NS("Float on Top")] )
911 var_Get( p_vout, "video-on-top", &val );
912 [o_mi setState: val.b_bool ? NSOnState : NSOffState];
915 while( (o_window = [o_enumerator nextObject]))
917 if( [[o_window className] isEqualToString: @"VLCVoutWindow"] ||
918 [[[VLCMain sharedInstance] getEmbeddedList]
919 windowContainsEmbedded: o_window])
925 vlc_object_release( (vlc_object_t *)p_vout );
927 else if( [[o_mi title] isEqualToString: _NS("Fullscreen")] )
929 var_Get( p_playlist, "fullscreen", &val );
930 [o_mi setState: val.b_bool];
933 [o_main setupMenus]; /* Make sure video menu is up to date */
936 vlc_mutex_unlock( &p_playlist->object_lock );
937 vlc_object_release( p_playlist );
944 /*****************************************************************************
945 * VLCMenuExt implementation
946 *****************************************************************************
947 * Object connected to a playlistitem which remembers the data belonging to
948 * the variable of the autogenerated menu
949 *****************************************************************************/
950 @implementation VLCMenuExt
952 - (id)initWithVar: (const char *)_psz_name Object: (int)i_id
953 Value: (vlc_value_t)val ofType: (int)_i_type
959 psz_name = strdup( _psz_name );
997 /*****************************************************************************
998 * VLCTimeField implementation
999 *****************************************************************************
1000 * we need this to catch our click-event in the controller window
1001 *****************************************************************************/
1003 @implementation VLCTimeField
1004 - (void)mouseDown: (NSEvent *)ourEvent
1006 if( [ourEvent clickCount] > 1 )
1007 [[[VLCMain sharedInstance] getControls] goToSpecificTime: nil];