From b2cd87cb722e004d47059397b3c1b60fb4c8438b Mon Sep 17 00:00:00 2001 From: Pieter de Bie Date: Sat, 4 Oct 2008 23:00:11 +0200 Subject: [PATCH] GitWindow: Don't try to be smart with the view selector Previously, we would try to copy the view selector from within the RepositoryWindow, so we could reuse it and change it if we need to. However, that causes problems if you have another window open: if we try to add an item using the insertItemWithIdentifier:atIndex: method, the item will be added to _all_ toolbars with the same identifier, even if those toolbars already have the item! As I see no easy way to fix that, we completely avoid the issue by not inserting any objects and just copying the view selector from view to view. --- English.lproj/RepositoryWindow.xib | 104 +--------- PBGitCommitView.xib | 175 +++++++++++++++- PBGitHistoryView.xib | 316 ++++++++++++++++++++--------- PBGitWindowController.h | 2 - PBGitWindowController.m | 34 +--- 5 files changed, 393 insertions(+), 238 deletions(-) diff --git a/English.lproj/RepositoryWindow.xib b/English.lproj/RepositoryWindow.xib index 6cd49fa..7474752 100644 --- a/English.lproj/RepositoryWindow.xib +++ b/English.lproj/RepositoryWindow.xib @@ -538,55 +538,6 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ {3.40282e+38, 3.40282e+38} GitX - - - B6D80172-2D01-49BD-8E3A-2F1D9F672390 - - View - View selector - - - - 268 - {{0, 14}, {142, 25}} - 3 - YES - - 67239424 - 0 - - LucidaGrande - 1.300000e+01 - 1044 - - - - YES - - History - 0 - - - Commit - YES - 0 - - - 1 - 2 - - - - - - {142, 25} - {142, 25} - YES - YES - 3 - YES - 0 - @@ -607,30 +558,6 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ 292 - - - selectedIndex: selectedViewIndex - - - - - - selectedIndex: selectedViewIndex - selectedIndex - selectedViewIndex - 2 - - - 329 - - - - viewSelector - - - - 350 - @@ -680,29 +607,6 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ - - 324 - - - YES - - - - - - 325 - - - YES - - - - - - 326 - - - 342 @@ -772,8 +676,6 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ 3.windowTemplate.hasMinSize 3.windowTemplate.maxSize 3.windowTemplate.minSize - 325.IBPluginDependency - 326.IBPluginDependency 342.IBPluginDependency 343.IBPluginDependency 344.IBPluginDependency @@ -790,9 +692,9 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilderKit com.apple.InterfaceBuilderKit - {{312, 315}, {850, 418}} + {{1047, -144}, {850, 418}} com.apple.InterfaceBuilder.CocoaPlugin - {{312, 315}, {850, 418}} + {{1047, -144}, {850, 418}} {{15, 196}, {850, 418}} @@ -809,8 +711,6 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin diff --git a/PBGitCommitView.xib b/PBGitCommitView.xib index 0260e41..007010b 100644 --- a/PBGitCommitView.xib +++ b/PBGitCommitView.xib @@ -898,6 +898,120 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA PBWebChangesController + + + F94591D2-A188-4B08-A8B2-8C8CEC03CB14 + + + YES + YES + NO + NO + 1 + 1 + + YES + + YES + 1E431E79-1591-49E7-9E17-49497CA4622A + NSToolbarSeparatorItem + + + YES + + + 1E431E79-1591-49E7-9E17-49497CA4622A + + View + View selector + + + + 268 + {{0, 14}, {142, 25}} + 3 + YES + + 67239424 + 0 + + + + YES + + History + 0 + + + Commit + YES + 0 + + + 1 + 2 + + + + + + {142, 25} + {142, 25} + YES + YES + 3 + YES + 0 + + + NSToolbarSeparatorItem + + Separator + + + + + + {12, 5} + {12, 1000} + YES + YES + -1 + YES + 0 + + YES + YES + + + 1048576 + 2147483647 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + + + + + + YES + + + + + YES + + + + + YES + + @@ -1126,6 +1240,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 224 + + + viewToolbar + + + + 241 + @@ -1419,6 +1541,45 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA + + 225 + + + YES + + + + + Commit Toolbar + + + 226 + + + YES + + + + + + 227 + + + + + 239 + + + YES + + + + + + 240 + + + @@ -1446,6 +1607,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 164.IBPluginDependency 2.IBPluginDependency 217.IBPluginDependency + 225.IBEditorWindowLastContentRect + 225.IBPluginDependency + 225.editorWindowContentRectSynchronizationRect + 227.IBPluginDependency + 239.IBPluginDependency + 240.IBPluginDependency 42.IBPluginDependency 45.IBPluginDependency 46.IBPluginDependency @@ -1482,6 +1649,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + {{341, 837}, {616, 169}} + com.apple.InterfaceBuilder.CocoaPlugin + {{132, 614}, {616, 0}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1516,7 +1689,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 224 + 241 diff --git a/PBGitHistoryView.xib b/PBGitHistoryView.xib index e008bb9..4df97b3 100644 --- a/PBGitHistoryView.xib +++ b/PBGitHistoryView.xib @@ -95,7 +95,7 @@ - B9F1B847-0DC3-4C13-A685-5F5A2D64BC93 + F94591D2-A188-4B08-A8B2-8C8CEC03CB14 YES @@ -108,12 +108,63 @@ YES YES + 1E431E79-1591-49E7-9E17-49497CA4622A 7FFB691C-2D2F-49A9-997F-AE1AE8BFF3F1 99C2C9EB-AE16-42A9-BE52-46CE903E9AF9 NSToolbarFlexibleSpaceItem + NSToolbarSeparatorItem YES + + + 1E431E79-1591-49E7-9E17-49497CA4622A + + View + View selector + + + + 268 + {{0, 14}, {142, 25}} + 3 + YES + + 67239424 + 0 + + LucidaGrande + 1.300000e+01 + 1044 + + + + YES + + History + 0 + + + Commit + YES + 0 + + + 1 + 2 + + + + + + {142, 25} + {142, 25} + YES + YES + 3 + YES + 0 + 7FFB691C-2D2F-49A9-997F-AE1AE8BFF3F1 @@ -131,11 +182,7 @@ 343014976 268436480 - - LucidaGrande - 1.300000e+01 - 1044 - + Subject YES @@ -330,16 +377,47 @@ + + NSToolbarSeparatorItem + + Separator + + + + + + {12, 5} + {12, 1000} + YES + YES + -1 + YES + 0 + + YES + YES + + + 1048576 + 2147483647 + + + + YES + + YES + + @@ -2052,99 +2130,6 @@ - - 113 - - - YES - - - - - - History Toolbar - - - 114 - - - YES - - - - - - 115 - - - - - 116 - - - YES - - - - - - 117 - - - YES - - - - - - 118 - - - - - 119 - - - YES - - - - - - 120 - - - YES - - - - - - 121 - - - YES - - - - - - - - 122 - - - - - 123 - - - - - 124 - - - 3 @@ -2232,6 +2217,129 @@ Branches Controller + + 113 + + + YES + + + + + + + + History Toolbar + + + 114 + + + YES + + + + + + 115 + + + + + 116 + + + YES + + + + + + 222 + + + + + 223 + + + YES + + + + + + 224 + + + YES + + + + + + 225 + + + + + 117 + + + YES + + + + + + 118 + + + + + 119 + + + YES + + + + + + 120 + + + YES + + + + + + 121 + + + YES + + + + + + + + 122 + + + + + 123 + + + + + 124 + + + @@ -2272,6 +2380,9 @@ 2.ImportedFromIB2 21.IBAttributePlaceholdersKey 21.IBPluginDependency + 222.IBPluginDependency + 224.IBPluginDependency + 225.IBPluginDependency 23.IBPluginDependency 24.IBPluginDependency 25.IBPluginDependency @@ -2319,7 +2430,7 @@ com.apple.InterfaceBuilderKit com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{244, 901}, {616, 0}} + {{341, 957}, {616, 0}} com.apple.InterfaceBuilder.CocoaPlugin {{132, 614}, {616, 0}} com.apple.InterfaceBuilder.CocoaPlugin @@ -2360,6 +2471,9 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin PBCommitList com.apple.InterfaceBuilder.CocoaPlugin @@ -2425,7 +2539,7 @@ - 217 + 225 diff --git a/PBGitWindowController.h b/PBGitWindowController.h index accde05..d243a37 100644 --- a/PBGitWindowController.h +++ b/PBGitWindowController.h @@ -14,8 +14,6 @@ int selectedViewIndex; IBOutlet NSView* contentView; NSViewController* viewController; - - IBOutlet NSToolbarItem *viewSelector; } @property (assign) __weak PBGitRepository *repository; diff --git a/PBGitWindowController.m b/PBGitWindowController.m index db530c0..18c2393 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -87,41 +87,11 @@ #pragma mark - #pragma mark Toolbar Delegates -- (NSToolbarItem *) toolbar:(NSToolbar *)toolbar - itemForItemIdentifier:(NSString *)itemIdentifier - willBeInsertedIntoToolbar:(BOOL)flag -{ - if ([itemIdentifier isEqualToString:[viewSelector itemIdentifier]]) - return viewSelector; - - return nil; -} - -- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar -{ - NSMutableArray *array = [NSMutableArray array]; - for (NSToolbarItem *item in [toolbar items]) - [array addObject:[item itemIdentifier]]; - return array; -} - -- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar -{ - NSMutableArray *array = [NSMutableArray array]; - for (NSToolbarItem *item in [toolbar items]) - [array addObject:[item itemIdentifier]]; - return array; -} - (void) useToolbar:(NSToolbar *)toolbar { - [toolbar setDelegate:self]; - - [toolbar insertItemWithItemIdentifier:NSToolbarSeparatorItemIdentifier atIndex:0]; - [toolbar insertItemWithItemIdentifier:[viewSelector itemIdentifier] atIndex:0]; - - NSSegmentedControl *viewSelect = (NSSegmentedControl *)[[[toolbar items] objectAtIndex:0] view]; - [viewSelect bind:@"selectedIndex" toObject:self withKeyPath:@"selectedViewIndex" options:0]; + NSSegmentedControl *item = (NSSegmentedControl *)[[[toolbar items] objectAtIndex:0] view]; + [item bind:@"selectedIndex" toObject:self withKeyPath:@"selectedViewIndex" options:0]; [self.window setToolbar:toolbar]; }