]> git.sesse.net Git - vlc/blob - modules/gui/macosx/controls.m
* fixed the autogenerated menu's.
[vlc] / modules / gui / macosx / controls.m
1 /*****************************************************************************
2  * controls.m: MacOS X interface plugin
3  *****************************************************************************
4  * Copyright (C) 2002-2003 VideoLAN
5  * $Id: controls.m,v 1.35 2003/05/05 22:04:11 hartman Exp $
6  *
7  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8  *          Christophe Massiot <massiot@via.ecp.fr>
9  *          Derk-Jan Hartman <thedj@users.sourceforge.net>
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
38 /*****************************************************************************
39  * VLCControls implementation 
40  *****************************************************************************/
41 @implementation VLCControls
42
43 - (IBAction)play:(id)sender
44 {
45     intf_thread_t * p_intf = [NSApp getIntf];
46
47     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
48                                                        FIND_ANYWHERE );
49     if( p_playlist == NULL )
50     {
51         return;
52     }
53
54     if( playlist_IsPlaying( p_playlist ) )
55     {
56         playlist_Pause( p_playlist );
57         vlc_object_release( p_playlist );
58     }
59     else
60     {
61         if( !playlist_IsEmpty( p_playlist ) )
62         {
63             playlist_Play( p_playlist );
64             vlc_object_release( p_playlist );
65         }
66         else
67         {
68             vlc_object_release( p_playlist );
69             [o_open openFileGeneric: nil];
70         }
71     }
72 }
73
74 - (IBAction)stop:(id)sender
75 {
76     intf_thread_t * p_intf = [NSApp getIntf];
77
78     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
79                                                        FIND_ANYWHERE );
80     if( p_playlist == NULL )
81     {
82         return;
83     }
84
85     playlist_Stop( p_playlist );
86     vlc_object_release( p_playlist );
87 }
88
89 - (IBAction)faster:(id)sender
90 {
91     intf_thread_t * p_intf = [NSApp getIntf];
92
93     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
94                                                        FIND_ANYWHERE );
95     if( p_playlist == NULL )
96     {
97         return;
98     }
99
100     vlc_mutex_lock( &p_playlist->object_lock );
101     if( p_playlist->p_input != NULL )
102     {
103         input_SetStatus( p_playlist->p_input, INPUT_STATUS_FASTER );
104     } 
105     vlc_mutex_unlock( &p_playlist->object_lock );
106
107     vlc_object_release( p_playlist );
108 }
109
110 - (IBAction)slower:(id)sender
111 {
112     intf_thread_t * p_intf = [NSApp getIntf];
113
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     vlc_mutex_lock( &p_playlist->object_lock );
122     if( p_playlist->p_input != NULL )
123     {
124         input_SetStatus( p_playlist->p_input, INPUT_STATUS_SLOWER );
125     }
126     vlc_mutex_unlock( &p_playlist->object_lock );
127
128     vlc_object_release( p_playlist );
129 }
130
131 - (IBAction)prev:(id)sender
132 {
133     intf_thread_t * p_intf = [NSApp getIntf];
134
135     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
136                                                        FIND_ANYWHERE );
137     if( p_playlist == NULL )
138     {
139         return;
140     }
141
142     vlc_mutex_lock( &p_playlist->object_lock );
143
144     if( p_playlist->p_input == NULL )
145     {
146         vlc_mutex_unlock( &p_playlist->object_lock );
147         vlc_object_release( p_playlist );  
148         return;
149     }
150
151     vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
152
153 #define p_area p_playlist->p_input->stream.p_selected_area
154
155     if( p_area->i_part_nb > 1 && p_area->i_part > 1 )
156     {
157         p_area->i_part--;
158
159         vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
160         input_ChangeArea( p_playlist->p_input, p_area );
161         vlc_mutex_unlock( &p_playlist->object_lock );
162
163         p_intf->p_sys->b_chapter_update = VLC_TRUE;
164     }
165     else
166     {
167         vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
168         vlc_mutex_unlock( &p_playlist->object_lock );
169         playlist_Prev( p_playlist );
170     }
171
172 #undef p_area
173
174     vlc_object_release( p_playlist );
175 }
176
177 - (IBAction)next:(id)sender
178 {
179     intf_thread_t * p_intf = [NSApp getIntf];
180
181     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
182                                                        FIND_ANYWHERE );
183     if( p_playlist == NULL )
184     {
185         return;
186     }
187
188     vlc_mutex_lock( &p_playlist->object_lock );
189
190     if( p_playlist->p_input == NULL )
191     {
192         vlc_mutex_unlock( &p_playlist->object_lock );
193         vlc_object_release( p_playlist );  
194         return;
195     }
196
197     vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
198
199 #define p_area p_playlist->p_input->stream.p_selected_area
200
201     if( p_area->i_part_nb > 1 && p_area->i_part + 1 < p_area->i_part_nb )
202     {
203         p_area->i_part++;
204
205         vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
206         input_ChangeArea( p_playlist->p_input, p_area );
207         vlc_mutex_unlock( &p_playlist->object_lock );
208
209         p_intf->p_sys->b_chapter_update = VLC_TRUE;
210     }
211     else
212     {
213         vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
214         vlc_mutex_unlock( &p_playlist->object_lock );
215         playlist_Next( p_playlist );
216     }
217
218 #undef p_area
219
220     vlc_object_release( p_playlist );
221 }
222
223 - (IBAction)loop:(id)sender
224 {
225     intf_thread_t * p_intf = [NSApp getIntf];
226
227     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
228                                                        FIND_ANYWHERE );
229     if( p_playlist == NULL )
230     {
231         return;
232     }
233
234     config_PutInt( p_playlist, "loop",
235                    !config_GetInt( p_playlist, "loop" ) );
236
237     vlc_object_release( p_playlist );
238 }
239
240 - (IBAction)forward:(id)sender
241 {
242     intf_thread_t * p_intf = [NSApp getIntf];
243     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
244                                                        FIND_ANYWHERE );
245     if( p_playlist == NULL || p_playlist->p_input == NULL )
246     {
247         if ( p_playlist != NULL ) vlc_object_release( p_playlist );
248         return;
249     }
250
251     input_Seek( p_playlist->p_input, 5, INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
252     vlc_object_release( p_playlist );
253 }
254
255 - (IBAction)backward:(id)sender
256 {
257     intf_thread_t * p_intf = [NSApp getIntf];
258     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
259                                                        FIND_ANYWHERE );
260     if( p_playlist == NULL || p_playlist->p_input == NULL )
261     {
262         if ( p_playlist != NULL ) vlc_object_release( p_playlist );
263         return;
264     }
265
266     input_Seek( p_playlist->p_input, -5, INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
267     vlc_object_release( p_playlist );
268 }
269
270 - (IBAction)volumeUp:(id)sender
271 {
272     intf_thread_t * p_intf = [NSApp getIntf];
273
274     if( p_intf->p_sys->b_mute )
275     {
276         [self mute: nil];
277     }
278
279     aout_VolumeUp( p_intf, 1, NULL );
280
281     [self updateVolumeSlider];
282 }
283
284 - (IBAction)volumeDown:(id)sender
285 {
286     intf_thread_t * p_intf = [NSApp getIntf];
287
288     if( p_intf->p_sys->b_mute )
289     {
290         [self mute: nil];
291     }
292     
293     aout_VolumeDown( p_intf, 1, NULL );
294
295     [self updateVolumeSlider];
296 }
297
298 - (IBAction)mute:(id)sender
299 {
300     intf_thread_t * p_intf = [NSApp getIntf];
301     audio_volume_t i_volume;
302
303     aout_VolumeMute( p_intf, &i_volume );
304     p_intf->p_sys->b_mute = ( i_volume == 0 );
305
306     [self updateVolumeSlider];
307 }
308
309 - (IBAction)volumeSliderUpdated:(id)sender
310 {
311     intf_thread_t * p_intf = [NSApp getIntf];
312     audio_volume_t i_volume = (audio_volume_t)[sender intValue];
313
314     aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_STEP );
315 }
316
317 - (void)updateVolumeSlider
318 {
319     intf_thread_t * p_intf = [NSApp getIntf];
320     audio_volume_t i_volume;
321
322     aout_VolumeGet( p_intf, &i_volume );
323
324     [o_volumeslider setFloatValue: (float)(i_volume / AOUT_VOLUME_STEP)]; 
325 }
326
327 - (IBAction)halfWindow:(id)sender
328 {
329     id o_window = [NSApp keyWindow];
330     NSArray *o_windows = [NSApp windows];
331     NSEnumerator *o_enumerator = [o_windows objectEnumerator];
332     
333     while ((o_window = [o_enumerator nextObject]))
334     {
335         if( [[o_window className] isEqualToString: @"VLCWindow"] )
336         {
337             [o_window scaleWindowWithFactor: 0.5];
338         }
339     }
340 }
341
342 - (IBAction)normalWindow:(id)sender
343 {
344     id o_window = [NSApp keyWindow];
345     NSArray *o_windows = [NSApp windows];
346     NSEnumerator *o_enumerator = [o_windows objectEnumerator];
347     
348     while ((o_window = [o_enumerator nextObject]))
349     {
350         if( [[o_window className] isEqualToString: @"VLCWindow"] )
351         {
352             [o_window scaleWindowWithFactor: 1];
353         }
354     }
355 }
356
357 - (IBAction)doubleWindow:(id)sender
358 {
359     id o_window = [NSApp keyWindow];
360     NSArray *o_windows = [NSApp windows];
361     NSEnumerator *o_enumerator = [o_windows objectEnumerator];
362     
363     while ((o_window = [o_enumerator nextObject]))
364     {
365         if( [[o_window className] isEqualToString: @"VLCWindow"] )
366         {
367             [o_window scaleWindowWithFactor: 2];
368         }
369     }
370 }
371
372
373 - (IBAction)fullscreen:(id)sender
374 {
375     id o_window = [NSApp keyWindow];
376     NSArray *o_windows = [NSApp windows];
377     NSEnumerator *o_enumerator = [o_windows objectEnumerator];
378     
379     while ((o_window = [o_enumerator nextObject]))
380     {
381         if( [[o_window className] isEqualToString: @"VLCWindow"] )
382         {
383             [o_window toggleFullscreen];
384         }
385     }
386 }
387
388 - (IBAction)floatOnTop:(id)sender
389 {
390     id o_window = [NSApp keyWindow];
391     NSArray *o_windows = [NSApp windows];
392     NSEnumerator *o_enumerator = [o_windows objectEnumerator];
393     
394     while ((o_window = [o_enumerator nextObject]))
395     {
396         if( [[o_window className] isEqualToString: @"VLCWindow"] )
397         {
398             [o_window toggleFloatOnTop];
399         }
400     }
401 }
402
403 - (IBAction)deinterlace:(id)sender
404 {
405     intf_thread_t * p_intf = [NSApp getIntf];
406     BOOL bEnable = [sender state] == NSOffState;
407
408     if( bEnable && ![[sender title] isEqualToString: @"none"] )
409     {
410         config_PutPsz( p_intf, "filter", "deinterlace" );
411         config_PutPsz( p_intf, "deinterlace-mode",
412                     [[sender title] lossyCString] );
413     }
414     else
415     {
416         config_PutPsz( p_intf, "filter", NULL );
417     }
418 }
419
420 - (IBAction)toggleProgram:(id)sender
421 {
422     NSMenuItem * o_mi = (NSMenuItem *)sender;
423     intf_thread_t * p_intf = [NSApp getIntf];
424
425     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
426                                                        FIND_ANYWHERE );
427     if( p_playlist == NULL )
428     {
429         return;
430     }
431
432     vlc_mutex_lock( &p_playlist->object_lock );
433
434     if( p_playlist->p_input == NULL )
435     {
436         vlc_mutex_unlock( &p_playlist->object_lock );
437         vlc_object_release( p_playlist );
438         return;
439     }
440
441     if( [o_mi state] == NSOffState )
442     {
443         u16 i_program_id = [o_mi tag];
444
445         input_ChangeProgram( p_playlist->p_input, i_program_id );
446         input_SetStatus( p_playlist->p_input, INPUT_STATUS_PLAY );
447     }
448
449     vlc_mutex_unlock( &p_playlist->object_lock );
450     vlc_object_release( p_playlist );
451 }
452
453 - (IBAction)toggleTitle:(id)sender
454 {
455     NSMenuItem * o_mi = (NSMenuItem *)sender;
456     intf_thread_t * p_intf = [NSApp getIntf];
457
458     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
459                                                        FIND_ANYWHERE );
460     if( p_playlist == NULL )
461     {
462         return;
463     }
464
465     vlc_mutex_lock( &p_playlist->object_lock );
466
467     if( p_playlist->p_input == NULL )
468     {
469         vlc_mutex_unlock( &p_playlist->object_lock );
470         vlc_object_release( p_playlist );
471         return;
472     }
473
474     if( [o_mi state] == NSOffState )
475     {
476         int i_title = [o_mi tag];
477
478 #define p_input p_playlist->p_input
479         input_ChangeArea( p_input, p_input->stream.pp_areas[i_title] );
480         input_SetStatus( p_input, INPUT_STATUS_PLAY );
481 #undef p_input
482     }
483
484     vlc_mutex_unlock( &p_playlist->object_lock );
485     vlc_object_release( p_playlist );
486 }
487
488 - (IBAction)toggleChapter:(id)sender
489 {
490     NSMenuItem * o_mi = (NSMenuItem *)sender;
491     intf_thread_t * p_intf = [NSApp getIntf];
492
493     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
494                                                        FIND_ANYWHERE );
495     if( p_playlist == NULL )
496     {
497         return;
498     }
499
500     vlc_mutex_lock( &p_playlist->object_lock );
501
502     if( p_playlist->p_input == NULL )
503     {
504         vlc_mutex_unlock( &p_playlist->object_lock );
505         vlc_object_release( p_playlist );
506         return;
507     }
508
509     if( [o_mi state] == NSOffState )
510     {
511         int i_chapter = [o_mi tag];
512
513 #define p_input p_playlist->p_input
514         p_input->stream.p_selected_area->i_part = i_chapter;
515         input_ChangeArea( p_input, p_input->stream.p_selected_area );
516         input_SetStatus( p_input, INPUT_STATUS_PLAY );
517 #undef p_input
518     }
519
520     vlc_mutex_unlock( &p_playlist->object_lock );
521     vlc_object_release( p_playlist );
522 }
523
524 - (IBAction)toggleLanguage:(id)sender
525 {
526     NSMenuItem * o_mi = (NSMenuItem *)sender;
527     intf_thread_t * p_intf = [NSApp getIntf];
528
529     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
530                                                        FIND_ANYWHERE );
531     if( p_playlist == NULL )
532     {
533         return;
534     }
535
536     vlc_mutex_lock( &p_playlist->object_lock );
537
538     if( p_playlist->p_input == NULL )
539     {
540         vlc_mutex_unlock( &p_playlist->object_lock );
541         vlc_object_release( p_playlist );
542         return;
543     }
544
545 #if 0
546     /* We do not use this code, because you need to start stop .avi for
547      * it to work, so not very useful now  --hartman */
548     if ( [o_mi state] == NSOffState && [o_mi tag] == 2000 )
549     {
550         NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
551         
552         [o_open_panel setAllowsMultipleSelection: NO];
553         [o_open_panel setTitle: _NS("Open subtitle file")];
554         [o_open_panel setPrompt: _NS("Open")];
555     
556         if( [o_open_panel runModalForDirectory: nil 
557                 file: nil types: nil] == NSOKButton )
558         {
559             NSString *o_filename = [[o_open_panel filenames] objectAtIndex: 0];
560             config_PutPsz( p_intf, "sub-file", strdup( [o_filename cString] ));
561         }
562     }
563 #endif
564
565 #define p_input p_playlist->p_input
566
567     if( !p_intf->p_sys->b_audio_update )
568     {
569         NSValue * o_value = [o_mi representedObject];
570         es_descriptor_t * p_es = [o_value pointerValue];
571
572         if( [o_mi state] == NSOnState )
573         {
574             /* we just have one ES to disable */
575             input_ToggleES( p_input, p_es, 0 );
576         }
577         else
578         {
579             unsigned int i;
580             int i_cat = [o_mi tag];
581
582             vlc_mutex_lock( &p_input->stream.stream_lock );
583
584 #define ES p_input->stream.pp_selected_es[i]
585
586             /* unselect the selected ES in the same class */
587             for( i = 0; i < p_input->stream.i_selected_es_number; i++ )
588             {
589                 if( ES->i_cat == i_cat )
590                 {
591                     vlc_mutex_unlock( &p_input->stream.stream_lock );
592                     input_ToggleES( p_input, ES, 0 );
593                     vlc_mutex_lock( &p_input->stream.stream_lock );
594                     break;
595                 }
596             }
597
598 #undef ES
599
600             vlc_mutex_unlock( &p_input->stream.stream_lock );
601
602             input_ToggleES( p_input, p_es, 1 );
603         }
604     }
605
606 #undef p_input
607
608     vlc_mutex_unlock( &p_playlist->object_lock );
609     vlc_object_release( p_playlist );
610 }
611
612 - (IBAction)toggleVar:(id)sender
613 {
614     NSMenuItem *o_mi = (NSMenuItem *)sender;
615     NSMenu *o_mu = [o_mi menu];
616     
617     if( [o_mi state] == NSOffState )
618     {
619         const char * psz_variable = (const char *)
620             [[[o_mu supermenu] itemWithTitle: [o_mu title]] tag];
621         vlc_object_t * p_object = (vlc_object_t *)
622             [[o_mi representedObject] pointerValue];
623         vlc_value_t val;
624         val.i_int = (int)[o_mi tag];
625
626         if ( var_Set( p_object, psz_variable, val ) < 0 )
627         {
628             msg_Warn( p_object, "cannot set variable %s: with %d", psz_variable, val.i_int );
629         }
630         if (psz_variable) free(psz_variable);
631     }
632 }
633
634 @end
635
636 @implementation VLCControls (NSMenuValidation)
637  
638 - (BOOL)validateMenuItem:(NSMenuItem *)o_mi
639 {
640     BOOL bEnabled = TRUE;
641     NSMenu * o_menu = [o_mi menu];
642     intf_thread_t * p_intf = [NSApp getIntf];
643
644     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
645                                                        FIND_ANYWHERE );
646
647     if( p_playlist != NULL )
648     {
649         vlc_mutex_lock( &p_playlist->object_lock );
650     }
651
652 #define p_input p_playlist->p_input
653
654     if( [[o_mi title] isEqualToString: _NS("Faster")] ||
655         [[o_mi title] isEqualToString: _NS("Slower")] )
656     {
657         if( p_playlist != NULL && p_input != NULL )
658         {
659             vlc_mutex_lock( &p_input->stream.stream_lock );
660             bEnabled = p_input->stream.b_pace_control;
661             vlc_mutex_unlock( &p_input->stream.stream_lock );
662         }
663         else
664         {
665             bEnabled = FALSE;
666         }
667     }
668     else if( [[o_mi title] isEqualToString: _NS("Stop")] )
669     {
670         if( p_playlist == NULL || p_input == NULL )
671         {
672             bEnabled = FALSE;
673         }
674     }
675     else if( [[o_mi title] isEqualToString: _NS("Previous")] ||
676              [[o_mi title] isEqualToString: _NS("Next")] )
677     {
678         if( p_playlist == NULL )
679         {
680             bEnabled = FALSE;
681         }
682         else
683         {
684             bEnabled = p_playlist->i_size > 1;
685
686             if( p_input != NULL )
687             {
688                 vlc_mutex_lock( &p_input->stream.stream_lock );
689                 bEnabled |= p_input->stream.p_selected_area->i_part_nb > 1;
690                 vlc_mutex_unlock( &p_input->stream.stream_lock );
691             }
692         }
693     }
694     else if( [[o_mi title] isEqualToString: _NS("Loop")] )
695     {
696         int i_state = config_GetInt( p_playlist, "loop" ) ?
697                       NSOnState : NSOffState;
698
699         [o_mi setState: i_state];
700     }
701     else if( [[o_mi title] isEqualToString: _NS("Step Forward")] ||
702              [[o_mi title] isEqualToString: _NS("Step Backward")] )
703     {
704         if( p_playlist != NULL && p_input != NULL )
705         {
706             vlc_mutex_lock( &p_input->stream.stream_lock );
707             bEnabled = p_input->stream.b_seekable;
708             vlc_mutex_unlock( &p_input->stream.stream_lock );
709         }
710         else
711         {
712             bEnabled = FALSE;
713         }
714     }
715     else if( [[o_mi title] isEqualToString: _NS("Mute")] ) 
716     {
717         [o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState];
718     }
719     else if( [[o_mi title] isEqualToString: _NS("Fullscreen")] ||
720                 [[o_mi title] isEqualToString: _NS("Half Size")] ||
721                 [[o_mi title] isEqualToString: _NS("Normal Size")] ||
722                 [[o_mi title] isEqualToString: _NS("Double Size")] ||
723                 [[o_mi title] isEqualToString: _NS("Float On Top")] )
724     {
725         id o_window;
726         NSArray *o_windows = [NSApp windows];
727         NSEnumerator *o_enumerator = [o_windows objectEnumerator];
728         bEnabled = FALSE;
729         
730         if ( [[o_mi title] isEqualToString: _NS("Float On Top")] )
731         {
732             int i_state = config_GetInt( p_playlist, "macosx-float" ) ?
733                       NSOnState : NSOffState;
734             [o_mi setState: i_state];
735         }
736         
737         while ((o_window = [o_enumerator nextObject]))
738         {
739             if( [[o_window className] isEqualToString: @"VLCWindow"] )
740             {
741                 bEnabled = TRUE;
742                 break;
743             }
744         }
745     }
746     else if( [[o_mi title] isEqualToString: _NS("Float On Top")] )
747     {
748         
749         bEnabled = TRUE;
750     }
751     else if( o_menu != nil && 
752              [[o_menu title] isEqualToString: _NS("Deinterlace")] )
753     {
754         char * psz_filter = config_GetPsz( p_intf, "filter" );
755         
756         if( psz_filter != NULL )
757         {
758             free( psz_filter );
759             
760             psz_filter = config_GetPsz( p_intf, "deinterlace-mode" );
761         }
762
763         if( psz_filter != NULL )
764         {
765             if( strcmp( psz_filter, [[o_mi title] lossyCString] ) == 0 )
766             {
767                 [o_mi setState: NSOnState];
768             }
769             else
770             {
771                 [o_mi setState: NSOffState];
772             }
773
774             free( psz_filter );
775         }
776         else
777         {
778             if( [[o_mi title] isEqualToString: @"none"] )
779             {
780                 [o_mi setState: NSOnState];
781             }
782             else
783             {
784                 [o_mi setState: NSOffState];
785             }
786         }
787     }
788
789     if( p_playlist != NULL )
790     {
791         vlc_mutex_unlock( &p_playlist->object_lock );
792         vlc_object_release( p_playlist );
793     }
794
795     return( bEnabled );
796 }
797
798 @end