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