diff --git a/ChangeLog b/ChangeLog index 8cd80d078..63d8aadd2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2010-03-30 Fred Kiefer + + * Headers/AppKit/NSNib.h: Make NSNibOwner and NSNibTopLevelObjects + available only for version > 10.3. + * Source/NSWindowController.m, + * Source/NSPageLayout.m, + * Source/GSGModelLoader.m, + * Source/NSDataLinkPanel.m, + * Source/NSPrintPanel.m, + * Source/NSSpellChecker.m: Use NSNibOwner instead of + @"NSOwner". Remove the hard coded "gorm" extension. Try to use + higher level NIB loading methods where possible. + 2010-03-30 Wolfgang Lux * Source/NSWindow.m (-sendEvent:): Remove a stray semicolon, which diff --git a/Headers/AppKit/NSNib.h b/Headers/AppKit/NSNib.h index c833ca527..18106b943 100644 --- a/Headers/AppKit/NSNib.h +++ b/Headers/AppKit/NSNib.h @@ -55,8 +55,10 @@ @class NSArray; @class NSMutableArray; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST) APPKIT_EXPORT NSString *NSNibTopLevelObjects; APPKIT_EXPORT NSString *NSNibOwner; +#endif @interface NSNib : NSObject { diff --git a/Source/GSGModelLoader.m b/Source/GSGModelLoader.m index 5fd18b82b..717e26024 100644 --- a/Source/GSGModelLoader.m +++ b/Source/GSGModelLoader.m @@ -26,11 +26,17 @@ Boston, MA 02110-1301, USA. */ -#include -#include +#import +#import +#import +#import +#import +#import +#import +#import "AppKit/NSNib.h" -#include "GNUstepGUI/GSModelLoaderFactory.h" -#include "GNUstepGUI/IMLoading.h" +#import "GNUstepGUI/GSModelLoaderFactory.h" +#import "GNUstepGUI/IMLoading.h" static Class gmodel_class(void) @@ -87,7 +93,7 @@ Class gmodel_class(void) externalNameTable: (NSDictionary *)context withZone: (NSZone *)zone; { - NSString *ext = [fileName pathExtension]; + NSString *ext = [fileName pathExtension]; /* * If the file to be read is a gmodel, use the GMModel method to @@ -96,7 +102,7 @@ Class gmodel_class(void) if ([ext isEqualToString: @"gmodel"]) { return [gmodel_class() loadIMFile: fileName - owner: [context objectForKey: @"NSOwner"]]; + owner: [context objectForKey: NSNibOwner]]; } return NO; diff --git a/Source/NSDataLinkPanel.m b/Source/NSDataLinkPanel.m index 4582994bd..ace6a632e 100644 --- a/Source/NSDataLinkPanel.m +++ b/Source/NSDataLinkPanel.m @@ -25,15 +25,16 @@ Boston, MA 02110-1301, USA. */ -#include "config.h" -#include "Foundation/NSDictionary.h" -#include "AppKit/NSDataLinkPanel.h" -#include "AppKit/NSDataLinkManager.h" -#include "AppKit/NSDataLink.h" -#include "AppKit/NSGraphics.h" -#include "AppKit/NSView.h" -#include "AppKit/NSNibLoading.h" -#include "GSGuiPrivate.h" +#import "config.h" +#import +#import "AppKit/NSApplication.h" +#import "AppKit/NSDataLinkPanel.h" +#import "AppKit/NSDataLinkManager.h" +#import "AppKit/NSDataLink.h" +#import "AppKit/NSGraphics.h" +#import "AppKit/NSView.h" +#import "AppKit/NSNibLoading.h" +#import "GSGuiPrivate.h" static NSDataLinkPanel *_sharedDataLinkPanel; @@ -47,19 +48,9 @@ static NSDataLinkPanel *_sharedDataLinkPanel; @implementation GSDataLinkPanelController - (id) init { - NSString *panelPath; - NSDictionary *table; - if ((self = [super init]) != nil) { - panelPath = [GSGuiBundle() pathForResource: @"GSDataLinkPanel" - ofType: @"gorm" - inDirectory: nil]; - NSLog(@"Panel path=%@",panelPath); - table = [NSDictionary dictionaryWithObject: self forKey: @"NSOwner"]; - if ([NSBundle loadNibFile: panelPath - externalNameTable: table - withZone: [self zone]] == NO) + if ([NSBundle loadNibNamed: @"GSDataLinkPanel" owner: self] == NO) { NSRunAlertPanel(@"Error", @"Could not load data link panel resource", @"OK", NULL, NULL); diff --git a/Source/NSPageLayout.m b/Source/NSPageLayout.m index 91bae82c5..ea1825b92 100644 --- a/Source/NSPageLayout.m +++ b/Source/NSPageLayout.m @@ -29,32 +29,32 @@ Boston, MA 02110-1301, USA. */ -#include -#include -#include -#include "AppKit/NSApplication.h" -#include "AppKit/NSFont.h" -#include "AppKit/NSTextField.h" -#include "AppKit/NSImage.h" -#include "AppKit/NSImageView.h" -#include "AppKit/NSBezierPath.h" -#include "AppKit/NSBox.h" -#include "AppKit/NSButton.h" -#include "AppKit/NSColor.h" -#include "AppKit/NSComboBox.h" -#include "AppKit/NSPopUpButton.h" -#include "AppKit/NSMatrix.h" -#include "AppKit/NSNibLoading.h" -#include "AppKit/NSForm.h" -#include "AppKit/NSFormCell.h" -#include "AppKit/NSPrintInfo.h" -#include "AppKit/NSPageLayout.h" -#include "AppKit/NSTableView.h" -#include "AppKit/NSTabView.h" -#include "AppKit/NSTabViewItem.h" -#include "AppKit/NSPrinter.h" -#include "GSGuiPrivate.h" -#include "GNUstepGUI/GSPrinting.h" +#import +#import +#import +#import "AppKit/NSApplication.h" +#import "AppKit/NSFont.h" +#import "AppKit/NSTextField.h" +#import "AppKit/NSImage.h" +#import "AppKit/NSImageView.h" +#import "AppKit/NSBezierPath.h" +#import "AppKit/NSBox.h" +#import "AppKit/NSButton.h" +#import "AppKit/NSColor.h" +#import "AppKit/NSComboBox.h" +#import "AppKit/NSPopUpButton.h" +#import "AppKit/NSMatrix.h" +#import "AppKit/NSNibLoading.h" +#import "AppKit/NSForm.h" +#import "AppKit/NSFormCell.h" +#import "AppKit/NSPrintInfo.h" +#import "AppKit/NSPageLayout.h" +#import "AppKit/NSTableView.h" +#import "AppKit/NSTabView.h" +#import "AppKit/NSTabViewItem.h" +#import "AppKit/NSPrinter.h" +#import "GSGuiPrivate.h" +#import "GNUstepGUI/GSPrinting.h" static NSPageLayout *shared_instance; @@ -404,25 +404,14 @@ enum { @implementation GSPageLayoutController - (id) init { - NSString *panelPath; - NSDictionary *table; NSImage *image; NSNumberFormatter *sizeFormatter; NSNumberFormatter *scaleFormatter; - self = [super init]; + if ((self = [super init]) == nil) + return nil; - panelPath = [GSGuiBundle() pathForResource: @"GSPageLayout" - ofType: @"gorm" - inDirectory: nil]; - - NSLog(@"Panel path=%@",panelPath); - table = [NSDictionary dictionaryWithObject: self - forKey: @"NSOwner"]; - - if ([NSBundle loadNibFile: panelPath - externalNameTable: table - withZone: [self zone]] == NO) + if ([NSBundle loadNibNamed: @"GSPageLayout" owner: self] == NO) { NSRunAlertPanel(@"Error", @"Could not load page layout panel resource", @"OK", NULL, NULL); diff --git a/Source/NSPrintPanel.m b/Source/NSPrintPanel.m index 9f5b2fb9e..9dff2e8cc 100644 --- a/Source/NSPrintPanel.m +++ b/Source/NSPrintPanel.m @@ -37,6 +37,7 @@ #import #import "AppKit/NSApplication.h" #import "AppKit/NSForm.h" +#import "AppKit/NSNib.h" #import "AppKit/NSNibLoading.h" #import "AppKit/NSPrinter.h" #import "AppKit/NSPrintPanel.h" @@ -138,15 +139,16 @@ static NSPrintPanel *shared_instance; if (self == nil) return nil; - panel = [GSGuiBundle() pathForResource: GSPANELNAME ofType: @"gorm" - inDirectory: nil]; + // self will come from a bundle, to get the panel from the GUI library + // we have to select that bundle explicitly + panel = [GSGuiBundle() pathForNibResource: GSPANELNAME]; if (panel == nil) { NSRunAlertPanel(@"Error", @"Could not find print panel resource", @"OK", NULL, NULL); return nil; } - table = [NSDictionary dictionaryWithObject: self forKey: @"NSOwner"]; + table = [NSDictionary dictionaryWithObject: self forKey: NSNibOwner]; if ([NSBundle loadNibFile: panel externalNameTable: table withZone: [self zone]] == NO) diff --git a/Source/NSSpellChecker.m b/Source/NSSpellChecker.m index 174c88cd7..307204bae 100644 --- a/Source/NSSpellChecker.m +++ b/Source/NSSpellChecker.m @@ -30,7 +30,7 @@ Boston, MA 02110-1301, USA. */ -#include "config.h" +#import "config.h" #import #import #import @@ -44,21 +44,22 @@ #import #import #import -#import "AppKit/NSNibLoading.h" +#import "AppKit/NSBrowser.h" +#import "AppKit/NSBrowserCell.h" #import "AppKit/NSEvent.h" +#import "AppKit/NSGraphics.h" #import "AppKit/NSImage.h" +#import "AppKit/NSMatrix.h" +#import "AppKit/NSNib.h" +#import "AppKit/NSNibLoading.h" +#import "AppKit/NSPanel.h" +#import "AppKit/NSPopUpButton.h" #import "AppKit/NSSpellChecker.h" #import "AppKit/NSApplication.h" #import "AppKit/NSTextField.h" -#import "AppKit/NSMatrix.h" -#import "AppKit/NSBrowser.h" -#import "AppKit/NSBrowserCell.h" -#import "AppKit/NSPopUpButton.h" -#import "AppKit/NSGraphics.h" #import "AppKit/NSWindow.h" -#import "AppKit/NSPanel.h" -#include "GSGuiPrivate.h" -#include "GNUstepGUI/GSServicesManager.h" +#import "GSGuiPrivate.h" +#import "GNUstepGUI/GSServicesManager.h" // prototype for function to create name for server NSString *GSSpellServerName(NSString *checkerDictionary, NSString *language); @@ -264,10 +265,12 @@ static int __documentTag = 0; - init { NSArray *userLanguages = [NSUserDefaults userLanguages]; - NSString *panel = nil; + + self = [super init]; + if (self == nil) + return nil; // Set the language to the default for the user. - self = [super init]; _language = [userLanguages objectAtIndex: 0]; _wrapFlag = NO; _position = 0; @@ -276,11 +279,9 @@ static int __documentTag = 0; _currentTag = 0; _ignoredWords = [NSMutableDictionary new]; - // Load the gmodel file - panel = [GSGuiBundle() pathForResource: @"GSSpellPanel" ofType: @"gorm" - inDirectory: nil]; - if (![NSBundle loadNibFile: panel - externalNameTable: [NSDictionary dictionaryWithObject: self forKey: @"NSOwner"] + // Load the NIB file from the GUI bundle + if (![GSGuiBundle() loadNibFile: @"GSSpellPanel" + externalNameTable: [NSDictionary dictionaryWithObject: self forKey: NSNibOwner] withZone: [self zone]]) { NSLog(@"Model file load failed for GSSpellPanel"); diff --git a/Source/NSWindowController.m b/Source/NSWindowController.m index bce9b8fb1..9a408f060 100644 --- a/Source/NSWindowController.m +++ b/Source/NSWindowController.m @@ -26,17 +26,18 @@ Boston, MA 02110-1301, USA. */ -#include -#include -#include -#include -#include -#include +#import +#import +#import +#import +#import +#import -#include "AppKit/NSNibLoading.h" -#include "AppKit/NSPanel.h" -#include "AppKit/NSWindowController.h" -#include "NSDocumentFrameworkPrivate.h" +#import "AppKit/NSNib.h" +#import "AppKit/NSNibLoading.h" +#import "AppKit/NSPanel.h" +#import "AppKit/NSWindowController.h" +#import "NSDocumentFrameworkPrivate.h" @implementation NSWindowController @@ -468,8 +469,7 @@ return; } - table = [NSDictionary dictionaryWithObject: _owner forKey: @"NSOwner"]; - + table = [NSDictionary dictionaryWithObject: _owner forKey: NSNibOwner]; if ([NSBundle loadNibFile: [self windowNibPath] externalNameTable: table withZone: [_owner zone]])