Commit c9a6d88b authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: moved all (main) menu related code to a separate class

This is a first step to re-organize the interface, more to come
parent 6c101d63
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -418,6 +418,8 @@
CC3F9F851350B2A000B0E885 /* Growl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Growl.framework; path = ../../contrib/Growl/Growl.framework; sourceTree = "<group>"; };
CC402F4B0E00ABBB006A4BA4 /* VLC.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VLC.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
CC426FD01020D44F00A32659 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = ../../contrib/Sparkle/Sparkle.framework; sourceTree = SOURCE_ROOT; };
CC448A5A13B61D49009F72E0 /* MainMenu.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MainMenu.h; path = ../../../modules/gui/macosx/MainMenu.h; sourceTree = "<group>"; };
CC448A5B13B61D49009F72E0 /* MainMenu.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = MainMenu.m; path = ../../../modules/gui/macosx/MainMenu.m; sourceTree = "<group>"; };
CC4A33210F8CB017000FC4A7 /* coredialogs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = coredialogs.m; path = ../../../modules/gui/macosx/coredialogs.m; sourceTree = SOURCE_ROOT; };
CC4A33220F8CB017000FC4A7 /* coredialogs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = coredialogs.h; path = ../../../modules/gui/macosx/coredialogs.h; sourceTree = SOURCE_ROOT; };
CC4D67F51348F587003FCC5B /* quartztext.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = quartztext.c; path = ../../../modules/misc/text_renderer/quartztext.c; sourceTree = "<group>"; };
......@@ -560,6 +562,8 @@
8ED6C27E03E2EB1C0059A3A7 /* macosx.m */,
8ED6C27C03E2EB1C0059A3A7 /* intf.h */,
8ED6C27D03E2EB1C0059A3A7 /* intf.m */,
CC448A5A13B61D49009F72E0 /* MainMenu.h */,
CC448A5B13B61D49009F72E0 /* MainMenu.m */,
CC4A33220F8CB017000FC4A7 /* coredialogs.h */,
CC4A33210F8CB017000FC4A7 /* coredialogs.m */,
8E6BC6FA041684EC0059A3A7 /* controls.h */,
......
/*****************************************************************************
* MainMenu.h: MacOS X interface module
*****************************************************************************
* Copyright (C) 2011 Felix Paul Kühne
* $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 <Cocoa/Cocoa.h>
#import <vlc_common.h>
#import <vlc_interface.h>
@interface VLCMainMenu : NSObject
{
intf_thread_t *p_intf;
BOOL b_mainMenu_setup;
BOOL b_nib_about_loaded;
BOOL b_nib_videoeffects_loaded;
BOOL b_nib_audioeffects_loaded;
BOOL b_nib_tracksynchro_loaded;
BOOL b_nib_bookmarks_loaded;
id o_about; /* VLAboutBox */
id o_videoeffects; /* VLCVideoEffects */
id o_audioeffects; /* VLCAudioEffects */
id o_trackSynchronization; /* VLCTrackSynchronization */
id o_bookmarks; /* VLCBookmarks */
/* main menu */
IBOutlet NSMenuItem * o_mi_about;
IBOutlet NSMenuItem * o_mi_prefs;
IBOutlet NSMenuItem * o_mi_checkForUpdate;
IBOutlet NSMenuItem * o_mi_add_intf;
IBOutlet NSMenu * o_mu_add_intf;
IBOutlet NSMenuItem * o_mi_services;
IBOutlet NSMenuItem * o_mi_hide;
IBOutlet NSMenuItem * o_mi_hide_others;
IBOutlet NSMenuItem * o_mi_show_all;
IBOutlet NSMenuItem * o_mi_quit;
IBOutlet NSMenu * o_mu_file;
IBOutlet NSMenuItem * o_mi_open_file;
IBOutlet NSMenuItem * o_mi_open_generic;
IBOutlet NSMenuItem * o_mi_open_disc;
IBOutlet NSMenuItem * o_mi_open_net;
IBOutlet NSMenuItem * o_mi_open_capture;
IBOutlet NSMenuItem * o_mi_open_recent;
IBOutlet NSMenuItem * o_mi_open_recent_cm;
IBOutlet NSMenuItem * o_mi_open_wizard;
IBOutlet NSMenu * o_mu_edit;
IBOutlet NSMenuItem * o_mi_cut;
IBOutlet NSMenuItem * o_mi_copy;
IBOutlet NSMenuItem * o_mi_paste;
IBOutlet NSMenuItem * o_mi_clear;
IBOutlet NSMenuItem * o_mi_select_all;
IBOutlet NSMenu * o_mu_controls;
IBOutlet NSMenuItem * o_mi_play;
IBOutlet NSMenuItem * o_mi_stop;
IBOutlet NSMenuItem * o_mi_faster;
IBOutlet NSMenuItem * o_mi_slower;
IBOutlet NSMenuItem * o_mi_normalSpeed;
IBOutlet NSMenuItem * o_mi_trackSynchronization;
IBOutlet NSMenuItem * o_mi_previous;
IBOutlet NSMenuItem * o_mi_next;
IBOutlet NSMenuItem * o_mi_random;
IBOutlet NSMenuItem * o_mi_repeat;
IBOutlet NSMenuItem * o_mi_loop;
IBOutlet NSMenuItem * o_mi_quitAfterPB;
IBOutlet NSMenuItem * o_mi_fwd;
IBOutlet NSMenuItem * o_mi_bwd;
IBOutlet NSMenuItem * o_mi_program;
IBOutlet NSMenu * o_mu_program;
IBOutlet NSMenuItem * o_mi_title;
IBOutlet NSMenu * o_mu_title;
IBOutlet NSMenuItem * o_mi_chapter;
IBOutlet NSMenu * o_mu_chapter;
IBOutlet NSMenu * o_mu_audio;
IBOutlet NSMenuItem * o_mi_vol_up;
IBOutlet NSMenuItem * o_mi_vol_down;
IBOutlet NSMenuItem * o_mi_mute;
IBOutlet NSMenuItem * o_mi_audiotrack;
IBOutlet NSMenu * o_mu_audiotrack;
IBOutlet NSMenuItem * o_mi_channels;
IBOutlet NSMenu * o_mu_channels;
IBOutlet NSMenuItem * o_mi_device;
IBOutlet NSMenu * o_mu_device;
IBOutlet NSMenuItem * o_mi_visual;
IBOutlet NSMenu * o_mu_visual;
IBOutlet NSMenu * o_mu_video;
IBOutlet NSMenuItem * o_mi_half_window;
IBOutlet NSMenuItem * o_mi_normal_window;
IBOutlet NSMenuItem * o_mi_double_window;
IBOutlet NSMenuItem * o_mi_fittoscreen;
IBOutlet NSMenuItem * o_mi_fullscreen;
IBOutlet NSMenuItem * o_mi_floatontop;
IBOutlet NSMenuItem * o_mi_snapshot;
IBOutlet NSMenuItem * o_mi_videotrack;
IBOutlet NSMenu * o_mu_videotrack;
IBOutlet NSMenuItem * o_mi_screen;
IBOutlet NSMenu * o_mu_screen;
IBOutlet NSMenuItem * o_mi_aspect_ratio;
IBOutlet NSMenu * o_mu_aspect_ratio;
IBOutlet NSMenuItem * o_mi_crop;
IBOutlet NSMenu * o_mu_crop;
IBOutlet NSMenuItem * o_mi_subtitle;
IBOutlet NSMenu * o_mu_subtitle;
IBOutlet NSMenuItem * o_mi_addSub;
IBOutlet NSMenuItem * o_mi_deinterlace;
IBOutlet NSMenu * o_mu_deinterlace;
IBOutlet NSMenuItem * o_mi_deinterlace_mode;
IBOutlet NSMenu * o_mu_deinterlace_mode;
IBOutlet NSMenuItem * o_mi_ffmpeg_pp;
IBOutlet NSMenu * o_mu_ffmpeg_pp;
IBOutlet NSMenuItem * o_mi_teletext;
IBOutlet NSMenuItem * o_mi_teletext_transparent;
IBOutlet NSMenuItem * o_mi_teletext_index;
IBOutlet NSMenuItem * o_mi_teletext_red;
IBOutlet NSMenuItem * o_mi_teletext_green;
IBOutlet NSMenuItem * o_mi_teletext_yellow;
IBOutlet NSMenuItem * o_mi_teletext_blue;
IBOutlet NSMenu * o_mu_window;
IBOutlet NSMenuItem * o_mi_minimize;
IBOutlet NSMenuItem * o_mi_close_window;
IBOutlet NSMenuItem * o_mi_player;
IBOutlet NSMenuItem * o_mi_controller;
IBOutlet NSMenuItem * o_mi_audioeffects;
IBOutlet NSMenuItem * o_mi_videoeffects;
IBOutlet NSMenuItem * o_mi_bookmarks;
IBOutlet NSMenuItem * o_mi_playlist;
IBOutlet NSMenuItem * o_mi_info;
IBOutlet NSMenuItem * o_mi_messages;
IBOutlet NSMenuItem * o_mi_bring_atf;
IBOutlet NSMenu * o_mu_help;
IBOutlet NSMenuItem * o_mi_help;
IBOutlet NSMenuItem * o_mi_readme;
IBOutlet NSMenuItem * o_mi_documentation;
IBOutlet NSMenuItem * o_mi_license;
IBOutlet NSMenuItem * o_mi_website;
IBOutlet NSMenuItem * o_mi_donation;
IBOutlet NSMenuItem * o_mi_forum;
IBOutlet NSMenuItem * o_mi_errorsAndWarnings;
/* dock menu */
IBOutlet NSMenuItem * o_dmi_play;
IBOutlet NSMenuItem * o_dmi_stop;
IBOutlet NSMenuItem * o_dmi_next;
IBOutlet NSMenuItem * o_dmi_previous;
IBOutlet NSMenuItem * o_dmi_mute;
/* vout menu */
IBOutlet NSMenu * o_vout_menu;
IBOutlet NSMenuItem * o_vmi_play;
IBOutlet NSMenuItem * o_vmi_stop;
IBOutlet NSMenuItem * o_vmi_prev;
IBOutlet NSMenuItem * o_vmi_next;
IBOutlet NSMenuItem * o_vmi_volup;
IBOutlet NSMenuItem * o_vmi_voldown;
IBOutlet NSMenuItem * o_vmi_mute;
IBOutlet NSMenuItem * o_vmi_fullscreen;
IBOutlet NSMenuItem * o_vmi_snapshot;
}
+ (VLCMainMenu *)sharedInstance;
- (void)initStrings;
- (void)releaseRepresentedObjects:(NSMenu *)the_menu;
- (void)setupMenus;
- (void)refreshVoutDeviceMenu:(NSNotification *)o_notification;
- (void)setSubmenusEnabled:(BOOL)b_enabled;
- (IBAction)clearRecentItems:(id)sender;
- (void)openRecentItem:(id)item;
- (IBAction)intfOpenFile:(id)sender;
- (IBAction)intfOpenFileGeneric:(id)sender;
- (IBAction)intfOpenDisc:(id)sender;
- (IBAction)intfOpenNet:(id)sender;
- (IBAction)intfOpenCapture:(id)sender;
- (IBAction)showWizard:(id)sender;
- (IBAction)showVideoEffects:(id)sender;
- (IBAction)showAudioEffects:(id)sender;
- (IBAction)showTrackSynchronization:(id)sender;
- (IBAction)showBookmarks:(id)sender;
- (IBAction)showInformationPanel:(id)sender;
- (IBAction)viewAbout:(id)sender;
- (IBAction)showLicense:(id)sender;
- (IBAction)viewPreferences:(id)sender;
- (IBAction)viewHelp:(id)sender;
- (IBAction)openReadMe:(id)sender;
- (IBAction)openDocumentation:(id)sender;
- (IBAction)openWebsite:(id)sender;
- (IBAction)openForum:(id)sender;
- (IBAction)openDonate:(id)sender;
- (IBAction)viewErrorsAndWarnings:(id)sender;
- (void)setPlay;
- (void)setPause;
- (IBAction)toggleVar:(id)sender;
- (int)toggleVarThread:(id)_o_data;
- (void)setupVarMenuItem:(NSMenuItem *)o_mi
target:(vlc_object_t *)p_object
var:(const char *)psz_variable
selector:(SEL)pf_callback;
- (void)setupVarMenu:(NSMenu *)o_menu
forMenuItem: (NSMenuItem *)o_parent
target:(vlc_object_t *)p_object
var:(const char *)psz_variable
selector:(SEL)pf_callback;
@end
/*****************************************************************************
* VLCAutoGeneratedMenuContent interface
*****************************************************************************
* This holds our data for autogenerated menus
*****************************************************************************/
@interface VLCAutoGeneratedMenuContent : NSObject
{
char *psz_name;
vlc_object_t * _vlc_object;
vlc_value_t value;
int i_type;
}
- (id)initWithVariableName: (const char *)name
ofObject: (vlc_object_t *)object
andValue: (vlc_value_t)value
ofType: (int)type;
- (const char *)name;
- (vlc_value_t)value;
- (vlc_object_t *)vlcObject;
- (int)type;
@end
/*****************************************************************************
* MainMenu.m: MacOS X interface module
*****************************************************************************
* Copyright (C) 2011 Felix Paul Kühne
* $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>
#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"
#import "playlistinfo.h"
#import "vout.h"
@implementation VLCMainMenu
static VLCMainMenu *_o_sharedInstance = nil;
+ (VLCMainMenu *)sharedInstance
{
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
}
#pragma mark -
#pragma mark Initialization
- (id)init
{
if( _o_sharedInstance)
{
[self dealloc];
return _o_sharedInstance;
}
else
{
_o_sharedInstance = [super init];
}
return _o_sharedInstance;
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
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];
[super dealloc];
}
- (void)awakeFromNib
{
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(applicationWillFinishLaunching:)
name: NSApplicationWillFinishLaunchingNotification
object: nil];
}
- (void)applicationWillFinishLaunching:(NSNotification *)o_notification
{
p_intf = VLCIntf;
NSString* o_key;
playlist_t *p_playlist;
vlc_value_t val;
id o_vlcmain = [VLCMain sharedInstance];
/* Check if we already did this once. Opening the other nibs calls it too,
because VLCMain is the owner */
if( b_mainMenu_setup ) return;
[self initStrings];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-quit" )];
[o_mi_quit setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_quit setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-play-pause" )];
[o_mi_play setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_play setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-stop" )];
[o_mi_stop setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_stop setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-faster" )];
[o_mi_faster setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_faster setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-slower" )];
[o_mi_slower setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_slower setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-rate-normal" )];
[o_mi_normalSpeed setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_normalSpeed setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-prev" )];
[o_mi_previous setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_previous setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-next" )];
[o_mi_next setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_next setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-jump+short" )];
[o_mi_fwd setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_fwd setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-jump-short" )];
[o_mi_bwd setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_bwd setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-vol-up" )];
[o_mi_vol_up setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_vol_up setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-vol-down" )];
[o_mi_vol_down setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_vol_down setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-vol-mute" )];
[o_mi_mute setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_mute setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-toggle-fullscreen" )];
[o_mi_fullscreen setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_fullscreen setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-snapshot" )];
[o_mi_snapshot setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_snapshot setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-random" )];
[o_mi_random setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_random setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-zoom-half" )];
[o_mi_half_window setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_half_window setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-zoom-original" )];
[o_mi_normal_window setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_normal_window setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-zoom-double" )];
[o_mi_double_window setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_double_window setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
[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:)];
}
- (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...")];
[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")];
[o_mi_open_recent_cm setTitle: _NS("Clear Menu")];
[o_mi_open_wizard setTitle: _NS("Streaming/Exporting Wizard...")];
[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")];
[o_mu_controls setTitle: _NS("Playback")];
[o_mi_play setTitle: _NS("Play")];
[o_mi_stop setTitle: _NS("Stop")];
[o_mi_faster setTitle: _NS("Faster")];
[o_mi_slower setTitle: _NS("Slower")];
[o_mi_normalSpeed setTitle: _NS("Normal rate")];
[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")];
[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")];
[o_mi_channels setTitle: _NS("Audio Channels")];
[o_mu_channels setTitle: _NS("Audio Channels")];
[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")];
[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_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")];
[o_mi_minimize setTitle: _NS("Minimize Window")];
[o_mi_close_window setTitle: _NS("Close Window")];
[o_mi_player setTitle: _NS("Player...")];
[o_mi_controller setTitle: _NS("Controller...")];
[o_mi_audioeffects setTitle: _NS("Audio Effects...")];
[o_mi_videoeffects setTitle: _NS("Video Filters...")];
[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")];
}
#pragma mark -
#pragma mark Termination
- (void)releaseRepresentedObjects:(NSMenu *)the_menu
{
if( !p_intf ) return;
NSArray *menuitems_array = [the_menu itemArray];
for( int i=0; i<[menuitems_array count]; 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
- (void)setupMenus
{
playlist_t * p_playlist = pl_Get( p_intf );
input_thread_t * p_input = playlist_CurrentInput( p_playlist );
if( p_input != NULL )
{
[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:)];
[self setupVarMenuItem: o_mi_subtitle 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];
aout_instance_t * p_aout = input_GetAout( p_input );
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:)];
[self setupVarMenuItem: o_mi_visual target: (vlc_object_t *)p_aout
var: "visual" selector: @selector(toggleVar:)];
vlc_object_release( (vlc_object_t *)p_aout );
}
vout_thread_t * p_vout = input_GetVout( p_input );
if( p_vout != NULL )
{
vlc_object_t * p_dec_obj;
[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_screen target: (vlc_object_t *)p_vout
var: "video-device" 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:)];
#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_input );
}
}
- (void)refreshVoutDeviceMenu:(NSNotification *)o_notification
{
int x, y = 0;
vout_thread_t * p_vout = getVout();
if( !p_vout )
return;
/* clean the menu before adding new entries */
if( [o_mi_screen hasSubmenu] )
{
y = [[o_mi_screen submenu] numberOfItems] - 1;
msg_Dbg( VLCIntf, "%i items in submenu", y );
while( x != y )
{
msg_Dbg( VLCIntf, "removing item %i of %i", x, y );
[[o_mi_screen submenu] removeItemAtIndex: x];
x++;
}
}
[self setupVarMenuItem: o_mi_screen target: (vlc_object_t *)p_vout
var: "video-device" selector: @selector(toggleVar:)];
vlc_object_release( (vlc_object_t *)p_vout );
}
- (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];
[o_mi_subtitle 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];
[o_mi_teletext setEnabled: b_enabled];
}
#pragma mark -
#pragma mark Recent Items
- (void)openRecentItem:(id)item
{
[[VLCMain sharedInstance] application: nil openFile: [item title]];
}
- (IBAction)clearRecentItems:(id)sender
{
[[NSDocumentController sharedDocumentController]
clearRecentDocuments: nil];
}
#pragma mark -
#pragma mark Panels
- (IBAction)intfOpenFile:(id)sender
{
[[[VLCMain sharedInstance] open] openFile];
}
- (IBAction)intfOpenFileGeneric:(id)sender
{
[[[VLCMain sharedInstance] open] openFileGeneric];
}
- (IBAction)intfOpenDisc:(id)sender
{
[[[VLCMain sharedInstance] open] openDisc];
}
- (IBAction)intfOpenNet:(id)sender
{
[[[VLCMain sharedInstance] open] openNet];
}
- (IBAction)intfOpenCapture:(id)sender
{
[[[VLCMain sharedInstance] open] openCapture];
}
- (IBAction)showWizard:(id)sender
{
[[[VLCMain sharedInstance] wizard] resetWizard];
[[[VLCMain sharedInstance] wizard] showWizard];
}
- (IBAction)showVideoEffects:(id)sender
{
if( o_videoeffects == nil )
o_videoeffects = [[VLCVideoEffects alloc] init];
if( !b_nib_videoeffects_loaded )
b_nib_videoeffects_loaded = [NSBundle loadNibNamed:@"VideoEffects" owner: NSApp];
[o_videoeffects toggleWindow:sender];
}
- (IBAction)showTrackSynchronization:(id)sender
{
if (!o_trackSynchronization)
o_trackSynchronization = [[VLCTrackSynchronization alloc] init];
if (!b_nib_tracksynchro_loaded)
b_nib_tracksynchro_loaded = [NSBundle loadNibNamed:@"SyncTracks" owner:NSApp];
[o_trackSynchronization toggleWindow:sender];
}
- (IBAction)showAudioEffects:(id)sender
{
if (!o_audioeffects)
o_audioeffects = [[VLCAudioEffects alloc] init];
if (!b_nib_audioeffects_loaded)
b_nib_audioeffects_loaded = [NSBundle loadNibNamed:@"AudioEffects" owner:NSApp];
[o_audioeffects toggleWindow:sender];
}
- (IBAction)showBookmarks:(id)sender
{
[[[VLCMain sharedInstance] bookmarks] showBookmarks];
}
- (IBAction)viewPreferences:(id)sender
{
[[[VLCMain sharedInstance] simplePreferences] showSimplePrefs];
}
#pragma mark -
#pragma mark Help and Docs
- (void)initAbout
{
if(! o_about )
o_about = [[VLAboutBox alloc] init];
if( !b_nib_about_loaded )
b_nib_about_loaded = [NSBundle loadNibNamed:@"About" owner: NSApp];
}
- (IBAction)viewAbout:(id)sender
{
[self initAbout];
[o_about showAbout];
}
- (IBAction)showLicense:(id)sender
{
[self initAbout];
[o_about showGPL: sender];
}
- (IBAction)viewHelp:(id)sender
{
[self initAbout];
[o_about showHelp];
}
- (IBAction)openReadMe:(id)sender
{
NSString * o_path = [[NSBundle mainBundle] pathForResource: @"README.MacOSX" ofType: @"rtf"];
[[NSWorkspace sharedWorkspace] openFile: o_path withApplication: @"TextEdit"];
}
- (IBAction)openDocumentation:(id)sender
{
NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org/doc/"];
[[NSWorkspace sharedWorkspace] openURL: o_url];
}
- (IBAction)openWebsite:(id)sender
{
NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org/"];
[[NSWorkspace sharedWorkspace] openURL: o_url];
}
- (IBAction)openForum:(id)sender
{
NSURL * o_url = [NSURL URLWithString: @"http://forum.videolan.org/"];
[[NSWorkspace sharedWorkspace] openURL: o_url];
}
- (IBAction)openDonate:(id)sender
{
NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org/contribute.html#paypal"];
[[NSWorkspace sharedWorkspace] openURL: o_url];
}
#pragma mark -
#pragma mark Errors, warnings and messages
- (IBAction)viewErrorsAndWarnings:(id)sender
{
[[[[VLCMain sharedInstance] coreDialogProvider] errorPanel] showPanel];
}
- (IBAction)showInformationPanel:(id)sender
{
[[[VLCMain sharedInstance] info] initPanel];
}
#pragma mark -
#pragma mark convinience stuff for other objects
- (void)setPlay
{
[o_mi_play setTitle: _NS("Play")];
[o_dmi_play setTitle: _NS("Play")];
[o_vmi_play setTitle: _NS("Play")];
}
- (void)setPause
{
[o_mi_play setTitle: _NS("Pause")];
[o_dmi_play setTitle: _NS("Pause")];
[o_vmi_play setTitle: _NS("Pause")];
}
#pragma mark -
#pragma mark Dynamic menu creation and validation
- (void)setupVarMenuItem:(NSMenuItem *)o_mi
target:(vlc_object_t *)p_object
var:(const char *)psz_variable
selector:(SEL)pf_callback
{
vlc_value_t val, text;
int i_type = var_Type( p_object, psz_variable );
switch( i_type & VLC_VAR_TYPE )
{
case VLC_VAR_VOID:
case VLC_VAR_BOOL:
case VLC_VAR_VARIABLE:
case VLC_VAR_STRING:
case VLC_VAR_INTEGER:
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 )
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 ]];
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 );
return;
}
if( var_Get( p_object, psz_variable, &val ) < 0 )
{
return;
}
VLCAutoGeneratedMenuContent *o_data;
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];
[o_mi setRepresentedObject: [o_data autorelease]];
break;
case VLC_VAR_BOOL:
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 ) )
[o_mi setState: val.b_bool ? TRUE : FALSE ];
break;
default:
break;
}
if( ( i_type & VLC_VAR_TYPE ) == VLC_VAR_STRING ) free( val.psz_string );
free( text.psz_string );
}
- (void)setupVarMenu:(NSMenu *)o_menu
forMenuItem: (NSMenuItem *)o_parent
target:(vlc_object_t *)p_object
var:(const char *)psz_variable
selector:(SEL)pf_callback
{
vlc_value_t val, val_list, text_list;
int i_type, i, i_nb_items;
/* remove previous items */
i_nb_items = [o_menu numberOfItems];
for( i = 0; i < i_nb_items; i++ )
[o_menu removeItemAtIndex: 0];
/* Check the type of the object 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 )
return;
}
else
return;
switch( i_type & VLC_VAR_TYPE )
{
case VLC_VAR_VOID:
case VLC_VAR_BOOL:
case VLC_VAR_VARIABLE:
case VLC_VAR_STRING:
case VLC_VAR_INTEGER:
break;
default:
/* Variable doesn't exist or isn't handled */
return;
}
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 );
return;
}
/* make (un)sensitive */
[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: [[[VLCMain sharedInstance] controls] 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++ )
{
NSMenuItem * o_lmi;
NSString *o_title = @"";
VLCAutoGeneratedMenuContent *o_data;
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_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
andValue: val_list.p_list->p_values[i] ofType: i_type];
[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 ) )
[o_lmi setState: TRUE ];
break;
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];
o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
andValue: val_list.p_list->p_values[i] ofType: i_type];
[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 ) )
[o_lmi setState: TRUE ];
break;
default:
break;
}
}
/* 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 );
}
- (IBAction)toggleVar:(id)sender
{
NSMenuItem *o_mi = (NSMenuItem *)sender;
VLCAutoGeneratedMenuContent *o_data = [o_mi representedObject];
[NSThread detachNewThreadSelector: @selector(toggleVarThread:)
toTarget: self withObject: o_data];
return;
}
- (int)toggleVarThread: (id)data
{
vlc_object_t *p_object;
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
assert([data isKindOfClass:[VLCAutoGeneratedMenuContent class]]);
VLCAutoGeneratedMenuContent *menuContent = (VLCAutoGeneratedMenuContent *)data;
p_object = [menuContent vlcObject];
if( p_object != NULL )
{
var_Set( p_object, [menuContent name], [menuContent value] );
vlc_object_release( p_object );
[o_pool release];
return true;
}
[o_pool release];
return VLC_EGENERIC;
}
@end
@implementation VLCMainMenu (NSMenuValidation)
- (BOOL)validateMenuItem:(NSMenuItem *)o_mi
{
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 );
/* Recent Items Menu */
if( [o_title isEqualToString: _NS("Clear Menu")] )
{
NSMenu * o_menu = [o_mi_open_recent submenu];
int i_nb_items = [o_menu numberOfItems];
NSArray * o_docs = [[NSDocumentController sharedDocumentController]
recentDocumentURLs];
UInt32 i_nb_docs = [o_docs count];
if( i_nb_items > 1 )
{
while( --i_nb_items )
{
[o_menu removeItemAtIndex: 0];
}
}
if( i_nb_docs > 0 )
{
NSURL * o_url;
NSString * o_doc;
[o_menu insertItem: [NSMenuItem separatorItem] atIndex: 0];
while( TRUE )
{
i_nb_docs--;
o_url = [o_docs objectAtIndex: i_nb_docs];
if( [o_url isFileURL] )
o_doc = [o_url path];
else
o_doc = [o_url absoluteString];
[o_menu insertItemWithTitle: o_doc
action: @selector(openRecentItem:)
keyEquivalent: @"" atIndex: 0];
if( i_nb_docs == 0 )
break;
}
}
else
{
bEnabled = FALSE;
}
}
else if( [o_title isEqualToString: _NS("Faster")] ||
[o_title isEqualToString: _NS("Slower")] ||
[o_title isEqualToString: _NS("Normal rate")] )
{
if( p_input != NULL )
{
bEnabled = var_GetBool( p_input, "can-rate" );
}
else
{
bEnabled = FALSE;
}
}
else if( [o_title isEqualToString: _NS("Stop")] )
{
if( p_input == NULL )
{
bEnabled = FALSE;
}
[self setupMenus]; /* Make sure input menu is up to date */
}
else if( [o_title isEqualToString: _NS("Previous")] ||
[o_title isEqualToString: _NS("Next")] )
{
PL_LOCK;
bEnabled = playlist_CurrentSize( p_playlist ) > 1;
PL_UNLOCK;
}
else if( [o_title isEqualToString: _NS("Random")] )
{
int i_state;
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")] )
{
int i_state;
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")] )
{
int i_state;
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")] )
{
int i_state;
var_Get( p_playlist, "play-and-exit", &val );
i_state = val.b_bool ? 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);
bEnabled = val.b_bool;
}
else bEnabled = FALSE;
}
else if( [o_title isEqualToString: _NS("Mute")] )
{
[o_mi setState: p_intf->p_sys->b_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")] )
{
id o_window;
NSArray *o_windows = [NSApp orderedWindows];
NSEnumerator *o_enumerator = [o_windows objectEnumerator];
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")] )
{
var_Get( p_vout, "video-on-top", &val );
[o_mi setState: val.b_bool ? NSOnState : NSOffState];
}
while( (o_window = [o_enumerator nextObject]))
{
if( [[o_window className] isEqualToString: @"VLCVoutWindow"] ||
[[[VLCMain sharedInstance] embeddedList]
windowContainsEmbedded: o_window])
{
bEnabled = TRUE;
break;
}
}
vlc_object_release( (vlc_object_t *)p_vout );
}
}
if( [o_title isEqualToString: _NS("Fullscreen")] )
{
var_Get( p_playlist, "fullscreen", &val );
[o_mi setState: val.b_bool];
bEnabled = TRUE;
}
[self setupMenus]; /* Make sure video menu is up to date */
}
/* Special case for telx menu */
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;
[[item submenu] setAutoenablesItems:NO];
for( int k=0; k < [[item submenu] numberOfItems]; k++ )
{
[[[item submenu] itemAtIndex:k] setEnabled: b_telx];
}
}
if( p_input ) vlc_object_release( p_input );
return( bEnabled );
}
@end
/*****************************************************************************
* VLCAutoGeneratedMenuContent implementation
*****************************************************************************
* Object connected to a playlistitem which remembers the data belonging to
* the variable of the autogenerated menu
*****************************************************************************/
@implementation VLCAutoGeneratedMenuContent
-(id) initWithVariableName:(const char *)name ofObject:(vlc_object_t *)object
andValue:(vlc_value_t)val ofType:(int)type
{
self = [super init];
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 );
}
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 );
[super dealloc];
}
- (const char *)name
{
return psz_name;
}
- (vlc_value_t)value
{
return value;
}
- (vlc_object_t *)vlcObject
{
return vlc_object_hold( _vlc_object );
}
- (int)type
{
return i_type;
}
@end
......@@ -10,6 +10,8 @@ SOURCES_macosx = \
SPInvocationGrabbing.m \
SPMediaKeyTap.h \
SPMediaKeyTap.m \
MainMenu.h \
MainMenu.m \
about.h \
about.m \
applescript.h \
......
......@@ -94,48 +94,12 @@
- (BOOL)keyEvent:(NSEvent *)o_event;
- (void)scrollWheel: (NSEvent *)theEvent;
- (void)setupVarMenuItem:(NSMenuItem *)o_mi
target:(vlc_object_t *)p_object
var:(const char *)psz_variable
selector:(SEL)pf_callback;
- (void)setupVarMenu:(NSMenu *)o_menu
forMenuItem: (NSMenuItem *)o_parent
target:(vlc_object_t *)p_object
var:(const char *)psz_variable
selector:(SEL)pf_callback;
- (IBAction)toggleVar:(id)sender;
- (int)toggleVarThread:(id)_o_data;
- (IBAction)goToSpecificTime:(id)sender;
- (id)fspanel;
@end
/*****************************************************************************
* VLCAutoGeneratedMenuContent interface
*****************************************************************************
* This holds our data for autogenerated menus
*****************************************************************************/
@interface VLCAutoGeneratedMenuContent : NSObject
{
char *psz_name;
vlc_object_t * _vlc_object;
vlc_value_t value;
int i_type;
}
- (id)initWithVariableName: (const char *)name
ofObject: (vlc_object_t *)object
andValue: (vlc_value_t)value
ofType: (int)type;
- (const char *)name;
- (vlc_value_t)value;
- (vlc_object_t *)vlcObject;
- (int)type;
@end
/*****************************************************************************
* VLCTimeField interface
*****************************************************************************
......
......@@ -84,7 +84,7 @@
PL_UNLOCK;
if( empty )
[o_main intfOpenFileGeneric: (id)sender];
[[VLCOpen sharedInstance] openFileGeneric];
var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_PLAY_PAUSE );
}
......@@ -626,255 +626,6 @@
return eventHandled;
}
- (void)setupVarMenuItem:(NSMenuItem *)o_mi
target:(vlc_object_t *)p_object
var:(const char *)psz_variable
selector:(SEL)pf_callback
{
vlc_value_t val, text;
int i_type = var_Type( p_object, psz_variable );
switch( i_type & VLC_VAR_TYPE )
{
case VLC_VAR_VOID:
case VLC_VAR_BOOL:
case VLC_VAR_VARIABLE:
case VLC_VAR_STRING:
case VLC_VAR_INTEGER:
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 )
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 ]];
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 );
return;
}
if( var_Get( p_object, psz_variable, &val ) < 0 )
{
return;
}
VLCAutoGeneratedMenuContent *o_data;
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];
[o_mi setRepresentedObject: [o_data autorelease]];
break;
case VLC_VAR_BOOL:
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 ) )
[o_mi setState: val.b_bool ? TRUE : FALSE ];
break;
default:
break;
}
if( ( i_type & VLC_VAR_TYPE ) == VLC_VAR_STRING ) free( val.psz_string );
free( text.psz_string );
}
- (void)setupVarMenu:(NSMenu *)o_menu
forMenuItem: (NSMenuItem *)o_parent
target:(vlc_object_t *)p_object
var:(const char *)psz_variable
selector:(SEL)pf_callback
{
vlc_value_t val, val_list, text_list;
int i_type, i, i_nb_items;
/* remove previous items */
i_nb_items = [o_menu numberOfItems];
for( i = 0; i < i_nb_items; i++ )
{
[o_menu removeItemAtIndex: 0];
}
/* Check the type of the object 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 )
return;
}
else
{
return;
}
switch( i_type & VLC_VAR_TYPE )
{
case VLC_VAR_VOID:
case VLC_VAR_BOOL:
case VLC_VAR_VARIABLE:
case VLC_VAR_STRING:
case VLC_VAR_INTEGER:
break;
default:
/* Variable doesn't exist or isn't handled */
return;
}
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 );
return;
}
/* make (un)sensitive */
[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: b_lockAspectRatio];
[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++ )
{
NSMenuItem * o_lmi;
NSString *o_title = @"";
VLCAutoGeneratedMenuContent *o_data;
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_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
andValue: val_list.p_list->p_values[i] ofType: i_type];
[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 ) )
[o_lmi setState: TRUE ];
break;
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];
o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
andValue: val_list.p_list->p_values[i] ofType: i_type];
[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 ) )
[o_lmi setState: TRUE ];
break;
default:
break;
}
}
/* 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 );
}
- (IBAction)toggleVar:(id)sender
{
NSMenuItem *o_mi = (NSMenuItem *)sender;
VLCAutoGeneratedMenuContent *o_data = [o_mi representedObject];
[NSThread detachNewThreadSelector: @selector(toggleVarThread:)
toTarget: self withObject: o_data];
return;
}
- (int)toggleVarThread: (id)data
{
vlc_object_t *p_object;
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
assert([data isKindOfClass:[VLCAutoGeneratedMenuContent class]]);
VLCAutoGeneratedMenuContent *menuContent = (VLCAutoGeneratedMenuContent *)data;
p_object = [menuContent vlcObject];
if( p_object != NULL )
{
var_Set( p_object, [menuContent name], [menuContent value] );
vlc_object_release( p_object );
[o_pool release];
return true;
}
[o_pool release];
return VLC_EGENERIC;
}
- (IBAction)goToSpecificTime:(id)sender
{
if( sender == o_specificTime_cancel_btn )
......@@ -951,214 +702,6 @@
@end
@implementation VLCControls (NSMenuValidation)
- (BOOL)validateMenuItem:(NSMenuItem *)o_mi
{
BOOL bEnabled = TRUE;
vlc_value_t val;
intf_thread_t * p_intf = VLCIntf;
playlist_t * p_playlist = pl_Get( p_intf );
input_thread_t * p_input = playlist_CurrentInput( p_playlist );
if( [[o_mi title] isEqualToString: _NS("Faster")] ||
[[o_mi title] isEqualToString: _NS("Slower")] ||
[[o_mi title] isEqualToString: _NS("Normal rate")] )
{
if( p_input != NULL )
{
bEnabled = var_GetBool( p_input, "can-rate" );
}
else
{
bEnabled = FALSE;
}
}
else if( [[o_mi title] isEqualToString: _NS("Stop")] )
{
if( p_input == NULL )
{
bEnabled = FALSE;
}
[o_main setupMenus]; /* Make sure input menu is up to date */
}
else if( [[o_mi title] isEqualToString: _NS("Previous")] ||
[[o_mi title] isEqualToString: _NS("Next")] )
{
PL_LOCK;
bEnabled = playlist_CurrentSize( p_playlist ) > 1;
PL_UNLOCK;
}
else if( [[o_mi title] isEqualToString: _NS("Random")] )
{
int i_state;
var_Get( p_playlist, "random", &val );
i_state = val.b_bool ? NSOnState : NSOffState;
[o_mi setState: i_state];
}
else if( [[o_mi title] isEqualToString: _NS("Repeat One")] )
{
int i_state;
var_Get( p_playlist, "repeat", &val );
i_state = val.b_bool ? NSOnState : NSOffState;
[o_mi setState: i_state];
}
else if( [[o_mi title] isEqualToString: _NS("Repeat All")] )
{
int i_state;
var_Get( p_playlist, "loop", &val );
i_state = val.b_bool ? NSOnState : NSOffState;
[o_mi setState: i_state];
}
else if( [[o_mi title] isEqualToString: _NS("Quit after Playback")] )
{
int i_state;
var_Get( p_playlist, "play-and-exit", &val );
i_state = val.b_bool ? NSOnState : NSOffState;
[o_mi setState: i_state];
}
else if( [[o_mi title] isEqualToString: _NS("Step Forward")] ||
[[o_mi title] isEqualToString: _NS("Step Backward")] ||
[[o_mi 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_mi title] isEqualToString: _NS("Mute")] )
{
[o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState];
[o_main setupMenus]; /* Make sure audio menu is up to date */
}
else if( [[o_mi title] isEqualToString: _NS("Half Size")] ||
[[o_mi title] isEqualToString: _NS("Normal Size")] ||
[[o_mi title] isEqualToString: _NS("Double Size")] ||
[[o_mi title] isEqualToString: _NS("Fit to Screen")] ||
[[o_mi title] isEqualToString: _NS("Snapshot")] ||
[[o_mi title] isEqualToString: _NS("Fullscreen")] ||
[[o_mi title] isEqualToString: _NS("Float on Top")] )
{
id o_window;
NSArray *o_windows = [NSApp orderedWindows];
NSEnumerator *o_enumerator = [o_windows objectEnumerator];
bEnabled = FALSE;
if( p_input != NULL )
{
vout_thread_t *p_vout = input_GetVout( p_input );
if( p_vout != NULL )
{
if( [[o_mi title] isEqualToString: _NS("Float on Top")] )
{
var_Get( p_vout, "video-on-top", &val );
[o_mi setState: val.b_bool ? NSOnState : NSOffState];
}
while( (o_window = [o_enumerator nextObject]))
{
if( [[o_window className] isEqualToString: @"VLCVoutWindow"] ||
[[[VLCMain sharedInstance] embeddedList]
windowContainsEmbedded: o_window])
{
bEnabled = TRUE;
break;
}
}
vlc_object_release( (vlc_object_t *)p_vout );
}
}
if( [[o_mi title] isEqualToString: _NS("Fullscreen")] )
{
var_Get( p_playlist, "fullscreen", &val );
[o_mi setState: val.b_bool];
bEnabled = TRUE;
}
[o_main setupMenus]; /* Make sure video menu is up to date */
}
/* Special case for telx menu */
if( [[o_mi 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;
[[item submenu] setAutoenablesItems:NO];
for( int k=0; k < [[item submenu] numberOfItems]; k++ )
{
[[[item submenu] itemAtIndex:k] setEnabled: b_telx];
}
}
if( p_input ) vlc_object_release( p_input );
return( bEnabled );
}
@end
/*****************************************************************************
* VLCAutoGeneratedMenuContent implementation
*****************************************************************************
* Object connected to a playlistitem which remembers the data belonging to
* the variable of the autogenerated menu
*****************************************************************************/
@implementation VLCAutoGeneratedMenuContent
-(id) initWithVariableName:(const char *)name ofObject:(vlc_object_t *)object
andValue:(vlc_value_t)val ofType:(int)type
{
self = [super init];
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 );
}
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 );
[super dealloc];
}
- (const char *)name
{
return psz_name;
}
- (vlc_value_t)value
{
return value;
}
- (vlc_object_t *)vlcObject
{
return vlc_object_hold( _vlc_object );
}
- (int)type
{
return i_type;
}
@end
/*****************************************************************************
* VLCTimeField implementation
*****************************************************************************
......
......@@ -100,36 +100,29 @@ struct intf_sys_t
@interface VLCMain : NSObject
{
intf_thread_t *p_intf; /* The main intf object */
id o_mainmenu; /* VLCMainMenu */
id o_prefs; /* VLCPrefs */
id o_sprefs; /* VLCSimplePrefs */
id o_about; /* VLAboutBox */
id o_open; /* VLCOpen */
id o_wizard; /* VLCWizard */
id o_videoeffects; /* VLCVideoEffects */
id o_bookmarks; /* VLCBookmarks */
id o_embedded_list; /* VLCEmbeddedList*/
id o_coredialogs; /* VLCCoreDialogProvider */
VLCInformation * o_info; /* VLCInformation */
id o_eyetv; /* VLCEyeTVController */
id o_audioeffects; /* VLCAudioEffects */
id o_trackSynchronization; /* VLCTrackSynchronization */
id o_bookmarks; /* VLCBookmarks */
BOOL nib_main_loaded; /* main nibfile */
BOOL nib_open_loaded; /* open nibfile */
BOOL nib_about_loaded; /* about nibfile */
BOOL nib_wizard_loaded; /* wizard nibfile */
BOOL nib_bookmarks_loaded; /* bookmarks nibfile */
BOOL nib_prefs_loaded; /* preferences nibfile */
BOOL nib_info_loaded; /* information panel nibfile */
BOOL nib_coredialogs_loaded; /* CoreDialogs nibfile */
BOOL nib_audioeffects_loaded; /* audio effects panel */
BOOL nib_tracksynchro_loaded; /* track synchro panel */
BOOL nib_videoeffects_loaded; /* video effects panel */
BOOL nib_bookmarks_loaded; /* Bookmarks nibfile */
IBOutlet VLCControllerWindow * o_window; /* main window */
IBOutlet NSView * o_playlist_view; /* playlist view */
IBOutlet id o_scrollfield; /* info field */
IBOutlet NSTextField * o_timefield; /* time field */
IBOutlet NSSlider * o_timeslider; /* time slider */
IBOutlet NSSlider * o_timeslider; /* time slider */
BOOL b_time_remaining; /* show remaining time or playtime ? */
IBOutlet VLCEmbeddedWindow * o_embedded_window; /* Embedded Vout Window */
float f_slider; /* slider value */
......@@ -173,151 +166,6 @@ struct intf_sys_t
IBOutlet NSButton * o_crashrep_includeEmail_ckb;
IBOutlet NSTextField * o_crashrep_includeEmail_txt;
/* main menu */
IBOutlet NSMenuItem * o_mi_about;
IBOutlet NSMenuItem * o_mi_prefs;
IBOutlet NSMenuItem * o_mi_sprefs;
IBOutlet NSMenuItem * o_mi_checkForUpdate;
IBOutlet NSMenuItem * o_mi_add_intf;
IBOutlet NSMenu * o_mu_add_intf;
IBOutlet NSMenuItem * o_mi_services;
IBOutlet NSMenuItem * o_mi_hide;
IBOutlet NSMenuItem * o_mi_hide_others;
IBOutlet NSMenuItem * o_mi_show_all;
IBOutlet NSMenuItem * o_mi_quit;
IBOutlet NSMenu * o_mu_file;
IBOutlet NSMenuItem * o_mi_open_file;
IBOutlet NSMenuItem * o_mi_open_generic;
IBOutlet NSMenuItem * o_mi_open_disc;
IBOutlet NSMenuItem * o_mi_open_net;
IBOutlet NSMenuItem * o_mi_open_capture;
IBOutlet NSMenuItem * o_mi_open_recent;
IBOutlet NSMenuItem * o_mi_open_recent_cm;
IBOutlet NSMenuItem * o_mi_open_wizard;
IBOutlet NSMenu * o_mu_edit;
IBOutlet NSMenuItem * o_mi_cut;
IBOutlet NSMenuItem * o_mi_copy;
IBOutlet NSMenuItem * o_mi_paste;
IBOutlet NSMenuItem * o_mi_clear;
IBOutlet NSMenuItem * o_mi_select_all;
IBOutlet NSMenu * o_mu_controls;
IBOutlet NSMenuItem * o_mi_play;
IBOutlet NSMenuItem * o_mi_stop;
IBOutlet NSMenuItem * o_mi_faster;
IBOutlet NSMenuItem * o_mi_slower;
IBOutlet NSMenuItem * o_mi_normalSpeed;
IBOutlet NSMenuItem * o_mi_trackSynchronization;
IBOutlet NSMenuItem * o_mi_previous;
IBOutlet NSMenuItem * o_mi_next;
IBOutlet NSMenuItem * o_mi_random;
IBOutlet NSMenuItem * o_mi_repeat;
IBOutlet NSMenuItem * o_mi_loop;
IBOutlet NSMenuItem * o_mi_quitAfterPB;
IBOutlet NSMenuItem * o_mi_fwd;
IBOutlet NSMenuItem * o_mi_bwd;
IBOutlet NSMenuItem * o_mi_fwd1m;
IBOutlet NSMenuItem * o_mi_bwd1m;
IBOutlet NSMenuItem * o_mi_fwd5m;
IBOutlet NSMenuItem * o_mi_bwd5m;
IBOutlet NSMenuItem * o_mi_program;
IBOutlet NSMenu * o_mu_program;
IBOutlet NSMenuItem * o_mi_title;
IBOutlet NSMenu * o_mu_title;
IBOutlet NSMenuItem * o_mi_chapter;
IBOutlet NSMenu * o_mu_chapter;
IBOutlet NSMenu * o_mu_audio;
IBOutlet NSMenuItem * o_mi_vol_up;
IBOutlet NSMenuItem * o_mi_vol_down;
IBOutlet NSMenuItem * o_mi_mute;
IBOutlet NSMenuItem * o_mi_audiotrack;
IBOutlet NSMenu * o_mu_audiotrack;
IBOutlet NSMenuItem * o_mi_channels;
IBOutlet NSMenu * o_mu_channels;
IBOutlet NSMenuItem * o_mi_device;
IBOutlet NSMenu * o_mu_device;
IBOutlet NSMenuItem * o_mi_visual;
IBOutlet NSMenu * o_mu_visual;
IBOutlet NSMenu * o_mu_video;
IBOutlet NSMenuItem * o_mi_half_window;
IBOutlet NSMenuItem * o_mi_normal_window;
IBOutlet NSMenuItem * o_mi_double_window;
IBOutlet NSMenuItem * o_mi_fittoscreen;
IBOutlet NSMenuItem * o_mi_fullscreen;
IBOutlet NSMenuItem * o_mi_floatontop;
IBOutlet NSMenuItem * o_mi_snapshot;
IBOutlet NSMenuItem * o_mi_videotrack;
IBOutlet NSMenu * o_mu_videotrack;
IBOutlet NSMenuItem * o_mi_screen;
IBOutlet NSMenu * o_mu_screen;
IBOutlet NSMenuItem * o_mi_aspect_ratio;
IBOutlet NSMenu * o_mu_aspect_ratio;
IBOutlet NSMenuItem * o_mi_crop;
IBOutlet NSMenu * o_mu_crop;
IBOutlet NSMenuItem * o_mi_subtitle;
IBOutlet NSMenu * o_mu_subtitle;
IBOutlet NSMenuItem * o_mi_addSub;
IBOutlet NSMenuItem * o_mi_deinterlace;
IBOutlet NSMenu * o_mu_deinterlace;
IBOutlet NSMenuItem * o_mi_deinterlace_mode;
IBOutlet NSMenu * o_mu_deinterlace_mode;
IBOutlet NSMenuItem * o_mi_ffmpeg_pp;
IBOutlet NSMenu * o_mu_ffmpeg_pp;
IBOutlet NSMenuItem * o_mi_teletext;
IBOutlet NSMenuItem * o_mi_teletext_transparent;
IBOutlet NSMenuItem * o_mi_teletext_index;
IBOutlet NSMenuItem * o_mi_teletext_red;
IBOutlet NSMenuItem * o_mi_teletext_green;
IBOutlet NSMenuItem * o_mi_teletext_yellow;
IBOutlet NSMenuItem * o_mi_teletext_blue;
IBOutlet NSMenu * o_mu_window;
IBOutlet NSMenuItem * o_mi_minimize;
IBOutlet NSMenuItem * o_mi_close_window;
IBOutlet NSMenuItem * o_mi_player;
IBOutlet NSMenuItem * o_mi_controller;
IBOutlet NSMenuItem * o_mi_audioeffects;
IBOutlet NSMenuItem * o_mi_videoeffects;
IBOutlet NSMenuItem * o_mi_bookmarks;
IBOutlet NSMenuItem * o_mi_playlist;
IBOutlet NSMenuItem * o_mi_info;
IBOutlet NSMenuItem * o_mi_messages;
IBOutlet NSMenuItem * o_mi_bring_atf;
IBOutlet NSMenu * o_mu_help;
IBOutlet NSMenuItem * o_mi_help;
IBOutlet NSMenuItem * o_mi_readme;
IBOutlet NSMenuItem * o_mi_documentation;
IBOutlet NSMenuItem * o_mi_license;
IBOutlet NSMenuItem * o_mi_website;
IBOutlet NSMenuItem * o_mi_donation;
IBOutlet NSMenuItem * o_mi_forum;
IBOutlet NSMenuItem * o_mi_errorsAndWarnings;
/* dock menu */
IBOutlet NSMenuItem * o_dmi_play;
IBOutlet NSMenuItem * o_dmi_stop;
IBOutlet NSMenuItem * o_dmi_next;
IBOutlet NSMenuItem * o_dmi_previous;
IBOutlet NSMenuItem * o_dmi_mute;
/* vout menu */
IBOutlet NSMenu * o_vout_menu;
IBOutlet NSMenuItem * o_vmi_play;
IBOutlet NSMenuItem * o_vmi_stop;
IBOutlet NSMenuItem * o_vmi_prev;
IBOutlet NSMenuItem * o_vmi_next;
IBOutlet NSMenuItem * o_vmi_volup;
IBOutlet NSMenuItem * o_vmi_voldown;
IBOutlet NSMenuItem * o_vmi_mute;
IBOutlet NSMenuItem * o_vmi_fullscreen;
IBOutlet NSMenuItem * o_vmi_snapshot;
mtime_t i_end_scroll;
int i_lastShownVolume;
......@@ -348,19 +196,20 @@ struct intf_sys_t
- (intf_thread_t *)intf;
- (void)setIntf:(intf_thread_t *)p_mainintf;
- (id)mainMenu;
- (id)controls;
- (id)bookmarks;
- (id)open;
- (id)simplePreferences;
- (id)preferences;
- (id)playlist;
- (BOOL)isPlaylistCollapsed;
- (id)info;
- (id)wizard;
- (id)bookmarks;
- (id)embeddedList;
- (id)coreDialogProvider;
- (id)mainIntfPgbar;
- (id)controllerWindow;
- (id)voutMenu;
- (id)eyeTVController;
- (id)appleRemoteController;
- (void)applicationWillTerminate:(NSNotification *)notification;
......@@ -373,52 +222,25 @@ struct intf_sys_t
- (void)updateCurrentlyUsedHotkeys;
- (void)initStrings;
- (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename;
- (void)manage;
- (void)manageIntf:(NSTimer *)o_timer;
- (void)setupMenus;
- (void)refreshVoutDeviceMenu:(NSNotification *)o_notification;
- (void)setScrollField:(NSString *)o_string stopAfter:(int )timeout;
- (void)resetScrollField;
- (void)updateMessageDisplay;
- (void)playStatusUpdated:(int) i_status;
- (void)setSubmenusEnabled:(BOOL)b_enabled;
- (void)manageVolumeSlider;
- (IBAction)timesliderUpdate:(id)sender;
- (IBAction)timeFieldWasClicked:(id)sender;
- (IBAction)clearRecentItems:(id)sender;
- (void)openRecentItem:(id)sender;
- (IBAction)intfOpenFile:(id)sender;
- (IBAction)intfOpenFileGeneric:(id)sender;
- (IBAction)intfOpenDisc:(id)sender;
- (IBAction)intfOpenNet:(id)sender;
- (IBAction)intfOpenCapture:(id)sender;
- (IBAction)showWizard:(id)sender;
- (IBAction)showVideoEffects:(id)sender;
- (IBAction)showAudioEffects:(id)sender;
- (IBAction)showTrackSynchronization:(id)sender;
- (IBAction)showBookmarks:(id)sender;
- (IBAction)viewAbout:(id)sender;
- (IBAction)showLicense:(id)sender;
- (IBAction)viewPreferences:(id)sender;
- (IBAction)viewHelp:(id)sender;
- (IBAction)openReadMe:(id)sender;
- (IBAction)openDocumentation:(id)sender;
- (IBAction)openWebsite:(id)sender;
- (IBAction)openForum:(id)sender;
- (IBAction)openDonate:(id)sender;
- (IBAction)openCrashLog:(id)sender;
- (IBAction)viewErrorsAndWarnings:(id)sender;
- (IBAction)showMessagesPanel:(id)sender;
- (IBAction)showInformationPanel:(id)sender;
- (IBAction)showController:(id)sender;
- (IBAction)crashReporterAction:(id)sender;
- (IBAction)openCrashLog:(id)sender;
- (IBAction)saveDebugLog:(id)sender;
- (IBAction)showMessagesPanel:(id)sender;
- (IBAction)togglePlaylist:(id)sender;
- (void)updateTogglePlaylistState;
......
......@@ -38,13 +38,13 @@
#include <unistd.h> /* execl() */
#import "intf.h"
#import "MainMenu.h"
#import "fspanel.h"
#import "vout.h"
#import "prefs.h"
#import "playlist.h"
#import "playlistinfo.h"
#import "controls.h"
#import "about.h"
#import "open.h"
#import "wizard.h"
#import "bookmarks.h"
......@@ -53,9 +53,6 @@
#import "AppleRemote.h"
#import "eyetv.h"
#import "simple_prefs.h"
#import "AudioEffects.h"
#import "VideoEffects.h"
#import "TrackSynchronization.h"
#import <AddressBook/AddressBook.h> /* for crashlog send mechanism */
#import <Sparkle/Sparkle.h> /* we're the update delegate */
......@@ -341,14 +338,11 @@ static VLCMain *_o_sharedMainInstance = nil;
/* subscribe to LibVLC's debug messages as early as possible (for us) */
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(libvlcMessageReceived:) name: @"VLCCoreMessageReceived" object: nil];
o_about = [[VLAboutBox alloc] init];
o_prefs = nil;
o_open = [[VLCOpen alloc] init];
o_wizard = [[VLCWizard alloc] init];
o_bookmarks = [[VLCBookmarks alloc] init];
//o_embedded_list = [[VLCEmbeddedList alloc] init];
o_coredialogs = [[VLCCoreDialogProvider alloc] init];
o_info = [[VLCInfo alloc] init];
o_mainmenu = [[VLCMainMenu alloc] init];
i_lastShownVolume = -1;
......@@ -372,98 +366,16 @@ static VLCMain *_o_sharedMainInstance = nil;
- (void)awakeFromNib
{
NSString* o_key;
playlist_t *p_playlist;
vlc_value_t val;
if( !p_intf ) return;
/* Check if we already did this once. Opening the other nibs calls it too,
because VLCMain is the owner */
if( nib_main_loaded ) return;
[self initStrings];
[o_window setExcludedFromWindowsMenu: YES];
[o_msgs_panel setExcludedFromWindowsMenu: YES];
[o_msgs_panel setDelegate: self];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-quit" )];
[o_mi_quit setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_quit setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-play-pause" )];
[o_mi_play setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_play setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-stop" )];
[o_mi_stop setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_stop setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-faster" )];
[o_mi_faster setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_faster setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-slower" )];
[o_mi_slower setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_slower setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-rate-normal" )];
[o_mi_normalSpeed setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_normalSpeed setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-prev" )];
[o_mi_previous setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_previous setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-next" )];
[o_mi_next setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_next setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-jump+short" )];
[o_mi_fwd setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_fwd setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-jump-short" )];
[o_mi_bwd setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_bwd setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-jump+medium" )];
[o_mi_fwd1m setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_fwd1m setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-jump-medium" )];
[o_mi_bwd1m setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_bwd1m setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-jump+long" )];
[o_mi_fwd5m setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_fwd5m setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-jump-long" )];
[o_mi_bwd5m setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_bwd5m setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-vol-up" )];
[o_mi_vol_up setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_vol_up setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-vol-down" )];
[o_mi_vol_down setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_vol_down setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-vol-mute" )];
[o_mi_mute setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_mute setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-toggle-fullscreen" )];
[o_mi_fullscreen setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_fullscreen setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-snapshot" )];
[o_mi_snapshot setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_snapshot setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-random" )];
[o_mi_random setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_random setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-zoom-half" )];
[o_mi_half_window setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_half_window setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-zoom-original" )];
[o_mi_normal_window setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_normal_window setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-zoom-double" )];
[o_mi_double_window setKeyEquivalent: [self VLCKeyToString: o_key]];
[o_mi_double_window setKeyEquivalentModifierMask: [self VLCModifiersToCocoa:o_key]];
var_Create( p_intf, "intf-change", VLC_VAR_BOOL );
[self setSubmenusEnabled: FALSE];
[o_volumeslider setEnabled: YES];
[self manageVolumeSlider];
[o_window setDelegate: self];
[o_window setExcludedFromWindowsMenu: YES];
[o_msgs_panel setExcludedFromWindowsMenu: YES];
[o_msgs_panel setDelegate: self];
// Set that here as IB seems to be buggy
[o_window setContentMinSize:NSMakeSize(500., 200.)];
......@@ -494,11 +406,6 @@ static VLCMain *_o_sharedMainInstance = nil;
/* update the playmode stuff */
p_intf->p_sys->b_playmode_update = true;
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(refreshVoutDeviceMenu:)
name: NSApplicationDidChangeScreenParametersNotification
object: nil];
/* take care of tint changes during runtime */
o_img_play = [NSImage imageNamed: @"play"];
o_img_pause = [NSImage imageNamed: @"pause"];
......@@ -523,9 +430,6 @@ static VLCMain *_o_sharedMainInstance = nil;
/* Note: we use the pthread API to support pre-10.5 */
pthread_create( &manage_thread, NULL, ManageThread, self );
[o_controls setupVarMenuItem: o_mi_add_intf target: (vlc_object_t *)p_intf
var: "intf-add" selector: @selector(toggleVar:)];
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
......@@ -575,147 +479,6 @@ static VLCMain *_o_sharedMainInstance = nil;
[o_msgs_crashlog_btn setTitle: _NS("Open CrashLog...")];
[o_msgs_save_btn setTitle: _NS("Save this Log...")];
/* 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...")];
[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")];
[o_mi_open_recent_cm setTitle: _NS("Clear Menu")];
[o_mi_open_wizard setTitle: _NS("Streaming/Exporting Wizard...")];
[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")];
[o_mu_controls setTitle: _NS("Playback")];
[o_mi_play setTitle: _NS("Play")];
[o_mi_stop setTitle: _NS("Stop")];
[o_mi_faster setTitle: _NS("Faster")];
[o_mi_slower setTitle: _NS("Slower")];
[o_mi_normalSpeed setTitle: _NS("Normal rate")];
[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")];
[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")];
[o_mi_channels setTitle: _NS("Audio Channels")];
[o_mu_channels setTitle: _NS("Audio Channels")];
[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")];
[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_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")];
[o_mi_minimize setTitle: _NS("Minimize Window")];
[o_mi_close_window setTitle: _NS("Close Window")];
[o_mi_player setTitle: _NS("Player...")];
[o_mi_controller setTitle: _NS("Controller...")];
[o_mi_audioeffects setTitle: _NS("Audio Effects...")];
[o_mi_videoeffects setTitle: _NS("Video Filters...")];
[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")];
/* crash reporter panel */
[o_crashrep_send_btn setTitle: _NS("Send")];
[o_crashrep_dontSend_btn setTitle: _NS("Don't Send")];
......@@ -729,21 +492,6 @@ static VLCMain *_o_sharedMainInstance = nil;
#pragma mark -
#pragma mark Termination
- (void)releaseRepresentedObjects:(NSMenu *)the_menu
{
if( !p_intf ) return;
NSArray *menuitems_array = [the_menu itemArray];
for( int i=0; i<[menuitems_array count]; i++ )
{
NSMenuItem *one_item = [menuitems_array objectAtIndex: i];
if( [one_item hasSubmenu] )
[self releaseRepresentedObjects: [one_item submenu]];
[one_item setRepresentedObject:NULL];
}
}
- (void)applicationWillTerminate:(NSNotification *)notification
{
playlist_t * p_playlist;
......@@ -792,29 +540,15 @@ static VLCMain *_o_sharedMainInstance = nil;
/* release some other objects here, because it isn't sure whether dealloc
* will be called later on */
if( nib_about_loaded )
[o_about release];
[o_mainmenu release];
if( nib_prefs_loaded )
{
if( o_sprefs )
[o_sprefs release];
[o_prefs release];
}
if( nib_open_loaded )
[o_open release];
if( nib_videoeffects_loaded )
[o_videoeffects release];
if (nib_audioeffects_loaded)
[o_audioeffects release];
if (nib_tracksynchro_loaded)
[o_trackSynchronization release];
if( o_prefs )
[o_prefs release];
if( nib_bookmarks_loaded )
[o_bookmarks release];
[o_open release];
if( o_info )
{
......@@ -822,7 +556,7 @@ static VLCMain *_o_sharedMainInstance = nil;
[o_info release];
}
if( nib_wizard_loaded )
if( o_wizard )
[o_wizard release];
[crashLogURLConnection cancel];
......@@ -849,7 +583,8 @@ static VLCMain *_o_sharedMainInstance = nil;
[[NSUserDefaults standardUserDefaults] synchronize];
/* Make sure the Menu doesn't have any references to vlc objects anymore */
[self releaseRepresentedObjects:[NSApp mainMenu]];
//FIXME: this should be moved to VLCMainMenu
[o_mainmenu releaseRepresentedObjects:[NSApp mainMenu]];
/* Kill the playlist, so that it doesn't accept new request
* such as the play request from vlc.c (we are a blocking interface). */
......@@ -1350,6 +1085,11 @@ unsigned int CocoaKeyToVLC( unichar i_key )
#pragma mark -
#pragma mark Other objects getters
- (id)mainMenu
{
return o_mainmenu;
}
- (id)controls
{
if( o_controls )
......@@ -1358,12 +1098,34 @@ unsigned int CocoaKeyToVLC( unichar i_key )
return nil;
}
- (id)simplePreferences
- (id)bookmarks
{
if( !o_sprefs )
if (!o_bookmarks )
o_bookmarks = [[VLCBookmarks alloc] init];
if( !nib_bookmarks_loaded )
nib_bookmarks_loaded = [NSBundle loadNibNamed:@"Bookmarks" owner: NSApp];
return o_bookmarks;
}
- (id)open
{
if (!o_open)
return nil;
if( !nib_prefs_loaded )
if (!nib_open_loaded)
nib_open_loaded = [NSBundle loadNibNamed:@"Open" owner: NSApp];
return o_open;
}
- (id)simplePreferences
{
if (!o_sprefs)
o_sprefs = [[VLCSimplePrefs alloc] init];
if (!nib_prefs_loaded)
nib_prefs_loaded = [NSBundle loadNibNamed:@"Preferences" owner: NSApp];
return o_sprefs;
......@@ -1372,7 +1134,7 @@ unsigned int CocoaKeyToVLC( unichar i_key )
- (id)preferences
{
if( !o_prefs )
return nil;
o_prefs = [[VLCPrefs alloc] init];
if( !nib_prefs_loaded )
nib_prefs_loaded = [NSBundle loadNibNamed:@"Preferences" owner: NSApp];
......@@ -1395,6 +1157,9 @@ unsigned int CocoaKeyToVLC( unichar i_key )
- (id)info
{
if(! nib_info_loaded )
nib_info_loaded = [NSBundle loadNibNamed:@"MediaInfo" owner: NSApp];
if( o_info )
return o_info;
......@@ -1403,18 +1168,15 @@ unsigned int CocoaKeyToVLC( unichar i_key )
- (id)wizard
{
if( o_wizard )
return o_wizard;
if( !o_wizard )
o_wizard = [[VLCWizard alloc] init];
return nil;
}
- (id)bookmarks
{
if( o_bookmarks )
return o_bookmarks;
return nil;
if( !nib_wizard_loaded )
{
nib_wizard_loaded = [NSBundle loadNibNamed:@"Wizard" owner: NSApp];
[o_wizard initStrings];
}
return o_wizard;
}
- (id)embeddedList
......@@ -1448,11 +1210,6 @@ unsigned int CocoaKeyToVLC( unichar i_key )
return nil;
}
- (id)voutMenu
{
return o_vout_menu;
}
- (id)eyeTVController
{
if( o_eyetv )
......@@ -1594,7 +1351,7 @@ static void manage_cleanup( void * args )
p_intf->p_sys->b_current_title_update = true;
p_intf->p_sys->b_intf_update = true;
p_intf->p_sys->b_input_update = false;
[self setupMenus]; /* Make sure input menu is up to date */
[o_mainmenu setupMenus]; /* Make sure input menu is up to date */
/* update our info-panel to reflect the new item, if we don't show
* the playlist or the selection is empty */
......@@ -1783,7 +1540,7 @@ static void manage_cleanup( void * args )
p_intf->p_sys->i_play_status = END_S;
[self playStatusUpdated: p_intf->p_sys->i_play_status];
[o_embedded_window playStatusUpdated: p_intf->p_sys->i_play_status];
[self setSubmenusEnabled: FALSE];
[o_mainmenu setSubmenusEnabled: FALSE];
}
if( p_intf->p_sys->b_volume_update )
......@@ -1819,106 +1576,6 @@ end:
#pragma mark -
#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_controls setupVarMenuItem: o_mi_program target: (vlc_object_t *)p_input
var: "program" selector: @selector(toggleVar:)];
[o_controls setupVarMenuItem: o_mi_title target: (vlc_object_t *)p_input
var: "title" selector: @selector(toggleVar:)];
[o_controls setupVarMenuItem: o_mi_chapter target: (vlc_object_t *)p_input
var: "chapter" selector: @selector(toggleVar:)];
[o_controls setupVarMenuItem: o_mi_audiotrack target: (vlc_object_t *)p_input
var: "audio-es" selector: @selector(toggleVar:)];
[o_controls setupVarMenuItem: o_mi_videotrack target: (vlc_object_t *)p_input
var: "video-es" selector: @selector(toggleVar:)];
[o_controls setupVarMenuItem: o_mi_subtitle 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];
aout_instance_t * p_aout = input_GetAout( p_input );
if( p_aout != NULL )
{
[o_controls setupVarMenuItem: o_mi_channels target: (vlc_object_t *)p_aout
var: "audio-channels" selector: @selector(toggleVar:)];
[o_controls setupVarMenuItem: o_mi_device target: (vlc_object_t *)p_aout
var: "audio-device" selector: @selector(toggleVar:)];
[o_controls setupVarMenuItem: o_mi_visual target: (vlc_object_t *)p_aout
var: "visual" selector: @selector(toggleVar:)];
vlc_object_release( (vlc_object_t *)p_aout );
}
vout_thread_t * p_vout = input_GetVout( p_input );
if( p_vout != NULL )
{
vlc_object_t * p_dec_obj;
[o_controls setupVarMenuItem: o_mi_aspect_ratio target: (vlc_object_t *)p_vout
var: "aspect-ratio" selector: @selector(toggleVar:)];
[o_controls setupVarMenuItem: o_mi_crop target: (vlc_object_t *) p_vout
var: "crop" selector: @selector(toggleVar:)];
[o_controls setupVarMenuItem: o_mi_screen target: (vlc_object_t *)p_vout
var: "video-device" selector: @selector(toggleVar:)];
[o_controls setupVarMenuItem: o_mi_deinterlace target: (vlc_object_t *)p_vout
var: "deinterlace" selector: @selector(toggleVar:)];
[o_controls setupVarMenuItem: o_mi_deinterlace_mode target: (vlc_object_t *)p_vout
var: "deinterlace-mode" selector: @selector(toggleVar:)];
#if 1
[o_controls 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_input );
}
}
- (void)refreshVoutDeviceMenu:(NSNotification *)o_notification
{
int x, y = 0;
vout_thread_t * p_vout = getVout();
if( !p_vout )
return;
/* clean the menu before adding new entries */
if( [o_mi_screen hasSubmenu] )
{
y = [[o_mi_screen submenu] numberOfItems] - 1;
msg_Dbg( VLCIntf, "%i items in submenu", y );
while( x != y )
{
msg_Dbg( VLCIntf, "removing item %i of %i", x, y );
[[o_mi_screen submenu] removeItemAtIndex: x];
x++;
}
}
[o_controls setupVarMenuItem: o_mi_screen target: (vlc_object_t *)p_vout
var: "video-device" selector: @selector(toggleVar:)];
vlc_object_release( (vlc_object_t *)p_vout );
}
- (void)setScrollField:(NSString *)o_string stopAfter:(int)timeout
{
if( timeout != -1 )
......@@ -1958,12 +1615,10 @@ end:
if( i_status == PLAYING_S )
{
[[[self controls] fspanel] setPause];
[[self mainMenu] setPause];
[o_btn_play setImage: o_img_pause];
[o_btn_play setAlternateImage: o_img_pause_pressed];
[o_btn_play setToolTip: _NS("Pause")];
[o_mi_play setTitle: _NS("Pause")];
[o_dmi_play setTitle: _NS("Pause")];
[o_vmi_play setTitle: _NS("Pause")];
}
else
{
......@@ -1971,32 +1626,9 @@ end:
[o_btn_play setImage: o_img_play];
[o_btn_play setAlternateImage: o_img_play_pressed];
[o_btn_play setToolTip: _NS("Play")];
[o_mi_play setTitle: _NS("Play")];
[o_dmi_play setTitle: _NS("Play")];
[o_vmi_play setTitle: _NS("Play")];
}
}
- (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];
[o_mi_subtitle 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];
[o_mi_teletext setEnabled: b_enabled];
}
- (IBAction)timesliderUpdate:(id)sender
{
float f_updated;
......@@ -2049,224 +1681,10 @@ end:
b_time_remaining = !b_time_remaining;
}
#pragma mark -
#pragma mark Recent Items
- (IBAction)clearRecentItems:(id)sender
{
[[NSDocumentController sharedDocumentController]
clearRecentDocuments: nil];
}
- (void)openRecentItem:(id)sender
- (IBAction)showController:(id)sender
{
[self application: nil openFile: [sender title]];
}
#pragma mark -
#pragma mark Panels
- (IBAction)intfOpenFile:(id)sender
{
if( !nib_open_loaded )
{
nib_open_loaded = [NSBundle loadNibNamed:@"Open" owner: NSApp];
[o_open awakeFromNib];
[o_open openFile];
} else {
[o_open openFile];
}
}
- (IBAction)intfOpenFileGeneric:(id)sender
{
if( !nib_open_loaded )
{
nib_open_loaded = [NSBundle loadNibNamed:@"Open" owner: NSApp];
[o_open awakeFromNib];
[o_open openFileGeneric];
} else {
[o_open openFileGeneric];
}
}
- (IBAction)intfOpenDisc:(id)sender
{
if( !nib_open_loaded )
{
nib_open_loaded = [NSBundle loadNibNamed:@"Open" owner: NSApp];
[o_open awakeFromNib];
[o_open openDisc];
} else {
[o_open openDisc];
}
}
- (IBAction)intfOpenNet:(id)sender
{
if( !nib_open_loaded )
{
nib_open_loaded = [NSBundle loadNibNamed:@"Open" owner: NSApp];
[o_open awakeFromNib];
[o_open openNet];
} else {
[o_open openNet];
}
}
- (IBAction)intfOpenCapture:(id)sender
{
if( !nib_open_loaded )
{
nib_open_loaded = [NSBundle loadNibNamed:@"Open" owner: NSApp];
[o_open awakeFromNib];
[o_open openCapture];
} else {
[o_open openCapture];
}
}
- (IBAction)showWizard:(id)sender
{
if( !nib_wizard_loaded )
{
nib_wizard_loaded = [NSBundle loadNibNamed:@"Wizard" owner: NSApp];
[o_wizard initStrings];
[o_wizard resetWizard];
[o_wizard showWizard];
} else {
[o_wizard resetWizard];
[o_wizard showWizard];
}
}
- (IBAction)showVideoEffects:(id)sender
{
if( o_videoeffects == nil )
o_videoeffects = [[VLCVideoEffects alloc] init];
if( !nib_videoeffects_loaded )
nib_videoeffects_loaded = [NSBundle loadNibNamed:@"VideoEffects" owner: NSApp];
[o_videoeffects toggleWindow:sender];
}
- (IBAction)showTrackSynchronization:(id)sender
{
if (!o_trackSynchronization)
o_trackSynchronization = [[VLCTrackSynchronization alloc] init];
if (!nib_tracksynchro_loaded)
nib_tracksynchro_loaded = [NSBundle loadNibNamed:@"SyncTracks" owner:NSApp];
[o_trackSynchronization toggleWindow:sender];
}
- (IBAction)showAudioEffects:(id)sender
{
if (!o_audioeffects)
o_audioeffects = [[VLCAudioEffects alloc] init];
if (!nib_audioeffects_loaded)
nib_audioeffects_loaded = [NSBundle loadNibNamed:@"AudioEffects" owner:NSApp];
[o_audioeffects toggleWindow:sender];
}
- (IBAction)showBookmarks:(id)sender
{
/* we need the wizard-nib for the bookmarks's extract functionality */
if( !nib_wizard_loaded )
{
nib_wizard_loaded = [NSBundle loadNibNamed:@"Wizard" owner: NSApp];
[o_wizard initStrings];
}
if( !nib_bookmarks_loaded )
nib_bookmarks_loaded = [NSBundle loadNibNamed:@"Bookmarks" owner: NSApp];
[o_bookmarks showBookmarks];
}
- (IBAction)viewPreferences:(id)sender
{
if( !nib_prefs_loaded )
{
nib_prefs_loaded = [NSBundle loadNibNamed:@"Preferences" owner: NSApp];
o_sprefs = [[VLCSimplePrefs alloc] init];
o_prefs= [[VLCPrefs alloc] init];
}
[o_sprefs showSimplePrefs];
}
#pragma mark -
#pragma mark Help and Docs
- (IBAction)viewAbout:(id)sender
{
if( !nib_about_loaded )
nib_about_loaded = [NSBundle loadNibNamed:@"About" owner: NSApp];
[o_about showAbout];
}
- (IBAction)showLicense:(id)sender
{
if( !nib_about_loaded )
nib_about_loaded = [NSBundle loadNibNamed:@"About" owner: NSApp];
[o_about showGPL: sender];
}
- (IBAction)viewHelp:(id)sender
{
if( !nib_about_loaded )
{
nib_about_loaded = [NSBundle loadNibNamed:@"About" owner: NSApp];
[o_about showHelp];
}
else
[o_about showHelp];
}
- (IBAction)openReadMe:(id)sender
{
NSString * o_path = [[NSBundle mainBundle]
pathForResource: @"README.MacOSX" ofType: @"rtf"];
[[NSWorkspace sharedWorkspace] openFile: o_path
withApplication: @"TextEdit"];
}
- (IBAction)openDocumentation:(id)sender
{
NSURL * o_url = [NSURL URLWithString:
@"http://www.videolan.org/doc/"];
[[NSWorkspace sharedWorkspace] openURL: o_url];
}
- (IBAction)openWebsite:(id)sender
{
NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org/"];
[[NSWorkspace sharedWorkspace] openURL: o_url];
}
- (IBAction)openForum:(id)sender
{
NSURL * o_url = [NSURL URLWithString: @"http://forum.videolan.org/"];
[[NSWorkspace sharedWorkspace] openURL: o_url];
}
- (IBAction)openDonate:(id)sender
{
NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org/contribute.html#paypal"];
[[NSWorkspace sharedWorkspace] openURL: o_url];
//FIXME: temporary hack until we have VLCMainWindow
[o_window makeKeyAndOrderFront:sender];
}
#pragma mark -
......@@ -2462,25 +1880,11 @@ end:
#pragma mark -
#pragma mark Errors, warnings and messages
- (IBAction)viewErrorsAndWarnings:(id)sender
{
[[[self coreDialogProvider] errorPanel] showPanel];
}
- (IBAction)showMessagesPanel:(id)sender
{
[o_msgs_panel makeKeyAndOrderFront: sender];
}
- (IBAction)showInformationPanel:(id)sender
{
if(! nib_info_loaded )
nib_info_loaded = [NSBundle loadNibNamed:@"MediaInfo" owner: NSApp];
[o_info initPanel];
}
- (void)windowDidBecomeKey:(NSNotification *)o_notification
{
if( [o_notification object] == o_msgs_panel )
......@@ -2595,72 +1999,6 @@ end:
@end
@implementation VLCMain (NSMenuValidation)
- (BOOL)validateMenuItem:(NSMenuItem *)o_mi
{
NSString *o_title = [o_mi title];
BOOL bEnabled = TRUE;
/* Recent Items Menu */
if( [o_title isEqualToString: _NS("Clear Menu")] )
{
NSMenu * o_menu = [o_mi_open_recent submenu];
int i_nb_items = [o_menu numberOfItems];
NSArray * o_docs = [[NSDocumentController sharedDocumentController]
recentDocumentURLs];
UInt32 i_nb_docs = [o_docs count];
if( i_nb_items > 1 )
{
while( --i_nb_items )
{
[o_menu removeItemAtIndex: 0];
}
}
if( i_nb_docs > 0 )
{
NSURL * o_url;
NSString * o_doc;
[o_menu insertItem: [NSMenuItem separatorItem] atIndex: 0];
while( TRUE )
{
i_nb_docs--;
o_url = [o_docs objectAtIndex: i_nb_docs];
if( [o_url isFileURL] )
{
o_doc = [o_url path];
}
else
{
o_doc = [o_url absoluteString];
}
[o_menu insertItemWithTitle: o_doc
action: @selector(openRecentItem:)
keyEquivalent: @"" atIndex: 0];
if( i_nb_docs == 0 )
{
break;
}
}
}
else
{
bEnabled = FALSE;
}
}
return( bEnabled );
}
@end
@implementation VLCMain (Internal)
- (void)handlePortMessage:(NSPortMessage *)o_msg
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment