]> git.sesse.net Git - vlc/blob - modules/gui/macosx/controls.m
FSF address change.
[vlc] / modules / gui / macosx / controls.m
1 /*****************************************************************************
2  * controls.m: MacOS X interface module
3  *****************************************************************************
4  * Copyright (C) 2002-2005 the VideoLAN team
5  * $Id$
6  *
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  *
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.
16  * 
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.
21  *
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  *****************************************************************************/
26
27 /*****************************************************************************
28  * Preamble
29  *****************************************************************************/
30 #include <stdlib.h>                                      /* malloc(), free() */
31 #include <sys/param.h>                                    /* for MAXPATHLEN */
32 #include <string.h>
33
34 #include "intf.h"
35 #include "vout.h"
36 #include "open.h"
37 #include "controls.h"
38 #include <vlc_osd.h>
39
40 /*****************************************************************************
41  * VLCControls implementation 
42  *****************************************************************************/
43 @implementation VLCControls
44
45 - (IBAction)play:(id)sender
46 {
47     vlc_value_t val;
48     intf_thread_t * p_intf = VLCIntf;
49     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
50                                         FIND_ANYWHERE );
51     if( p_playlist )
52     {
53         vlc_mutex_lock( &p_playlist->object_lock );
54         if( p_playlist->i_size <= 0 )
55         {
56             vlc_mutex_unlock( &p_playlist->object_lock );
57             vlc_object_release( p_playlist );
58             [o_main intfOpenFileGeneric: (id)sender];
59         }
60         else
61         {
62             vlc_mutex_unlock( &p_playlist->object_lock );
63             vlc_object_release( p_playlist );
64         }
65
66     }
67     val.i_int = config_GetInt( p_intf, "key-play-pause" );
68     var_Set( p_intf->p_vlc, "key-pressed", val );
69 }
70
71 - (IBAction)stop:(id)sender
72 {
73     vlc_value_t val;
74     intf_thread_t * p_intf = VLCIntf;
75     val.i_int = config_GetInt( p_intf, "key-stop" );
76     var_Set( p_intf->p_vlc, "key-pressed", val );
77 }
78
79 - (IBAction)faster:(id)sender
80 {
81     vlc_value_t val;
82     intf_thread_t * p_intf = VLCIntf;
83     val.i_int = config_GetInt( p_intf, "key-faster" );
84     var_Set( p_intf->p_vlc, "key-pressed", val );
85 }
86
87 - (IBAction)slower:(id)sender
88 {
89     vlc_value_t val;
90     intf_thread_t * p_intf = VLCIntf;
91     val.i_int = config_GetInt( p_intf, "key-slower" );
92     var_Set( p_intf->p_vlc, "key-pressed", val );
93 }
94
95 - (IBAction)prev:(id)sender
96 {
97     vlc_value_t val;
98     intf_thread_t * p_intf = VLCIntf;
99     val.i_int = config_GetInt( p_intf, "key-prev" );
100     var_Set( p_intf->p_vlc, "key-pressed", val );
101 }
102
103 - (IBAction)next:(id)sender
104 {
105     vlc_value_t val;
106     intf_thread_t * p_intf = VLCIntf;
107     val.i_int = config_GetInt( p_intf, "key-next" );
108     var_Set( p_intf->p_vlc, "key-pressed", val );
109 }
110
111 - (IBAction)random:(id)sender
112 {
113     vlc_value_t val;
114     intf_thread_t * p_intf = VLCIntf;
115     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
116                                                        FIND_ANYWHERE );
117     if( p_playlist == NULL )
118     {
119         return;
120     }
121
122     var_Get( p_playlist, "random", &val );
123     val.b_bool = !val.b_bool;
124     var_Set( p_playlist, "random", val );
125     if( val.b_bool )
126     {
127         vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Random On" ) );
128     }
129     else
130     {
131         vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Random Off" ) );
132     }
133
134     p_intf->p_sys->b_playmode_update = VLC_TRUE;
135     p_intf->p_sys->b_intf_update = VLC_TRUE;
136     vlc_object_release( p_playlist );
137 }
138
139 - (IBAction)repeat:(id)sender
140 {
141     vlc_value_t val;
142     intf_thread_t * p_intf = VLCIntf;
143     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
144                                                        FIND_ANYWHERE );
145     if( p_playlist == NULL )
146     {
147         return;
148     }
149
150     var_Get( p_playlist, "repeat", &val );
151     if (!val.b_bool)
152     {
153         var_Set( p_playlist, "loop", val );
154     }
155     val.b_bool = !val.b_bool;
156     var_Set( p_playlist, "repeat", val );
157     if( val.b_bool )
158     {
159         vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
160     }
161     else
162     {
163         vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
164     }
165
166     p_intf->p_sys->b_playmode_update = VLC_TRUE;
167     p_intf->p_sys->b_intf_update = VLC_TRUE;
168     vlc_object_release( p_playlist );
169 }
170
171 - (IBAction)loop:(id)sender
172 {
173     vlc_value_t val;
174     intf_thread_t * p_intf = VLCIntf;
175     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
176                                                        FIND_ANYWHERE );
177     if( p_playlist == NULL )
178     {
179         return;
180     }
181
182     var_Get( p_playlist, "loop", &val );
183     if (!val.b_bool)
184     {
185         var_Set( p_playlist, "repeat", val );
186     }
187     val.b_bool = !val.b_bool;
188     var_Set( p_playlist, "loop", val );
189     if( val.b_bool )
190     {
191         vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
192     }
193     else
194     {
195         vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
196     }
197
198     p_intf->p_sys->b_playmode_update = VLC_TRUE;
199     p_intf->p_sys->b_intf_update = VLC_TRUE;
200     vlc_object_release( p_playlist );
201 }
202
203 - (IBAction)forward:(id)sender
204 {
205     vlc_value_t val;
206     intf_thread_t * p_intf = VLCIntf;
207     val.i_int = config_GetInt( p_intf, "key-jump+short" );
208     var_Set( p_intf->p_vlc, "key-pressed", val );
209 }
210
211 - (IBAction)backward:(id)sender
212 {
213     vlc_value_t val;
214     intf_thread_t * p_intf = VLCIntf;
215     val.i_int = config_GetInt( p_intf, "key-jump-short" );
216     var_Set( p_intf->p_vlc, "key-pressed", val );
217 }
218
219
220 - (IBAction)volumeUp:(id)sender
221 {
222     vlc_value_t val;
223     intf_thread_t * p_intf = VLCIntf;
224     val.i_int = config_GetInt( p_intf, "key-vol-up" );
225     var_Set( p_intf->p_vlc, "key-pressed", val );
226     /* Manage volume status */
227     [o_main manageVolumeSlider];
228 }
229
230 - (IBAction)volumeDown:(id)sender
231 {
232     vlc_value_t val;
233     intf_thread_t * p_intf = VLCIntf;
234     val.i_int = config_GetInt( p_intf, "key-vol-down" );
235     var_Set( p_intf->p_vlc, "key-pressed", val );
236     /* Manage volume status */
237     [o_main manageVolumeSlider];
238 }
239
240 - (IBAction)mute:(id)sender
241 {
242     vlc_value_t val;
243     intf_thread_t * p_intf = VLCIntf;
244     val.i_int = config_GetInt( p_intf, "key-vol-mute" );
245     var_Set( p_intf->p_vlc, "key-pressed", val );
246     /* Manage volume status */
247     [o_main manageVolumeSlider];
248 }
249
250 - (IBAction)volumeSliderUpdated:(id)sender
251 {
252     intf_thread_t * p_intf = VLCIntf;
253     audio_volume_t i_volume = (audio_volume_t)[sender intValue];
254     int i_volume_step = 0;
255     i_volume_step = config_GetInt( p_intf->p_vlc, "volume-step" );
256     aout_VolumeSet( p_intf, i_volume * i_volume_step );
257     /* Manage volume status */
258     [o_main manageVolumeSlider];
259 }
260
261 - (IBAction)windowAction:(id)sender
262 {
263     id o_window = [NSApp keyWindow];
264     NSString *o_title = [sender title];
265     NSArray *o_windows = [NSApp orderedWindows];
266     NSEnumerator *o_enumerator = [o_windows objectEnumerator];
267     vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
268                                               FIND_ANYWHERE );
269
270     if( p_vout != NULL )
271     {
272         id o_embedded_vout_list = [[VLCMain sharedInstance] getEmbeddedList];
273         while ((o_window = [o_enumerator nextObject]))
274         {
275             id o_vout_view = nil;
276             /* We have an embedded vout */
277             if( [o_embedded_vout_list windowContainsEmbedded: o_window] )
278             {
279                 o_vout_view = [o_embedded_vout_list getViewForWindow: o_window];
280             }
281             /* We have a detached Vout */
282             else if( [[o_window className] isEqualToString: @"VLCWindow"] )
283             {
284                 o_vout_view = [o_window getVoutView];
285             }
286
287             if( o_vout_view )
288             {
289                 if( [o_title isEqualToString: _NS("Half Size") ] )
290                     [o_vout_view scaleWindowWithFactor: 0.5];
291                 else if( [o_title isEqualToString: _NS("Normal Size") ] )
292                     [o_vout_view scaleWindowWithFactor: 1.0];
293                 else if( [o_title isEqualToString: _NS("Double Size") ] )
294                     [o_vout_view scaleWindowWithFactor: 2.0];
295                 else if( [o_title isEqualToString: _NS("Float on Top") ] )
296                     [o_vout_view toggleFloatOnTop];
297                 else if( [o_title isEqualToString: _NS("Fit to Screen") ] )
298                 {
299                     if( ![o_window isZoomed] )
300                         [o_window performZoom:self];
301                 }
302                 else if( [o_title isEqualToString: _NS("Snapshot") ] )
303                 {
304                     [o_vout_view snapshot];
305                 }
306                 else
307                 {
308                     [o_vout_view toggleFullscreen];
309                 }
310                 break;
311             }
312         }
313         vlc_object_release( (vlc_object_t *)p_vout );
314     }
315     else
316     {
317         playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
318                                               FIND_ANYWHERE );
319
320         if( p_playlist && ( [o_title isEqualToString: _NS("Fullscreen")] ||
321             [sender isKindOfClass:[NSButton class]] ) )
322         {
323             vlc_value_t val;
324             var_Get( p_playlist, "fullscreen", &val );
325             var_Set( p_playlist, "fullscreen", (vlc_value_t)!val.b_bool );
326         }
327         if( p_playlist ) vlc_object_release( (vlc_object_t *)p_playlist );
328     }
329
330 }
331
332 - (void)setupVarMenuItem:(NSMenuItem *)o_mi
333                     target:(vlc_object_t *)p_object
334                     var:(const char *)psz_variable
335                     selector:(SEL)pf_callback
336 {
337     vlc_value_t val, text;
338     int i_type = var_Type( p_object, psz_variable );
339
340     switch( i_type & VLC_VAR_TYPE )
341     {
342     case VLC_VAR_VOID:
343     case VLC_VAR_BOOL:
344     case VLC_VAR_VARIABLE:
345     case VLC_VAR_STRING:
346     case VLC_VAR_INTEGER:
347         break;
348     default:
349         /* Variable doesn't exist or isn't handled */
350         return;
351     }
352     
353     /* Make sure we want to display the variable */
354     if( i_type & VLC_VAR_HASCHOICE )
355     {
356         var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
357         if( val.i_int == 0 ) return;
358         if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
359             return;
360     }
361     
362     /* Get the descriptive name of the variable */
363     var_Change( p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL );
364     [o_mi setTitle: [[VLCMain sharedInstance] localizedString: text.psz_string ?
365                                         text.psz_string : strdup( psz_variable ) ]];
366
367     var_Get( p_object, psz_variable, &val );
368     if( i_type & VLC_VAR_HASCHOICE )
369     {
370         NSMenu *o_menu = [o_mi submenu];
371
372         [self setupVarMenu: o_menu forMenuItem: o_mi target:p_object
373                         var:psz_variable selector:pf_callback];
374         
375         if( text.psz_string ) free( text.psz_string );
376         return;
377     }
378
379     VLCMenuExt *o_data;
380     switch( i_type & VLC_VAR_TYPE )
381     {
382     case VLC_VAR_VOID:
383         o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
384                 Value: val ofType: i_type];
385         [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
386         break;
387
388     case VLC_VAR_BOOL:
389         o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
390                 Value: val ofType: i_type];
391         [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
392         if( !( i_type & VLC_VAR_ISCOMMAND ) )
393             [o_mi setState: val.b_bool ? TRUE : FALSE ];
394         break;
395
396     default:
397         if( text.psz_string ) free( text.psz_string );
398         return;
399     }
400
401     if( ( i_type & VLC_VAR_TYPE ) == VLC_VAR_STRING ) free( val.psz_string );
402     if( text.psz_string ) free( text.psz_string );
403 }
404
405
406 - (void)setupVarMenu:(NSMenu *)o_menu
407                     forMenuItem: (NSMenuItem *)o_parent
408                     target:(vlc_object_t *)p_object
409                     var:(const char *)psz_variable
410                     selector:(SEL)pf_callback
411 {
412     vlc_value_t val, val_list, text_list;
413     int i_type, i, i_nb_items;
414
415     /* remove previous items */
416     i_nb_items = [o_menu numberOfItems];
417     for( i = 0; i < i_nb_items; i++ )
418     {
419         [o_menu removeItemAtIndex: 0];
420     }
421
422     /* Check the type of the object variable */
423     i_type = var_Type( p_object, psz_variable );
424
425     /* Make sure we want to display the variable */
426     if( i_type & VLC_VAR_HASCHOICE )
427     {
428         var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
429         if( val.i_int == 0 ) return;
430         if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
431             return;
432     }
433     else
434     {
435         return;
436     }
437
438     switch( i_type & VLC_VAR_TYPE )
439     {
440     case VLC_VAR_VOID:
441     case VLC_VAR_BOOL:
442     case VLC_VAR_VARIABLE:
443     case VLC_VAR_STRING:
444     case VLC_VAR_INTEGER:
445         break;
446     default:
447         /* Variable doesn't exist or isn't handled */
448         return;
449     }
450
451     if( var_Get( p_object, psz_variable, &val ) < 0 )
452     {
453         return;
454     }
455
456     if( var_Change( p_object, psz_variable, VLC_VAR_GETLIST,
457                     &val_list, &text_list ) < 0 )
458     {
459         if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
460         return;
461     }
462
463     /* make (un)sensitive */
464     [o_parent setEnabled: ( val_list.p_list->i_count > 1 )];
465
466     for( i = 0; i < val_list.p_list->i_count; i++ )
467     {
468         vlc_value_t another_val;
469         NSMenuItem * o_lmi;
470         NSString *o_title = @"";
471         VLCMenuExt *o_data;
472
473         switch( i_type & VLC_VAR_TYPE )
474         {
475         case VLC_VAR_STRING:
476             another_val.psz_string =
477                 strdup(val_list.p_list->p_values[i].psz_string);
478
479             o_title = [[VLCMain sharedInstance] localizedString: text_list.p_list->p_values[i].psz_string ?
480                 text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string ];
481
482             o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
483             o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
484                     Value: another_val ofType: i_type];
485             [o_lmi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
486             [o_lmi setTarget: self];
487
488             if( !strcmp( val.psz_string, val_list.p_list->p_values[i].psz_string ) && !( i_type & VLC_VAR_ISCOMMAND ) )
489                 [o_lmi setState: TRUE ];
490
491             break;
492
493         case VLC_VAR_INTEGER:
494
495              o_title = text_list.p_list->p_values[i].psz_string ?
496                                  [[VLCMain sharedInstance] localizedString: strdup( text_list.p_list->p_values[i].psz_string )] :
497                                  [NSString stringWithFormat: @"%d",
498                                  val_list.p_list->p_values[i].i_int];
499
500             o_lmi = [[o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""] retain ];
501             o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
502                     Value: val_list.p_list->p_values[i] ofType: i_type];
503             [o_lmi setRepresentedObject: [NSValue valueWithPointer:[ o_data retain]]];
504             [o_lmi setTarget: self];
505
506             if( val_list.p_list->p_values[i].i_int == val.i_int && !( i_type & VLC_VAR_ISCOMMAND ) )
507                 [o_lmi setState: TRUE ];
508             break;
509
510         default:
511           break;
512         }
513     }
514
515     /* clean up everything */
516     if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
517     var_Change( p_object, psz_variable, VLC_VAR_FREELIST, &val_list, &text_list );
518 }
519
520 - (IBAction)toggleVar:(id)sender
521 {
522     NSMenuItem *o_mi = (NSMenuItem *)sender;
523     VLCMenuExt *o_data = [[o_mi representedObject] pointerValue];
524     [NSThread detachNewThreadSelector: @selector(toggleVarThread:)
525         toTarget: self withObject: o_data];
526
527     return;
528 }
529
530 - (int)toggleVarThread: (id)_o_data
531 {
532     vlc_object_t *p_object;
533     NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
534     VLCMenuExt *o_data = (VLCMenuExt *)_o_data;
535
536     vlc_thread_set_priority( VLCIntf , VLC_THREAD_PRIORITY_LOW );
537
538     p_object = (vlc_object_t *)vlc_object_get( VLCIntf,
539                                     [o_data objectID] );
540
541     if( p_object != NULL )
542     {
543         var_Set( p_object, strdup([o_data name]), [o_data value] );
544         vlc_object_release( p_object );
545         [o_pool release];
546         return VLC_TRUE;
547     }
548     [o_pool release];
549     return VLC_EGENERIC;
550 }
551
552 @end
553
554 @implementation VLCControls (NSMenuValidation)
555  
556 - (BOOL)validateMenuItem:(NSMenuItem *)o_mi
557 {
558     BOOL bEnabled = TRUE;
559     vlc_value_t val;
560     intf_thread_t * p_intf = VLCIntf;
561     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
562                                                        FIND_ANYWHERE );
563
564     if( p_playlist != NULL )
565     {
566         vlc_mutex_lock( &p_playlist->object_lock );
567     }
568     else return FALSE;
569
570 #define p_input p_playlist->p_input
571
572     if( [[o_mi title] isEqualToString: _NS("Faster")] ||
573         [[o_mi title] isEqualToString: _NS("Slower")] )
574     {
575         if( p_input != NULL )
576         {
577             bEnabled = p_input->input.b_can_pace_control;
578         }
579         else
580         {
581             bEnabled = FALSE;
582         }
583     }
584     else if( [[o_mi title] isEqualToString: _NS("Stop")] )
585     {
586         if( p_input == NULL )
587         {
588             bEnabled = FALSE;
589         }
590                 [o_main setupMenus]; /* Make sure input menu is up to date */
591     }
592     else if( [[o_mi title] isEqualToString: _NS("Previous")] ||
593              [[o_mi title] isEqualToString: _NS("Next")] )
594     {
595             bEnabled = p_playlist->i_size > 1;
596     }
597     else if( [[o_mi title] isEqualToString: _NS("Random")] )
598     {
599         int i_state;
600         var_Get( p_playlist, "random", &val );
601         i_state = val.b_bool ? NSOnState : NSOffState;
602         [o_mi setState: i_state];
603     }
604     else if( [[o_mi title] isEqualToString: _NS("Repeat One")] )
605     {
606         int i_state;
607         var_Get( p_playlist, "repeat", &val );
608         i_state = val.b_bool ? NSOnState : NSOffState;
609         [o_mi setState: i_state];
610     }
611     else if( [[o_mi title] isEqualToString: _NS("Repeat All")] )
612     {
613         int i_state;
614         var_Get( p_playlist, "loop", &val );
615         i_state = val.b_bool ? NSOnState : NSOffState;
616         [o_mi setState: i_state];
617     }
618     else if( [[o_mi title] isEqualToString: _NS("Step Forward")] ||
619              [[o_mi title] isEqualToString: _NS("Step Backward")] )
620     {
621         if( p_input != NULL )
622         {
623             var_Get( p_input, "seekable", &val);
624             bEnabled = val.b_bool;
625         }
626     }
627     else if( [[o_mi title] isEqualToString: _NS("Mute")] ) 
628     {
629         [o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState];
630                 [o_main setupMenus]; /* Make sure audio menu is up to date */
631     }
632     else if( [[o_mi title] isEqualToString: _NS("Half Size")] ||
633                 [[o_mi title] isEqualToString: _NS("Normal Size")] ||
634                 [[o_mi title] isEqualToString: _NS("Double Size")] ||
635                 [[o_mi title] isEqualToString: _NS("Fit to Screen")] ||
636                 [[o_mi title] isEqualToString: _NS("Snapshot")] ||
637                 [[o_mi title] isEqualToString: _NS("Fullscreen")] ||
638                 [[o_mi title] isEqualToString: _NS("Float on Top")] )
639     {
640         id o_window;
641         NSArray *o_windows = [NSApp orderedWindows];
642         NSEnumerator *o_enumerator = [o_windows objectEnumerator];
643         bEnabled = FALSE;
644         
645         vout_thread_t   *p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
646                                               FIND_ANYWHERE );
647         if( p_vout != NULL )
648         {
649             if( [[o_mi title] isEqualToString: _NS("Float on Top")] )
650             {
651                 var_Get( p_vout, "video-on-top", &val );
652                 [o_mi setState: val.b_bool ?  NSOnState : NSOffState];
653             }
654
655             while( (o_window = [o_enumerator nextObject]))
656             {
657                 if( [[o_window className] isEqualToString: @"VLCWindow"] ||
658                             [[[VLCMain sharedInstance] getEmbeddedList]
659                             windowContainsEmbedded: o_window])
660                 {
661                     bEnabled = TRUE;
662                     break;
663                 }
664             }
665             vlc_object_release( (vlc_object_t *)p_vout );
666         }
667         else if( [[o_mi title] isEqualToString: _NS("Fullscreen")] )
668         {
669             var_Get( p_playlist, "fullscreen", &val );
670             [o_mi setState: val.b_bool];
671             bEnabled = TRUE;
672         }
673                 [o_main setupMenus]; /* Make sure video menu is up to date */
674     }
675
676     vlc_mutex_unlock( &p_playlist->object_lock );
677     vlc_object_release( p_playlist );
678
679     return( bEnabled );
680 }
681
682 @end
683
684 /*****************************************************************************
685  * VLCMenuExt implementation 
686  *****************************************************************************
687  * Object connected to a playlistitem which remembers the data belonging to
688  * the variable of the autogenerated menu
689  *****************************************************************************/
690 @implementation VLCMenuExt
691
692 - (id)initWithVar: (const char *)_psz_name Object: (int)i_id
693         Value: (vlc_value_t)val ofType: (int)_i_type
694 {
695     self = [super init];
696
697     if( self != nil )
698     {
699         psz_name = strdup( _psz_name );
700         i_object_id = i_id;
701         value = val;
702         i_type = _i_type;
703     }
704
705     return( self );
706 }
707
708 - (void)dealloc
709 {
710     free( psz_name );
711     [super dealloc];
712 }
713
714 - (char *)name
715 {
716     return psz_name;
717 }
718
719 - (int)objectID
720 {
721     return i_object_id;
722 }
723
724 - (vlc_value_t)value
725 {
726     return value;
727 }
728
729 - (int)type
730 {
731     return i_type;
732 }
733
734 @end