Commit 491bef0b authored by David Fuhrmann's avatar David Fuhrmann

macosx: Remove sharedInstance from About window and rework

Removes sharedInstance from About window controller, and rework
as a NSWindowController subclass. This is the new owner of the xib
and thus instantiated outside the nib bundle.

Splits Help window in own xib and add own NSWindowController as
well.

refs #5556
parent 55c15c23
......@@ -145,6 +145,7 @@ EXTRA_DIST += \
extras/package/macosx/Resources/English.lproj/ErrorPanel.xib \
extras/package/macosx/Resources/English.lproj/FSPanel.xib \
extras/package/macosx/Resources/English.lproj/InfoPlist.strings.in \
extras/package/macosx/Resources/English.lproj/Help.xib \
extras/package/macosx/Resources/English.lproj/MainMenu.xib \
extras/package/macosx/Resources/English.lproj/MainWindow.xib \
extras/package/macosx/Resources/English.lproj/MediaInfo.xib \
......
This diff is collapsed.
......@@ -342,6 +342,7 @@
1C88BCC119DC7CB300645190 /* ys-fs_volume_slider_knob@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1C88BC8B19DC7CB300645190 /* ys-fs_volume_slider_knob@2x.png */; };
1C88BCC219DC7CB300645190 /* ys-fs_volume_slider_knob_highlight.png in Resources */ = {isa = PBXBuildFile; fileRef = 1C88BC8C19DC7CB300645190 /* ys-fs_volume_slider_knob_highlight.png */; };
1C88BCC319DC7CB300645190 /* ys-fs_volume_slider_knob_highlight@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1C88BC8D19DC7CB300645190 /* ys-fs_volume_slider_knob_highlight@2x.png */; };
1CBB2CC81B06A6DE00110ADA /* Help.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1CBB2CC61B06A6DE00110ADA /* Help.xib */; };
1CCB5F511A62A724004C3E90 /* about.h in Sources */ = {isa = PBXBuildFile; fileRef = 8EE1AF9F044465080059A3A7 /* about.h */; };
1CCB5F521A62A724004C3E90 /* about.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EE1AFA0044465080059A3A7 /* about.m */; };
1CCB5F531A62A724004C3E90 /* AddonListDataSource.h in Sources */ = {isa = PBXBuildFile; fileRef = 7DF0435E1972E26A0022B534 /* AddonListDataSource.h */; };
......@@ -1204,6 +1205,7 @@
1C88BC8B19DC7CB300645190 /* ys-fs_volume_slider_knob@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ys-fs_volume_slider_knob@2x.png"; sourceTree = "<group>"; };
1C88BC8C19DC7CB300645190 /* ys-fs_volume_slider_knob_highlight.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ys-fs_volume_slider_knob_highlight.png"; sourceTree = "<group>"; };
1C88BC8D19DC7CB300645190 /* ys-fs_volume_slider_knob_highlight@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ys-fs_volume_slider_knob_highlight@2x.png"; sourceTree = "<group>"; };
1CBB2CC71B06A6DE00110ADA /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/Help.xib; sourceTree = "<group>"; };
1CCB5F2F1A62A6A5004C3E90 /* pseudo-vlc.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "pseudo-vlc.app"; sourceTree = BUILT_PRODUCTS_DIR; };
1CE5ED1B19DD6AB700FCEFD3 /* lion-window-fullscreen-on.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "lion-window-fullscreen-on.png"; sourceTree = "<group>"; };
1CE5ED1C19DD6AB700FCEFD3 /* lion-window-fullscreen-on@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "lion-window-fullscreen-on@2x.png"; sourceTree = "<group>"; };
......@@ -2882,6 +2884,7 @@
children = (
E0FB95CC1615B6DF0005069A /* DetachedVideoWindow.xib */,
CCD83E2E13FEA143004F1652 /* About.xib */,
1CBB2CC61B06A6DE00110ADA /* Help.xib */,
CCD83E3013FEA143004F1652 /* AudioEffects.xib */,
CCD83E3213FEA143004F1652 /* Bookmarks.xib */,
CCD83E3413FEA143004F1652 /* CoreDialogs.xib */,
......@@ -3691,6 +3694,7 @@
CC166FEC15F517660088201B /* backward-6btns@2x.png in Resources */,
CC166FF115F517720088201B /* forward-6btns-pressed.png in Resources */,
1C88BCB319DC7CB300645190 /* ys-fs_time_slider_knob@2x.png in Resources */,
1CBB2CC81B06A6DE00110ADA /* Help.xib in Resources */,
CC166FF215F517720088201B /* forward-6btns-pressed@2x.png in Resources */,
CC166FF315F517720088201B /* forward-6btns.png in Resources */,
CC166FF415F517720088201B /* forward-6btns@2x.png in Resources */,
......@@ -3835,6 +3839,14 @@
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
1CBB2CC61B06A6DE00110ADA /* Help.xib */ = {
isa = PBXVariantGroup;
children = (
1CBB2CC71B06A6DE00110ADA /* English */,
);
name = Help.xib;
sourceTree = "<group>";
};
7D3F6523188051F2005776C4 /* BWQuincyMain.xib */ = {
isa = PBXVariantGroup;
children = (
......@@ -4267,6 +4279,7 @@
1CCB5F4C1A62A6A5004C3E90 /* Default */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Default;
};
C2F2A6EA09588F1B00018C74 /* Build configuration list for PBXProject "vlc" */ = {
isa = XCConfigurationList;
......
......@@ -25,11 +25,13 @@
#import <vlc_common.h>
#import <vlc_interface.h>
@class AboutWindowController;
@class HelpWindowController;
@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;
......@@ -37,7 +39,8 @@
BOOL b_nib_convertandsave_loaded;
BOOL b_nib_addonmanager_loaded;
id o_about; /* VLAboutBox */
AboutWindowController *o_about;
HelpWindowController *o_helpWin;
id o_videoeffects; /* VLCVideoEffects */
id o_audioeffects; /* VLCAudioEffects */
id o_trackSynchronization; /* VLCTrackSynchronization */
......@@ -346,4 +349,3 @@
- (int)type;
@end
......@@ -94,8 +94,8 @@ static VLCMainMenu *_o_sharedInstance = nil;
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
if (b_nib_about_loaded)
[o_about release];
[o_helpWin release];
if (b_nib_videoeffects_loaded)
[o_videoeffects release];
......@@ -1200,11 +1200,8 @@ static VLCMainMenu *_o_sharedInstance = nil;
- (void)initAbout
{
if (! o_about)
o_about = [[VLAboutBox alloc] init];
if (!b_nib_about_loaded)
b_nib_about_loaded = [NSBundle loadNibNamed:@"About" owner: NSApp];
if (!o_about)
o_about = [[AboutWindowController alloc] init];
}
- (IBAction)viewAbout:(id)sender
......@@ -1221,8 +1218,10 @@ static VLCMainMenu *_o_sharedInstance = nil;
- (IBAction)viewHelp:(id)sender
{
[self initAbout];
[o_about showHelp];
if (!o_helpWin)
o_helpWin = [[HelpWindowController alloc] init];
[o_helpWin showHelp];
}
- (IBAction)openReadMe:(id)sender
......
......@@ -27,10 +27,9 @@
/*****************************************************************************
* VLAboutBox interface
*****************************************************************************/
@interface VLAboutBox : NSObject
@interface AboutWindowController : NSWindowController<NSWindowDelegate>
{
/* main about panel and stuff related to its views */
IBOutlet id o_about_window;
IBOutlet id o_name_version_field;
IBOutlet id o_revision_field;
IBOutlet id o_copyright_field;
......@@ -49,23 +48,25 @@
CGFloat f_end;
NSTimeInterval i_start;
BOOL b_restart;
BOOL b_isSetUp;
NSString *o_authors;
}
- (void)showAbout;
- (void)showGPL;
- (IBAction)buttonAction:(id)sender;
@end
/* generic help window */
IBOutlet id o_help_window;
@interface HelpWindowController : NSWindowController
{
IBOutlet WebView *o_help_web_view; //we may _not_ use id here because of method name collisions
IBOutlet id o_help_bwd_btn;
IBOutlet id o_help_fwd_btn;
IBOutlet id o_help_home_btn;
}
+ (VLAboutBox *)sharedInstance;
- (void)showAbout;
- (void)showHelp;
- (void)showGPL;
- (IBAction)buttonAction:(id)sender;
- (IBAction)helpGoHome:(id)sender;
- (void)showHelp;
@end
......@@ -38,23 +38,17 @@
/*****************************************************************************
* VLAboutBox implementation
*****************************************************************************/
@implementation VLAboutBox
static VLAboutBox *_o_sharedInstance = nil;
+ (VLAboutBox *)sharedInstance
{
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
}
@implementation AboutWindowController
- (id)init
{
if (_o_sharedInstance)
[self dealloc];
else
_o_sharedInstance = [super init];
self = [super initWithWindowNibName:@"About"];
if (self) {
[self setWindowFrameAutosaveName:@"about"];
}
return _o_sharedInstance;
return self;
}
- (void) dealloc
......@@ -64,19 +58,32 @@ static VLAboutBox *_o_sharedInstance = nil;
[super dealloc];
}
- (void)awakeFromNib
{
if (!OSX_SNOW_LEOPARD)
[o_about_window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
}
/*****************************************************************************
* VLC About Window
*****************************************************************************/
- (void)showAbout
{
if (! b_isSetUp) {
[self window];
/* Show the window */
b_restart = YES;
[o_credits_scrollview setHidden:YES];
[o_credits_textview setHidden:YES];
[o_joinus_txt setHidden:NO];
[o_copyright_field setHidden:NO];
[o_revision_field setHidden:NO];
[o_name_version_field setHidden:NO];
[o_credits_textview scrollPoint:NSMakePoint(0, 0)];
[self showWindow:nil];
}
- (void)windowDidLoad
{
if (!OSX_SNOW_LEOPARD)
[[self window] setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
/* Get the localized info dictionary (InfoPlist.strings) */
NSDictionary *o_local_dict;
o_local_dict = [[NSBundle mainBundle] localizedInfoDictionary];
......@@ -85,7 +92,7 @@ static VLAboutBox *_o_sharedInstance = nil;
[o_copyright_field setStringValue: [o_local_dict objectForKey:@"NSHumanReadableCopyright"]];
/* l10n */
[o_about_window setTitle: _NS("About VLC media player")];
[[self window] setTitle: _NS("About VLC media player")];
NSDictionary *stringAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:NSUnderlineStyleSingle], NSUnderlineStyleAttributeName, [NSColor colorWithCalibratedRed:0. green:0.3411 blue:0.6824 alpha:1.], NSForegroundColorAttributeName, [NSFont systemFontOfSize:13], NSFontAttributeName, nil];
NSAttributedString *attrStr;
attrStr = [[NSAttributedString alloc] initWithString:_NS("Credits") attributes:stringAttributes];
......@@ -150,10 +157,9 @@ static VLAboutBox *_o_sharedInstance = nil;
/* Setup the window */
[o_credits_textview setDrawsBackground: NO];
[o_credits_scrollview setDrawsBackground: NO];
[o_about_window setExcludedFromWindowsMenu:YES];
[o_about_window setMenu:nil];
[o_about_window center];
[o_about_window setBackgroundColor: [NSColor colorWithCalibratedWhite:.96 alpha:1.]];
[[self window] setExcludedFromWindowsMenu:YES];
[[self window] setMenu:nil];
[[self window] setBackgroundColor: [NSColor colorWithCalibratedWhite:.96 alpha:1.]];
if (config_GetInt(VLCIntf, "macosx-icon-change")) {
/* After day 354 of the year, the usual VLC cone is replaced by another cone
......@@ -168,20 +174,6 @@ static VLAboutBox *_o_sharedInstance = nil;
if (dayOfYear >= 354)
[o_icon_view setImage: [NSImage imageNamed:@"vlc-xmas"]];
}
b_isSetUp = YES;
}
/* Show the window */
b_restart = YES;
[o_credits_scrollview setHidden:YES];
[o_credits_textview setHidden:YES];
[o_joinus_txt setHidden:NO];
[o_copyright_field setHidden:NO];
[o_revision_field setHidden:NO];
[o_name_version_field setHidden:NO];
[o_credits_textview scrollPoint:NSMakePoint(0, 0)];
[o_about_window makeKeyAndOrderFront: nil];
}
- (void)windowDidBecomeKey:(NSNotification *)notification
......@@ -258,21 +250,37 @@ static VLAboutBox *_o_sharedInstance = nil;
[self buttonAction:nil];
}
@end
/*****************************************************************************
* VLC Generic Help Window
*****************************************************************************/
* VLC Help Window Controller
*****************************************************************************/
- (void)showHelp
@implementation HelpWindowController
- (id)init
{
self = [super initWithWindowNibName:@"Help"];
if (self) {
[self setWindowFrameAutosaveName:@"help"];
}
return self;
}
- (void)windowDidLoad
{
[o_help_window setTitle: _NS("VLC media player Help")];
[[self window] setTitle: _NS("VLC media player Help")];
[o_help_fwd_btn setToolTip: _NS("Next")];
[o_help_bwd_btn setToolTip: _NS("Previous")];
[o_help_home_btn setToolTip: _NS("Index")];
}
[o_help_window makeKeyAndOrderFront: self];
[[o_help_web_view mainFrame] loadHTMLString: _NS(I_LONGHELP)
baseURL: [NSURL URLWithString:@"http://videolan.org"]];
- (void)showHelp
{
[self showWindow:nil];
[self helpGoHome:nil];
}
- (IBAction)helpGoHome:(id)sender
......
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