Skip to content

Commit 60d2348

Browse files
committed
Make the sidebar controller accessible from the window controller
1 parent c7fa9ec commit 60d2348

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

Classes/Controllers/PBGitWindowController.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ NS_ASSUME_NONNULL_BEGIN
2626
@property (nonatomic, strong) PBGitRepository *repository;
2727
/* This is assign because that's what NSWindowController says :-S */
2828
@property (assign) PBGitRepositoryDocument *document;
29-
@property (readonly) PBGitHistoryController *historyViewController;
30-
@property (readonly) PBGitCommitController *commitViewController;
29+
@property (readonly, nullable) PBGitHistoryController *historyViewController;
30+
@property (readonly, nullable) PBGitCommitController *commitViewController;
31+
@property (readonly, nullable) PBGitSidebarController *sidebarViewController;
3132

3233
- (instancetype)init;
3334

Classes/Controllers/PBGitWindowController.m

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
@interface PBGitWindowController () {
3232
__weak PBViewController *contentController;
3333

34-
PBGitSidebarController *sidebarController;
34+
PBGitSidebarController *_sidebarController;
3535
PBGitHistoryController *_historyViewController;
3636
PBGitCommitController *_commitViewController;
3737

@@ -77,11 +77,12 @@ - (void)windowWillClose:(NSNotification *)notification
7777
{
7878
// NSLog(@"Window will close!");
7979

80-
if (sidebarController)
81-
[sidebarController closeView];
82-
80+
[self.sidebarViewController closeView];
8381
[self.historyViewController closeView];
8482
[self.commitViewController closeView];
83+
_sidebarViewController = nil;
84+
_historyViewController = nil;
85+
_commitViewController = nil;
8586
}
8687

8788
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
@@ -130,13 +131,13 @@ - (void) windowDidLoad
130131
[[self window] setFrameUsingName:@"GitX"];
131132
[[self window] setRepresentedURL:self.repository.workingDirectoryURL];
132133

133-
sidebarController = [[PBGitSidebarController alloc] initWithRepository:self.repository superController:self];
134+
_sidebarController = [[PBGitSidebarController alloc] initWithRepository:self.repository superController:self];
134135
_historyViewController = [[PBGitHistoryController alloc] initWithRepository:self.repository superController:self];
135136
_commitViewController = [[PBGitCommitController alloc] initWithRepository:self.repository superController:self];
136137

137-
[[sidebarController view] setFrame:[sourceSplitView bounds]];
138-
[sourceSplitView addSubview:[sidebarController view]];
139-
[sourceListControlsView addSubview:sidebarController.sourceListControlsView];
138+
[[_sidebarController view] setFrame:[sourceSplitView bounds]];
139+
[sourceSplitView addSubview:_sidebarController.view];
140+
[sourceListControlsView addSubview:_sidebarController.sourceListControlsView];
140141

141142
[[statusField cell] setBackgroundStyle:NSBackgroundStyleRaised];
142143
[progressIndicator setUsesThreadedAnimation:YES];
@@ -174,12 +175,12 @@ - (void) changeContentController:(PBViewController *)controller
174175

175176
- (void) showCommitView:(id)sender
176177
{
177-
[sidebarController selectStage];
178+
[_sidebarController selectStage];
178179
}
179180

180181
- (void) showHistoryView:(id)sender
181182
{
182-
[sidebarController selectCurrentBranch];
183+
[_sidebarController selectCurrentBranch];
183184
}
184185

185186
- (void)showCommitHookFailedSheet:(NSString *)messageText infoText:(NSString *)infoText commitController:(PBGitCommitController *)controller
@@ -431,11 +432,11 @@ - (void)performPushForBranch:(PBGitRef *)branchRef toRemote:(PBGitRef *)remoteRe
431432

432433
- (PBGitRef *)selectedRef {
433434
id firstResponder = self.window.firstResponder;
434-
if (firstResponder == sidebarController.sourceView) {
435-
NSOutlineView *sourceView = sidebarController.sourceView;
435+
if (firstResponder == self.sidebarViewController.sourceView) {
436+
NSOutlineView *sourceView = self.sidebarViewController.sourceView;
436437
PBSourceViewItem *item = [sourceView itemAtRow:sourceView.selectedRow];
437438
PBGitRef *ref = item.ref;
438-
if (ref && (item.parent == sidebarController.remotes)) {
439+
if (ref && (item.parent == self.sidebarViewController.remotes)) {
439440
ref = [PBGitRef refFromString:[kGitXRemoteRefPrefix stringByAppendingString:item.title]];
440441
}
441442
return ref;

0 commit comments

Comments
 (0)