[vlc-commits] macosx: Use NSWindowController for error panel, lazy initialization

David Fuhrmann git at videolan.org
Sat May 16 21:57:55 CEST 2015


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sat May 16 21:55:13 2015 +0200| [0aad5ff31efeee398742f957c185c8532dbb412a] | committer: David Fuhrmann

macosx: Use NSWindowController for error panel, lazy initialization

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0aad5ff31efeee398742f957c185c8532dbb412a
---

 .../macosx/Resources/English.lproj/ErrorPanel.xib  |   45 +++++++++++++------
 modules/gui/macosx/MainMenu.m                      |    2 +-
 modules/gui/macosx/coredialogs.h                   |   46 ++++++++++----------
 modules/gui/macosx/coredialogs.m                   |   35 +++++++--------
 4 files changed, 72 insertions(+), 56 deletions(-)

diff --git a/extras/package/macosx/Resources/English.lproj/ErrorPanel.xib b/extras/package/macosx/Resources/English.lproj/ErrorPanel.xib
index 5c41dbc..bb1d7b8 100644
--- a/extras/package/macosx/Resources/English.lproj/ErrorPanel.xib
+++ b/extras/package/macosx/Resources/English.lproj/ErrorPanel.xib
@@ -32,7 +32,7 @@
 		</object>
 		<array class="NSMutableArray" key="IBDocument.RootObjects" id="638050510">
 			<object class="NSCustomObject" id="923016430">
-				<string key="NSClassName">VLCErrorPanel</string>
+				<string key="NSClassName">ErrorWindowController</string>
 			</object>
 			<object class="NSCustomObject" id="159526500">
 				<string key="NSClassName">FirstResponder</string>
@@ -304,14 +304,6 @@
 					<int key="connectionID">13</int>
 				</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="IBActionConnection" key="connection">
 						<string key="label">cleanupTable:</string>
 						<reference key="source" ref="923016430"/>
@@ -321,6 +313,14 @@
 				</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="IBOutletConnection" key="connection">
 						<string key="label">dataSource</string>
 						<reference key="source" ref="523335037"/>
 						<reference key="destination" ref="923016430"/>
@@ -474,13 +474,13 @@
 			<nil key="activeLocalization"/>
 			<dictionary class="NSMutableDictionary" key="localizations"/>
 			<nil key="sourceID"/>
-			<int key="maxID">74</int>
+			<int key="maxID">75</int>
 		</object>
 		<object class="IBClassDescriber" key="IBDocument.Classes">
 			<array class="NSMutableArray" key="referencedPartialClassDescriptions">
 				<object class="IBPartialClassDescription">
-					<string key="className">VLCErrorPanel</string>
-					<string key="superclassName">NSObject</string>
+					<string key="className">ErrorWindowController</string>
+					<string key="superclassName">NSWindowController</string>
 					<object class="NSMutableDictionary" key="actions">
 						<string key="NS.key.0">cleanupTable:</string>
 						<string key="NS.object.0">id</string>
@@ -517,7 +517,7 @@
 					</object>
 				</object>
 				<object class="IBPartialClassDescription">
-					<string key="className">VLCErrorPanel</string>
+					<string key="className">ErrorWindowController</string>
 					<object class="NSMutableDictionary" key="actions">
 						<string key="NS.key.0">cleanupTable:</string>
 						<string key="NS.object.0">id</string>
@@ -680,6 +680,25 @@
 						<string key="minorKey">AppKit.framework/Headers/NSWindow.h</string>
 					</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>
 		</object>
 		<int key="IBDocument.localizationMode">0</int>
diff --git a/modules/gui/macosx/MainMenu.m b/modules/gui/macosx/MainMenu.m
index eb7bf0c..3660bc0 100644
--- a/modules/gui/macosx/MainMenu.m
+++ b/modules/gui/macosx/MainMenu.m
@@ -1262,7 +1262,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
 
 - (IBAction)viewErrorsAndWarnings:(id)sender
 {
-    [[[[VLCMain sharedInstance] coreDialogProvider] errorPanel] showPanel];
+    [[[[VLCMain sharedInstance] coreDialogProvider] errorPanel] showWindow:self];
 }
 
 - (IBAction)showInformationPanel:(id)sender
diff --git a/modules/gui/macosx/coredialogs.h b/modules/gui/macosx/coredialogs.h
index 2c96247..229e7c9 100644
--- a/modules/gui/macosx/coredialogs.h
+++ b/modules/gui/macosx/coredialogs.h
@@ -25,35 +25,15 @@
 #import <vlc_dialog.h>
 #import <Cocoa/Cocoa.h>
 
-
 /*****************************************************************************
- * VLCErrorPanel interface
+ * VLCCoreDialogProvider interface
  *****************************************************************************/
 
- at interface VLCErrorPanel : NSObject
-{
-    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;
-
- at end
+ at class ErrorWindowController;
 
-/*****************************************************************************
- * VLCCoreDialogProvider interface
- *****************************************************************************/
 @interface VLCCoreDialogProvider : NSObject
 {
-    VLCErrorPanel *o_error_panel;
+    ErrorWindowController *o_error_panel;
 
     /* authentication dialogue */
     IBOutlet id o_auth_cancel_btn;
@@ -96,3 +76,23 @@
 -(id)errorPanel;
 
 @end
+
+
+/*****************************************************************************
+ * VLCErrorPanel interface
+ *****************************************************************************/
+
+ at 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;
+
+ at end
diff --git a/modules/gui/macosx/coredialogs.m b/modules/gui/macosx/coredialogs.m
index af438eb..6442334 100644
--- a/modules/gui/macosx/coredialogs.m
+++ b/modules/gui/macosx/coredialogs.m
@@ -49,7 +49,6 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
         [self dealloc];
     else {
         _o_sharedInstance = [super init];
-        o_error_panel = [[VLCErrorPanel alloc] init];
         b_progress_cancelled = NO;
     }
 
@@ -89,8 +88,8 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
 {
     dialog_fatal_t *p_dialog = [o_value pointerValue];
 
-    [o_error_panel addError: toNSStr(p_dialog->title) withMsg: toNSStr(p_dialog->message)];
-    [o_error_panel showPanel];
+    [[self errorPanel] addError: toNSStr(p_dialog->title) withMsg: toNSStr(p_dialog->message)];
+    [[self errorPanel] showWindow:self];
 }
 
 -(void)showFatalWaitDialog: (NSValue *)o_value
@@ -211,6 +210,9 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
 
 -(id)errorPanel
 {
+    if (!o_error_panel)
+        o_error_panel = [[ErrorWindowController alloc] init];
+
     return o_error_panel;
 }
 
@@ -219,25 +221,25 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
 /*****************************************************************************
  * VLCErrorPanel implementation
  *****************************************************************************/
- at implementation VLCErrorPanel
--(id)init
-{
-    [super init];
 
-    if (!b_nib_loaded)
-        b_nib_loaded = [NSBundle loadNibNamed:@"ErrorPanel" owner:self];
+ at implementation ErrorWindowController
 
-    /* init data sources */
-    o_errors = [[NSMutableArray alloc] init];
-    o_icons = [[NSMutableArray alloc] init];
+- (id)init
+{
+    self = [super initWithWindowNibName:@"ErrorPanel"];
+    if (self) {
+        /* init data sources */
+        o_errors = [[NSMutableArray alloc] init];
+        o_icons = [[NSMutableArray alloc] init];
+    }
 
     return self;
 }
 
-- (void)awakeFromNib
+- (void)windowDidLoad
 {
     /* init strings */
-    [o_window setTitle: _NS("Errors and Warnings")];
+    [[self window] setTitle: _NS("Errors and Warnings")];
     [o_cleanup_button setTitle: _NS("Clean up")];
 }
 
@@ -248,11 +250,6 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
     [super dealloc];
 }
 
--(void)showPanel
-{
-    [o_window makeKeyAndOrderFront: self];
-}
-
 -(void)addError: (NSString *)o_error withMsg:(NSString *)o_msg
 {
     /* format our string as desired */



More information about the vlc-commits mailing list