⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simple_prefs.m

📁 VLC Player Source Code
💻 M
📖 第 1 页 / 共 4 页
字号:
        else if( p_item->ppsz_list[i] )            mi = [[NSMenuItem alloc] initWithTitle: [NSString stringWithUTF8String: p_item->ppsz_list[i]] action:NULL keyEquivalent: @""];        else NSLog( @"item %d of pref %s failed to be created", i, name);        [mi setRepresentedObject:[NSString stringWithUTF8String: p_item->ppsz_list[i]]];        [[object menu] addItem: [mi autorelease]];        if( p_item->value.psz && !strcmp( p_item->value.psz, p_item->ppsz_list[i] ) )            [object selectItem:[object lastItem]];    }    [object setToolTip: _NS( p_item->psz_longtext )];}- (void)setupButton: (NSPopUpButton *)object forIntList: (const char *)name{    module_config_t *p_item;    [object removeAllItems];    p_item = config_FindConfig( VLC_OBJECT(p_intf), name );    /* serious problem, if no item found */    assert( p_item );    for( int i = 0; i < p_item->i_list; i++ )    {        NSMenuItem *mi;        if( p_item->ppsz_list_text != NULL)            mi = [[NSMenuItem alloc] initWithTitle: _NS( p_item->ppsz_list_text[i] ) action:NULL keyEquivalent: @""];        else if( p_item->pi_list[i] )            mi = [[NSMenuItem alloc] initWithTitle: [NSString stringWithFormat: @"%d", p_item->pi_list[i]] action:NULL keyEquivalent: @""];        else NSLog( @"item %d of pref %s failed to be created", i, name);        [mi setRepresentedObject:[NSNumber numberWithInt: p_item->pi_list[i]]];        [[object menu] addItem: [mi autorelease]];        if( p_item->value.i == p_item->pi_list[i] )            [object selectItem:[object lastItem]];    }    [object setToolTip: _NS( p_item->psz_longtext )];}- (void)setupButton: (NSPopUpButton *)object forModuleList: (const char *)name{    module_config_t *p_item;    vlc_list_t *p_list;    module_t *p_parser;    int y = 0;        [object removeAllItems];        p_item = config_FindConfig( VLC_OBJECT(p_intf), name );    p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );    if( !p_item ||!p_list )    {        if( p_list ) vlc_list_release(p_list);        NSLog( @"serious problem, item or list not found" );        return;    }    [object addItemWithTitle: _NS("Default")];    for( int i_index = 0; i_index < p_list->i_count; i_index++ )    {        p_parser = (module_t *)p_list->p_values[i_index].p_object;        if( p_parser && module_IsCapable( p_parser, p_item->psz_type ) )        {            [object addItemWithTitle: [NSString stringWithUTF8String: module_GetLongName( p_parser ) ?: ""]];            if( p_item->value.psz && !strcmp( p_item->value.psz, module_GetObjName( p_parser ) ) )                [object selectItem: [object lastItem]];        }    }    vlc_list_release( p_list );    [object setToolTip: _NS(p_item->psz_longtext)];}- (void)resetControls{    module_config_t *p_item;    int i, y = 0;    char *psz_tmp;    [[o_sprefs_basicFull_matrix cellAtRow:0 column:0] setState: NSOnState];    [[o_sprefs_basicFull_matrix cellAtRow:0 column:1] setState: NSOffState];        /**********************     * interface settings *     **********************/    [self setupButton: o_intf_lang_pop forStringList: "language"];    [self setupButton: o_intf_art_pop forIntList: "album-art"];    [o_intf_fspanel_ckb setState: config_GetInt( p_intf, "macosx-fspanel" )];    [o_intf_embedded_ckb setState: config_GetInt( p_intf, "embedded-video" )];    /******************     * audio settings *     ******************/    [o_audio_enable_ckb setState: config_GetInt( p_intf, "audio" )];    [o_audio_vol_fld setIntValue: config_GetInt( p_intf, "volume" )];    [o_audio_vol_sld setIntValue: config_GetInt( p_intf, "volume" )];    [o_audio_spdif_ckb setState: config_GetInt( p_intf, "spdif" )];    [self setupButton: o_audio_dolby_pop forIntList: "force-dolby-surround"];    [o_audio_lang_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "audio-language" ) ?: ""]];    [o_audio_headphone_ckb setState: config_GetInt( p_intf, "headphone-dolby" )];        psz_tmp = config_GetPsz( p_intf, "audio-filter" );    if( psz_tmp )        [o_audio_norm_ckb setState: (int)strstr( psz_tmp, "normvol" )];    [o_audio_norm_fld setFloatValue: config_GetFloat( p_intf, "norm-max-level" )];    [self setupButton: o_audio_visual_pop forModuleList: "audio-visual"];    /* Last.FM is optional */    if( module_Exists( p_intf, "audioscrobbler" ) )    {        [o_audio_lastuser_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "lastfm-username" ) ?: ""]];        [o_audio_lastpwd_sfld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "lastfm-password" ) ?: ""]];        if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )        {            [o_audio_last_ckb setState: NSOnState];            [o_audio_lastuser_fld setEnabled: YES];            [o_audio_lastpwd_sfld setEnabled: YES];        }        else        {            [o_audio_last_ckb setState: NSOffState];            [o_audio_lastuser_fld setEnabled: NO];            [o_audio_lastpwd_sfld setEnabled: NO];        }    }    else        [o_audio_last_ckb setEnabled: NO];    /******************     * video settings *     ******************/    [o_video_enable_ckb setState: config_GetInt( p_intf, "video" )];    [o_video_fullscreen_ckb setState: config_GetInt( p_intf, "fullscreen" )];    [o_video_onTop_ckb setState: config_GetInt( p_intf, "video-on-top" )];    [o_video_skipFrames_ckb setState: config_GetInt( p_intf, "skip-frames" )];    [o_video_black_ckb setState: config_GetInt( p_intf, "macosx-black" )];    [self setupButton: o_video_output_pop forModuleList: "vout"];    [o_video_device_pop removeAllItems];    i = 0;    y = [[NSScreen screens] count];    [o_video_device_pop addItemWithTitle: _NS("Default")];    [[o_video_device_pop lastItem] setTag: 0];    while( i < y )    {        NSRect s_rect = [[[NSScreen screens] objectAtIndex: i] frame];        [o_video_device_pop addItemWithTitle:          [NSString stringWithFormat: @"%@ %i (%ix%i)", _NS("Screen"), i+1,                   (int)s_rect.size.width, (int)s_rect.size.height]];        [[o_video_device_pop lastItem] setTag: (int)[[[NSScreen screens] objectAtIndex: i] displayID]];        i++;    }    [o_video_device_pop selectItemAtIndex: 0];    [o_video_device_pop selectItemWithTag: config_GetInt( p_intf, "macosx-vdev" )];    [o_video_snap_folder_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "snapshot-path" ) ?: ""]];    [o_video_snap_prefix_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "snapshot-prefix" ) ?: ""]];    [o_video_snap_seqnum_ckb setState: config_GetInt( p_intf, "snapshot-sequential" )];    [self setupButton: o_video_snap_format_pop forStringList: "snapshot-format"];    /***************************     * input & codecs settings *     ***************************/    [o_input_serverport_fld setIntValue: config_GetInt( p_intf, "server-port" )];    if( config_GetPsz( p_intf, "http-proxy" ) != NULL )        [o_input_httpproxy_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "http-proxy" ) ?: ""]];    if( config_GetPsz( p_intf, "http-proxy" ) != NULL )        [o_input_httpproxypwd_sfld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "http-proxy-pwd" ) ?: ""]];    [o_input_postproc_fld setIntValue: config_GetInt( p_intf, "ffmpeg-pp-q" )];    [self setupButton: o_input_avi_pop forIntList: "avi-index"];    [o_input_rtsp_ckb setState: config_GetInt( p_intf, "rtsp-tcp" )];    psz_tmp = config_GetPsz( p_intf, "access-filter" );    if( psz_tmp )    {        [o_input_record_ckb setState: (int)strstr( psz_tmp, "record" )];        [o_input_dump_ckb setState: (int)strstr( psz_tmp, "dump" )];        [o_input_bandwidth_ckb setState: (int)strstr( psz_tmp, "bandwidth" )];        [o_input_timeshift_ckb setState: (int)strstr( psz_tmp, "timeshift" )];    }    [o_input_cachelevel_pop removeAllItems];    [o_input_cachelevel_pop addItemsWithTitles:         [NSArray arrayWithObjects: _NS("Custom"), _NS("Lowest latency"), _NS("Low latency"), _NS("Normal"),            _NS("High latency"), _NS("Higher latency"), nil]];    [[o_input_cachelevel_pop itemAtIndex: 0] setTag: 0];    [[o_input_cachelevel_pop itemAtIndex: 1] setTag: 100];    [[o_input_cachelevel_pop itemAtIndex: 2] setTag: 200];    [[o_input_cachelevel_pop itemAtIndex: 3] setTag: 300];    [[o_input_cachelevel_pop itemAtIndex: 4] setTag: 400];    [[o_input_cachelevel_pop itemAtIndex: 5] setTag: 500];    #define TestCaC( name ) \    b_cache_equal =  b_cache_equal && \        ( i_cache == config_GetInt( p_intf, name ) )#define TestCaCi( name, int ) \        b_cache_equal = b_cache_equal &&  \        ( ( i_cache * int ) == config_GetInt( p_intf, name ) )    /* Select the accurate value of the PopupButton */    bool b_cache_equal = true;    int i_cache = config_GetInt( p_intf, "file-caching");        TestCaC( "udp-caching" );    if( module_Exists (p_intf, "dvdread") )        TestCaC( "dvdread-caching" );    if( module_Exists (p_intf, "dvdnav") )        TestCaC( "dvdnav-caching" );    TestCaC( "tcp-caching" );    TestCaC( "fake-caching" );    TestCaC( "cdda-caching" );    TestCaC( "screen-caching" );    TestCaC( "vcd-caching" );    TestCaCi( "rtsp-caching", 4 );    TestCaCi( "ftp-caching", 2 );    TestCaCi( "http-caching", 4 );    if(module_Exists (p_intf, "access_realrtsp"))        TestCaCi( "realrtsp-caching", 10 );    TestCaCi( "mms-caching", 19 );    if( b_cache_equal )    {        [o_input_cachelevel_pop selectItemWithTag: i_cache];        [o_input_cachelevel_custom_txt setHidden: YES];    }    else    {        [o_input_cachelevel_pop selectItemWithTitle: _NS("Custom")];        [o_input_cachelevel_custom_txt setHidden: NO];    }    /*********************     * subtitle settings *     *********************/    [o_osd_osd_ckb setState: config_GetInt( p_intf, "osd" )];        [self setupButton: o_osd_encoding_pop forStringList: "subsdec-encoding"];        [o_osd_lang_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "sub-language" ) ?: ""]];    if( config_GetPsz( p_intf, "quartztext-font" ) != NULL )        [o_osd_font_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "quartztext-font" ) ?: ""]];    [self setupButton: o_osd_font_color_pop forIntList: "quartztext-color"];    [self setupButton: o_osd_font_size_pop forIntList: "quartztext-rel-fontsize"];    /********************     * hotkeys settings *     ********************/    struct hotkey *p_hotkeys = p_intf->p_libvlc->p_hotkeys;    o_hotkeySettings = [[NSMutableArray alloc] init];    NSMutableArray *o_tempArray_desc = [[NSMutableArray alloc] init];    i = 1;    while( i < 100 )    {        p_item = config_FindConfig( VLC_OBJECT(p_intf), p_hotkeys[i].psz_action );        if( !p_item )            break;        [o_tempArray_desc addObject: _NS( p_item->psz_text )];        [o_hotkeySettings addObject: [NSNumber numberWithInt: p_item->value.i]];        i++;    }    o_hotkeyDescriptions = [[NSArray alloc] initWithArray: o_tempArray_desc copyItems: YES];    [o_tempArray_desc release];    [o_hotkeys_listbox reloadData];}- (void)showSimplePrefs{    /* we want to show the interface settings, if no category was chosen */    if( [[o_sprefs_win toolbar] selectedItemIdentifier] == nil )    {        [[o_sprefs_win toolbar] setSelectedItemIdentifier: VLCIntfSettingToolbarIdentifier];        [self showInterfaceSettings];    }        [self resetControls];    [o_sprefs_win center];    [o_sprefs_win makeKeyAndOrderFront: self];}- (IBAction)buttonAction:(id)sender{    if( sender == o_sprefs_cancel_btn )        [o_sprefs_win orderOut: sender];    else if( sender == o_sprefs_save_btn )    {        [self saveChangedSettings];        [o_sprefs_win orderOut: sender];    }    else if( sender == o_sprefs_reset_btn )        NSBeginInformationalAlertSheet( _NS("Reset Preferences"), _NS("Cancel"),                                        _NS("Continue"), nil, o_sprefs_win, self,                                        @selector(sheetDidEnd: returnCode: contextInfo:), NULL, nil,                                        _NS("Beware this will reset the VLC media player preferences.\n"                                            "Are you sure you want to continue?") );    else if( sender == o_sprefs_basicFull_matrix )    {        [o_sprefs_win orderOut: self];        [[o_sprefs_basicFull_matrix cellAtRow:0 column:0] setState: NSOffState];        [[o_sprefs_basicFull_matrix cellAtRow:0 column:1] setState: NSOnState];        [[[VLCMain sharedInstance] getPreferences] showPrefs];    }    else        msg_Warn( p_intf, "unknown buttonAction sender" );}- (void)sheetDidEnd:(NSWindow *)o_sheet          returnCode:(int)i_return        contextInfo:(void *)o_context{    if( i_return == NSAlertAlternateReturn )    {        config_ResetAll( p_intf );        b_intfSettingChanged = b_videoSettingChanged = b_audioSettingChanged = YES;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -