]> git.sesse.net Git - vlc/blob - modules/gui/macosx/controls.m
* A few Mac OS X intf fixes. To be honest. we should rewrite the thing from scratch...
[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                 msg_Dbg( VLCIntf, "detached vout controls.m call getVoutView" );
285                 o_vout_view = [o_window getVoutView];
286             }
287
288             if( o_vout_view )
289             {
290                 if( [o_title isEqualToString: _NS("Half Size") ] )
291                     [o_vout_view scaleWindowWithFactor: 0.5];
292                 else if( [o_title isEqualToString: _NS("Normal Size") ] )
293                     [o_vout_view scaleWindowWithFactor: 1.0];
294                 else if( [o_title isEqualToString: _NS("Double Size") ] )
295                     [o_vout_view scaleWindowWithFactor: 2.0];
296                 else if( [o_title isEqualToString: _NS("Float on Top") ] )
297                     [o_vout_view toggleFloatOnTop];
298                 else if( [o_title isEqualToString: _NS("Fit to Screen") ] )
299                 {
300                     if( ![o_window isZoomed] )
301                         [o_window performZoom:self];
302                 }
303                 else if( [o_title isEqualToString: _NS("Snapshot") ] )
304                 {
305                     [o_vout_view snapshot];
306                 }
307                 else
308                 {
309                     [o_vout_view toggleFullscreen];
310                 }
311                 break;
312             }
313         }
314         vlc_object_release( (vlc_object_t *)p_vout );
315     }
316     else
317     {
318         playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
319                                               FIND_ANYWHERE );
320
321         if( p_playlist && ( [o_title isEqualToString: _NS("Fullscreen")] ||
322             [sender isKindOfClass:[NSButton class]] ) )
323         {
324             vlc_value_t val;
325             var_Get( p_playlist, "fullscreen", &val );
326             var_Set( p_playlist, "fullscreen", (vlc_value_t)!val.b_bool );
327         }
328         if( p_playlist ) vlc_object_release( (vlc_object_t *)p_playlist );
329     }
330
331 }
332
333 - (void)setupVarMenuItem:(NSMenuItem *)o_mi
334                     target:(vlc_object_t *)p_object
335                     var:(const char *)psz_variable
336                     selector:(SEL)pf_callback
337 {
338     vlc_value_t val, text;
339     int i_type = var_Type( p_object, psz_variable );
340
341     switch( i_type & VLC_VAR_TYPE )
342     {
343     case VLC_VAR_VOID:
344     case VLC_VAR_BOOL:
345     case VLC_VAR_VARIABLE:
346     case VLC_VAR_STRING:
347     case VLC_VAR_INTEGER:
348         break;
349     default:
350         /* Variable doesn't exist or isn't handled */
351         return;
352     }
353     
354     /* Make sure we want to display the variable */
355     if( i_type & VLC_VAR_HASCHOICE )
356     {
357         var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
358         if( val.i_int == 0 ) return;
359         if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
360             return;
361     }
362     
363     /* Get the descriptive name of the variable */
364     var_Change( p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL );
365     [o_mi setTitle: [[VLCMain sharedInstance] localizedString: text.psz_string ?
366                                         text.psz_string : strdup( psz_variable ) ]];
367
368     var_Get( p_object, psz_variable, &val );
369     if( i_type & VLC_VAR_HASCHOICE )
370     {
371         NSMenu *o_menu = [o_mi submenu];
372
373         [self setupVarMenu: o_menu forMenuItem: o_mi target:p_object
374                         var:psz_variable selector:pf_callback];
375         
376         if( text.psz_string ) free( text.psz_string );
377         return;
378     }
379
380     VLCMenuExt *o_data;
381     switch( i_type & VLC_VAR_TYPE )
382     {
383     case VLC_VAR_VOID:
384         o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
385                 Value: val ofType: i_type];
386         [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
387         break;
388
389     case VLC_VAR_BOOL:
390         o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
391                 Value: val ofType: i_type];
392         [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
393         if( !( i_type & VLC_VAR_ISCOMMAND ) )
394             [o_mi setState: val.b_bool ? TRUE : FALSE ];
395         break;
396
397     default:
398         if( text.psz_string ) free( text.psz_string );
399         return;
400     }
401
402     if( ( i_type & VLC_VAR_TYPE ) == VLC_VAR_STRING ) free( val.psz_string );
403     if( text.psz_string ) free( text.psz_string );
404 }
405
406
407 - (void)setupVarMenu:(NSMenu *)o_menu
408                     forMenuItem: (NSMenuItem *)o_parent
409                     target:(vlc_object_t *)p_object
410                     var:(const char *)psz_variable
411                     selector:(SEL)pf_callback
412 {
413     vlc_value_t val, val_list, text_list;
414     int i_type, i, i_nb_items;
415
416     /* remove previous items */
417     i_nb_items = [o_menu numberOfItems];
418     for( i = 0; i < i_nb_items; i++ )
419     {
420         [o_menu removeItemAtIndex: 0];
421     }
422
423     /* Check the type of the object variable */
424     i_type = var_Type( p_object, psz_variable );
425
426     /* Make sure we want to display the variable */
427     if( i_type & VLC_VAR_HASCHOICE )
428     {
429         var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
430         if( val.i_int == 0 ) return;
431         if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
432             return;
433     }
434     else
435     {
436         return;
437     }
438
439     switch( i_type & VLC_VAR_TYPE )
440     {
441     case VLC_VAR_VOID:
442     case VLC_VAR_BOOL:
443     case VLC_VAR_VARIABLE:
444     case VLC_VAR_STRING:
445     case VLC_VAR_INTEGER:
446         break;
447     default:
448         /* Variable doesn't exist or isn't handled */
449         return;
450     }
451
452     if( var_Get( p_object, psz_variable, &val ) < 0 )
453     {
454         return;
455     }
456
457     if( var_Change( p_object, psz_variable, VLC_VAR_GETLIST,
458                     &val_list, &text_list ) < 0 )
459     {
460         if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
461         return;
462     }
463
464     /* make (un)sensitive */
465     [o_parent setEnabled: ( val_list.p_list->i_count > 1 )];
466
467     for( i = 0; i < val_list.p_list->i_count; i++ )
468     {
469         vlc_value_t another_val;
470         NSMenuItem * o_lmi;
471         NSString *o_title = @"";
472         VLCMenuExt *o_data;
473
474         switch( i_type & VLC_VAR_TYPE )
475         {
476         case VLC_VAR_STRING:
477             another_val.psz_string =
478                 strdup(val_list.p_list->p_values[i].psz_string);
479
480             o_title = [[VLCMain sharedInstance] localizedString: text_list.p_list->p_values[i].psz_string ?
481                 text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string ];
482
483             o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
484             o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
485                     Value: another_val ofType: i_type];
486             [o_lmi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
487             [o_lmi setTarget: self];
488
489             if( !strcmp( val.psz_string, val_list.p_list->p_values[i].psz_string ) && !( i_type & VLC_VAR_ISCOMMAND ) )
490                 [o_lmi setState: TRUE ];
491
492             break;
493
494         case VLC_VAR_INTEGER:
495
496              o_title = text_list.p_list->p_values[i].psz_string ?
497                                  [[VLCMain sharedInstance] localizedString: strdup( text_list.p_list->p_values[i].psz_string )] :
498                                  [NSString stringWithFormat: @"%d",
499                                  val_list.p_list->p_values[i].i_int];
500
501             o_lmi = [[o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""] retain ];
502             o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
503                     Value: val_list.p_list->p_values[i] ofType: i_type];
504             [o_lmi setRepresentedObject: [NSValue valueWithPointer:[ o_data retain]]];
505             [o_lmi setTarget: self];
506
507             if( val_list.p_list->p_values[i].i_int == val.i_int && !( i_type & VLC_VAR_ISCOMMAND ) )
508                 [o_lmi setState: TRUE ];
509             break;
510
511         default:
512           break;
513         }
514     }
515
516     /* clean up everything */
517     if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
518     var_Change( p_object, psz_variable, VLC_VAR_FREELIST, &val_list, &text_list );
519 }
520
521 - (IBAction)toggleVar:(id)sender
522 {
523     NSMenuItem *o_mi = (NSMenuItem *)sender;
524     VLCMenuExt *o_data = [[o_mi representedObject] pointerValue];
525     [NSThread detachNewThreadSelector: @selector(toggleVarThread:)
526         toTarget: self withObject: o_data];
527
528     return;
529 }
530
531 - (int)toggleVarThread: (id)_o_data
532 {
533     vlc_object_t *p_object;
534     NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
535     VLCMenuExt *o_data = (VLCMenuExt *)_o_data;
536
537     vlc_thread_set_priority( VLCIntf , VLC_THREAD_PRIORITY_LOW );
538
539     p_object = (vlc_object_t *)vlc_object_get( VLCIntf,
540                                     [o_data objectID] );
541
542     if( p_object != NULL )
543     {
544         var_Set( p_object, strdup([o_data name]), [o_data value] );
545         vlc_object_release( p_object );
546         [o_pool release];
547         return VLC_TRUE;
548     }
549     [o_pool release];
550     return VLC_EGENERIC;
551 }
552
553 @end
554
555 @implementation VLCControls (NSMenuValidation)
556  
557 - (BOOL)validateMenuItem:(NSMenuItem *)o_mi
558 {
559     BOOL bEnabled = TRUE;
560     vlc_value_t val;
561     intf_thread_t * p_intf = VLCIntf;
562     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
563                                                        FIND_ANYWHERE );
564
565     if( p_playlist != NULL )
566     {
567         vlc_mutex_lock( &p_playlist->object_lock );
568     }
569     else return FALSE;
570
571 #define p_input p_playlist->p_input
572
573     if( [[o_mi title] isEqualToString: _NS("Faster")] ||
574         [[o_mi title] isEqualToString: _NS("Slower")] )
575     {
576         if( p_input != NULL )
577         {
578             bEnabled = p_input->input.b_can_pace_control;
579         }
580         else
581         {
582             bEnabled = FALSE;
583         }
584     }
585     else if( [[o_mi title] isEqualToString: _NS("Stop")] )
586     {
587         if( p_input == NULL )
588         {
589             bEnabled = FALSE;
590         }
591                 [o_main setupMenus]; /* Make sure input menu is up to date */
592     }
593     else if( [[o_mi title] isEqualToString: _NS("Previous")] ||
594              [[o_mi title] isEqualToString: _NS("Next")] )
595     {
596             bEnabled = p_playlist->i_size > 1;
597     }
598     else if( [[o_mi title] isEqualToString: _NS("Random")] )
599     {
600         int i_state;
601         var_Get( p_playlist, "random", &val );
602         i_state = val.b_bool ? NSOnState : NSOffState;
603         [o_mi setState: i_state];
604     }
605     else if( [[o_mi title] isEqualToString: _NS("Repeat One")] )
606     {
607         int i_state;
608         var_Get( p_playlist, "repeat", &val );
609         i_state = val.b_bool ? NSOnState : NSOffState;
610         [o_mi setState: i_state];
611     }
612     else if( [[o_mi title] isEqualToString: _NS("Repeat All")] )
613     {
614         int i_state;
615         var_Get( p_playlist, "loop", &val );
616         i_state = val.b_bool ? NSOnState : NSOffState;
617         [o_mi setState: i_state];
618     }
619     else if( [[o_mi title] isEqualToString: _NS("Step Forward")] ||
620              [[o_mi title] isEqualToString: _NS("Step Backward")] )
621     {
622         if( p_input != NULL )
623         {
624             var_Get( p_input, "seekable", &val);
625             bEnabled = val.b_bool;
626         }
627     }
628     else if( [[o_mi title] isEqualToString: _NS("Mute")] ) 
629     {
630         [o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState];
631                 [o_main setupMenus]; /* Make sure audio menu is up to date */
632     }
633     else if( [[o_mi title] isEqualToString: _NS("Half Size")] ||
634                 [[o_mi title] isEqualToString: _NS("Normal Size")] ||
635                 [[o_mi title] isEqualToString: _NS("Double Size")] ||
636                 [[o_mi title] isEqualToString: _NS("Fit to Screen")] ||
637                 [[o_mi title] isEqualToString: _NS("Snapshot")] ||
638                 [[o_mi title] isEqualToString: _NS("Fullscreen")] ||
639                 [[o_mi title] isEqualToString: _NS("Float on Top")] )
640     {
641         id o_window;
642         NSArray *o_windows = [NSApp orderedWindows];
643         NSEnumerator *o_enumerator = [o_windows objectEnumerator];
644         bEnabled = FALSE;
645         
646         vout_thread_t   *p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
647                                               FIND_ANYWHERE );
648         if( p_vout != NULL )
649         {
650             if( [[o_mi title] isEqualToString: _NS("Float on Top")] )
651             {
652                 var_Get( p_vout, "video-on-top", &val );
653                 [o_mi setState: val.b_bool ?  NSOnState : NSOffState];
654             }
655
656             while( (o_window = [o_enumerator nextObject]))
657             {
658                 if( [[o_window className] isEqualToString: @"VLCWindow"] ||
659                             [[[VLCMain sharedInstance] getEmbeddedList]
660                             windowContainsEmbedded: o_window])
661                 {
662                     bEnabled = TRUE;
663                     break;
664                 }
665             }
666             vlc_object_release( (vlc_object_t *)p_vout );
667         }
668         else if( [[o_mi title] isEqualToString: _NS("Fullscreen")] )
669         {
670             var_Get( p_playlist, "fullscreen", &val );
671             [o_mi setState: val.b_bool];
672             bEnabled = TRUE;
673         }
674                 [o_main setupMenus]; /* Make sure video menu is up to date */
675     }
676
677     vlc_mutex_unlock( &p_playlist->object_lock );
678     vlc_object_release( p_playlist );
679
680     return( bEnabled );
681 }
682
683 @end
684
685 /*****************************************************************************
686  * VLCMenuExt implementation 
687  *****************************************************************************
688  * Object connected to a playlistitem which remembers the data belonging to
689  * the variable of the autogenerated menu
690  *****************************************************************************/
691 @implementation VLCMenuExt
692
693 - (id)initWithVar: (const char *)_psz_name Object: (int)i_id
694         Value: (vlc_value_t)val ofType: (int)_i_type
695 {
696     self = [super init];
697
698     if( self != nil )
699     {
700         psz_name = strdup( _psz_name );
701         i_object_id = i_id;
702         value = val;
703         i_type = _i_type;
704     }
705
706     return( self );
707 }
708
709 - (void)dealloc
710 {
711     free( psz_name );
712     [super dealloc];
713 }
714
715 - (char *)name
716 {
717     return psz_name;
718 }
719
720 - (int)objectID
721 {
722     return i_object_id;
723 }
724
725 - (vlc_value_t)value
726 {
727     return value;
728 }
729
730 - (int)type
731 {
732     return i_type;
733 }
734
735 @end