File tree 3 files changed +34
-14
lines changed
3 files changed +34
-14
lines changed Original file line number Diff line number Diff line change @@ -69,28 +69,32 @@ - (void)changeViewController:(NSInteger)whichViewTag
69
69
selectedViewIndex = whichViewTag;
70
70
[[NSUserDefaults standardUserDefaults ] setInteger: whichViewTag forKey: @" selectedViewIndex" ];
71
71
72
+ BOOL justLoaded = NO ;
72
73
switch (whichViewTag)
73
74
{
74
- case 0 : // swap in the "CustomImageViewController - NSImageView"
75
- if (!historyViewController)
75
+ case 0 :
76
+ if (!historyViewController) {
76
77
historyViewController = [[PBGitHistoryController alloc ] initWithRepository: repository superController: self ];
77
- else
78
- [historyViewController updateView ];
78
+ justLoaded = YES ;
79
+ }
79
80
viewController = historyViewController;
80
81
break ;
81
82
case 1 :
82
- if (!commitViewController)
83
+ if (!commitViewController) {
83
84
commitViewController = [[PBGitCommitController alloc ] initWithRepository: repository superController: self ];
84
- else
85
- [commitViewController updateView ];
86
-
85
+ justLoaded = YES ;
86
+ }
87
87
viewController = commitViewController;
88
88
break ;
89
89
}
90
90
91
91
// make sure we automatically resize the controller's view to the current window size
92
92
[[viewController view ] setFrame: [contentView bounds ]];
93
-
93
+ if (justLoaded)
94
+ [viewController viewLoaded ];
95
+ else
96
+ [viewController updateView ];
97
+
94
98
// // embed the current view to our host view
95
99
[contentView addSubview: [viewController view ]];
96
100
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
@end
Original file line number Diff line number Diff line change @@ -35,14 +35,18 @@ - (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
}
47
+
48
+ - (void )viewLoaded
49
+ {
50
+ }
51
+
48
52
@end
You can’t perform that action at this time.
0 commit comments