Commit 0aad5ff3 authored by David Fuhrmann's avatar David Fuhrmann

macosx: Use NSWindowController for error panel, lazy initialization

parent d7657086
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
</object> </object>
<array class="NSMutableArray" key="IBDocument.RootObjects" id="638050510"> <array class="NSMutableArray" key="IBDocument.RootObjects" id="638050510">
<object class="NSCustomObject" id="923016430"> <object class="NSCustomObject" id="923016430">
<string key="NSClassName">VLCErrorPanel</string> <string key="NSClassName">ErrorWindowController</string>
</object> </object>
<object class="NSCustomObject" id="159526500"> <object class="NSCustomObject" id="159526500">
<string key="NSClassName">FirstResponder</string> <string key="NSClassName">FirstResponder</string>
...@@ -303,14 +303,6 @@ ...@@ -303,14 +303,6 @@
</object> </object>
<int key="connectionID">13</int> <int key="connectionID">13</int>
</object> </object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">o_window</string>
<reference key="source" ref="923016430"/>
<reference key="destination" ref="883469087"/>
</object>
<int key="connectionID">14</int>
</object>
<object class="IBConnectionRecord"> <object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection"> <object class="IBActionConnection" key="connection">
<string key="label">cleanupTable:</string> <string key="label">cleanupTable:</string>
...@@ -319,6 +311,14 @@ ...@@ -319,6 +311,14 @@
</object> </object>
<int key="connectionID">15</int> <int key="connectionID">15</int>
</object> </object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">window</string>
<reference key="source" ref="923016430"/>
<reference key="destination" ref="883469087"/>
</object>
<int key="connectionID">75</int>
</object>
<object class="IBConnectionRecord"> <object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection"> <object class="IBOutletConnection" key="connection">
<string key="label">dataSource</string> <string key="label">dataSource</string>
...@@ -474,13 +474,13 @@ ...@@ -474,13 +474,13 @@
<nil key="activeLocalization"/> <nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/> <dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/> <nil key="sourceID"/>
<int key="maxID">74</int> <int key="maxID">75</int>
</object> </object>
<object class="IBClassDescriber" key="IBDocument.Classes"> <object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions"> <array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription"> <object class="IBPartialClassDescription">
<string key="className">VLCErrorPanel</string> <string key="className">ErrorWindowController</string>
<string key="superclassName">NSObject</string> <string key="superclassName">NSWindowController</string>
<object class="NSMutableDictionary" key="actions"> <object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">cleanupTable:</string> <string key="NS.key.0">cleanupTable:</string>
<string key="NS.object.0">id</string> <string key="NS.object.0">id</string>
...@@ -517,7 +517,7 @@ ...@@ -517,7 +517,7 @@
</object> </object>
</object> </object>
<object class="IBPartialClassDescription"> <object class="IBPartialClassDescription">
<string key="className">VLCErrorPanel</string> <string key="className">ErrorWindowController</string>
<object class="NSMutableDictionary" key="actions"> <object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">cleanupTable:</string> <string key="NS.key.0">cleanupTable:</string>
<string key="NS.object.0">id</string> <string key="NS.object.0">id</string>
...@@ -680,6 +680,25 @@ ...@@ -680,6 +680,25 @@
<string key="minorKey">AppKit.framework/Headers/NSWindow.h</string> <string key="minorKey">AppKit.framework/Headers/NSWindow.h</string>
</object> </object>
</object> </object>
<object class="IBPartialClassDescription">
<string key="className">NSWindowController</string>
<string key="superclassName">NSResponder</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">showWindow:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">showWindow:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">showWindow:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSWindowController.h</string>
</object>
</object>
</array> </array>
</object> </object>
<int key="IBDocument.localizationMode">0</int> <int key="IBDocument.localizationMode">0</int>
......
...@@ -1262,7 +1262,7 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -1262,7 +1262,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
- (IBAction)viewErrorsAndWarnings:(id)sender - (IBAction)viewErrorsAndWarnings:(id)sender
{ {
[[[[VLCMain sharedInstance] coreDialogProvider] errorPanel] showPanel]; [[[[VLCMain sharedInstance] coreDialogProvider] errorPanel] showWindow:self];
} }
- (IBAction)showInformationPanel:(id)sender - (IBAction)showInformationPanel:(id)sender
......
...@@ -25,35 +25,15 @@ ...@@ -25,35 +25,15 @@
#import <vlc_dialog.h> #import <vlc_dialog.h>
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
/***************************************************************************** /*****************************************************************************
* VLCErrorPanel interface * VLCCoreDialogProvider interface
*****************************************************************************/ *****************************************************************************/
@interface VLCErrorPanel : NSObject @class ErrorWindowController;
{
IBOutlet id o_window;
IBOutlet id o_cleanup_button;
IBOutlet id o_error_table;
NSMutableArray * o_errors;
NSMutableArray * o_icons;
BOOL b_nib_loaded;
}
- (IBAction)cleanupTable:(id)sender;
-(void)showPanel;
-(void)addError: (NSString *)o_error withMsg:(NSString *)o_msg;
@end
/*****************************************************************************
* VLCCoreDialogProvider interface
*****************************************************************************/
@interface VLCCoreDialogProvider : NSObject @interface VLCCoreDialogProvider : NSObject
{ {
VLCErrorPanel *o_error_panel; ErrorWindowController *o_error_panel;
/* authentication dialogue */ /* authentication dialogue */
IBOutlet id o_auth_cancel_btn; IBOutlet id o_auth_cancel_btn;
...@@ -96,3 +76,23 @@ ...@@ -96,3 +76,23 @@
-(id)errorPanel; -(id)errorPanel;
@end @end
/*****************************************************************************
* VLCErrorPanel interface
*****************************************************************************/
@interface ErrorWindowController : NSWindowController
{
IBOutlet id o_cleanup_button;
IBOutlet id o_error_table;
NSMutableArray *o_errors;
NSMutableArray *o_icons;
}
- (IBAction)cleanupTable:(id)sender;
-(void)addError:(NSString *)o_error withMsg:(NSString *)o_msg;
@end
...@@ -49,7 +49,6 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil; ...@@ -49,7 +49,6 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
[self dealloc]; [self dealloc];
else { else {
_o_sharedInstance = [super init]; _o_sharedInstance = [super init];
o_error_panel = [[VLCErrorPanel alloc] init];
b_progress_cancelled = NO; b_progress_cancelled = NO;
} }
...@@ -89,8 +88,8 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil; ...@@ -89,8 +88,8 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
{ {
dialog_fatal_t *p_dialog = [o_value pointerValue]; dialog_fatal_t *p_dialog = [o_value pointerValue];
[o_error_panel addError: toNSStr(p_dialog->title) withMsg: toNSStr(p_dialog->message)]; [[self errorPanel] addError: toNSStr(p_dialog->title) withMsg: toNSStr(p_dialog->message)];
[o_error_panel showPanel]; [[self errorPanel] showWindow:self];
} }
-(void)showFatalWaitDialog: (NSValue *)o_value -(void)showFatalWaitDialog: (NSValue *)o_value
...@@ -211,6 +210,9 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil; ...@@ -211,6 +210,9 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
-(id)errorPanel -(id)errorPanel
{ {
if (!o_error_panel)
o_error_panel = [[ErrorWindowController alloc] init];
return o_error_panel; return o_error_panel;
} }
...@@ -219,25 +221,25 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil; ...@@ -219,25 +221,25 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
/***************************************************************************** /*****************************************************************************
* VLCErrorPanel implementation * VLCErrorPanel implementation
*****************************************************************************/ *****************************************************************************/
@implementation VLCErrorPanel
-(id)init
{
[super init];
if (!b_nib_loaded) @implementation ErrorWindowController
b_nib_loaded = [NSBundle loadNibNamed:@"ErrorPanel" owner:self];
/* init data sources */ - (id)init
o_errors = [[NSMutableArray alloc] init]; {
o_icons = [[NSMutableArray alloc] init]; self = [super initWithWindowNibName:@"ErrorPanel"];
if (self) {
/* init data sources */
o_errors = [[NSMutableArray alloc] init];
o_icons = [[NSMutableArray alloc] init];
}
return self; return self;
} }
- (void)awakeFromNib - (void)windowDidLoad
{ {
/* init strings */ /* init strings */
[o_window setTitle: _NS("Errors and Warnings")]; [[self window] setTitle: _NS("Errors and Warnings")];
[o_cleanup_button setTitle: _NS("Clean up")]; [o_cleanup_button setTitle: _NS("Clean up")];
} }
...@@ -248,11 +250,6 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil; ...@@ -248,11 +250,6 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
[super dealloc]; [super dealloc];
} }
-(void)showPanel
{
[o_window makeKeyAndOrderFront: self];
}
-(void)addError: (NSString *)o_error withMsg:(NSString *)o_msg -(void)addError: (NSString *)o_error withMsg:(NSString *)o_msg
{ {
/* format our string as desired */ /* format our string as desired */
......
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