From e1f55fce3a51bd98d648bd023fdd48a43bf7131b Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Mon, 30 May 2011 21:15:43 -0400 Subject: [PATCH] nib2cib support for CPUserDefaultsController. --- Tools/nib2cib/NSAppKit.j | 1 + Tools/nib2cib/NSUserDefaultsController.j | 58 ++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 Tools/nib2cib/NSUserDefaultsController.j diff --git a/Tools/nib2cib/NSAppKit.j b/Tools/nib2cib/NSAppKit.j index ad4143650..435281373 100644 --- a/Tools/nib2cib/NSAppKit.j +++ b/Tools/nib2cib/NSAppKit.j @@ -71,6 +71,7 @@ @import "NSToolbarShowColorsItem.j" @import "NSToolbarSeparatorItem.j" @import "NSToolbarSpaceItem.j" +@import "NSUserDefaultsController.j" @import "NSView.j" @import "NSViewController.j" @import "NSWindowTemplate.j" diff --git a/Tools/nib2cib/NSUserDefaultsController.j b/Tools/nib2cib/NSUserDefaultsController.j new file mode 100644 index 000000000..7cf08cfd9 --- /dev/null +++ b/Tools/nib2cib/NSUserDefaultsController.j @@ -0,0 +1,58 @@ +/* + * NSUserDefaultsController.j + * AppKit + * + * Created by Alexander Ljungberg. + * Copyright 2011, WireLoad Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +@import + +@implementation CPUserDefaultsController (CPCoding) + +- (id)NS_initWithCoder:(CPCoder)aCoder +{ + if ([aCoder decodeBoolForKey:@"NSSharedInstance"]) + return [CPUserDefaultsController sharedUserDefaultsController]; + + self = [super NS_initWithCoder:aCoder]; + + if (self) + { + [CPException raise:CPUnsupportedMethodException reason:@"decoding of non-shared NSUserDefaultsController not implemented"]; + } + + return self; +} + +@end + +@implementation NSUserDefaultsController : CPUserDefaultsController +{ +} + +- (id)initWithCoder:(CPCoder)aCoder +{ + return [self NS_initWithCoder:aCoder]; +} + +- (Class)classForKeyedArchiver +{ + return [CPUserDefaultsController class]; +} + +@end