mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 15:30:18 +00:00
HistoryView: Correctly update branches when changing them
I stupidly used "observe.." instead of register.. so KVC didn't even work
This commit is contained in:
@@ -29,4 +29,9 @@
|
||||
- (IBAction)saveSheet:(id) sender;
|
||||
|
||||
- (NSArray *) menuItemsForRef:(PBGitRef *)ref commit:(PBGitCommit *)commit;
|
||||
|
||||
- (void) changeBranch:(NSMenuItem *)sender;
|
||||
- (void) selectCurrentBranch;
|
||||
- (void) updateBranchMenu;
|
||||
|
||||
@end
|
||||
|
||||
+13
-3
@@ -15,7 +15,9 @@
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
[commitList registerForDraggedTypes:[NSArray arrayWithObject:@"PBGitRef"]];
|
||||
[self observeValueForKeyPath:@"repository.branches" ofObject:historyController change:NULL context:@"branchChange"];
|
||||
[historyController addObserver:self forKeyPath:@"repository.branches" options:0 context:@"branchChange"];
|
||||
[historyController addObserver:self forKeyPath:@"repository.currentBranch" options:0 context:@"currentBranchChange"];
|
||||
[self updateBranchMenu];
|
||||
}
|
||||
|
||||
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(id)context
|
||||
@@ -23,6 +25,9 @@
|
||||
if ([context isEqualToString: @"branchChange"]) {
|
||||
[self updateBranchMenu];
|
||||
}
|
||||
else if ([context isEqualToString:@"currentBranchChange"]) {
|
||||
[self selectCurrentBranch];
|
||||
}
|
||||
else {
|
||||
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
|
||||
}
|
||||
@@ -186,7 +191,6 @@
|
||||
|
||||
- (void) updateBranchMenu
|
||||
{
|
||||
NSLog(@"Updating branch");
|
||||
if (!branchPopUp)
|
||||
return;
|
||||
|
||||
@@ -286,6 +290,12 @@
|
||||
{
|
||||
PBGitRevSpecifier *rev = [sender representedObject];
|
||||
historyController.repository.currentBranch = rev;
|
||||
[branchPopUp setTitle:[sender title]];
|
||||
}
|
||||
|
||||
- (void) selectCurrentBranch
|
||||
{
|
||||
PBGitRevSpecifier *rev = historyController.repository.currentBranch;
|
||||
[branchPopUp setTitle:[rev description]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user