MainMenu.m 60.2 KB
Newer Older
1 2 3
/*****************************************************************************
 * MainMenu.m: MacOS X interface module
 *****************************************************************************
4
 * Copyright (C) 2011-2013 Felix Paul Kühne
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 * $Id$
 *
 * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
 *
 * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#import "MainMenu.h"
#import <vlc_common.h>
#import <vlc_playlist.h>
27
#import <vlc_input.h>
28 29 30 31 32 33 34 35 36 37 38 39

#import "intf.h"
#import "open.h"
#import "wizard.h"
#import "about.h"
#import "AudioEffects.h"
#import "TrackSynchronization.h"
#import "VideoEffects.h"
#import "bookmarks.h"
#import "simple_prefs.h"
#import "coredialogs.h"
#import "controls.h"
40
#import "playlist.h"
41
#import "playlistinfo.h"
42
#import "VideoView.h"
43
#import "CoreInteraction.h"
44
#import "MainWindow.h"
45
#import "ControlsBar.h"
46
#import "ExtensionsManager.h"
47
#import "ConvertAndSave.h"
48
#import "DebugMessageVisualizer.h"
49
#import "AddonManager.h"
50 51 52 53 54 55 56 57 58 59 60 61 62 63

@implementation VLCMainMenu
static VLCMainMenu *_o_sharedInstance = nil;

+ (VLCMainMenu *)sharedInstance
{
    return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
}

#pragma mark -
#pragma mark Initialization

- (id)init
{
64
    if (_o_sharedInstance) {
65 66
        [self dealloc];
        return _o_sharedInstance;
67
    } else {
68
        _o_sharedInstance = [super init];
69

70
        o_ptc_translation_dict = [[NSDictionary alloc] initWithObjectsAndKeys:
71 72
                      _NS("Track Number"),  TRACKNUM_COLUMN,
                      _NS("Title"),         TITLE_COLUMN,
73
                      _NS("Author"),        ARTIST_COLUMN,
74 75 76 77 78 79 80
                      _NS("Duration"),      DURATION_COLUMN,
                      _NS("Genre"),         GENRE_COLUMN,
                      _NS("Album"),         ALBUM_COLUMN,
                      _NS("Description"),   DESCRIPTION_COLUMN,
                      _NS("Date"),          DATE_COLUMN,
                      _NS("Language"),      LANGUAGE_COLUMN,
                      _NS("URI"),           URI_COLUMN,
81
                      _NS("File Size"),     FILESIZE_COLUMN,
82 83
                      nil];
        // this array also assigns tags (index) to type of menu item
84 85
        o_ptc_menuorder = [[NSArray alloc] initWithObjects: TRACKNUM_COLUMN, TITLE_COLUMN,
                           ARTIST_COLUMN, DURATION_COLUMN, GENRE_COLUMN, ALBUM_COLUMN,
86 87
                           DESCRIPTION_COLUMN, DATE_COLUMN, LANGUAGE_COLUMN, URI_COLUMN,
                           FILESIZE_COLUMN,nil];
88 89 90 91 92 93 94 95
    }

    return _o_sharedInstance;
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver: self];
96

97 98 99 100 101 102 103 104 105 106 107 108
    if (b_nib_about_loaded)
        [o_about release];

    if (b_nib_videoeffects_loaded)
        [o_videoeffects release];

    if (b_nib_audioeffects_loaded)
        [o_audioeffects release];

    if (b_nib_tracksynchro_loaded)
        [o_trackSynchronization release];

109 110 111
    if (b_nib_convertandsave_loaded)
        [o_convertandsave release];

112 113
    [o_extMgr release];

114
    if (o_mu_playlistTableColumnsContextMenu)
115 116
        [o_mu_playlistTableColumnsContextMenu release];

117 118
    [self releaseRepresentedObjects:[NSApp mainMenu]];

119 120 121
    [o_ptc_translation_dict release];
    [o_ptc_menuorder release];

122 123 124 125 126
    [super dealloc];
}

- (void)awakeFromNib
{
127
    [[NSNotificationCenter defaultCenter] addObserver: self
128 129 130
                                             selector: @selector(applicationWillFinishLaunching:)
                                                 name: NSApplicationWillFinishLaunchingNotification
                                               object: nil];
131 132 133

    /* check whether the user runs OSX with a RTL language */
    NSArray* languages = [NSLocale preferredLanguages];
134
    NSString* preferredLanguage = [languages objectAtIndex:0];
135 136 137 138 139

    if ([NSLocale characterDirectionForLanguage:preferredLanguage] == NSLocaleLanguageDirectionRightToLeft) {
        msg_Dbg(VLCIntf, "adapting interface since '%s' is a RTL language", [preferredLanguage UTF8String]);
        [o_mi_rate_fld setAlignment: NSLeftTextAlignment];
    }
140 141 142 143 144 145 146 147 148
}

- (void)applicationWillFinishLaunching:(NSNotification *)o_notification
{
    p_intf = VLCIntf;

    NSString* o_key;
    playlist_t *p_playlist;
    vlc_value_t val;
149
    id o_vlcstringutility = [VLCStringUtility sharedInstance];
150
    char * key;
151 152 153

    /* Check if we already did this once. Opening the other nibs calls it too,
     because VLCMain is the owner */
154 155
    if (b_mainMenu_setup)
        return;
156

157 158 159 160
    /* Get ExtensionsManager */
    o_extMgr = [ExtensionsManager getInstance:p_intf];
    [o_extMgr retain];

161 162
    [self initStrings];

163
    key = config_GetPsz(p_intf, "key-quit");
164
    o_key = [NSString stringWithFormat:@"%s", key];
165 166
    [o_mi_quit setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
    [o_mi_quit setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
167
    FREENULL(key);
168

169
    // do not assign play/pause key
170

171
    key = config_GetPsz(p_intf, "key-stop");
172
    o_key = [NSString stringWithFormat:@"%s", key];
173 174
    [o_mi_stop setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
    [o_mi_stop setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
175
    FREENULL(key);
176

177
    key = config_GetPsz(p_intf, "key-prev");
178
    o_key = [NSString stringWithFormat:@"%s", key];
179 180
    [o_mi_previous setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
    [o_mi_previous setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
181
    FREENULL(key);
182

183
    key = config_GetPsz(p_intf, "key-next");
184
    o_key = [NSString stringWithFormat:@"%s", key];
185 186
    [o_mi_next setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
    [o_mi_next setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
187
    FREENULL(key);
188

189
    key = config_GetPsz(p_intf, "key-jump+short");
190
    o_key = [NSString stringWithFormat:@"%s", key];
191 192
    [o_mi_fwd setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
    [o_mi_fwd setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
193
    FREENULL(key);
194

195
    key = config_GetPsz(p_intf, "key-jump-short");
196
    o_key = [NSString stringWithFormat:@"%s", key];
197 198
    [o_mi_bwd setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
    [o_mi_bwd setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
199
    FREENULL(key);
200

201
    key = config_GetPsz(p_intf, "key-vol-up");
202
    o_key = [NSString stringWithFormat:@"%s", key];
203 204
    [o_mi_vol_up setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
    [o_mi_vol_up setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
205
    FREENULL(key);
206

207
    key = config_GetPsz(p_intf, "key-vol-down");
208
    o_key = [NSString stringWithFormat:@"%s", key];
209 210
    [o_mi_vol_down setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
    [o_mi_vol_down setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
211
    FREENULL(key);
212

213
    key = config_GetPsz(p_intf, "key-vol-mute");
214
    o_key = [NSString stringWithFormat:@"%s", key];
215 216
    [o_mi_mute setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
    [o_mi_mute setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
217
    FREENULL(key);
218

219
    key = config_GetPsz(p_intf, "key-toggle-fullscreen");
220
    o_key = [NSString stringWithFormat:@"%s", key];
221 222
    [o_mi_fullscreen setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
    [o_mi_fullscreen setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
223
    FREENULL(key);
224

225
    key = config_GetPsz(p_intf, "key-snapshot");
226
    o_key = [NSString stringWithFormat:@"%s", key];
227 228
    [o_mi_snapshot setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
    [o_mi_snapshot setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
229
    FREENULL(key);
230

231
    key = config_GetPsz(p_intf, "key-random");
232
    o_key = [NSString stringWithFormat:@"%s", key];
233 234
    [o_mi_random setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
    [o_mi_random setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
235
    FREENULL(key);
236

237
    key = config_GetPsz(p_intf, "key-zoom-half");
238
    o_key = [NSString stringWithFormat:@"%s", key];
239 240
    [o_mi_half_window setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
    [o_mi_half_window setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
241
    FREENULL(key);
242

243
    key = config_GetPsz(p_intf, "key-zoom-original");
244
    o_key = [NSString stringWithFormat:@"%s", key];
245 246
    [o_mi_normal_window setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
    [o_mi_normal_window setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
247
    FREENULL(key);
248

249
    key = config_GetPsz(p_intf, "key-zoom-double");
250
    o_key = [NSString stringWithFormat:@"%s", key];
251 252
    [o_mi_double_window setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
    [o_mi_double_window setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
253
    FREENULL(key);
254 255 256 257 258 259 260 261 262 263 264 265 266

    [self setSubmenusEnabled: FALSE];

    [[NSNotificationCenter defaultCenter] addObserver: self
                                             selector: @selector(refreshVoutDeviceMenu:)
                                                 name: NSApplicationDidChangeScreenParametersNotification
                                               object: nil];

    /* we're done */
    b_mainMenu_setup = YES;

    [self setupVarMenuItem: o_mi_add_intf target: (vlc_object_t *)p_intf
                             var: "intf-add" selector: @selector(toggleVar:)];
267 268

    [self setupExtensionsMenu];
269

270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
    NSUInteger count = (NSUInteger) [o_mu_ffmpeg_pp numberOfItems];
    if (count > 0)
        [o_mu_ffmpeg_pp removeAllItems];

    NSMenuItem * o_mitem;
    [o_mu_ffmpeg_pp setAutoenablesItems: YES];
    [o_mu_ffmpeg_pp addItemWithTitle: _NS("Disable") action:@selector(togglePostProcessing:) keyEquivalent:@""];
    o_mitem = [o_mu_ffmpeg_pp itemAtIndex: 0];
    [o_mitem setTag: -1];
    [o_mitem setEnabled: YES];
    [o_mitem setTarget: self];
    for (NSUInteger x = 0; x < 7; x++) {
        [o_mu_ffmpeg_pp addItemWithTitle:[NSString stringWithFormat:_NS("Level %i"), x]
                                               action:@selector(togglePostProcessing:)
                                        keyEquivalent:@""];
        o_mitem = [o_mu_ffmpeg_pp itemAtIndex:x+1];
        [o_mitem setEnabled: YES];
        [o_mitem setTag:x];
        [o_mitem setTarget: self];
    }
    char *psz_config = config_GetPsz(p_intf, "video-filter");
    if (psz_config) {
        if (!strstr(psz_config, "postprocess"))
            [[o_mu_ffmpeg_pp itemAtIndex:0] setState:NSOnState];
        else
            [[o_mu_ffmpeg_pp itemWithTag:config_GetInt(p_intf, "postproc-q")] setState:NSOnState];
        free(psz_config);
    } else
        [[o_mu_ffmpeg_pp itemAtIndex:0] setState:NSOnState];
    [o_mi_ffmpeg_pp setEnabled: NO];

301
    [self refreshAudioDeviceList];
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326

    /* setup subtitles menu */
    [self setupMenu: o_mu_subtitle_size withIntList:"freetype-rel-fontsize" andSelector:@selector(switchSubtitleOption:)];
    [self setupMenu: o_mu_subtitle_textcolor withIntList:"freetype-color" andSelector:@selector(switchSubtitleOption:)];
    [o_mi_subtitle_bgopacity_sld setIntValue: config_GetInt(VLC_OBJECT(p_intf), "freetype-background-opacity")];
    [self setupMenu: o_mu_subtitle_bgcolor withIntList:"freetype-background-color" andSelector:@selector(switchSubtitleOption:)];
    [self setupMenu: o_mu_subtitle_outlinethickness withIntList:"freetype-outline-thickness" andSelector:@selector(switchSubtitleOption:)];
}

- (void)setupMenu: (NSMenu*)menu withIntList: (char *)psz_name andSelector:(SEL)selector
{
    module_config_t *p_item;

    [menu removeAllItems];
    p_item = config_FindConfig(VLC_OBJECT(p_intf), psz_name);

    /* serious problem, if no item found */
    assert(p_item);

    for (int i = 0; i < p_item->list_count; i++) {
        NSMenuItem *mi;
        if (p_item->list_text != NULL)
            mi = [[NSMenuItem alloc] initWithTitle: _NS(p_item->list_text[i]) action:NULL keyEquivalent: @""];
        else if (p_item->list.i[i])
            mi = [[NSMenuItem alloc] initWithTitle: [NSString stringWithFormat: @"%d", p_item->list.i[i]] action:NULL keyEquivalent: @""];
327
        else {
328
            msg_Err(p_intf, "item %d of pref %s failed to be created", i, psz_name);
329 330 331
            continue;
        }

332 333 334
        [mi setTarget:self];
        [mi setAction:selector];
        [mi setTag:p_item->list.i[i]];
335
        [mi setRepresentedObject:[NSString stringWithUTF8String:psz_name]];
336 337 338 339
        [menu addItem: [mi autorelease]];
        if (p_item->value.i == p_item->list.i[i])
            [mi setState:NSOnState];
    }
340 341 342 343 344 345 346 347 348
}

- (void)initStrings
{
    /* main menu */
    [o_mi_about setTitle: [_NS("About VLC media player") \
                           stringByAppendingString: @"..."]];
    [o_mi_checkForUpdate setTitle: _NS("Check for Update...")];
    [o_mi_prefs setTitle: _NS("Preferences...")];
349 350
    [o_mi_extensions setTitle: _NS("Extensions")];
    [o_mu_extensions setTitle: _NS("Extensions")];
David Fuhrmann's avatar
David Fuhrmann committed
351
    [o_mi_addonManager setTitle: _NS("Addons Manager")];
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366
    [o_mi_add_intf setTitle: _NS("Add Interface")];
    [o_mu_add_intf setTitle: _NS("Add Interface")];
    [o_mi_services setTitle: _NS("Services")];
    [o_mi_hide setTitle: _NS("Hide VLC")];
    [o_mi_hide_others setTitle: _NS("Hide Others")];
    [o_mi_show_all setTitle: _NS("Show All")];
    [o_mi_quit setTitle: _NS("Quit VLC")];

    [o_mu_file setTitle: _ANS("1:File")];
    [o_mi_open_generic setTitle: _NS("Advanced Open File...")];
    [o_mi_open_file setTitle: _NS("Open File...")];
    [o_mi_open_disc setTitle: _NS("Open Disc...")];
    [o_mi_open_net setTitle: _NS("Open Network...")];
    [o_mi_open_capture setTitle: _NS("Open Capture Device...")];
    [o_mi_open_recent setTitle: _NS("Open Recent")];
367
    [o_mi_close_window setTitle: _NS("Close Window")];
368
    [o_mi_open_wizard setTitle: _NS("Streaming/Exporting Wizard...")];
369
    [o_mi_convertandsave setTitle: _NS("Convert / Stream...")];
370
    [o_mi_save_playlist setTitle: _NS("Save Playlist...")];
371 372 373 374 375 376 377 378

    [o_mu_edit setTitle: _NS("Edit")];
    [o_mi_cut setTitle: _NS("Cut")];
    [o_mi_copy setTitle: _NS("Copy")];
    [o_mi_paste setTitle: _NS("Paste")];
    [o_mi_clear setTitle: _NS("Clear")];
    [o_mi_select_all setTitle: _NS("Select All")];

379 380
    [o_mu_view setTitle: _NS("View")];
    [o_mi_toggleJumpButtons setTitle: _NS("Show Previous & Next Buttons")];
381
    [o_mi_toggleJumpButtons setState: config_GetInt(VLCIntf, "macosx-show-playback-buttons")];
382
    [o_mi_togglePlaymodeButtons setTitle: _NS("Show Shuffle & Repeat Buttons")];
383
    [o_mi_togglePlaymodeButtons setState: config_GetInt(VLCIntf, "macosx-show-playmode-buttons")];
384 385
    [o_mi_toggleEffectsButton setTitle: _NS("Show Audio Effects Button")];
    [o_mi_toggleEffectsButton setState: config_GetInt(VLCIntf, "macosx-show-effects-button")];
386 387
    [o_mi_toggleSidebar setTitle: _NS("Show Sidebar")];
    [o_mi_toggleSidebar setState: config_GetInt(VLCIntf, "macosx-show-sidebar")];
388
    [o_mu_playlistTableColumns setTitle: _NS("Playlist Table Columns")];
389
    [o_mi_playlistTableColumns setTitle: _NS("Playlist Table Columns")];
390

391 392 393
    [o_mu_controls setTitle: _NS("Playback")];
    [o_mi_play setTitle: _NS("Play")];
    [o_mi_stop setTitle: _NS("Stop")];
394
    [o_mi_record setTitle: _NS("Record")];
395 396 397 398 399 400
    [o_mi_rate setView: o_mi_rate_view];
    [o_mi_rate_lbl setStringValue: _NS("Playback Speed")];
    [o_mi_rate_lbl_gray setStringValue: _NS("Playback Speed")];
    [o_mi_rate_slower_lbl setStringValue: _NS("Slower")];
    [o_mi_rate_normal_lbl setStringValue: _NS("Normal")];
    [o_mi_rate_faster_lbl setStringValue: _NS("Faster")];
401 402 403 404 405 406
    [o_mi_trackSynchronization setTitle: _NS("Track Synchronization")];
    [o_mi_previous setTitle: _NS("Previous")];
    [o_mi_next setTitle: _NS("Next")];
    [o_mi_random setTitle: _NS("Random")];
    [o_mi_repeat setTitle: _NS("Repeat One")];
    [o_mi_loop setTitle: _NS("Repeat All")];
407
    [o_mi_AtoBloop setTitle: _NS("A→B Loop")];
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
    [o_mi_quitAfterPB setTitle: _NS("Quit after Playback")];
    [o_mi_fwd setTitle: _NS("Step Forward")];
    [o_mi_bwd setTitle: _NS("Step Backward")];

    [o_mi_program setTitle: _NS("Program")];
    [o_mu_program setTitle: _NS("Program")];
    [o_mi_title setTitle: _NS("Title")];
    [o_mu_title setTitle: _NS("Title")];
    [o_mi_chapter setTitle: _NS("Chapter")];
    [o_mu_chapter setTitle: _NS("Chapter")];

    [o_mu_audio setTitle: _NS("Audio")];
    [o_mi_vol_up setTitle: _NS("Increase Volume")];
    [o_mi_vol_down setTitle: _NS("Decrease Volume")];
    [o_mi_mute setTitle: _NS("Mute")];
    [o_mi_audiotrack setTitle: _NS("Audio Track")];
    [o_mu_audiotrack setTitle: _NS("Audio Track")];
425 426
    [o_mi_channels setTitle: _NS("Stereo audio mode")];
    [o_mu_channels setTitle: _NS("Stereo audio mode")];
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441
    [o_mi_device setTitle: _NS("Audio Device")];
    [o_mu_device setTitle: _NS("Audio Device")];
    [o_mi_visual setTitle: _NS("Visualizations")];
    [o_mu_visual setTitle: _NS("Visualizations")];

    [o_mu_video setTitle: _NS("Video")];
    [o_mi_half_window setTitle: _NS("Half Size")];
    [o_mi_normal_window setTitle: _NS("Normal Size")];
    [o_mi_double_window setTitle: _NS("Double Size")];
    [o_mi_fittoscreen setTitle: _NS("Fit to Screen")];
    [o_mi_fullscreen setTitle: _NS("Fullscreen")];
    [o_mi_floatontop setTitle: _NS("Float on Top")];
    [o_mi_snapshot setTitle: _NS("Snapshot")];
    [o_mi_videotrack setTitle: _NS("Video Track")];
    [o_mu_videotrack setTitle: _NS("Video Track")];
Christoph Miebach's avatar
Christoph Miebach committed
442 443
    [o_mi_aspect_ratio setTitle: _NS("Aspect ratio")];
    [o_mu_aspect_ratio setTitle: _NS("Aspect ratio")];
444 445 446 447 448 449 450 451 452 453
    [o_mi_crop setTitle: _NS("Crop")];
    [o_mu_crop setTitle: _NS("Crop")];
    [o_mi_screen setTitle: _NS("Fullscreen Video Device")];
    [o_mu_screen setTitle: _NS("Fullscreen Video Device")];
    [o_mi_deinterlace setTitle: _NS("Deinterlace")];
    [o_mu_deinterlace setTitle: _NS("Deinterlace")];
    [o_mi_deinterlace_mode setTitle: _NS("Deinterlace mode")];
    [o_mu_deinterlace_mode setTitle: _NS("Deinterlace mode")];
    [o_mi_ffmpeg_pp setTitle: _NS("Post processing")];
    [o_mu_ffmpeg_pp setTitle: _NS("Post processing")];
454 455

    [o_mu_subtitles setTitle:_NS("Subtitles")];
456
    [o_mi_openSubtitleFile setTitle: _NS("Add Subtitle File...")];
457 458
    [o_mi_subtitle_track setTitle: _NS("Subtitles Track")];
    [o_mu_subtitle_tracks setTitle: _NS("Subtitles Track")];
459 460 461
    [o_mi_subtitle_size setTitle: _NS("Text Size")];
    [o_mi_subtitle_textcolor setTitle: _NS("Text Color")];
    [o_mi_subtitle_outlinethickness setTitle: _NS("Outline Thickness")];
462
    [o_mi_subtitle_bgopacity setView: o_mi_subtitle_bgopacity_view];
463 464 465
    [o_mi_subtitle_bgopacity_lbl setStringValue: _NS("Background Opacity")];
    [o_mi_subtitle_bgopacity_lbl_gray setStringValue: _NS("Background Opacity")];
    [o_mi_subtitle_bgcolor setTitle: _NS("Background Color")];
466 467 468 469 470 471 472 473 474
    [o_mi_teletext setTitle: _NS("Teletext")];
    [o_mi_teletext_transparent setTitle: _NS("Transparent")];
    [o_mi_teletext_index setTitle: _NS("Index")];
    [o_mi_teletext_red setTitle: _NS("Red")];
    [o_mi_teletext_green setTitle: _NS("Green")];
    [o_mi_teletext_yellow setTitle: _NS("Yellow")];
    [o_mi_teletext_blue setTitle: _NS("Blue")];

    [o_mu_window setTitle: _NS("Window")];
475 476
    [o_mi_minimize setTitle: _NS("Minimize")];
    [o_mi_zoom_window setTitle: _NS("Zoom")];
477
    [o_mi_player setTitle: _NS("Player...")];
478
    [o_mi_controller setTitle: _NS("Main Window...")];
479
    [o_mi_audioeffects setTitle: _NS("Audio Effects...")];
480
    [o_mi_videoeffects setTitle: _NS("Video Effects...")];
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516
    [o_mi_bookmarks setTitle: _NS("Bookmarks...")];
    [o_mi_playlist setTitle: _NS("Playlist...")];
    [o_mi_info setTitle: _NS("Media Information...")];
    [o_mi_messages setTitle: _NS("Messages...")];
    [o_mi_errorsAndWarnings setTitle: _NS("Errors and Warnings...")];

    [o_mi_bring_atf setTitle: _NS("Bring All to Front")];

    [o_mu_help setTitle: _NS("Help")];
    [o_mi_help setTitle: _NS("VLC media player Help...")];
    [o_mi_readme setTitle: _NS("ReadMe / FAQ...")];
    [o_mi_license setTitle: _NS("License")];
    [o_mi_documentation setTitle: _NS("Online Documentation...")];
    [o_mi_website setTitle: _NS("VideoLAN Website...")];
    [o_mi_donation setTitle: _NS("Make a donation...")];
    [o_mi_forum setTitle: _NS("Online Forum...")];

    /* dock menu */
    [o_dmi_play setTitle: _NS("Play")];
    [o_dmi_stop setTitle: _NS("Stop")];
    [o_dmi_next setTitle: _NS("Next")];
    [o_dmi_previous setTitle: _NS("Previous")];
    [o_dmi_mute setTitle: _NS("Mute")];

    /* vout menu */
    [o_vmi_play setTitle: _NS("Play")];
    [o_vmi_stop setTitle: _NS("Stop")];
    [o_vmi_prev setTitle: _NS("Previous")];
    [o_vmi_next setTitle: _NS("Next")];
    [o_vmi_volup setTitle: _NS("Volume Up")];
    [o_vmi_voldown setTitle: _NS("Volume Down")];
    [o_vmi_mute setTitle: _NS("Mute")];
    [o_vmi_fullscreen setTitle: _NS("Fullscreen")];
    [o_vmi_snapshot setTitle: _NS("Snapshot")];
}

517 518 519 520 521
- (NSMenu *)setupPlaylistTableColumnsMenu
{
    NSMenu *o_context_menu = [[NSMenu alloc] init];

    NSMenuItem *o_mi_tmp;
522
    NSUInteger count = [o_ptc_menuorder count];
523
    for (NSUInteger i = 0; i < count; i++) {
524
        NSString *o_title = [o_ptc_translation_dict objectForKey:[o_ptc_menuorder objectAtIndex:i]];
525 526 527
        o_mi_tmp = [o_mu_playlistTableColumns addItemWithTitle:o_title
                                                        action:@selector(togglePlaylistColumnTable:)
                                                 keyEquivalent:@""];
528
        /* don't set a valid target for the title column selector, since we want it to be disabled */
529
        if (![[o_ptc_menuorder objectAtIndex:i] isEqualToString: TITLE_COLUMN])
530
            [o_mi_tmp setTarget:self];
531 532 533 534 535
        [o_mi_tmp setTag:i];

        o_mi_tmp = [o_context_menu addItemWithTitle:o_title
                                             action:@selector(togglePlaylistColumnTable:)
                                      keyEquivalent:@""];
536
        /* don't set a valid target for the title column selector, since we want it to be disabled */
537
        if (![[o_ptc_menuorder objectAtIndex:i] isEqualToString: TITLE_COLUMN])
538
            [o_mi_tmp setTarget:self];
539 540
        [o_mi_tmp setTag:i];
    }
541
    if (!o_mu_playlistTableColumnsContextMenu)
542 543 544 545
        o_mu_playlistTableColumnsContextMenu = [o_context_menu retain];
    return [o_context_menu autorelease];
}

546 547 548 549 550
#pragma mark -
#pragma mark Termination

- (void)releaseRepresentedObjects:(NSMenu *)the_menu
{
551
    if (!p_intf) return;
552

553
    NSArray *menuitems_array = [the_menu itemArray];
554
    NSUInteger menuItemCount = [menuitems_array count];
555
    for (NSUInteger i=0; i < menuItemCount; i++) {
556
        NSMenuItem *one_item = [menuitems_array objectAtIndex:i];
557
        if ([one_item hasSubmenu])
558 559 560 561 562 563 564 565 566 567 568
            [self releaseRepresentedObjects: [one_item submenu]];

        [one_item setRepresentedObject:NULL];
    }
}

#pragma mark -
#pragma mark Interface update

- (void)setupMenus
{
569 570 571 572
    playlist_t * p_playlist = pl_Get(p_intf);
    input_thread_t * p_input = playlist_CurrentInput(p_playlist);
    if (p_input != NULL) {
        [o_mi_record setEnabled: var_GetBool(p_input, "can-record")];
573

574 575 576 577 578 579 580 581 582 583 584 585 586 587 588
        [self setupVarMenuItem: o_mi_program target: (vlc_object_t *)p_input
                                 var: "program" selector: @selector(toggleVar:)];

        [self setupVarMenuItem: o_mi_title target: (vlc_object_t *)p_input
                                 var: "title" selector: @selector(toggleVar:)];

        [self setupVarMenuItem: o_mi_chapter target: (vlc_object_t *)p_input
                                 var: "chapter" selector: @selector(toggleVar:)];

        [self setupVarMenuItem: o_mi_audiotrack target: (vlc_object_t *)p_input
                                 var: "audio-es" selector: @selector(toggleVar:)];

        [self setupVarMenuItem: o_mi_videotrack target: (vlc_object_t *)p_input
                                 var: "video-es" selector: @selector(toggleVar:)];

589
        [self setupVarMenuItem: o_mi_subtitle_track target: (vlc_object_t *)p_input
590 591
                                 var: "spu-es" selector: @selector(toggleVar:)];

592
        audio_output_t * p_aout = playlist_GetAout(p_playlist);
593
        if (p_aout != NULL) {
594
            [self setupVarMenuItem: o_mi_channels target: (vlc_object_t *)p_aout
595
                                     var: "stereo-mode" selector: @selector(toggleVar:)];
596 597 598

            [self setupVarMenuItem: o_mi_visual target: (vlc_object_t *)p_aout
                                     var: "visual" selector: @selector(toggleVar:)];
599
            vlc_object_release(p_aout);
600 601
        }

602
        vout_thread_t * p_vout = getVoutForActiveWindow();
603

604
        if (p_vout != NULL) {
605 606 607 608 609 610 611 612 613 614 615 616
            [self setupVarMenuItem: o_mi_aspect_ratio target: (vlc_object_t *)p_vout
                                     var: "aspect-ratio" selector: @selector(toggleVar:)];

            [self setupVarMenuItem: o_mi_crop target: (vlc_object_t *) p_vout
                                     var: "crop" selector: @selector(toggleVar:)];

            [self setupVarMenuItem: o_mi_deinterlace target: (vlc_object_t *)p_vout
                                     var: "deinterlace" selector: @selector(toggleVar:)];

            [self setupVarMenuItem: o_mi_deinterlace_mode target: (vlc_object_t *)p_vout
                                     var: "deinterlace-mode" selector: @selector(toggleVar:)];

617
            vlc_object_release(p_vout);
618 619

            [self refreshVoutDeviceMenu:nil];
620
        }
621
        [o_mi_ffmpeg_pp setEnabled:YES];
622
        vlc_object_release(p_input);
623
    } else {
624
        [o_mi_record setEnabled: NO];
625 626
        [o_mi_ffmpeg_pp setEnabled:NO];
    }
627 628 629 630
}

- (void)refreshVoutDeviceMenu:(NSNotification *)o_notification
{
631
    NSUInteger count = (NSUInteger) [o_mu_screen numberOfItems];
632 633
    NSMenu * o_submenu = o_mu_screen;
    if (count > 0)
634
        [o_submenu removeAllItems];
635

636
    NSArray * o_screens = [NSScreen screens];
637
    NSMenuItem * o_mitem;
638
    count = [o_screens count];
639
    [o_mi_screen setEnabled: YES];
640
    [o_submenu addItemWithTitle: _NS("Default") action:@selector(toggleFullscreenDevice:) keyEquivalent:@""];
641 642 643 644
    o_mitem = [o_submenu itemAtIndex: 0];
    [o_mitem setTag: 0];
    [o_mitem setEnabled: YES];
    [o_mitem setTarget: self];
645
    NSRect s_rect;
646
    for (NSUInteger i = 0; i < count; i++) {
647
        s_rect = [[o_screens objectAtIndex:i] frame];
648
        [o_submenu addItemWithTitle: [NSString stringWithFormat: @"%@ %li (%ix%i)", _NS("Screen"), i+1,
649
                                      (int)s_rect.size.width, (int)s_rect.size.height] action:@selector(toggleFullscreenDevice:) keyEquivalent:@""];
650
        o_mitem = [o_submenu itemAtIndex:i+1];
651
        [o_mitem setTag: (int)[[o_screens objectAtIndex:i] displayID]];
652 653
        [o_mitem setEnabled: YES];
        [o_mitem setTarget: self];
654
    }
655
    [[o_submenu itemWithTag: var_InheritInteger(VLCIntf, "macosx-vdev")] setState: NSOnState];
656 657 658 659 660 661 662 663 664 665
}

- (void)setSubmenusEnabled:(BOOL)b_enabled
{
    [o_mi_program setEnabled: b_enabled];
    [o_mi_title setEnabled: b_enabled];
    [o_mi_chapter setEnabled: b_enabled];
    [o_mi_audiotrack setEnabled: b_enabled];
    [o_mi_visual setEnabled: b_enabled];
    [o_mi_videotrack setEnabled: b_enabled];
666
    [o_mi_subtitle_track setEnabled: b_enabled];
667 668 669 670 671 672
    [o_mi_channels setEnabled: b_enabled];
    [o_mi_deinterlace setEnabled: b_enabled];
    [o_mi_deinterlace_mode setEnabled: b_enabled];
    [o_mi_screen setEnabled: b_enabled];
    [o_mi_aspect_ratio setEnabled: b_enabled];
    [o_mi_crop setEnabled: b_enabled];
673 674 675 676 677
}

- (void)setSubtitleMenuEnabled:(BOOL)b_enabled
{
    [o_mi_openSubtitleFile setEnabled: b_enabled];
678 679 680 681 682 683 684 685
    if (b_enabled) {
        [o_mi_subtitle_bgopacity_lbl_gray setHidden: YES];
        [o_mi_subtitle_bgopacity_lbl setHidden: NO];
    } else {
        [o_mi_subtitle_bgopacity_lbl_gray setHidden: NO];
        [o_mi_subtitle_bgopacity_lbl setHidden: YES];
    }
    [o_mi_subtitle_bgopacity_sld setEnabled: b_enabled];
686 687 688
    [o_mi_teletext setEnabled: b_enabled];
}

689 690
- (void)setRateControlsEnabled:(BOOL)b_enabled
{
691
    NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
692 693 694
    [o_mi_rate_sld setEnabled: b_enabled];
    [o_mi_rate_sld setIntValue: [[VLCCoreInteraction sharedInstance] playbackRate]];
    int i = [[VLCCoreInteraction sharedInstance] playbackRate];
695
    double speed =  pow(2, (double)i / 17);
696
    [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%.2fx", speed]];
697 698 699
    if (b_enabled) {
        [o_mi_rate_lbl setHidden: NO];
        [o_mi_rate_lbl_gray setHidden: YES];
700
    } else {
701 702 703
        [o_mi_rate_lbl setHidden: YES];
        [o_mi_rate_lbl_gray setHidden: NO];
    }
704
    [self setSubtitleMenuEnabled: b_enabled];
705
    [o_pool release];
706 707
}

708 709 710 711 712 713 714 715
#pragma mark -
#pragma mark Extensions

- (void)setupExtensionsMenu
{
    /* Load extensions if needed */
    // TODO: Implement preference for autoloading extensions on mac

716 717
    // if (!var_InheritBool(p_intf, "qt-autoload-extensions")
    //     && ![o_extMgr isLoaded])
718 719 720 721
    // {
    //     return;
    // }

722
    if (![o_extMgr isLoaded] && ![o_extMgr cannotLoad]) {
723 724 725 726 727
        [o_extMgr loadExtensions];
    }

    /* Let the ExtensionsManager itself build the menu */
    [o_extMgr buildMenu:o_mu_extensions];
728
    [o_mi_extensions setEnabled: ([o_mu_extensions numberOfItems] > 0)];
729 730
}

731
#pragma mark -
Felix Paul Kühne's avatar
Felix Paul Kühne committed
732
#pragma mark View
733 734 735 736 737 738 739 740 741

- (IBAction)toggleEffectsButton:(id)sender
{
    BOOL b_value = !config_GetInt(VLCIntf, "macosx-show-effects-button");
    config_PutInt(VLCIntf, "macosx-show-effects-button", b_value);
    [[[[VLCMain sharedInstance] mainWindow] controlsBar] toggleEffectsButton];
    [o_mi_toggleEffectsButton setState: b_value];
}

742 743
- (IBAction)toggleJumpButtons:(id)sender
{
744 745
    BOOL b_value = !config_GetInt(VLCIntf, "macosx-show-playback-buttons");
    config_PutInt(VLCIntf, "macosx-show-playback-buttons", b_value);
746

747
    [[[[VLCMain sharedInstance] mainWindow] controlsBar] toggleJumpButtons];
748 749 750 751
    [[[VLCMain sharedInstance] voutController] updateWindowsUsingBlock:^(VLCVideoWindowCommon *o_window) {
        [[o_window controlsBar] toggleForwardBackwardMode: b_value];
    }];

752 753 754
    [o_mi_toggleJumpButtons setState: b_value];
}

755 756
- (IBAction)togglePlaymodeButtons:(id)sender
{
757 758
    BOOL b_value = !config_GetInt(VLCIntf, "macosx-show-playmode-buttons");
    config_PutInt(VLCIntf, "macosx-show-playmode-buttons", b_value);
759
    [[[[VLCMain sharedInstance] mainWindow] controlsBar] togglePlaymodeButtons];
760 761 762
    [o_mi_togglePlaymodeButtons setState: b_value];
}

763 764 765 766 767 768 769 770 771 772
- (IBAction)toggleSidebar:(id)sender
{
    [[[VLCMain sharedInstance] mainWindow] toggleLeftSubSplitView];
}

- (void)updateSidebarMenuItem
{
    [o_mi_toggleSidebar setState: config_GetInt(VLCIntf, "macosx-show-sidebar")];
}

773 774
- (IBAction)togglePlaylistColumnTable:(id)sender
{
775 776 777 778 779
    NSInteger i_new_state = ![sender state];
    NSInteger i_tag = [sender tag];
    [[o_mu_playlistTableColumns            itemWithTag: i_tag] setState: i_new_state];
    [[o_mu_playlistTableColumnsContextMenu itemWithTag: i_tag] setState: i_new_state];

780
    NSString *o_column = [o_ptc_menuorder objectAtIndex:i_tag];
781
    [[[VLCMain sharedInstance] playlist] setColumn: o_column state: i_new_state translationDict: o_ptc_translation_dict];
782 783
}

784
- (BOOL)setPlaylistColumnTableState:(NSInteger)i_state forColumn:(NSString *)o_column
785
{
786 787 788 789 790
    NSUInteger i_tag = [o_ptc_menuorder indexOfObject: o_column];
    // prevent setting unknown columns
    if(i_tag == NSNotFound)
        return NO;

791 792
    [[o_mu_playlistTableColumns            itemWithTag: i_tag] setState: i_state];
    [[o_mu_playlistTableColumnsContextMenu itemWithTag: i_tag] setState: i_state];
793
    [[[VLCMain sharedInstance] playlist] setColumn: o_column state: i_state translationDict: o_ptc_translation_dict];
794 795

    return YES;
796 797
}

Felix Paul Kühne's avatar
Felix Paul Kühne committed
798 799
#pragma mark -
#pragma mark Playback
800 801 802 803 804 805 806 807 808

- (IBAction)quitAfterPlayback:(id)sender
{
    playlist_t *p_playlist = pl_Get(VLCIntf);
    bool b_value = !var_CreateGetBool(p_playlist, "play-and-exit");
    var_SetBool(p_playlist, "play-and-exit", b_value);
    config_PutInt(p_intf, "play-and-exit", b_value);
}

Felix Paul Kühne's avatar
Felix Paul Kühne committed
809 810 811 812 813 814 815 816 817 818 819 820 821 822
- (IBAction)toggleRecord:(id)sender
{
    [[VLCCoreInteraction sharedInstance] toggleRecord];
}

- (void)updateRecordState:(BOOL)b_value
{
    [o_mi_record setState:b_value];
}

- (IBAction)setPlaybackRate:(id)sender
{
    [[VLCCoreInteraction sharedInstance] setPlaybackRate: [o_mi_rate_sld intValue]];
    int i = [[VLCCoreInteraction sharedInstance] playbackRate];
823
    double speed =  pow(2, (double)i / 17);
Felix Paul Kühne's avatar
Felix Paul Kühne committed
824 825 826 827 828 829
    [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%.2fx", speed]];
}

- (void)updatePlaybackRate
{
    int i = [[VLCCoreInteraction sharedInstance] playbackRate];
830
    double speed =  pow(2, (double)i / 17);
Felix Paul Kühne's avatar
Felix Paul Kühne committed
831 832 833 834
    [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%.2fx", speed]];
    [o_mi_rate_sld setIntValue: i];
}

835 836 837 838 839
- (IBAction)toggleAtoBloop:(id)sender
{
    [[VLCCoreInteraction sharedInstance] setAtoB];
}

840 841 842 843 844 845 846 847 848 849 850 851 852 853
#pragma mark -
#pragma mark audio menu
- (void)refreshAudioDeviceList
{
    char **ids, **names;
    char *currentDevice;

    [o_mu_device removeAllItems];

    audio_output_t * p_aout = getAout();
    if (!p_aout)
        return;

    int n = aout_DevicesList(p_aout, &ids, &names);
854 855
    if (n == -1) {
        vlc_object_release(p_aout);
856
        return;
857
    }
858 859 860 861 862

    currentDevice = aout_DeviceGet(p_aout);
    NSMenuItem * o_mi_tmp;

    for (NSUInteger x = 0; x < n; x++) {
863
        o_mi_tmp = [o_mu_device addItemWithTitle:toNSStr(names[x]) action:@selector(toggleAudioDevice:) keyEquivalent:@""];
864 865 866 867 868
        [o_mi_tmp setTarget:self];
        [o_mi_tmp setTag:[[NSString stringWithFormat:@"%s", ids[x]] intValue]];
    }
    vlc_object_release(p_aout);

869 870
    [[o_mu_device itemWithTag:[[NSString stringWithFormat:@"%s", currentDevice] intValue]] setState:NSOnState];

871 872
    free(currentDevice);

873 874 875 876 877 878 879 880 881 882 883 884 885 886
    for (NSUInteger x = 0; x < n; x++) {
        free(ids[x]);
        free(names[x]);
    }
    free(ids);
    free(names);

    [o_mu_device setAutoenablesItems:YES];
    [o_mi_device setEnabled:YES];
}

- (IBAction)toggleAudioDevice:(id)sender
{
    audio_output_t * p_aout = getAout();
887 888
    if (!p_aout)
        return;
889 890 891 892

    int returnValue = 0;

    if ([sender tag] > 0)
893
        returnValue = aout_DeviceSet(p_aout, [[NSString stringWithFormat:@"%li", [sender tag]] UTF8String]);
894
    else
895
        returnValue = aout_DeviceSet(p_aout, NULL);
896 897 898 899

    if (returnValue != 0)
        msg_Warn(VLCIntf, "failed to set audio device %li", [sender tag]);

900
    vlc_object_release(p_aout);
901 902 903
    [self refreshAudioDeviceList];
}

904
#pragma mark -
905
#pragma mark video menu
906

907 908 909 910 911 912 913
- (IBAction)toggleFullscreen:(id)sender
{
    [[VLCCoreInteraction sharedInstance] toggleFullscreen];
}

- (IBAction)resizeVideoWindow:(id)sender
{
914 915
    input_thread_t *p_input = pl_CurrentInput(VLCIntf);
    if (p_input) {
916
        vout_thread_t *p_vout = getVoutForActiveWindow();
917
        if (p_vout) {
918
            if (sender == o_mi_half_window)
919
                var_SetFloat(p_vout, "zoom", 0.5);
920
            else if (sender == o_mi_normal_window)
921
                var_SetFloat(p_vout, "zoom", 1.0);
922
            else if (sender == o_mi_double_window)
923
                var_SetFloat(p_vout, "zoom", 2.0);
924 925
            else
            {
926
                [[NSApp keyWindow] performZoom:sender];
927
            }
928
            vlc_object_release(p_vout);
929
        }
930
        vlc_object_release(p_input);
931 932 933 934 935
    }
}

- (IBAction)floatOnTop:(id)sender
{
936 937
    input_thread_t *p_input = pl_CurrentInput(VLCIntf);
    if (p_input) {
938
        vout_thread_t *p_vout = getVoutForActiveWindow();
939
        if (p_vout) {
940 941 942
            BOOL b_fs = var_ToggleBool(p_vout, "video-on-top");
            var_SetBool(pl_Get(p_intf), "video-on-top", b_fs);

943
            vlc_object_release(p_vout);
944
        }
945
        vlc_object_release(p_input);
946 947 948 949 950
    }
}

- (IBAction)createVideoSnapshot:(id)sender
{
951 952
    input_thread_t *p_input = pl_CurrentInput(VLCIntf);
    if (p_input) {
953
        vout_thread_t *p_vout = getVoutForActiveWindow();
954 955 956
        if (p_vout) {
            var_TriggerCallback(p_vout, "video-snapshot");
            vlc_object_release(p_vout);
957
        }
958
        vlc_object_release(p_input);
959 960 961
    }
}

962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053
- (void)_disablePostProcessing
{
    char *psz_name = "postprocess";
    char *psz_string, *psz_parser;
    psz_string = config_GetPsz(p_intf, "video-filter");

    if (!psz_string)
        return;

    psz_parser = strstr(psz_string, psz_name