controls.m 20.5 KB
Newer Older
1
2
3
/*****************************************************************************
 * controls.m: MacOS X interface plugin
 *****************************************************************************
hartman's avatar
hartman committed
4
5
 * Copyright (C) 2002-2003 VideoLAN
 * $Id: controls.m,v 1.29 2003/03/06 11:43:07 hartman Exp $
6
7
8
 *
 * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
 *          Christophe Massiot <massiot@via.ecp.fr>
hartman's avatar
hartman committed
9
 *          Derk-Jan Hartman <thedj@users.sourceforge.net>
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#include <stdlib.h>                                      /* malloc(), free() */
#include <sys/param.h>                                    /* for MAXPATHLEN */
#include <string.h>

#include "intf.h"
#include "vout.h"
hartman's avatar
hartman committed
35
#include "controls.h"
36
37
38
39
40
41
42
43
44

/*****************************************************************************
 * VLCControls implementation 
 *****************************************************************************/
@implementation VLCControls

- (IBAction)play:(id)sender
{
    intf_thread_t * p_intf = [NSApp getIntf];
45

46
47
48
49
50
51
52
    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

53
    if( playlist_IsPlaying( p_playlist ) )
54
    {
55
        playlist_Pause( p_playlist );
56
        vlc_object_release( p_playlist );
57
58
59
    }
    else
    {
60
        if( !playlist_IsEmpty( p_playlist ) )
hartman's avatar
hartman committed
61
62
        {
            playlist_Play( p_playlist );
63
            vlc_object_release( p_playlist );
hartman's avatar
hartman committed
64
65
66
        }
        else
        {
67
            vlc_object_release( p_playlist );
hartman's avatar
hartman committed
68
69
            [o_open openFile: nil];
        }
70
71
72
73
74
75
    }
}

- (IBAction)stop:(id)sender
{
    intf_thread_t * p_intf = [NSApp getIntf];
76

77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

    playlist_Stop( p_playlist );
    vlc_object_release( p_playlist );
}

- (IBAction)faster:(id)sender
{
    intf_thread_t * p_intf = [NSApp getIntf];

92
93
94
    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
95
96
97
98
    {
        return;
    }

99
100
101
102
103
104
105
106
    vlc_mutex_lock( &p_playlist->object_lock );
    if( p_playlist->p_input != NULL )
    {
        input_SetStatus( p_playlist->p_input, INPUT_STATUS_FASTER );
    } 
    vlc_mutex_unlock( &p_playlist->object_lock );

    vlc_object_release( p_playlist );
107
108
109
110
111
112
}

- (IBAction)slower:(id)sender
{
    intf_thread_t * p_intf = [NSApp getIntf];

113
114
115
    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
116
117
118
119
    {
        return;
    }

120
121
    vlc_mutex_lock( &p_playlist->object_lock );
    if( p_playlist->p_input != NULL )
hartman's avatar
hartman committed
122
    {
123
        input_SetStatus( p_playlist->p_input, INPUT_STATUS_SLOWER );
hartman's avatar
hartman committed
124
    }
125
    vlc_mutex_unlock( &p_playlist->object_lock );
hartman's avatar
hartman committed
126

127
    vlc_object_release( p_playlist );
hartman's avatar
hartman committed
128
129
}

130
131
132
- (IBAction)prev:(id)sender
{
    intf_thread_t * p_intf = [NSApp getIntf];
133

134
135
    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );
136
137
138
139
140
141
142
143
144
145
146
147
148
    if( p_playlist == NULL )
    {
        return;
    }

    vlc_mutex_lock( &p_playlist->object_lock );

    if( p_playlist->p_input == NULL )
    {
        vlc_mutex_unlock( &p_playlist->object_lock );
        vlc_object_release( p_playlist );  
        return;
    }
149

150
    vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
151

152
153
154
#define p_area p_playlist->p_input->stream.p_selected_area

    if( p_area->i_part_nb > 1 && p_area->i_part > 1 )
155
    {
156
        p_area->i_part--;
157

158
159
160
        vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
        input_ChangeArea( p_playlist->p_input, p_area );
        vlc_mutex_unlock( &p_playlist->object_lock );
161
162
163
164
165

        p_intf->p_sys->b_chapter_update = VLC_TRUE;
    }
    else
    {
166
167
168
        vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
        vlc_mutex_unlock( &p_playlist->object_lock );
        playlist_Prev( p_playlist );
169
    }
170
171
172
173

#undef p_area

    vlc_object_release( p_playlist );
174
175
176
177
178
}

- (IBAction)next:(id)sender
{
    intf_thread_t * p_intf = [NSApp getIntf];
179

180
181
    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );
182
183
184
185
    if( p_playlist == NULL )
    {
        return;
    }
186

187
    vlc_mutex_lock( &p_playlist->object_lock );
188

189
190
191
192
193
194
195
196
197
198
199
200
    if( p_playlist->p_input == NULL )
    {
        vlc_mutex_unlock( &p_playlist->object_lock );
        vlc_object_release( p_playlist );  
        return;
    }

    vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );

#define p_area p_playlist->p_input->stream.p_selected_area

    if( p_area->i_part_nb > 1 && p_area->i_part + 1 < p_area->i_part_nb )
201
    {
202
        p_area->i_part++;
203

204
205
206
        vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
        input_ChangeArea( p_playlist->p_input, p_area );
        vlc_mutex_unlock( &p_playlist->object_lock );
207
208
209
210
211

        p_intf->p_sys->b_chapter_update = VLC_TRUE;
    }
    else
    {
212
213
214
        vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
        vlc_mutex_unlock( &p_playlist->object_lock );
        playlist_Next( p_playlist );
215
    }
216
217
218
219

#undef p_area

    vlc_object_release( p_playlist );
220
221
222
223
224
}

- (IBAction)loop:(id)sender
{
    intf_thread_t * p_intf = [NSApp getIntf];
225

226
227
228
229
230
231
232
    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

233
234
    config_PutInt( p_playlist, "loop",
                   !config_GetInt( p_playlist, "loop" ) );
235
236
237
238

    vlc_object_release( p_playlist );
}

239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
- (IBAction)forward:(id)sender
{
    intf_thread_t * p_intf = [NSApp getIntf];
    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );
    if( p_playlist == NULL || p_playlist->p_input == NULL )
    {
        if ( p_playlist != NULL ) vlc_object_release( p_playlist );
        return;
    }

    input_Seek( p_playlist->p_input, 5, INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
    vlc_object_release( p_playlist );
}

- (IBAction)backward:(id)sender
{
    intf_thread_t * p_intf = [NSApp getIntf];
    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );
    if( p_playlist == NULL || p_playlist->p_input == NULL )
    {
        if ( p_playlist != NULL ) vlc_object_release( p_playlist );
        return;
    }

    input_Seek( p_playlist->p_input, -5, INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
    vlc_object_release( p_playlist );
}

269
270
271
- (IBAction)volumeUp:(id)sender
{
    intf_thread_t * p_intf = [NSApp getIntf];
272

273
274
275
    if( p_intf->p_sys->b_mute )
    {
        [self mute: nil];
276
    }
277

hartman's avatar
hartman committed
278
279
    aout_VolumeUp( p_intf, 1, NULL );

280
    [self updateVolumeSlider];
281
282
283
284
285
}

- (IBAction)volumeDown:(id)sender
{
    intf_thread_t * p_intf = [NSApp getIntf];
286

287
288
289
    if( p_intf->p_sys->b_mute )
    {
        [self mute: nil];
290
    }
hartman's avatar
hartman committed
291
292
    
    aout_VolumeDown( p_intf, 1, NULL );
293
294

    [self updateVolumeSlider];
295
296
297
298
}

- (IBAction)mute:(id)sender
{
299
    intf_thread_t * p_intf = [NSApp getIntf];
300
    audio_volume_t i_volume;
301

302
303
    aout_VolumeMute( p_intf, &i_volume );
    p_intf->p_sys->b_mute = ( i_volume == 0 );
304

305
    [self updateVolumeSlider];
hartman's avatar
hartman committed
306
307
}

308
- (IBAction)volumeSliderUpdated:(id)sender
hartman's avatar
hartman committed
309
310
{
    intf_thread_t * p_intf = [NSApp getIntf];
311
    audio_volume_t i_volume = (audio_volume_t)[sender intValue];
hartman's avatar
hartman committed
312

313
    aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_STEP );
hartman's avatar
hartman committed
314
315
}

316
- (void)updateVolumeSlider
hartman's avatar
hartman committed
317
318
{
    intf_thread_t * p_intf = [NSApp getIntf];
319
    audio_volume_t i_volume;
320

321
    aout_VolumeGet( p_intf, &i_volume );
322

323
    [o_volumeslider setFloatValue: (float)(i_volume / AOUT_VOLUME_STEP)]; 
324
325
}

326
327
328
329
330
331
332
333
334
335
- (IBAction)halfWindow:(id)sender
{
    id o_window = [NSApp keyWindow];
    NSArray *o_windows = [NSApp windows];
    NSEnumerator *o_enumerator = [o_windows objectEnumerator];
    
    while ((o_window = [o_enumerator nextObject]))
    {
        if( [[o_window className] isEqualToString: @"VLCWindow"] )
        {
hartman's avatar
hartman committed
336
            [o_window scaleWindowWithFactor: 0.5];
337
338
339
340
341
342
343
344
345
346
347
348
349
350
        }
    }
}

- (IBAction)normalWindow:(id)sender
{
    id o_window = [NSApp keyWindow];
    NSArray *o_windows = [NSApp windows];
    NSEnumerator *o_enumerator = [o_windows objectEnumerator];
    
    while ((o_window = [o_enumerator nextObject]))
    {
        if( [[o_window className] isEqualToString: @"VLCWindow"] )
        {
hartman's avatar
hartman committed
351
            [o_window scaleWindowWithFactor: 1];
352
353
354
355
356
357
358
359
360
361
362
363
364
365
        }
    }
}

- (IBAction)doubleWindow:(id)sender
{
    id o_window = [NSApp keyWindow];
    NSArray *o_windows = [NSApp windows];
    NSEnumerator *o_enumerator = [o_windows objectEnumerator];
    
    while ((o_window = [o_enumerator nextObject]))
    {
        if( [[o_window className] isEqualToString: @"VLCWindow"] )
        {
hartman's avatar
hartman committed
366
            [o_window scaleWindowWithFactor: 2];
367
368
369
370
371
        }
    }
}


372
373
374
- (IBAction)fullscreen:(id)sender
{
    id o_window = [NSApp keyWindow];
375
376
377
378
    NSArray *o_windows = [NSApp windows];
    NSEnumerator *o_enumerator = [o_windows objectEnumerator];
    
    while ((o_window = [o_enumerator nextObject]))
379
    {
380
381
382
383
        if( [[o_window className] isEqualToString: @"VLCWindow"] )
        {
            [o_window toggleFullscreen];
        }
384
385
386
387
388
    }
}

- (IBAction)deinterlace:(id)sender
{
389
390
391
392
393
394
395
    intf_thread_t * p_intf = [NSApp getIntf];
    BOOL bEnable = [sender state] == NSOffState;
    
    if( bEnable )
    {
        config_PutPsz( p_intf, "filter", "deinterlace" );
	config_PutPsz( p_intf, "deinterlace-mode",
396
                    [[sender title] lossyCString] );
397
398
399
400
401
    }
    else
    {
        config_PutPsz( p_intf, "filter", NULL );
    }
402
}
403

404
405
406
407
408
409
410
411
- (IBAction)toggleProgram:(id)sender
{
    NSMenuItem * o_mi = (NSMenuItem *)sender;
    intf_thread_t * p_intf = [NSApp getIntf];

    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
412
    {
413
        return;
414
415
    }

416
    vlc_mutex_lock( &p_playlist->object_lock );
417

418
    if( p_playlist->p_input == NULL )
419
    {
420
421
422
        vlc_mutex_unlock( &p_playlist->object_lock );
        vlc_object_release( p_playlist );
        return;
423
424
    }

425
    if( [o_mi state] == NSOffState )
426
    {
427
        u16 i_program_id = [o_mi tag];
428

429
430
        input_ChangeProgram( p_playlist->p_input, i_program_id );
        input_SetStatus( p_playlist->p_input, INPUT_STATUS_PLAY );
431
    }
432
433
434

    vlc_mutex_unlock( &p_playlist->object_lock );
    vlc_object_release( p_playlist );
435
436
}

437
- (IBAction)toggleTitle:(id)sender
438
439
440
441
{
    NSMenuItem * o_mi = (NSMenuItem *)sender;
    intf_thread_t * p_intf = [NSApp getIntf];

442
443
444
    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
445
    {
446
        return;
447
448
    }

449
450
451
452
453
454
455
456
    vlc_mutex_lock( &p_playlist->object_lock );

    if( p_playlist->p_input == NULL )
    {
        vlc_mutex_unlock( &p_playlist->object_lock );
        vlc_object_release( p_playlist );
        return;
    }
457
458
459
460
461

    if( [o_mi state] == NSOffState )
    {
        int i_title = [o_mi tag];

462
#define p_input p_playlist->p_input
463
464
465
466
        input_ChangeArea( p_input, p_input->stream.pp_areas[i_title] );
        input_SetStatus( p_input, INPUT_STATUS_PLAY );
#undef p_input
    }
467
468
469

    vlc_mutex_unlock( &p_playlist->object_lock );
    vlc_object_release( p_playlist );
470
471
472
473
474
475
476
}

- (IBAction)toggleChapter:(id)sender
{
    NSMenuItem * o_mi = (NSMenuItem *)sender;
    intf_thread_t * p_intf = [NSApp getIntf];

477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

    vlc_mutex_lock( &p_playlist->object_lock );

    if( p_playlist->p_input == NULL )
    {
        vlc_mutex_unlock( &p_playlist->object_lock );
        vlc_object_release( p_playlist );
        return;
    }

493
494
495
496
    if( [o_mi state] == NSOffState )
    {
        int i_chapter = [o_mi tag];

497
#define p_input p_playlist->p_input
498
499
500
501
502
        p_input->stream.p_selected_area->i_part = i_chapter;
        input_ChangeArea( p_input, p_input->stream.p_selected_area );
        input_SetStatus( p_input, INPUT_STATUS_PLAY );
#undef p_input
    }
503
504
505

    vlc_mutex_unlock( &p_playlist->object_lock );
    vlc_object_release( p_playlist );
506
507
508
509
510
511
512
}

- (IBAction)toggleLanguage:(id)sender
{
    NSMenuItem * o_mi = (NSMenuItem *)sender;
    intf_thread_t * p_intf = [NSApp getIntf];

513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

    vlc_mutex_lock( &p_playlist->object_lock );

    if( p_playlist->p_input == NULL )
    {
        vlc_mutex_unlock( &p_playlist->object_lock );
        vlc_object_release( p_playlist );
        return;
    }

529
530
531
532
533
534
535
536
#if 0
    /* We do not use this code, because you need to start stop .avi for
     * it to work, so not very useful now  --hartman */
    if ( [o_mi state] == NSOffState && [o_mi tag] == 2000 )
    {
        NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
        
        [o_open_panel setAllowsMultipleSelection: NO];
537
        [o_open_panel setTitle: _NS("Open subtitle file")];
538
539
540
541
542
543
544
545
546
547
548
        [o_open_panel setPrompt: _NS("Open")];
    
        if( [o_open_panel runModalForDirectory: nil 
                file: nil types: nil] == NSOKButton )
        {
            NSString *o_filename = [[o_open_panel filenames] objectAtIndex: 0];
            config_PutPsz( p_intf, "sub-file", strdup( [o_filename cString] ));
        }
    }
#endif

549
#define p_input p_playlist->p_input
550
551
552
553
554
555
556
557
558
559
560
561
562

    if( !p_intf->p_sys->b_audio_update )
    {
        NSValue * o_value = [o_mi representedObject];
        es_descriptor_t * p_es = [o_value pointerValue];

        if( [o_mi state] == NSOnState )
        {
            /* we just have one ES to disable */
            input_ToggleES( p_input, p_es, 0 );
        }
        else
        {
563
            unsigned int i;
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
            int i_cat = [o_mi tag];

            vlc_mutex_lock( &p_input->stream.stream_lock );

#define ES p_input->stream.pp_selected_es[i]

            /* unselect the selected ES in the same class */
            for( i = 0; i < p_input->stream.i_selected_es_number; i++ )
            {
                if( ES->i_cat == i_cat )
                {
                    vlc_mutex_unlock( &p_input->stream.stream_lock );
                    input_ToggleES( p_input, ES, 0 );
                    vlc_mutex_lock( &p_input->stream.stream_lock );
                    break;
                }
            }

#undef ES

            vlc_mutex_unlock( &p_input->stream.stream_lock );

            input_ToggleES( p_input, p_es, 1 );
        }
    }

#undef p_input
591
592
593

    vlc_mutex_unlock( &p_playlist->object_lock );
    vlc_object_release( p_playlist );
594
595
}

596
597
598
- (IBAction)toggleVar:(id)sender
{
    NSMenuItem * o_mi = (NSMenuItem *)sender;
599
    
600
601
602
    if( [o_mi state] == NSOffState )
    {
        const char * psz_variable = (const char *)[o_mi tag];
603
        char * psz_value = [NSApp delocalizeString: [o_mi title]];
604
605
606
        vlc_object_t * p_object = (vlc_object_t *)
            [[o_mi representedObject] pointerValue];
        vlc_value_t val;
607
608
        /* psz_string sucks */
        val.psz_string = (char *)psz_value;
609
610
611
612
613

        if ( var_Set( p_object, psz_variable, val ) < 0 )
        {
            msg_Warn( p_object, "cannot set variable (%s)", psz_value );
        }
614
615

        free( psz_value );
616
617
618
    }
}

619
620
621
622
623
624
625
626
627
628
@end

@implementation VLCControls (NSMenuValidation)
 
- (BOOL)validateMenuItem:(NSMenuItem *)o_mi
{
    BOOL bEnabled = TRUE;
    NSMenu * o_menu = [o_mi menu];
    intf_thread_t * p_intf = [NSApp getIntf];

629
630
631
632
633
634
635
636
    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );

    if( p_playlist != NULL )
    {
        vlc_mutex_lock( &p_playlist->object_lock );
    }

637
638
#define p_input p_playlist->p_input

hartman's avatar
hartman committed
639
    if( [[o_mi title] isEqualToString: _NS("Faster")] ||
640
641
        [[o_mi title] isEqualToString: _NS("Slower")] )
    {
642
        if( p_playlist != NULL && p_input != NULL )
643
        {
644
645
646
            vlc_mutex_lock( &p_input->stream.stream_lock );
            bEnabled = p_input->stream.b_pace_control;
            vlc_mutex_unlock( &p_input->stream.stream_lock );
647
648
649
650
651
652
653
654
        }
        else
        {
            bEnabled = FALSE;
        }
    }
    else if( [[o_mi title] isEqualToString: _NS("Stop")] )
    {
655
        if( p_playlist == NULL || p_input == NULL )
656
657
658
        {
            bEnabled = FALSE;
        }
659
    }
Jon Lech Johansen's avatar
Jon Lech Johansen committed
660
    else if( [[o_mi title] isEqualToString: _NS("Previous")] ||
661
662
663
664
665
666
667
668
669
             [[o_mi title] isEqualToString: _NS("Next")] )
    {
        if( p_playlist == NULL )
        {
            bEnabled = FALSE;
        }
        else
        {
            bEnabled = p_playlist->i_size > 1;
670
671
672
673
674
675
676

            if( p_input != NULL )
            {
                vlc_mutex_lock( &p_input->stream.stream_lock );
                bEnabled |= p_input->stream.p_selected_area->i_part_nb > 1;
                vlc_mutex_unlock( &p_input->stream.stream_lock );
            }
677
678
        }
    }
679
680
681
682
683
684
685
    else if( [[o_mi title] isEqualToString: _NS("Loop")] )
    {
        int i_state = config_GetInt( p_playlist, "loop" ) ?
                      NSOnState : NSOffState;

        [o_mi setState: i_state];
    }
686
687
688
689
690
691
692
693
694
695
696
697
698
699
    else if( [[o_mi title] isEqualToString: _NS("Step Forward")] ||
             [[o_mi title] isEqualToString: _NS("Step Backward")] )
    {
        if( p_playlist != NULL && p_input != NULL )
        {
            vlc_mutex_lock( &p_input->stream.stream_lock );
            bEnabled = p_input->stream.b_seekable;
            vlc_mutex_unlock( &p_input->stream.stream_lock );
        }
        else
        {
            bEnabled = FALSE;
        }
    }
700
701
702
703
    else if( [[o_mi title] isEqualToString: _NS("Mute")] ) 
    {
        [o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState];
    }
704
705
706
707
    else if( [[o_mi title] isEqualToString: _NS("Fullscreen")] ||
                [[o_mi title] isEqualToString: _NS("Half Size")] ||
                [[o_mi title] isEqualToString: _NS("Normal Size")] ||
                [[o_mi title] isEqualToString: _NS("Double Size")])    
708
    {
709
710
711
712
713
714
        id o_window;
        NSArray *o_windows = [NSApp windows];
        NSEnumerator *o_enumerator = [o_windows objectEnumerator];
        bEnabled = FALSE;
        
        while ((o_window = [o_enumerator nextObject]))
715
        {
716
717
718
719
720
            if( [[o_window className] isEqualToString: @"VLCWindow"] )
            {
                bEnabled = TRUE;
                break;
            }
721
722
723
724
        }
    }
    else if( o_menu != nil && 
             [[o_menu title] isEqualToString: _NS("Deinterlace")] )
725
    {
726
        char * psz_filter = config_GetPsz( p_intf, "filter" );
727
        
728
729
730
        if( psz_filter != NULL )
        {
            free( psz_filter );
731
            
732
            psz_filter = config_GetPsz( p_intf, "deinterlace-mode" );
733
        }
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752

        if( psz_filter != NULL )
        {
            if( strcmp( psz_filter, [[o_mi title] lossyCString] ) == 0 )
            {
                [o_mi setState: NSOnState];
            }
            else
            {
                [o_mi setState: NSOffState];
            }

            free( psz_filter );
        }
        else
        {
            [o_mi setState: NSOffState];
        }
    }
753

754
755
756
757
758
759
    if( p_playlist != NULL )
    {
        vlc_mutex_unlock( &p_playlist->object_lock );
        vlc_object_release( p_playlist );
    }

760
761
762
763
    return( bEnabled );
}

@end