mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
2e4ea6edab
This makes the initial startup much faster. Commits get loaded in a separate thread, and are displayed every 1000 commits. There is a bug in here that makes fails a click while it is loading the commit list. Not sure how to fix this, perhaps send the arrayController?
54 lines
1.5 KiB
Objective-C
54 lines
1.5 KiB
Objective-C
//
|
|
// PBWebGitController.m
|
|
// GitTest
|
|
//
|
|
// Created by Pieter de Bie on 14-06-08.
|
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
|
//
|
|
|
|
#import "PBWebGitController.h"
|
|
|
|
|
|
@implementation PBWebGitController
|
|
|
|
@synthesize diff;
|
|
|
|
- (void) awakeFromNib
|
|
{
|
|
[commitsController addObserver:self forKeyPath:@"selection" options:0 context:@"ChangedCommit"];
|
|
NSLog(@"WebGitController activated");
|
|
NSLog([[NSBundle mainBundle] resourcePath]);
|
|
NSString* file = [[NSBundle mainBundle] pathForResource:@"commit" ofType:@"html"];
|
|
NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:file]];
|
|
NSLog(@"Request: %@", request);
|
|
[[view mainFrame] loadRequest:request];
|
|
}
|
|
|
|
- (void) webView:(id) view didFinishLoadForFrame:(id) frame
|
|
{
|
|
NSLog(@"Loading done");
|
|
[self changeContentTo: [[commitsController selectedObjects] objectAtIndex:0]];
|
|
}
|
|
|
|
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
|
|
{
|
|
if (context == @"ChangedCommit") {
|
|
if ([[commitsController selectedObjects] count] != 0)
|
|
[self changeContentTo: [[commitsController selectedObjects] objectAtIndex:0]];
|
|
}
|
|
else {
|
|
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
|
|
}
|
|
}
|
|
|
|
- (void) changeContentTo: (PBGitCommit *) content
|
|
{
|
|
if ([currentSha isEqualToString: content.sha])
|
|
return;
|
|
currentSha = content.sha;
|
|
id script = [view windowScriptObject];
|
|
[script setValue: content forKey:@"CommitObject"];
|
|
[script callWebScriptMethod:@"doeHet" withArguments: nil];
|
|
}
|
|
@end
|