X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fmacosx%2FMainMenu.m;h=2fda43e98586e745e27d4e2f68ea1ef82e911ab6;hb=028d21434fc906d94caa4a2b3eb0e1a4a40cdabc;hp=657a7e3c5a467daf1b1e809c44ece59cd7a4f57a;hpb=b9e1088003e3e5c1fb6202affd63b3b6b3d914ed;p=vlc diff --git a/modules/gui/macosx/MainMenu.m b/modules/gui/macosx/MainMenu.m index 657a7e3c5a..2fda43e985 100644 --- a/modules/gui/macosx/MainMenu.m +++ b/modules/gui/macosx/MainMenu.m @@ -1,7 +1,7 @@ /***************************************************************************** * MainMenu.m: MacOS X interface module ***************************************************************************** - * Copyright (C) 2011 Felix Paul Kühne + * Copyright (C) 2011-2014 Felix Paul Kühne * $Id$ * * Authors: Felix Paul Kühne @@ -22,10 +22,12 @@ *****************************************************************************/ #import "MainMenu.h" +#import "intf.h" + #import #import +#import -#import "intf.h" #import "open.h" #import "wizard.h" #import "about.h" @@ -36,10 +38,16 @@ #import "simple_prefs.h" #import "coredialogs.h" #import "controls.h" +#import "playlist.h" #import "playlistinfo.h" #import "VideoView.h" #import "CoreInteraction.h" #import "MainWindow.h" +#import "ControlsBar.h" +#import "ExtensionsManager.h" +#import "ConvertAndSave.h" +#import "DebugMessageVisualizer.h" +#import "AddonManager.h" @implementation VLCMainMenu static VLCMainMenu *_o_sharedInstance = nil; @@ -49,19 +57,34 @@ static VLCMainMenu *_o_sharedInstance = nil; return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init]; } -#pragma mark - -#pragma mark Initialization +#pragma mark - Initialization - (id)init { - if( _o_sharedInstance) - { + if (_o_sharedInstance) { [self dealloc]; return _o_sharedInstance; - } - else - { + } else { _o_sharedInstance = [super init]; + + o_ptc_translation_dict = [[NSDictionary alloc] initWithObjectsAndKeys: + _NS("Track Number"), TRACKNUM_COLUMN, + _NS("Title"), TITLE_COLUMN, + _NS("Author"), ARTIST_COLUMN, + _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, + _NS("File Size"), FILESIZE_COLUMN, + nil]; + // this array also assigns tags (index) to type of menu item + o_ptc_menuorder = [[NSArray alloc] initWithObjects: TRACKNUM_COLUMN, TITLE_COLUMN, + ARTIST_COLUMN, DURATION_COLUMN, GENRE_COLUMN, ALBUM_COLUMN, + DESCRIPTION_COLUMN, DATE_COLUMN, LANGUAGE_COLUMN, URI_COLUMN, + FILESIZE_COLUMN,nil]; } return _o_sharedInstance; @@ -70,7 +93,7 @@ static VLCMainMenu *_o_sharedInstance = nil; - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver: self]; - + if (b_nib_about_loaded) [o_about release]; @@ -83,15 +106,37 @@ static VLCMainMenu *_o_sharedInstance = nil; if (b_nib_tracksynchro_loaded) [o_trackSynchronization release]; + if (b_nib_convertandsave_loaded) + [o_convertandsave release]; + + [o_extMgr release]; + + if (o_mu_playlistTableColumnsContextMenu) + [o_mu_playlistTableColumnsContextMenu release]; + + [self releaseRepresentedObjects:[NSApp mainMenu]]; + + [o_ptc_translation_dict release]; + [o_ptc_menuorder release]; + [super dealloc]; } - (void)awakeFromNib { - [[NSNotificationCenter defaultCenter] addObserver: self + [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(applicationWillFinishLaunching:) name: NSApplicationWillFinishLaunchingNotification object: nil]; + + /* check whether the user runs OSX with a RTL language */ + NSArray* languages = [NSLocale preferredLanguages]; + NSString* preferredLanguage = [languages objectAtIndex:0]; + + if ([NSLocale characterDirectionForLanguage:preferredLanguage] == NSLocaleLanguageDirectionRightToLeft) { + msg_Dbg(VLCIntf, "adapting interface since '%s' is a RTL language", [preferredLanguage UTF8String]); + [o_mi_rate_fld setAlignment: NSLeftTextAlignment]; + } } - (void)applicationWillFinishLaunching:(NSNotification *)o_notification @@ -101,110 +146,111 @@ static VLCMainMenu *_o_sharedInstance = nil; NSString* o_key; playlist_t *p_playlist; vlc_value_t val; - id o_vlcmain = [VLCMain sharedInstance]; + id o_vlcstringutility = [VLCStringUtility sharedInstance]; char * key; /* Check if we already did this once. Opening the other nibs calls it too, because VLCMain is the owner */ - if( b_mainMenu_setup ) return; + if (b_mainMenu_setup) + return; + + /* Get ExtensionsManager */ + o_extMgr = [ExtensionsManager getInstance:p_intf]; + [o_extMgr retain]; [self initStrings]; - key = config_GetPsz( p_intf, "key-quit" ); + key = config_GetPsz(p_intf, "key-quit"); o_key = [NSString stringWithFormat:@"%s", key]; - [o_mi_quit setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]]; - [o_mi_quit setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]]; - FREENULL( key ); + [o_mi_quit setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]]; + [o_mi_quit setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]]; + FREENULL(key); - key = config_GetPsz( p_intf, "key-play-pause" ); - o_key = [NSString stringWithFormat:@"%s", key]; - [o_mi_play setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]]; - [o_mi_play setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]]; - FREENULL( key ); + // do not assign play/pause key - key = config_GetPsz( p_intf, "key-stop" ); + key = config_GetPsz(p_intf, "key-stop"); o_key = [NSString stringWithFormat:@"%s", key]; - [o_mi_stop setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]]; - [o_mi_stop setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]]; - FREENULL( key ); + [o_mi_stop setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]]; + [o_mi_stop setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]]; + FREENULL(key); - key = config_GetPsz( p_intf, "key-prev" ); + key = config_GetPsz(p_intf, "key-prev"); o_key = [NSString stringWithFormat:@"%s", key]; - [o_mi_previous setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]]; - [o_mi_previous setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]]; - FREENULL( key ); + [o_mi_previous setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]]; + [o_mi_previous setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]]; + FREENULL(key); - key = config_GetPsz( p_intf, "key-next" ); + key = config_GetPsz(p_intf, "key-next"); o_key = [NSString stringWithFormat:@"%s", key]; - [o_mi_next setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]]; - [o_mi_next setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]]; - FREENULL( key ); + [o_mi_next setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]]; + [o_mi_next setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]]; + FREENULL(key); - key = config_GetPsz( p_intf, "key-jump+short" ); + key = config_GetPsz(p_intf, "key-jump+short"); o_key = [NSString stringWithFormat:@"%s", key]; - [o_mi_fwd setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]]; - [o_mi_fwd setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]]; - FREENULL( key ); + [o_mi_fwd setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]]; + [o_mi_fwd setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]]; + FREENULL(key); - key = config_GetPsz( p_intf, "key-jump-short" ); + key = config_GetPsz(p_intf, "key-jump-short"); o_key = [NSString stringWithFormat:@"%s", key]; - [o_mi_bwd setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]]; - [o_mi_bwd setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]]; - FREENULL( key ); + [o_mi_bwd setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]]; + [o_mi_bwd setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]]; + FREENULL(key); - key = config_GetPsz( p_intf, "key-vol-up" ); + key = config_GetPsz(p_intf, "key-vol-up"); o_key = [NSString stringWithFormat:@"%s", key]; - [o_mi_vol_up setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]]; - [o_mi_vol_up setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]]; - FREENULL( key ); + [o_mi_vol_up setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]]; + [o_mi_vol_up setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]]; + FREENULL(key); - key = config_GetPsz( p_intf, "key-vol-down" ); + key = config_GetPsz(p_intf, "key-vol-down"); o_key = [NSString stringWithFormat:@"%s", key]; - [o_mi_vol_down setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]]; - [o_mi_vol_down setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]]; - FREENULL( key ); + [o_mi_vol_down setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]]; + [o_mi_vol_down setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]]; + FREENULL(key); - key = config_GetPsz( p_intf, "key-vol-mute" ); + key = config_GetPsz(p_intf, "key-vol-mute"); o_key = [NSString stringWithFormat:@"%s", key]; - [o_mi_mute setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]]; - [o_mi_mute setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]]; - FREENULL( key ); + [o_mi_mute setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]]; + [o_mi_mute setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]]; + FREENULL(key); - key = config_GetPsz( p_intf, "key-toggle-fullscreen" ); + key = config_GetPsz(p_intf, "key-toggle-fullscreen"); o_key = [NSString stringWithFormat:@"%s", key]; - [o_mi_fullscreen setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]]; - [o_mi_fullscreen setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]]; - FREENULL( key ); + [o_mi_fullscreen setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]]; + [o_mi_fullscreen setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]]; + FREENULL(key); - key = config_GetPsz( p_intf, "key-snapshot" ); + key = config_GetPsz(p_intf, "key-snapshot"); o_key = [NSString stringWithFormat:@"%s", key]; - [o_mi_snapshot setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]]; - [o_mi_snapshot setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]]; - FREENULL( key ); + [o_mi_snapshot setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]]; + [o_mi_snapshot setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]]; + FREENULL(key); - key = config_GetPsz( p_intf, "key-random" ); + key = config_GetPsz(p_intf, "key-random"); o_key = [NSString stringWithFormat:@"%s", key]; - [o_mi_random setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]]; - [o_mi_random setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]]; - FREENULL( key ); + [o_mi_random setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]]; + [o_mi_random setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]]; + FREENULL(key); - key = config_GetPsz( p_intf, "key-zoom-half" ); + key = config_GetPsz(p_intf, "key-zoom-half"); o_key = [NSString stringWithFormat:@"%s", key]; - [o_mi_half_window setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]]; - [o_mi_half_window setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]]; - FREENULL( key ); + [o_mi_half_window setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]]; + [o_mi_half_window setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]]; + FREENULL(key); - key = config_GetPsz( p_intf, "key-zoom-original" ); + key = config_GetPsz(p_intf, "key-zoom-original"); o_key = [NSString stringWithFormat:@"%s", key]; - [o_mi_normal_window setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]]; - [o_mi_normal_window setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]]; - FREENULL( key ); + [o_mi_normal_window setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]]; + [o_mi_normal_window setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]]; + FREENULL(key); - key = config_GetPsz( p_intf, "key-zoom-double" ); + key = config_GetPsz(p_intf, "key-zoom-double"); o_key = [NSString stringWithFormat:@"%s", key]; - [o_mi_double_window setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]]; - [o_mi_double_window setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]]; - FREENULL( key ); + [o_mi_double_window setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]]; + [o_mi_double_window setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]]; + FREENULL(key); [self setSubmenusEnabled: FALSE]; @@ -218,6 +264,87 @@ static VLCMainMenu *_o_sharedInstance = nil; [self setupVarMenuItem: o_mi_add_intf target: (vlc_object_t *)p_intf var: "intf-add" selector: @selector(toggleVar:)]; + + /* setup extensions menu */ + // FIXME: Implement preference for autoloading extensions on mac + if (![o_extMgr isLoaded] && ![o_extMgr cannotLoad]) + [o_extMgr loadExtensions]; + + /* Let the ExtensionsManager itself build the menu */ + [o_extMgr buildMenu:o_mu_extensions]; + [o_mi_extensions setEnabled: ([o_mu_extensions numberOfItems] > 0)]; + + /* setup post-proc menu */ + 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 = 1; 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]; + [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, "postproc")) + [[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]; + + [self refreshAudioDeviceList]; + + /* 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: @""]; + else { + msg_Err(p_intf, "item %d of pref %s failed to be created", i, psz_name); + continue; + } + + [mi setTarget:self]; + [mi setAction:selector]; + [mi setTag:p_item->list.i[i]]; + [mi setRepresentedObject:[NSString stringWithUTF8String:psz_name]]; + [menu addItem: [mi autorelease]]; + if (p_item->value.i == p_item->list.i[i]) + [mi setState:NSOnState]; + } } - (void)initStrings @@ -227,6 +354,9 @@ static VLCMainMenu *_o_sharedInstance = nil; stringByAppendingString: @"..."]]; [o_mi_checkForUpdate setTitle: _NS("Check for Update...")]; [o_mi_prefs setTitle: _NS("Preferences...")]; + [o_mi_extensions setTitle: _NS("Extensions")]; + [o_mu_extensions setTitle: _NS("Extensions")]; + [o_mi_addonManager setTitle: _NS("Addons Manager")]; [o_mi_add_intf setTitle: _NS("Add Interface")]; [o_mu_add_intf setTitle: _NS("Add Interface")]; [o_mi_services setTitle: _NS("Services")]; @@ -242,7 +372,10 @@ static VLCMainMenu *_o_sharedInstance = nil; [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")]; + [o_mi_close_window setTitle: _NS("Close Window")]; [o_mi_open_wizard setTitle: _NS("Streaming/Exporting Wizard...")]; + [o_mi_convertandsave setTitle: _NS("Convert / Stream...")]; + [o_mi_save_playlist setTitle: _NS("Save Playlist...")]; [o_mu_edit setTitle: _NS("Edit")]; [o_mi_cut setTitle: _NS("Cut")]; @@ -251,6 +384,18 @@ static VLCMainMenu *_o_sharedInstance = nil; [o_mi_clear setTitle: _NS("Clear")]; [o_mi_select_all setTitle: _NS("Select All")]; + [o_mu_view setTitle: _NS("View")]; + [o_mi_toggleJumpButtons setTitle: _NS("Show Previous & Next Buttons")]; + [o_mi_toggleJumpButtons setState: config_GetInt(VLCIntf, "macosx-show-playback-buttons")]; + [o_mi_togglePlaymodeButtons setTitle: _NS("Show Shuffle & Repeat Buttons")]; + [o_mi_togglePlaymodeButtons setState: config_GetInt(VLCIntf, "macosx-show-playmode-buttons")]; + [o_mi_toggleEffectsButton setTitle: _NS("Show Audio Effects Button")]; + [o_mi_toggleEffectsButton setState: config_GetInt(VLCIntf, "macosx-show-effects-button")]; + [o_mi_toggleSidebar setTitle: _NS("Show Sidebar")]; + [o_mi_toggleSidebar setState: config_GetInt(VLCIntf, "macosx-show-sidebar")]; + [o_mu_playlistTableColumns setTitle: _NS("Playlist Table Columns")]; + [o_mi_playlistTableColumns setTitle: _NS("Playlist Table Columns")]; + [o_mu_controls setTitle: _NS("Playback")]; [o_mi_play setTitle: _NS("Play")]; [o_mi_stop setTitle: _NS("Stop")]; @@ -267,6 +412,7 @@ static VLCMainMenu *_o_sharedInstance = nil; [o_mi_random setTitle: _NS("Random")]; [o_mi_repeat setTitle: _NS("Repeat One")]; [o_mi_loop setTitle: _NS("Repeat All")]; + [o_mi_AtoBloop setTitle: _NS("A→B Loop")]; [o_mi_quitAfterPB setTitle: _NS("Quit after Playback")]; [o_mi_fwd setTitle: _NS("Step Forward")]; [o_mi_bwd setTitle: _NS("Step Backward")]; @@ -284,8 +430,8 @@ static VLCMainMenu *_o_sharedInstance = nil; [o_mi_mute setTitle: _NS("Mute")]; [o_mi_audiotrack setTitle: _NS("Audio Track")]; [o_mu_audiotrack setTitle: _NS("Audio Track")]; - [o_mi_channels setTitle: _NS("Audio Channels")]; - [o_mu_channels setTitle: _NS("Audio Channels")]; + [o_mi_channels setTitle: _NS("Stereo audio mode")]; + [o_mu_channels setTitle: _NS("Stereo audio mode")]; [o_mi_device setTitle: _NS("Audio Device")]; [o_mu_device setTitle: _NS("Audio Device")]; [o_mi_visual setTitle: _NS("Visualizations")]; @@ -301,21 +447,30 @@ static VLCMainMenu *_o_sharedInstance = nil; [o_mi_snapshot setTitle: _NS("Snapshot")]; [o_mi_videotrack setTitle: _NS("Video Track")]; [o_mu_videotrack setTitle: _NS("Video Track")]; - [o_mi_aspect_ratio setTitle: _NS("Aspect-ratio")]; - [o_mu_aspect_ratio setTitle: _NS("Aspect-ratio")]; + [o_mi_aspect_ratio setTitle: _NS("Aspect ratio")]; + [o_mu_aspect_ratio setTitle: _NS("Aspect ratio")]; [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_subtitle setTitle: _NS("Subtitles Track")]; - [o_mu_subtitle setTitle: _NS("Subtitles Track")]; - [o_mi_addSub setTitle: _NS("Open File...")]; [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")]; + + [o_mu_subtitles setTitle:_NS("Subtitles")]; + [o_mi_openSubtitleFile setTitle: _NS("Add Subtitle File...")]; + [o_mi_subtitle_track setTitle: _NS("Subtitles Track")]; + [o_mu_subtitle_tracks setTitle: _NS("Subtitles Track")]; + [o_mi_subtitle_size setTitle: _NS("Text Size")]; + [o_mi_subtitle_textcolor setTitle: _NS("Text Color")]; + [o_mi_subtitle_outlinethickness setTitle: _NS("Outline Thickness")]; + [o_mi_subtitle_bgopacity setView: o_mi_subtitle_bgopacity_view]; + [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")]; [o_mi_teletext setTitle: _NS("Teletext")]; [o_mi_teletext_transparent setTitle: _NS("Transparent")]; [o_mi_teletext_index setTitle: _NS("Index")]; @@ -325,12 +480,12 @@ static VLCMainMenu *_o_sharedInstance = nil; [o_mi_teletext_blue setTitle: _NS("Blue")]; [o_mu_window setTitle: _NS("Window")]; - [o_mi_minimize setTitle: _NS("Minimize Window")]; - [o_mi_close_window setTitle: _NS("Close Window")]; + [o_mi_minimize setTitle: _NS("Minimize")]; + [o_mi_zoom_window setTitle: _NS("Zoom")]; [o_mi_player setTitle: _NS("Player...")]; [o_mi_controller setTitle: _NS("Main Window...")]; [o_mi_audioeffects setTitle: _NS("Audio Effects...")]; - [o_mi_videoeffects setTitle: _NS("Video Filters...")]; + [o_mi_videoeffects setTitle: _NS("Video Effects...")]; [o_mi_bookmarks setTitle: _NS("Bookmarks...")]; [o_mi_playlist setTitle: _NS("Playlist...")]; [o_mi_info setTitle: _NS("Media Information...")]; @@ -367,35 +522,60 @@ static VLCMainMenu *_o_sharedInstance = nil; [o_vmi_snapshot setTitle: _NS("Snapshot")]; } -#pragma mark - -#pragma mark Termination +- (NSMenu *)setupPlaylistTableColumnsMenu +{ + NSMenu *o_context_menu = [[NSMenu alloc] init]; + + NSMenuItem *o_mi_tmp; + NSUInteger count = [o_ptc_menuorder count]; + for (NSUInteger i = 0; i < count; i++) { + NSString *o_title = [o_ptc_translation_dict objectForKey:[o_ptc_menuorder objectAtIndex:i]]; + o_mi_tmp = [o_mu_playlistTableColumns addItemWithTitle:o_title + action:@selector(togglePlaylistColumnTable:) + keyEquivalent:@""]; + /* don't set a valid target for the title column selector, since we want it to be disabled */ + if (![[o_ptc_menuorder objectAtIndex:i] isEqualToString: TITLE_COLUMN]) + [o_mi_tmp setTarget:self]; + [o_mi_tmp setTag:i]; + + o_mi_tmp = [o_context_menu addItemWithTitle:o_title + action:@selector(togglePlaylistColumnTable:) + keyEquivalent:@""]; + /* don't set a valid target for the title column selector, since we want it to be disabled */ + if (![[o_ptc_menuorder objectAtIndex:i] isEqualToString: TITLE_COLUMN]) + [o_mi_tmp setTarget:self]; + [o_mi_tmp setTag:i]; + } + if (!o_mu_playlistTableColumnsContextMenu) + o_mu_playlistTableColumnsContextMenu = [o_context_menu retain]; + return [o_context_menu autorelease]; +} + +#pragma mark - Termination - (void)releaseRepresentedObjects:(NSMenu *)the_menu { - if( !p_intf ) return; - + if (!p_intf) return; + NSArray *menuitems_array = [the_menu itemArray]; NSUInteger menuItemCount = [menuitems_array count]; - for( NSUInteger i=0; i < menuItemCount; i++ ) - { - NSMenuItem *one_item = [menuitems_array objectAtIndex: i]; - if( [one_item hasSubmenu] ) + for (NSUInteger i=0; i < menuItemCount; i++) { + NSMenuItem *one_item = [menuitems_array objectAtIndex:i]; + if ([one_item hasSubmenu]) [self releaseRepresentedObjects: [one_item submenu]]; [one_item setRepresentedObject:NULL]; } } -#pragma mark - -#pragma mark Interface update +#pragma mark - Interface update - (void)setupMenus { - 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" )]; + 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")]; [self setupVarMenuItem: o_mi_program target: (vlc_object_t *)p_input var: "program" selector: @selector(toggleVar:)]; @@ -412,33 +592,22 @@ static VLCMainMenu *_o_sharedInstance = nil; [self setupVarMenuItem: o_mi_videotrack target: (vlc_object_t *)p_input var: "video-es" selector: @selector(toggleVar:)]; - [self setupVarMenuItem: o_mi_subtitle target: (vlc_object_t *)p_input + [self setupVarMenuItem: o_mi_subtitle_track target: (vlc_object_t *)p_input var: "spu-es" selector: @selector(toggleVar:)]; - /* special case for "Open File" inside the subtitles menu item */ - if( [o_mi_videotrack isEnabled] == YES ) - [o_mi_subtitle setEnabled: YES]; - - audio_output_t * p_aout = input_GetAout( p_input ); - if( p_aout != NULL ) - { + audio_output_t * p_aout = playlist_GetAout(p_playlist); + if (p_aout != NULL) { [self setupVarMenuItem: o_mi_channels target: (vlc_object_t *)p_aout - var: "audio-channels" selector: @selector(toggleVar:)]; - - [self setupVarMenuItem: o_mi_device target: (vlc_object_t *)p_aout - var: "audio-device" selector: @selector(toggleVar:)]; + var: "stereo-mode" selector: @selector(toggleVar:)]; [self setupVarMenuItem: o_mi_visual target: (vlc_object_t *)p_aout var: "visual" selector: @selector(toggleVar:)]; - vlc_object_release( (vlc_object_t *)p_aout ); + vlc_object_release(p_aout); } - vout_thread_t * p_vout = input_GetVout( p_input ); - - if( p_vout != NULL ) - { - vlc_object_t * p_dec_obj; + vout_thread_t * p_vout = getVoutForActiveWindow(); + if (p_vout != NULL) { [self setupVarMenuItem: o_mi_aspect_ratio target: (vlc_object_t *)p_vout var: "aspect-ratio" selector: @selector(toggleVar:)]; @@ -451,57 +620,45 @@ static VLCMainMenu *_o_sharedInstance = nil; [self setupVarMenuItem: o_mi_deinterlace_mode target: (vlc_object_t *)p_vout var: "deinterlace-mode" selector: @selector(toggleVar:)]; -#if 1 - [self setupVarMenuItem: o_mi_ffmpeg_pp target: - (vlc_object_t *)p_vout var:"postprocess" selector: - @selector(toggleVar:)]; -#endif - vlc_object_release( (vlc_object_t *)p_vout ); + vlc_object_release(p_vout); [self refreshVoutDeviceMenu:nil]; - [self setSubmenusEnabled: YES]; } - vlc_object_release( p_input ); - } - else - { + [o_mi_ffmpeg_pp setEnabled:YES]; + vlc_object_release(p_input); + } else { [o_mi_record setEnabled: NO]; + [o_mi_ffmpeg_pp setEnabled:NO]; } } - (void)refreshVoutDeviceMenu:(NSNotification *)o_notification { - NSUInteger count = [o_mu_screen numberOfItems]; + NSUInteger count = (NSUInteger) [o_mu_screen numberOfItems]; NSMenu * o_submenu = o_mu_screen; if (count > 0) - { - if (OSX_LEOPARD) - { - NSUInteger count = [o_submenu numberOfItems]; - for( NSUInteger i = 0; i < count; i++ ) - [o_submenu removeItemAtIndex: 0]; - } - else - [o_submenu removeAllItems]; - } + [o_submenu removeAllItems]; NSArray * o_screens = [NSScreen screens]; + NSMenuItem * o_mitem; count = [o_screens count]; + [o_mi_screen setEnabled: YES]; [o_submenu addItemWithTitle: _NS("Default") action:@selector(toggleFullscreenDevice:) keyEquivalent:@""]; - [[o_submenu itemAtIndex: 0] setTag: 0]; - [[o_submenu itemAtIndex: 0] setEnabled: YES]; - [[o_submenu itemAtIndex: 0] setTarget: self]; + o_mitem = [o_submenu itemAtIndex: 0]; + [o_mitem setTag: 0]; + [o_mitem setEnabled: YES]; + [o_mitem setTarget: self]; NSRect s_rect; - for (NSUInteger i = 0; i < count; i++) - { - s_rect = [[o_screens objectAtIndex: i] frame]; - [o_submenu addItemWithTitle: [NSString stringWithFormat: @"%@ %i (%ix%i)", _NS("Screen"), i+1, + for (NSUInteger i = 0; i < count; i++) { + s_rect = [[o_screens objectAtIndex:i] frame]; + [o_submenu addItemWithTitle: [NSString stringWithFormat: @"%@ %li (%ix%i)", _NS("Screen"), i+1, (int)s_rect.size.width, (int)s_rect.size.height] action:@selector(toggleFullscreenDevice:) keyEquivalent:@""]; - [[o_submenu itemAtIndex:i+1] setTag: (int)[[o_screens objectAtIndex: i] displayID]]; - [[o_submenu itemAtIndex:i+1] setEnabled: YES]; - [[o_submenu itemAtIndex:i+1] setTarget: self]; + o_mitem = [o_submenu itemAtIndex:i+1]; + [o_mitem setTag: (int)[[o_screens objectAtIndex:i] displayID]]; + [o_mitem setEnabled: YES]; + [o_mitem setTarget: self]; } - [[o_submenu itemWithTag: config_GetInt( VLCIntf, "macosx-vdev" )] setState: NSOnState]; + [[o_submenu itemWithTag: var_InheritInteger(VLCIntf, "macosx-vdev")] setState: NSOnState]; } - (void)setSubmenusEnabled:(BOOL)b_enabled @@ -512,15 +669,26 @@ static VLCMainMenu *_o_sharedInstance = nil; [o_mi_audiotrack setEnabled: b_enabled]; [o_mi_visual setEnabled: b_enabled]; [o_mi_videotrack setEnabled: b_enabled]; - [o_mi_subtitle setEnabled: b_enabled]; + [o_mi_subtitle_track setEnabled: b_enabled]; [o_mi_channels setEnabled: b_enabled]; [o_mi_deinterlace setEnabled: b_enabled]; [o_mi_deinterlace_mode setEnabled: b_enabled]; - [o_mi_ffmpeg_pp setEnabled: b_enabled]; - [o_mi_device setEnabled: b_enabled]; [o_mi_screen setEnabled: b_enabled]; [o_mi_aspect_ratio setEnabled: b_enabled]; [o_mi_crop setEnabled: b_enabled]; +} + +- (void)setSubtitleMenuEnabled:(BOOL)b_enabled +{ + [o_mi_openSubtitleFile setEnabled: b_enabled]; + 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]; [o_mi_teletext setEnabled: b_enabled]; } @@ -530,23 +698,95 @@ static VLCMainMenu *_o_sharedInstance = nil; [o_mi_rate_sld setEnabled: b_enabled]; [o_mi_rate_sld setIntValue: [[VLCCoreInteraction sharedInstance] playbackRate]]; int i = [[VLCCoreInteraction sharedInstance] playbackRate]; - if (i == 0) - i = 1; - [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%ix", i]]; + double speed = pow(2, (double)i / 17); + [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%.2fx", speed]]; if (b_enabled) { [o_mi_rate_lbl setHidden: NO]; [o_mi_rate_lbl_gray setHidden: YES]; - } - else - { + } else { [o_mi_rate_lbl setHidden: YES]; [o_mi_rate_lbl_gray setHidden: NO]; } + [self setSubtitleMenuEnabled: b_enabled]; [o_pool release]; } -#pragma mark - -#pragma mark Playback +#pragma mark - View + +- (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]; +} + +- (IBAction)toggleJumpButtons:(id)sender +{ + BOOL b_value = !config_GetInt(VLCIntf, "macosx-show-playback-buttons"); + config_PutInt(VLCIntf, "macosx-show-playback-buttons", b_value); + + [[[[VLCMain sharedInstance] mainWindow] controlsBar] toggleJumpButtons]; + [[[VLCMain sharedInstance] voutController] updateWindowsUsingBlock:^(VLCVideoWindowCommon *o_window) { + [[o_window controlsBar] toggleForwardBackwardMode: b_value]; + }]; + + [o_mi_toggleJumpButtons setState: b_value]; +} + +- (IBAction)togglePlaymodeButtons:(id)sender +{ + BOOL b_value = !config_GetInt(VLCIntf, "macosx-show-playmode-buttons"); + config_PutInt(VLCIntf, "macosx-show-playmode-buttons", b_value); + [[[[VLCMain sharedInstance] mainWindow] controlsBar] togglePlaymodeButtons]; + [o_mi_togglePlaymodeButtons setState: b_value]; +} + +- (IBAction)toggleSidebar:(id)sender +{ + [[[VLCMain sharedInstance] mainWindow] toggleLeftSubSplitView]; +} + +- (void)updateSidebarMenuItem +{ + [o_mi_toggleSidebar setState: config_GetInt(VLCIntf, "macosx-show-sidebar")]; +} + +- (IBAction)togglePlaylistColumnTable:(id)sender +{ + 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]; + + NSString *o_column = [o_ptc_menuorder objectAtIndex:i_tag]; + [[[VLCMain sharedInstance] playlist] setColumn: o_column state: i_new_state translationDict: o_ptc_translation_dict]; +} + +- (BOOL)setPlaylistColumnTableState:(NSInteger)i_state forColumn:(NSString *)o_column +{ + NSUInteger i_tag = [o_ptc_menuorder indexOfObject: o_column]; + // prevent setting unknown columns + if(i_tag == NSNotFound) + return NO; + + [[o_mu_playlistTableColumns itemWithTag: i_tag] setState: i_state]; + [[o_mu_playlistTableColumnsContextMenu itemWithTag: i_tag] setState: i_state]; + [[[VLCMain sharedInstance] playlist] setColumn: o_column state: i_state translationDict: o_ptc_translation_dict]; + + return YES; +} + +#pragma mark - Playback + +- (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); +} + - (IBAction)toggleRecord:(id)sender { [[VLCCoreInteraction sharedInstance] toggleRecord]; @@ -561,22 +801,89 @@ static VLCMainMenu *_o_sharedInstance = nil; { [[VLCCoreInteraction sharedInstance] setPlaybackRate: [o_mi_rate_sld intValue]]; int i = [[VLCCoreInteraction sharedInstance] playbackRate]; - if (i == 0) - i = 1; - [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%ix", i]]; + double speed = pow(2, (double)i / 17); + [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%.2fx", speed]]; } - (void)updatePlaybackRate { int i = [[VLCCoreInteraction sharedInstance] playbackRate]; - if (i == 0) - i = 1; - [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%ix", i]]; + double speed = pow(2, (double)i / 17); + [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%.2fx", speed]]; [o_mi_rate_sld setIntValue: i]; } -#pragma mark - -#pragma video menu +- (IBAction)toggleAtoBloop:(id)sender +{ + [[VLCCoreInteraction sharedInstance] setAtoB]; +} + +#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); + if (n == -1) { + vlc_object_release(p_aout); + return; + } + + currentDevice = aout_DeviceGet(p_aout); + NSMenuItem * o_mi_tmp; + + for (NSUInteger x = 0; x < n; x++) { + o_mi_tmp = [o_mu_device addItemWithTitle:toNSStr(names[x]) action:@selector(toggleAudioDevice:) keyEquivalent:@""]; + [o_mi_tmp setTarget:self]; + [o_mi_tmp setTag:[[NSString stringWithFormat:@"%s", ids[x]] intValue]]; + } + vlc_object_release(p_aout); + + [[o_mu_device itemWithTag:[[NSString stringWithFormat:@"%s", currentDevice] intValue]] setState:NSOnState]; + + free(currentDevice); + + 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(); + if (!p_aout) + return; + + int returnValue = 0; + + if ([sender tag] > 0) + returnValue = aout_DeviceSet(p_aout, [[NSString stringWithFormat:@"%li", [sender tag]] UTF8String]); + else + returnValue = aout_DeviceSet(p_aout, NULL); + + if (returnValue != 0) + msg_Warn(VLCIntf, "failed to set audio device %li", [sender tag]); + + vlc_object_release(p_aout); + [self refreshAudioDeviceList]; +} + +#pragma mark - video menu + - (IBAction)toggleFullscreen:(id)sender { [[VLCCoreInteraction sharedInstance] toggleFullscreen]; @@ -584,61 +891,85 @@ static VLCMainMenu *_o_sharedInstance = nil; - (IBAction)resizeVideoWindow:(id)sender { - input_thread_t *p_input = pl_CurrentInput( VLCIntf ); - if (p_input) - { - vout_thread_t *p_vout = getVout(); - if (p_vout) - { + input_thread_t *p_input = pl_CurrentInput(VLCIntf); + if (p_input) { + vout_thread_t *p_vout = getVoutForActiveWindow(); + if (p_vout) { if (sender == o_mi_half_window) - var_SetFloat( p_vout, "zoom", 0.5 ); + var_SetFloat(p_vout, "zoom", 0.5); else if (sender == o_mi_normal_window) - var_SetFloat( p_vout, "zoom", 1.0 ); + var_SetFloat(p_vout, "zoom", 1.0); else if (sender == o_mi_double_window) - var_SetFloat( p_vout, "zoom", 2.0 ); + var_SetFloat(p_vout, "zoom", 2.0); else { - var_ToggleBool( p_vout, "autoscale" ); + [[NSApp keyWindow] performZoom:sender]; } - vlc_object_release( p_vout ); + vlc_object_release(p_vout); } - vlc_object_release( p_input ); + vlc_object_release(p_input); } } - (IBAction)floatOnTop:(id)sender { - input_thread_t *p_input = pl_CurrentInput( VLCIntf ); - if (p_input) - { - vout_thread_t *p_vout = getVout(); - if (p_vout) - { - var_ToggleBool( p_vout, "video-on-top" ); - vlc_object_release( p_vout ); + input_thread_t *p_input = pl_CurrentInput(VLCIntf); + if (p_input) { + vout_thread_t *p_vout = getVoutForActiveWindow(); + if (p_vout) { + BOOL b_fs = var_ToggleBool(p_vout, "video-on-top"); + var_SetBool(pl_Get(p_intf), "video-on-top", b_fs); + + vlc_object_release(p_vout); } - vlc_object_release( p_input ); + vlc_object_release(p_input); } } - (IBAction)createVideoSnapshot:(id)sender { - input_thread_t *p_input = pl_CurrentInput( VLCIntf ); - if (p_input) - { - vout_thread_t *p_vout = getVout(); - if (p_vout) - { - var_TriggerCallback( p_vout, "video-snapshot" ); - vlc_object_release( p_vout ); + input_thread_t *p_input = pl_CurrentInput(VLCIntf); + if (p_input) { + vout_thread_t *p_vout = getVoutForActiveWindow(); + if (p_vout) { + var_TriggerCallback(p_vout, "video-snapshot"); + vlc_object_release(p_vout); } - vlc_object_release( p_input ); + vlc_object_release(p_input); + } +} + +- (void)_disablePostProcessing +{ + [[VLCCoreInteraction sharedInstance] setVideoFilter:"postproc" on:false]; +} + +- (void)_enablePostProcessing +{ + [[VLCCoreInteraction sharedInstance] setVideoFilter:"postproc" on:true]; +} + +- (IBAction)togglePostProcessing:(id)sender +{ + char *psz_name = "postproc"; + NSInteger count = [o_mu_ffmpeg_pp numberOfItems]; + for (NSUInteger x = 0; x < count; x++) + [[o_mu_ffmpeg_pp itemAtIndex:x] setState:NSOffState]; + + if ([sender tag] == -1) { + [self _disablePostProcessing]; + [sender setState:NSOnState]; + } else { + [self _enablePostProcessing]; + [sender setState:NSOnState]; + + [[VLCCoreInteraction sharedInstance] setVideoFilterProperty:"postproc-q" forFilter:"postproc" integer:[sender tag]]; } } - (IBAction)toggleFullscreenDevice:(id)sender { - config_PutInt( VLCIntf, "macosx-vdev", [sender tag] ); + config_PutInt(VLCIntf, "macosx-vdev", [sender tag]); [self refreshVoutDeviceMenu: nil]; } @@ -647,8 +978,100 @@ static VLCMainMenu *_o_sharedInstance = nil; return o_vout_menu; } -#pragma mark - -#pragma mark Panels +#pragma mark - Subtitles Menu + +- (IBAction)addSubtitleFile:(id)sender +{ + NSInteger i_returnValue = 0; + input_thread_t * p_input = pl_CurrentInput(VLCIntf); + if (!p_input) + return; + + input_item_t *p_item = input_GetItem(p_input); + if (!p_item) { + vlc_object_release(p_input); + return; + } + + char *path = input_item_GetURI(p_item); + + if (!path) + path = strdup(""); + + NSOpenPanel * openPanel = [NSOpenPanel openPanel]; + [openPanel setCanChooseFiles: YES]; + [openPanel setCanChooseDirectories: NO]; + [openPanel setAllowsMultipleSelection: YES]; + + [openPanel setAllowedFileTypes: [NSArray arrayWithObjects:@"cdg",@"idx",@"srt",@"sub",@"utf",@"ass",@"ssa",@"aqt",@"jss",@"psb",@"rt",@"smi",@"txt",@"smil",nil]]; + + NSURL *o_url = [NSURL URLWithString:[[NSString stringWithUTF8String:path] stringByExpandingTildeInPath]]; + o_url = [o_url URLByDeletingLastPathComponent]; + [openPanel setDirectoryURL: o_url]; + free(path); + vlc_object_release(p_input); + + i_returnValue = [openPanel runModal]; + + if (i_returnValue == NSOKButton) + [[VLCCoreInteraction sharedInstance] addSubtitlesToCurrentInput:[openPanel URLs]]; +} + +- (IBAction)switchSubtitleOption:(id)sender +{ + int intValue = [sender tag]; + NSString *representedObject = [sender representedObject]; + + config_PutInt(p_intf, [representedObject UTF8String], intValue); + + NSMenu *menu = [sender menu]; + NSUInteger count = (NSUInteger) [menu numberOfItems]; + for (NSUInteger x = 0; x < count; x++) + [[menu itemAtIndex:x] setState:NSOffState]; + [[menu itemWithTag:intValue] setState:NSOnState]; +} + +- (IBAction)switchSubtitleBackgroundOpacity:(id)sender +{ + config_PutInt(p_intf, "freetype-background-opacity", [sender intValue]); +} + +- (IBAction)telxTransparent:(id)sender +{ + vlc_object_t *p_vbi; + p_vbi = (vlc_object_t *) vlc_object_find_name(pl_Get(VLCIntf), "zvbi"); + if (p_vbi) { + var_SetBool(p_vbi, "vbi-opaque", [sender state]); + [sender setState: ![sender state]]; + vlc_object_release(p_vbi); + } +} + +- (IBAction)telxNavLink:(id)sender +{ + vlc_object_t *p_vbi; + int i_page = 0; + + if ([[sender title] isEqualToString: _NS("Index")]) + i_page = 'i' << 16; + else if ([[sender title] isEqualToString: _NS("Red")]) + i_page = 'r' << 16; + else if ([[sender title] isEqualToString: _NS("Green")]) + i_page = 'g' << 16; + else if ([[sender title] isEqualToString: _NS("Yellow")]) + i_page = 'y' << 16; + else if ([[sender title] isEqualToString: _NS("Blue")]) + i_page = 'b' << 16; + if (i_page == 0) return; + + p_vbi = (vlc_object_t *) vlc_object_find_name(pl_Get(VLCIntf), "zvbi"); + if (p_vbi) { + var_SetInteger(p_vbi, "vbi-page", i_page); + vlc_object_release(p_vbi); + } +} + +#pragma mark - Panels - (IBAction)intfOpenFile:(id)sender { @@ -681,12 +1104,28 @@ static VLCMainMenu *_o_sharedInstance = nil; [[[VLCMain sharedInstance] wizard] showWizard]; } +- (IBAction)savePlaylist:(id)sender +{ + [[[VLCMain sharedInstance] playlist] savePlaylist:sender]; +} + +- (IBAction)showConvertAndSave:(id)sender +{ + if (o_convertandsave == nil) + o_convertandsave = [[VLCConvertAndSave alloc] init]; + + if (!b_nib_convertandsave_loaded) + b_nib_convertandsave_loaded = [NSBundle loadNibNamed:@"ConvertAndSave" owner: NSApp]; + + [o_convertandsave toggleWindow]; +} + - (IBAction)showVideoEffects:(id)sender { - if( o_videoeffects == nil ) + if (o_videoeffects == nil) o_videoeffects = [[VLCVideoEffects alloc] init]; - if( !b_nib_videoeffects_loaded ) + if (!b_nib_videoeffects_loaded) b_nib_videoeffects_loaded = [NSBundle loadNibNamed:@"VideoEffects" owner: NSApp]; [o_videoeffects toggleWindow:sender]; @@ -721,18 +1160,44 @@ static VLCMainMenu *_o_sharedInstance = nil; - (IBAction)viewPreferences:(id)sender { - [[[VLCMain sharedInstance] simplePreferences] showSimplePrefs]; + NSInteger i_level = [[[VLCMain sharedInstance] voutController] currentStatusWindowLevel]; + [[[VLCMain sharedInstance] simplePreferences] showSimplePrefsWithLevel:i_level]; } -#pragma mark - -#pragma mark Help and Docs +- (IBAction)openAddonManager:(id)sender +{ + if (!o_addonManager) + o_addonManager = [[VLCAddonManager alloc] init]; + + if (!b_nib_addonmanager_loaded) + b_nib_addonmanager_loaded = [NSBundle loadNibNamed:@"AddonManager" owner:NSApp]; + + [o_addonManager showWindow]; +} + +- (IBAction)showMessagesPanel:(id)showMessagesPanel +{ + [[VLCDebugMessageVisualizer sharedInstance] showPanel]; +} + +- (IBAction)showMainWindow:(id)sender +{ + [[VLCMainWindow sharedInstance] makeKeyAndOrderFront:sender]; +} + +- (IBAction)showPlaylist:(id)sender +{ + [[VLCMainWindow sharedInstance] changePlaylistState: psUserMenuEvent]; +} + +#pragma mark - Help and Docs - (void)initAbout { - if(! o_about ) + if (! o_about) o_about = [[VLAboutBox alloc] init]; - if( !b_nib_about_loaded ) + if (!b_nib_about_loaded) b_nib_about_loaded = [NSBundle loadNibNamed:@"About" owner: NSApp]; } @@ -745,7 +1210,7 @@ static VLCMainMenu *_o_sharedInstance = nil; - (IBAction)showLicense:(id)sender { [self initAbout]; - [o_about showGPL: sender]; + [o_about showGPL]; } - (IBAction)viewHelp:(id)sender @@ -789,8 +1254,7 @@ static VLCMainMenu *_o_sharedInstance = nil; [[NSWorkspace sharedWorkspace] openURL: o_url]; } -#pragma mark - -#pragma mark Errors, warnings and messages +#pragma mark - Errors, warnings and messages - (IBAction)viewErrorsAndWarnings:(id)sender { @@ -802,8 +1266,8 @@ static VLCMainMenu *_o_sharedInstance = nil; [[[VLCMain sharedInstance] info] initPanel]; } -#pragma mark - -#pragma mark convinience stuff for other objects +#pragma mark - convinience stuff for other objects + - (void)setPlay { [o_mi_play setTitle: _NS("Play")]; @@ -839,13 +1303,13 @@ static VLCMainMenu *_o_sharedInstance = nil; - (void)setShuffle { bool b_value; - playlist_t *p_playlist = pl_Get( VLCIntf ); - b_value = var_GetBool( p_playlist, "random" ); - [o_mi_random setState: b_value]; + playlist_t *p_playlist = pl_Get(VLCIntf); + b_value = var_GetBool(p_playlist, "random"); + + [o_mi_random setState: b_value]; } -#pragma mark - -#pragma mark Dynamic menu creation and validation +#pragma mark - Dynamic menu creation and validation - (void)setupVarMenuItem:(NSMenuItem *)o_mi target:(vlc_object_t *)p_object @@ -853,10 +1317,9 @@ static VLCMainMenu *_o_sharedInstance = nil; selector:(SEL)pf_callback { vlc_value_t val, text; - int i_type = var_Type( p_object, psz_variable ); + int i_type = var_Type(p_object, psz_variable); - switch( i_type & VLC_VAR_TYPE ) - { + switch(i_type & VLC_VAR_TYPE) { case VLC_VAR_VOID: case VLC_VAR_BOOL: case VLC_VAR_VARIABLE: @@ -865,41 +1328,29 @@ static VLCMainMenu *_o_sharedInstance = nil; break; default: /* Variable doesn't exist or isn't handled */ - return; - } - - /* Make sure we want to display the variable */ - if( i_type & VLC_VAR_HASCHOICE ) - { - var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL ); - if( val.i_int == 0 ) return; - if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 ) + msg_Warn(p_object, "variable %s doesn't exist or isn't handled", psz_variable); return; } /* Get the descriptive name of the variable */ - var_Change( p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL ); - [o_mi setTitle: [[VLCMain sharedInstance] localizedString: text.psz_string ? - text.psz_string : psz_variable ]]; + var_Change(p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL); + [o_mi setTitle: _NS(text.psz_string ? text.psz_string : psz_variable)]; - if( i_type & VLC_VAR_HASCHOICE ) - { + if (i_type & VLC_VAR_HASCHOICE) { NSMenu *o_menu = [o_mi submenu]; - + [self setupVarMenu: o_menu forMenuItem: o_mi target:p_object var:psz_variable selector:pf_callback]; - - free( text.psz_string ); + + free(text.psz_string); return; } - if( var_Get( p_object, psz_variable, &val ) < 0 ) - { + + if (var_Get(p_object, psz_variable, &val) < 0) return; - } VLCAutoGeneratedMenuContent *o_data; - switch( i_type & VLC_VAR_TYPE ) - { + switch(i_type & VLC_VAR_TYPE) { case VLC_VAR_VOID: o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object andValue: val ofType: i_type]; @@ -910,7 +1361,7 @@ static VLCMainMenu *_o_sharedInstance = nil; o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object andValue: val ofType: i_type]; [o_mi setRepresentedObject: [o_data autorelease]]; - if( !( i_type & VLC_VAR_ISCOMMAND ) ) + if (!(i_type & VLC_VAR_ISCOMMAND)) [o_mi setState: val.b_bool ? TRUE : FALSE ]; break; @@ -918,8 +1369,8 @@ static VLCMainMenu *_o_sharedInstance = nil; break; } - if( ( i_type & VLC_VAR_TYPE ) == VLC_VAR_STRING ) free( val.psz_string ); - free( text.psz_string ); + if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING) free(val.psz_string); + free(text.psz_string); } @@ -933,35 +1384,37 @@ static VLCMainMenu *_o_sharedInstance = nil; int i_type, i; /* remove previous items */ - if (OSX_LEOPARD) - { - int i_nb_items; - i_nb_items = [o_menu numberOfItems]; - for( i = 0; i < i_nb_items; i++ ) - [o_menu removeItemAtIndex: 0]; - } - else - { - /* this is more efficient then the legacy code, but 10.6+ only */ - [o_menu removeAllItems]; + [o_menu removeAllItems]; + + /* we disable everything here, and enable it again when needed, below */ + [o_parent setEnabled:NO]; + + /* Aspect Ratio */ + if ([[o_parent title] isEqualToString: _NS("Aspect ratio")] == YES) { + NSMenuItem *o_lmi_tmp2; + o_lmi_tmp2 = [o_menu addItemWithTitle: _NS("Lock Aspect Ratio") action: @selector(lockVideosAspectRatio:) keyEquivalent: @""]; + [o_lmi_tmp2 setTarget: [[VLCMain sharedInstance] controls]]; + [o_lmi_tmp2 setEnabled: YES]; + [o_lmi_tmp2 setState: [[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]]; + [o_parent setEnabled: YES]; + [o_menu addItem: [NSMenuItem separatorItem]]; } /* Check the type of the object variable */ - i_type = var_Type( p_object, psz_variable ); + i_type = var_Type(p_object, psz_variable); /* Make sure we want to display the variable */ - if( i_type & VLC_VAR_HASCHOICE ) - { - var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL ); - if( val.i_int == 0 ) return; - if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 ) + if (i_type & VLC_VAR_HASCHOICE) { + var_Change(p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL); + if (val.i_int == 0) + return; + if ((i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1) return; } else return; - switch( i_type & VLC_VAR_TYPE ) - { + switch(i_type & VLC_VAR_TYPE) { case VLC_VAR_VOID: case VLC_VAR_BOOL: case VLC_VAR_VARIABLE: @@ -973,56 +1426,28 @@ static VLCMainMenu *_o_sharedInstance = nil; return; } - if( var_Get( p_object, psz_variable, &val ) < 0 ) - { + if (var_Get(p_object, psz_variable, &val) < 0) { return; } - if( var_Change( p_object, psz_variable, VLC_VAR_GETLIST, - &val_list, &text_list ) < 0 ) - { - if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string ); + if (var_Change(p_object, psz_variable, VLC_VAR_GETCHOICES, + &val_list, &text_list) < 0) { + if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING) free(val.psz_string); return; } /* make (un)sensitive */ - [o_parent setEnabled: ( val_list.p_list->i_count > 1 )]; + [o_parent setEnabled: (val_list.p_list->i_count > 1)]; - /* Aspect Ratio */ - if( [[o_parent title] isEqualToString: _NS("Aspect-ratio")] == YES ) - { - NSMenuItem *o_lmi_tmp2; - o_lmi_tmp2 = [o_menu addItemWithTitle: _NS("Lock Aspect Ratio") action: @selector(lockVideosAspectRatio:) keyEquivalent: @""]; - [o_lmi_tmp2 setTarget: self]; - [o_lmi_tmp2 setEnabled: YES]; - [o_lmi_tmp2 setState: [[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]]; - [o_parent setEnabled: YES]; - [o_menu addItem: [NSMenuItem separatorItem]]; - } - - /* special case for the subtitles items */ - if( [[o_parent title] isEqualToString: _NS("Subtitles Track")] == YES ) - { - NSMenuItem * o_lmi_tmp; - o_lmi_tmp = [o_menu addItemWithTitle: _NS("Open File...") action: @selector(addSubtitleFile:) keyEquivalent: @""]; - [o_lmi_tmp setTarget: self]; - [o_lmi_tmp setEnabled: YES]; - [o_parent setEnabled: YES]; - [o_menu addItem: [NSMenuItem separatorItem]]; - } - - for( i = 0; i < val_list.p_list->i_count; i++ ) - { + for (i = 0; i < val_list.p_list->i_count; i++) { NSMenuItem * o_lmi; NSString *o_title = @""; VLCAutoGeneratedMenuContent *o_data; - switch( i_type & VLC_VAR_TYPE ) - { + switch(i_type & VLC_VAR_TYPE) { case VLC_VAR_STRING: - o_title = [[VLCMain sharedInstance] localizedString: text_list.p_list->p_values[i].psz_string ? - text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string ]; + o_title = _NS(text_list.p_list->p_values[i].psz_string ? text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string); o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""]; o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object @@ -1030,7 +1455,7 @@ static VLCMainMenu *_o_sharedInstance = nil; [o_lmi setRepresentedObject: [o_data autorelease]]; [o_lmi setTarget: self]; - if( !strcmp( val.psz_string, val_list.p_list->p_values[i].psz_string ) && !( i_type & VLC_VAR_ISCOMMAND ) ) + if (!strcmp(val.psz_string, val_list.p_list->p_values[i].psz_string) && !(i_type & VLC_VAR_ISCOMMAND)) [o_lmi setState: TRUE ]; break; @@ -1038,9 +1463,7 @@ static VLCMainMenu *_o_sharedInstance = nil; case VLC_VAR_INTEGER: o_title = text_list.p_list->p_values[i].psz_string ? - [[VLCMain sharedInstance] localizedString: text_list.p_list->p_values[i].psz_string] : - [NSString stringWithFormat: @"%"PRId64, - val_list.p_list->p_values[i].i_int]; + _NS(text_list.p_list->p_values[i].psz_string) : [NSString stringWithFormat: @"%"PRId64, val_list.p_list->p_values[i].i_int]; o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""]; o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object @@ -1048,7 +1471,7 @@ static VLCMainMenu *_o_sharedInstance = nil; [o_lmi setRepresentedObject: [o_data autorelease]]; [o_lmi setTarget: self]; - if( val_list.p_list->p_values[i].i_int == val.i_int && !( i_type & VLC_VAR_ISCOMMAND ) ) + if (val_list.p_list->p_values[i].i_int == val.i_int && !(i_type & VLC_VAR_ISCOMMAND)) [o_lmi setState: TRUE ]; break; @@ -1057,17 +1480,9 @@ static VLCMainMenu *_o_sharedInstance = nil; } } - /* special case for the subtitles sub-menu - * In case that we don't have any subs, we don't want a separator item at the end */ - if( [[o_parent title] isEqualToString: _NS("Subtitles Track")] == YES ) - { - if( [o_menu numberOfItems] == 2 ) - [o_menu removeItemAtIndex: 1]; - } - /* clean up everything */ - if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string ); - var_FreeList( &val_list, &text_list ); + if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING) free(val.psz_string); + var_FreeList(&val_list, &text_list); } - (IBAction)toggleVar:(id)sender @@ -1090,10 +1505,9 @@ static VLCMainMenu *_o_sharedInstance = nil; p_object = [menuContent vlcObject]; - if( p_object != NULL ) - { - var_Set( p_object, [menuContent name], [menuContent value] ); - vlc_object_release( p_object ); + if (p_object != NULL) { + var_Set(p_object, [menuContent name], [menuContent value]); + vlc_object_release(p_object); [o_pool release]; return true; } @@ -1110,117 +1524,104 @@ static VLCMainMenu *_o_sharedInstance = nil; NSString *o_title = [o_mi title]; BOOL bEnabled = TRUE; vlc_value_t val; - playlist_t * p_playlist = pl_Get( p_intf ); - input_thread_t * p_input = playlist_CurrentInput( p_playlist ); + playlist_t * p_playlist = pl_Get(p_intf); + input_thread_t * p_input = playlist_CurrentInput(p_playlist); - if( [o_title isEqualToString: _NS("Stop")] ) - { - if( p_input == NULL ) - { + if ([o_title isEqualToString: _NS("Stop")]) { + if (!p_input) bEnabled = FALSE; - } [self setupMenus]; /* Make sure input menu is up to date */ - } - else if( [o_title isEqualToString: _NS("Previous")] || - [o_title isEqualToString: _NS("Next")] ) - { + } else if ([o_title isEqualToString: _NS("Previous")] || + [o_title isEqualToString: _NS("Next")]) { PL_LOCK; - bEnabled = playlist_CurrentSize( p_playlist ) > 1; + bEnabled = playlist_CurrentSize(p_playlist) > 1; PL_UNLOCK; - } - else if( [o_title isEqualToString: _NS("Random")] ) - { + } else if ([o_title isEqualToString: _NS("Random")]) { int i_state; - var_Get( p_playlist, "random", &val ); + var_Get(p_playlist, "random", &val); i_state = val.b_bool ? NSOnState : NSOffState; [o_mi setState: i_state]; - } - else if( [o_title isEqualToString: _NS("Repeat One")] ) - { + } else if ([o_title isEqualToString: _NS("Repeat One")]) { int i_state; - var_Get( p_playlist, "repeat", &val ); + var_Get(p_playlist, "repeat", &val); i_state = val.b_bool ? NSOnState : NSOffState; [o_mi setState: i_state]; - } - else if( [o_title isEqualToString: _NS("Repeat All")] ) - { + } else if ([o_title isEqualToString: _NS("Repeat All")]) { int i_state; - var_Get( p_playlist, "loop", &val ); + var_Get(p_playlist, "loop", &val); i_state = val.b_bool ? NSOnState : NSOffState; [o_mi setState: i_state]; - } - else if( [o_title isEqualToString: _NS("Quit after Playback")] ) - { + } else if ([o_title isEqualToString: _NS("Quit after Playback")]) { int i_state; - var_Get( p_playlist, "play-and-exit", &val ); - i_state = val.b_bool ? NSOnState : NSOffState; + bool b_value = var_InheritBool(p_playlist, "play-and-exit"); + i_state = b_value ? NSOnState : NSOffState; [o_mi setState: i_state]; - } - else if( [o_title isEqualToString: _NS("Step Forward")] || - [o_title isEqualToString: _NS("Step Backward")] || - [o_title isEqualToString: _NS("Jump To Time")]) - { - if( p_input != NULL ) - { - var_Get( p_input, "can-seek", &val); + } else if ([o_title isEqualToString: _NS("Step Forward")] || + [o_title isEqualToString: _NS("Step Backward")] || + [o_title isEqualToString: _NS("Jump to Time")]) { + if (p_input != NULL) { + var_Get(p_input, "can-seek", &val); bEnabled = val.b_bool; } else bEnabled = FALSE; - } - else if( [o_title isEqualToString: _NS("Mute")] ) - { - //FIXME [o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState]; + } else if ([o_title isEqualToString: _NS("Mute")]) { + [o_mi setState: [[VLCCoreInteraction sharedInstance] mute] ? NSOnState : NSOffState]; [self setupMenus]; /* Make sure audio menu is up to date */ - } - else if( [o_title isEqualToString: _NS("Half Size")] || - [o_title isEqualToString: _NS("Normal Size")] || - [o_title isEqualToString: _NS("Double Size")] || - [o_title isEqualToString: _NS("Fit to Screen")] || - [o_title isEqualToString: _NS("Snapshot")] || - [o_title isEqualToString: _NS("Fullscreen")] || - [o_title isEqualToString: _NS("Float on Top")] ) - { + [self refreshAudioDeviceList]; + } else if ([o_title isEqualToString: _NS("Half Size")] || + [o_title isEqualToString: _NS("Normal Size")] || + [o_title isEqualToString: _NS("Double Size")] || + [o_title isEqualToString: _NS("Fit to Screen")] || + [o_title isEqualToString: _NS("Snapshot")] || + [o_title isEqualToString: _NS("Fullscreen")] || + [o_title isEqualToString: _NS("Float on Top")]) { bEnabled = FALSE; - if( p_input != NULL ) - { - vout_thread_t *p_vout = input_GetVout( p_input ); - if( p_vout != NULL ) - { - if( [o_title isEqualToString: _NS("Float on Top")] ) - { - [o_mi setState: var_GetBool( p_vout, "video-on-top" )]; - } + if (p_input != NULL) { + vout_thread_t *p_vout = getVoutForActiveWindow(); + if (p_vout != NULL) { + if ([o_title isEqualToString: _NS("Float on Top")]) + [o_mi setState: var_GetBool(p_vout, "video-on-top")]; - bEnabled = TRUE; + if ([o_title isEqualToString: _NS("Fullscreen")]) + [o_mi setState: var_GetBool(p_vout, "fullscreen")]; - vlc_object_release( (vlc_object_t *)p_vout ); + bEnabled = TRUE; + vlc_object_release(p_vout); } } - if( [o_title isEqualToString: _NS("Fullscreen")] ) - { - [o_mi setState: var_GetBool( p_playlist, "fullscreen" )]; - bEnabled = TRUE; - } + [self setupMenus]; /* Make sure video menu is up to date */ + + } else if ([o_title isEqualToString: _NS("Add Subtitle File...")]) { + bEnabled = [o_mi isEnabled]; + [self setupMenus]; /* Make sure subtitles menu is up to date */ + } else { + NSMenuItem *o_mi_parent = [o_mi parentItem]; + if (o_mi_parent == o_mi_subtitle_size || o_mi == o_mi_subtitle_size || + o_mi_parent == o_mi_subtitle_textcolor || o_mi == o_mi_subtitle_textcolor || + o_mi_parent == o_mi_subtitle_bgcolor || o_mi == o_mi_subtitle_bgcolor || + o_mi_parent == o_mi_subtitle_bgopacity || o_mi == o_mi_subtitle_bgopacity || + o_mi_parent == o_mi_subtitle_outlinethickness || o_mi == o_mi_subtitle_outlinethickness || + o_mi_parent == o_mi_teletext || o_mi == o_mi_teletext) + bEnabled = o_mi_openSubtitleFile.isEnabled; } /* Special case for telx menu */ - if( [o_title isEqualToString: _NS("Normal Size")] ) - { + if ([o_title isEqualToString: _NS("Normal Size")]) { NSMenuItem *item = [[o_mi menu] itemWithTitle:_NS("Teletext")]; - bool b_telx = p_input && var_GetInteger( p_input, "teletext-es" ) >= 0; + bool b_telx = p_input && var_GetInteger(p_input, "teletext-es") >= 0; [[item submenu] setAutoenablesItems:NO]; - for( int k=0; k < [[item submenu] numberOfItems]; k++ ) - { + + for (int k=0; k < [[item submenu] numberOfItems]; k++) [[[item submenu] itemAtIndex:k] setEnabled: b_telx]; - } } - if( p_input ) vlc_object_release( p_input ); + if (p_input) + vlc_object_release(p_input); - return( bEnabled ); + return bEnabled; } @end @@ -1239,25 +1640,25 @@ static VLCMainMenu *_o_sharedInstance = nil; { self = [super init]; - if( self != nil ) - { - _vlc_object = vlc_object_hold( object ); - psz_name = strdup( name ); + if (self != nil) { + _vlc_object = vlc_object_hold(object); + psz_name = strdup(name); i_type = type; value = val; - if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) - value.psz_string = strdup( val.psz_string ); + if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING) + value.psz_string = strdup(val.psz_string); } - return( self ); + return(self); } - (void)dealloc { - vlc_object_release( _vlc_object ); - if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) - free( value.psz_string ); - free( psz_name ); + if (_vlc_object) + vlc_object_release(_vlc_object); + if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING) + free(value.psz_string); + free(psz_name); [super dealloc]; } @@ -1273,7 +1674,7 @@ static VLCMainMenu *_o_sharedInstance = nil; - (vlc_object_t *)vlcObject { - return vlc_object_hold( _vlc_object ); + return vlc_object_hold(_vlc_object); }