mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
PBViewController: add a method that is called when a view is loaded for the first time
This commit is contained in:
+13
-9
@@ -69,28 +69,32 @@
|
||||
selectedViewIndex = whichViewTag;
|
||||
[[NSUserDefaults standardUserDefaults] setInteger:whichViewTag forKey:@"selectedViewIndex"];
|
||||
|
||||
BOOL justLoaded = NO;
|
||||
switch (whichViewTag)
|
||||
{
|
||||
case 0: // swap in the "CustomImageViewController - NSImageView"
|
||||
if (!historyViewController)
|
||||
case 0:
|
||||
if (!historyViewController) {
|
||||
historyViewController = [[PBGitHistoryController alloc] initWithRepository:repository superController:self];
|
||||
else
|
||||
[historyViewController updateView];
|
||||
justLoaded = YES;
|
||||
}
|
||||
viewController = historyViewController;
|
||||
break;
|
||||
case 1:
|
||||
if (!commitViewController)
|
||||
if (!commitViewController) {
|
||||
commitViewController = [[PBGitCommitController alloc] initWithRepository:repository superController:self];
|
||||
else
|
||||
[commitViewController updateView];
|
||||
|
||||
justLoaded = YES;
|
||||
}
|
||||
viewController = commitViewController;
|
||||
break;
|
||||
}
|
||||
|
||||
// make sure we automatically resize the controller's view to the current window size
|
||||
[[viewController view] setFrame: [contentView bounds]];
|
||||
|
||||
if (justLoaded)
|
||||
[viewController viewLoaded];
|
||||
else
|
||||
[viewController updateView];
|
||||
|
||||
//// embed the current view to our host view
|
||||
[contentView addSubview: [viewController view]];
|
||||
|
||||
|
||||
@@ -21,8 +21,20 @@
|
||||
@property (readonly) NSToolbar *viewToolbar;
|
||||
|
||||
- (id)initWithRepository:(PBGitRepository *)theRepository superController:(PBGitWindowController *)controller;
|
||||
|
||||
/* removeView is called whenever the view is removed, either to be swapped
|
||||
* with a different view, or when the repository window will be destroyed
|
||||
*/
|
||||
- (void) removeView;
|
||||
|
||||
/* Updateview is called every time it is loaded into the main view */
|
||||
- (void) updateView;
|
||||
|
||||
/* Called after awakeFromNib:, and the view has been loaded into the main view.
|
||||
* Useful for resizing stuff after everything has been set in the right position
|
||||
*/
|
||||
- (void)viewLoaded;
|
||||
|
||||
- (NSResponder *)firstResponder;
|
||||
|
||||
@end
|
||||
|
||||
+10
-6
@@ -35,14 +35,18 @@
|
||||
{
|
||||
}
|
||||
|
||||
// This is called when the view is displayed again; it
|
||||
// should be updated to show the most recent information
|
||||
- (void) updateView
|
||||
{
|
||||
}
|
||||
|
||||
- (NSResponder *)firstResponder;
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
// The next methods should be implemented in the subclass if necessary
|
||||
- (void)updateView
|
||||
{
|
||||
}
|
||||
|
||||
- (void)viewLoaded
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user