Skip to content

Commit 68ea0b1

Browse files
committed
Merge branch 'stable' of git://github.com/pieter/gitx
Conflicts: PBViewController.m
2 parents 15b394b + e901894 commit 68ea0b1

File tree

4 files changed

+44
-14
lines changed

4 files changed

+44
-14
lines changed

PBGitHistoryController.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@ - (void) updateView
180180
[self refresh:nil];
181181
}
182182

183+
- (void)viewLoaded
184+
{
185+
float position = [[NSUserDefaults standardUserDefaults] floatForKey:@"PBGitSplitViewPosition"];
186+
if (position)
187+
[historySplitView setPosition:position ofDividerAtIndex:0];
188+
}
189+
183190
- (NSResponder *)firstResponder;
184191
{
185192
return commitList;
@@ -201,6 +208,9 @@ - (BOOL) hasNonlinearPath
201208

202209
- (void) removeView
203210
{
211+
float position = [[[historySplitView subviews] objectAtIndex:0] frame].size.height;
212+
[[NSUserDefaults standardUserDefaults] setFloat:position forKey:@"PBGitSplitViewPosition"];
213+
[[NSUserDefaults standardUserDefaults] synchronize];
204214
[webView close];
205215
[commitController removeObserver:self forKeyPath:@"selection"];
206216
[treeController removeObserver:self forKeyPath:@"selection"];

PBGitWindowController.m

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,28 +70,32 @@ - (void)changeViewController:(NSInteger)whichViewTag
7070
selectedViewIndex = whichViewTag;
7171
[[NSUserDefaults standardUserDefaults] setInteger:whichViewTag forKey:@"selectedViewIndex"];
7272

73+
BOOL justLoaded = NO;
7374
switch (whichViewTag)
7475
{
75-
case 0: // swap in the "CustomImageViewController - NSImageView"
76-
if (!historyViewController)
76+
case 0:
77+
if (!historyViewController) {
7778
historyViewController = [[PBGitHistoryController alloc] initWithRepository:repository superController:self];
78-
else
79-
[historyViewController updateView];
79+
justLoaded = YES;
80+
}
8081
viewController = historyViewController;
8182
break;
8283
case 1:
83-
if (!commitViewController)
84+
if (!commitViewController) {
8485
commitViewController = [[PBGitCommitController alloc] initWithRepository:repository superController:self];
85-
else
86-
[commitViewController updateView];
87-
86+
justLoaded = YES;
87+
}
8888
viewController = commitViewController;
8989
break;
9090
}
9191

9292
// make sure we automatically resize the controller's view to the current window size
9393
[[viewController view] setFrame: [contentView bounds]];
94-
94+
if (justLoaded)
95+
[viewController viewLoaded];
96+
else
97+
[viewController updateView];
98+
9599
//// embed the current view to our host view
96100
[contentView addSubview: [viewController view]];
97101

PBViewController.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,20 @@
2121
@property (readonly) NSToolbar *viewToolbar;
2222

2323
- (id)initWithRepository:(PBGitRepository *)theRepository superController:(PBGitWindowController *)controller;
24+
25+
/* removeView is called whenever the view is removed, either to be swapped
26+
* with a different view, or when the repository window will be destroyed
27+
*/
2428
- (void) removeView;
29+
30+
/* Updateview is called every time it is loaded into the main view */
2531
- (void) updateView;
32+
33+
/* Called after awakeFromNib:, and the view has been loaded into the main view.
34+
* Useful for resizing stuff after everything has been set in the right position
35+
*/
36+
- (void)viewLoaded;
37+
2638
- (NSResponder *)firstResponder;
2739

2840
- (IBAction) refresh:(id)sender;

PBViewController.m

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,23 @@ - (void) awakeFromNib
3535
{
3636
}
3737

38-
// This is called when the view is displayed again; it
39-
// should be updated to show the most recent information
40-
- (void) updateView
38+
- (NSResponder *)firstResponder;
4139
{
40+
return nil;
4241
}
4342

44-
- (NSResponder *)firstResponder;
43+
// The next methods should be implemented in the subclass if necessary
44+
- (void)updateView
4545
{
46-
return nil;
4746
}
4847

4948
- (IBAction) refresh:(id)sender
5049
{
5150
return;
5251
}
52+
53+
- (void)viewLoaded
54+
{
55+
}
56+
5357
@end

0 commit comments

Comments
 (0)