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