Files
gitx/PBWebDiffController.m
T
Nathan Kinsinger c19d2c8058 Add Diff to contextual menus
- added to menus for refs, commits, and files
    - show a message when there are no changes
2010-03-13 22:16:24 -07:00

45 lines
1.0 KiB
Objective-C

//
// PBWebDiffController.m
// GitX
//
// Created by Pieter de Bie on 13-10-08.
// Copyright 2008 Pieter de Bie. All rights reserved.
//
#import "PBWebDiffController.h"
@implementation PBWebDiffController
- (void) awakeFromNib
{
startFile = @"diff";
[super awakeFromNib];
[diffController addObserver:self forKeyPath:@"diff" options:0 context:@"ChangedDiff"];
}
- (void) didLoad
{
[self showDiff:diffController.diff];
}
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if ([(NSString *)context isEqualToString: @"ChangedDiff"])
[self showDiff:diffController.diff];
}
- (void) showDiff: (NSString *) diff
{
if (diff == nil || !finishedLoading)
return;
id script = [view windowScriptObject];
if ([diff length] == 0)
[script callWebScriptMethod:@"setMessage" withArguments:[NSArray arrayWithObject:@"There are no differences"]];
else
[script callWebScriptMethod:@"showDiff" withArguments:[NSArray arrayWithObject:diff]];
}
@end