File tree Expand file tree Collapse file tree 4 files changed +44
-14
lines changed Expand file tree Collapse file tree 4 files changed +44
-14
lines changed Original file line number Diff line number Diff line change @@ -180,6 +180,13 @@ - (void) updateView
180
180
[self refresh: nil ];
181
181
}
182
182
183
+ - (void )viewLoaded
184
+ {
185
+ float position = [[NSUserDefaults standardUserDefaults ] floatForKey: @" PBGitSplitViewPosition" ];
186
+ if (position)
187
+ [historySplitView setPosition: position ofDividerAtIndex: 0 ];
188
+ }
189
+
183
190
- (NSResponder *)firstResponder ;
184
191
{
185
192
return commitList;
@@ -201,6 +208,9 @@ - (BOOL) hasNonlinearPath
201
208
202
209
- (void ) removeView
203
210
{
211
+ float position = [[[historySplitView subviews ] objectAtIndex: 0 ] frame ].size .height ;
212
+ [[NSUserDefaults standardUserDefaults ] setFloat: position forKey: @" PBGitSplitViewPosition" ];
213
+ [[NSUserDefaults standardUserDefaults ] synchronize ];
204
214
[webView close ];
205
215
[commitController removeObserver: self forKeyPath: @" selection" ];
206
216
[treeController removeObserver: self forKeyPath: @" selection" ];
Original file line number Diff line number Diff line change @@ -70,28 +70,32 @@ - (void)changeViewController:(NSInteger)whichViewTag
70
70
selectedViewIndex = whichViewTag;
71
71
[[NSUserDefaults standardUserDefaults ] setInteger: whichViewTag forKey: @" selectedViewIndex" ];
72
72
73
+ BOOL justLoaded = NO ;
73
74
switch (whichViewTag)
74
75
{
75
- case 0 : // swap in the "CustomImageViewController - NSImageView"
76
- if (!historyViewController)
76
+ case 0 :
77
+ if (!historyViewController) {
77
78
historyViewController = [[PBGitHistoryController alloc ] initWithRepository: repository superController: self ];
78
- else
79
- [historyViewController updateView ];
79
+ justLoaded = YES ;
80
+ }
80
81
viewController = historyViewController;
81
82
break ;
82
83
case 1 :
83
- if (!commitViewController)
84
+ if (!commitViewController) {
84
85
commitViewController = [[PBGitCommitController alloc ] initWithRepository: repository superController: self ];
85
- else
86
- [commitViewController updateView ];
87
-
86
+ justLoaded = YES ;
87
+ }
88
88
viewController = commitViewController;
89
89
break ;
90
90
}
91
91
92
92
// make sure we automatically resize the controller's view to the current window size
93
93
[[viewController view ] setFrame: [contentView bounds ]];
94
-
94
+ if (justLoaded)
95
+ [viewController viewLoaded ];
96
+ else
97
+ [viewController updateView ];
98
+
95
99
// // embed the current view to our host view
96
100
[contentView addSubview: [viewController view ]];
97
101
Original file line number Diff line number Diff line change 21
21
@property (readonly ) NSToolbar *viewToolbar;
22
22
23
23
- (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
+ */
24
28
- (void ) removeView ;
29
+
30
+ /* Updateview is called every time it is loaded into the main view */
25
31
- (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
+
26
38
- (NSResponder *)firstResponder ;
27
39
28
40
- (IBAction ) refresh : (id )sender ;
Original file line number Diff line number Diff line change @@ -35,19 +35,23 @@ - (void) awakeFromNib
35
35
{
36
36
}
37
37
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 ;
41
39
{
40
+ return nil ;
42
41
}
43
42
44
- - (NSResponder *)firstResponder ;
43
+ // The next methods should be implemented in the subclass if necessary
44
+ - (void )updateView
45
45
{
46
- return nil ;
47
46
}
48
47
49
48
- (IBAction ) refresh : (id )sender
50
49
{
51
50
return ;
52
51
}
52
+
53
+ - (void )viewLoaded
54
+ {
55
+ }
56
+
53
57
@end
You can’t perform that action at this time.
0 commit comments