Permalink
Browse files

Add method for removing ViewController

  • Loading branch information...
1 parent eaa0305 commit 846054a720028162d2a255764b421501f5ca2209 @FlyingDiver FlyingDiver committed Sep 9, 2013
Showing with 66 additions and 61 deletions.
  1. +50 −54 MASPreferencesWindow.xib
  2. +5 −2 MASPreferencesWindowController.h
  3. +11 −5 MASPreferencesWindowController.m
View
104 MASPreferencesWindow.xib
@@ -1,30 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
- <int key="IBDocument.SystemTarget">1060</int>
- <string key="IBDocument.SystemVersion">10K549</string>
- <string key="IBDocument.InterfaceBuilderVersion">851</string>
- <string key="IBDocument.AppKitVersion">1038.36</string>
- <string key="IBDocument.HIToolboxVersion">461.00</string>
+ <int key="IBDocument.SystemTarget">1080</int>
+ <string key="IBDocument.SystemVersion">12E55</string>
+ <string key="IBDocument.InterfaceBuilderVersion">3084</string>
+ <string key="IBDocument.AppKitVersion">1187.39</string>
+ <string key="IBDocument.HIToolboxVersion">626.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="NS.object.0">851</string>
+ <string key="NS.object.0">3084</string>
</object>
- <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
+ <object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <string>NSCustomObject</string>
+ <string>NSToolbar</string>
+ <string>NSView</string>
+ <string>NSWindowTemplate</string>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSArray" key="dict.sortedKeys" id="0">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
- <object class="NSMutableArray" key="dict.values">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
+ <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
+ <integer value="1" key="NS.object.0"/>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -57,28 +56,28 @@
<int key="NSToolbarSizeMode">1</int>
<object class="NSMutableDictionary" key="NSToolbarIBIdentifiedItems">
<bool key="EncodedWithXMLCoder">YES</bool>
- <reference key="dict.sortedKeys" ref="0"/>
- <object class="NSMutableArray" key="dict.values">
+ <object class="NSArray" key="dict.sortedKeys" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
+ <reference key="dict.values" ref="0"/>
</object>
<reference key="NSToolbarIBAllowedItems" ref="0"/>
- <object class="NSMutableArray" key="NSToolbarIBDefaultItems">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
- <object class="NSMutableArray" key="NSToolbarIBSelectableItems">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
+ <reference key="NSToolbarIBDefaultItems" ref="0"/>
+ <reference key="NSToolbarIBSelectableItems" ref="0"/>
</object>
- <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
+ <nil key="NSUserInterfaceItemIdentifier"/>
<object class="NSView" key="NSWindowView" id="1006">
- <nil key="NSNextResponder"/>
+ <reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
- <string key="NSFrame">{{7, 11}, {360, 270}}</string>
+ <string key="NSFrameSize">{360, 270}</string>
+ <reference key="NSSuperview"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView"/>
</object>
- <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
- <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
+ <string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
+ <string key="NSMaxSize">{10000000000000, 10000000000000}</string>
<string key="NSFrameAutosaveName"/>
+ <bool key="NSWindowIsRestorable">YES</bool>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
@@ -94,11 +93,11 @@
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
- <string key="label">delegate</string>
- <reference key="source" ref="693562270"/>
- <reference key="destination" ref="1001"/>
+ <string key="label">toolbar</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="693562270"/>
</object>
- <int key="connectionID">12</int>
+ <int key="connectionID">23</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
@@ -108,6 +107,14 @@
</object>
<int key="connectionID">20</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="693562270"/>
+ <reference key="destination" ref="1001"/>
+ </object>
+ <int key="connectionID">22</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -165,50 +172,44 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
- <string>1.IBEditorWindowLastContentRect</string>
+ <string>-1.IBPluginDependency</string>
+ <string>-2.IBPluginDependency</string>
+ <string>-3.IBPluginDependency</string>
<string>1.IBNSWindowAutoPositionCentersHorizontal</string>
<string>1.IBNSWindowAutoPositionCentersVertical</string>
<string>1.IBPluginDependency</string>
<string>1.IBWindowTemplateEditedContentRect</string>
<string>1.NSWindowTemplate.visibleAtLaunch</string>
- <string>1.WindowOrigin</string>
- <string>1.editorWindowContentRectSynchronizationRect</string>
<string>2.IBPluginDependency</string>
- <string>4.IBEditorWindowLastContentRect</string>
<string>4.IBPluginDependency</string>
</object>
- <object class="NSMutableArray" key="dict.values">
+ <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
- <string>{{484, 402}, {360, 270}}</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="NO"/>
<boolean value="NO"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{484, 402}, {360, 270}}</string>
<boolean value="NO"/>
- <string>{196, 240}</string>
- <string>{{202, 428}, {480, 270}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{416, 672}, {616, 0}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
- <object class="NSMutableArray" key="dict.values">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
+ <reference key="dict.values" ref="0"/>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
- <object class="NSMutableArray" key="dict.values">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
+ <reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
- <int key="maxID">20</int>
+ <int key="maxID">23</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -223,7 +224,7 @@
<string>goNextTab:</string>
<string>goPreviousTab:</string>
</object>
- <object class="NSMutableArray" key="dict.values">
+ <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
@@ -236,7 +237,7 @@
<string>goNextTab:</string>
<string>goPreviousTab:</string>
</object>
- <object class="NSMutableArray" key="dict.values">
+ <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBActionInfo">
<string key="name">goNextTab:</string>
@@ -257,16 +258,11 @@
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
- <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
- <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
- <integer value="1060" key="NS.object.0"/>
- </object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
<integer value="3000" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
- <nil key="IBDocument.LastKnownRelativeProjectPath"/>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
</archive>
View
7 MASPreferencesWindowController.h
@@ -19,19 +19,22 @@ __attribute__((__visibility__("default")))
#endif
{
@private
- NSArray *_viewControllers;
+ NSMutableArray *_viewControllers;
NSMutableDictionary *_minimumViewRects;
NSString *_title;
NSViewController <MASPreferencesViewController> *_selectedViewController;
+ IBOutlet NSToolbar *toolbar;
}
-@property (nonatomic, readonly) NSArray *viewControllers;
+@property (nonatomic, readonly) NSMutableArray *viewControllers;
@property (nonatomic, readonly) NSUInteger indexOfSelectedController;
@property (nonatomic, readonly, retain) NSViewController <MASPreferencesViewController> *selectedViewController;
@property (nonatomic, readonly) NSString *title;
+@property (nonatomic, retain) IBOutlet NSToolbar *toolbar;
- (id)initWithViewControllers:(NSArray *)viewControllers;
- (id)initWithViewControllers:(NSArray *)viewControllers title:(NSString *)title;
+- (void)addViewController:(NSViewController <MASPreferencesViewController> *) viewController;
- (void)selectControllerAtIndex:(NSUInteger)controllerIndex;
View
16 MASPreferencesWindowController.m
@@ -26,7 +26,7 @@ @implementation MASPreferencesWindowController
@synthesize viewControllers = _viewControllers;
@synthesize selectedViewController = _selectedViewController;
@synthesize title = _title;
-
+@synthesize toolbar = _toolbar;
#pragma mark -
- (id)initWithViewControllers:(NSArray *)viewControllers
@@ -38,10 +38,9 @@ - (id)initWithViewControllers:(NSArray *)viewControllers title:(NSString *)title
{
if ((self = [super initWithWindowNibName:@"MASPreferencesWindow"]))
{
-#if __has_feature(objc_arc)
- _viewControllers = viewControllers;
-#else
- _viewControllers = [viewControllers retain];
+ _viewControllers = [NSMutableArray arrayWithArray: viewControllers];
+#if !__has_feature(objc_arc)
+ _viewControllers = [_viewControllers retain];
#endif
_minimumViewRects = [[NSMutableDictionary alloc] init];
_title = [title copy];
@@ -62,6 +61,13 @@ - (void)dealloc
#endif
}
+- (void)addViewController: (NSViewController <MASPreferencesViewController> *) viewController
+{
+ [_viewControllers addObject: viewController];
+ [_toolbar insertItemWithItemIdentifier: [viewController identifier] atIndex: ([_viewControllers count] - 1)];
+ [_toolbar validateVisibleItems];
+}
+
#pragma mark -
- (void)windowDidLoad

0 comments on commit 846054a

Please sign in to comment.