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