]> git.sesse.net Git - vlc/blob - modules/gui/macosx/controls.m
* macosx: simplify volume update method for scrollfield usage.
[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     intf_thread_t * p_intf = VLCIntf;
258     audio_volume_t i_volume;
259
260     aout_VolumeGet( p_intf, &i_volume );
261
262     o_text = [NSString stringWithFormat: @"Volume: %d", i_volume * 200 / AOUT_VOLUME_MAX];
263     [o_main setScrollField:o_text stopAfter:1000000];
264     
265     [o_volumeslider setFloatValue: (float)(i_volume / AOUT_VOLUME_STEP)];
266 }
267
268 - (IBAction)windowAction:(id)sender
269 {
270     id o_window = [NSApp keyWindow];
271     NSString *o_title = [sender title];
272     NSArray *o_windows = [NSApp orderedWindows];
273     NSEnumerator *o_enumerator = [o_windows objectEnumerator];
274     vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
275                                               FIND_ANYWHERE );
276
277     playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
278                                               FIND_ANYWHERE );
279
280     if( p_vout != NULL )
281     {
282         while ((o_window = [o_enumerator nextObject]))
283         {
284             if( [[o_window className] isEqualToString: @"VLCWindow"] )
285             {
286                 if( [o_title isEqualToString: _NS("Half Size") ] )
287                     [o_window scaleWindowWithFactor: 0.5];
288                 else if( [o_title isEqualToString: _NS("Normal Size") ] )
289                     [o_window scaleWindowWithFactor: 1.0];
290                 else if( [o_title isEqualToString: _NS("Double Size") ] )
291                     [o_window scaleWindowWithFactor: 2.0];
292                 else if( [o_title isEqualToString: _NS("Float on Top") ] )
293                     [o_window toggleFloatOnTop];
294                 else if( [o_title isEqualToString: _NS("Fit to Screen") ] )
295                 {
296                     if( ![o_window isZoomed] )
297                         [o_window performZoom:self];
298                 }
299                 else if( [o_title isEqualToString: _NS("Snapshot") ] )
300                 {
301                     [o_window snapshot];
302                 }
303                 else
304                 {
305                     vlc_value_t val;
306                     var_Get( p_vout, "fullscreen", &val );
307                     var_Set( p_vout, "fullscreen", (vlc_value_t)!val.b_bool );
308                 }
309                 break;
310             }
311         }
312         vlc_object_release( (vlc_object_t *)p_vout );
313         if (p_playlist) vlc_object_release(p_playlist);
314     }
315
316     else if ( p_playlist != NULL )
317     {
318         if (! ([o_title isEqualToString: _NS("Half Size") ] ||
319                [o_title isEqualToString: _NS("Normal Size") ] ||
320                [o_title isEqualToString: _NS("Double Size") ] ||
321                [o_title isEqualToString: _NS("Float on Top") ] ||
322                [o_title isEqualToString: _NS("Fit to Screen") ] ))
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     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
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_playlist != NULL && 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_playlist == NULL || p_input == NULL )
587         {
588             bEnabled = FALSE;
589         }
590     }
591     else if( [[o_mi title] isEqualToString: _NS("Previous")] ||
592              [[o_mi title] isEqualToString: _NS("Next")] )
593     {
594         if( p_playlist == NULL )
595         {
596             bEnabled = FALSE;
597         }
598         else
599         {
600             bEnabled = p_playlist->i_size > 1;
601         }
602     }
603     else if( [[o_mi title] isEqualToString: _NS("Random")] )
604     {
605         int i_state;
606         var_Get( p_playlist, "random", &val );
607         i_state = val.b_bool ? NSOnState : NSOffState;
608         [o_mi setState: i_state];
609     }
610     else if( [[o_mi title] isEqualToString: _NS("Repeat One")] )
611     {
612         int i_state;
613         var_Get( p_playlist, "repeat", &val );
614         i_state = val.b_bool ? NSOnState : NSOffState;
615         [o_mi setState: i_state];
616     }
617     else if( [[o_mi title] isEqualToString: _NS("Repeat All")] )
618     {
619         int i_state;
620         var_Get( p_playlist, "loop", &val );
621         i_state = val.b_bool ? NSOnState : NSOffState;
622         [o_mi setState: i_state];
623     }
624     else if( [[o_mi title] isEqualToString: _NS("Step Forward")] ||
625              [[o_mi title] isEqualToString: _NS("Step Backward")] )
626     {
627         bEnabled = FALSE;
628         if( p_playlist != NULL && p_input != NULL )
629         {
630             var_Get( p_input, "seekable", &val);
631             if( val.b_bool )
632             {
633                 bEnabled = TRUE;
634             }
635         }
636     }
637     else if( [[o_mi title] isEqualToString: _NS("Mute")] ) 
638     {
639         [o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState];
640     }
641     else if( [[o_mi title] isEqualToString: _NS("Half Size")] ||
642                 [[o_mi title] isEqualToString: _NS("Normal Size")] ||
643                 [[o_mi title] isEqualToString: _NS("Double Size")] ||
644                 [[o_mi title] isEqualToString: _NS("Fit to Screen")] ||
645                 [[o_mi title] isEqualToString: _NS("Snapshot")] ||
646                 [[o_mi title] isEqualToString: _NS("Float on Top")] )
647     {
648         id o_window;
649         NSArray *o_windows = [NSApp orderedWindows];
650         NSEnumerator *o_enumerator = [o_windows objectEnumerator];
651         bEnabled = FALSE;
652         
653         vout_thread_t   *p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
654                                               FIND_ANYWHERE );
655         if( p_vout != NULL )
656         {
657             if ( [[o_mi title] isEqualToString: _NS("Float on Top")] )
658             {
659                 var_Get( p_vout, "video-on-top", &val );
660                 [o_mi setState: val.b_bool ?  NSOnState : NSOffState];
661             }
662
663             while ((o_window = [o_enumerator nextObject]))
664             {
665                 if( [[o_window className] isEqualToString: @"VLCWindow"] )
666                 {
667                     bEnabled = TRUE;
668                     break;
669                 }
670             }
671             vlc_object_release( (vlc_object_t *)p_vout );
672         }
673     }
674     else if( [[o_mi title] isEqualToString: _NS("Fullscreen")])
675     {
676         if (p_playlist)
677         {
678             var_Get(p_playlist, "fullscreen", &val );
679             [o_mi setState: val.b_bool];
680             bEnabled = TRUE;
681         }
682         else
683         {
684             bEnabled = FALSE;
685         }
686     }
687
688
689     if( p_playlist != NULL )
690     {
691         vlc_mutex_unlock( &p_playlist->object_lock );
692         vlc_object_release( p_playlist );
693     }
694
695     return( bEnabled );
696 }
697
698 @end
699
700 /*****************************************************************************
701  * VLCMenuExt implementation 
702  *****************************************************************************
703  * Object connected to a playlistitem which remembers the data belonging to
704  * the variable of the autogenerated menu
705  *****************************************************************************/
706 @implementation VLCMenuExt
707
708 - (id)initWithVar: (const char *)_psz_name Object: (int)i_id
709         Value: (vlc_value_t)val ofType: (int)_i_type
710 {
711     self = [super init];
712
713     if( self != nil )
714     {
715         psz_name = strdup( _psz_name );
716         i_object_id = i_id;
717         value = val;
718         i_type = _i_type;
719     }
720
721     return( self );
722 }
723
724 - (void)dealloc
725 {
726     free( psz_name );
727 }
728
729 - (char *)name
730 {
731     return psz_name;
732 }
733
734 - (int)objectID
735 {
736     return i_object_id;
737 }
738
739 - (vlc_value_t)value
740 {
741     return value;
742 }
743
744 - (int)type
745 {
746     return i_type;
747 }
748
749 @end