diff --git a/FileViewer/FileViewer.xib b/FileViewer/FileViewer.xib new file mode 100644 index 0000000..4747fb0 --- /dev/null +++ b/FileViewer/FileViewer.xib @@ -0,0 +1,816 @@ + + + + 1050 + 10D573 + 762 + 1038.29 + 460.00 + + YES + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.WebKitIBPlugin + + + YES + 762 + 762 + + + + YES + + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.WebKitIBPlugin + + + YES + + YES + + + YES + + + + YES + + FileViewerController + + + FirstResponder + + + NSApplication + + + + 274 + + YES + + + 274 + + YES + + YES + Apple HTML pasteboard type + Apple PDF pasteboard type + Apple PICT pasteboard type + Apple URL pasteboard type + Apple Web Archive pasteboard type + NSColor pasteboard type + NSFilenamesPboardType + NSStringPboardType + NeXT RTFD pasteboard type + NeXT Rich Text Format v1.0 pasteboard type + NeXT TIFF v4.0 pasteboard type + WebURLsWithTitlesPboardType + public.png + public.url + public.url-name + + + {{0, 3}, {800, 474}} + + + + + + + + YES + + YES + WebKitDefaultFixedFontSize + WebKitDefaultFontSize + WebKitMinimumFontSize + + + YES + + + + + + + YES + YES + + + + 266 + {{0, 475}, {800, 25}} + + MGScopeBar + + + {800, 500} + + NSView + + + FileViewerController + + + + + YES + + + scopeBar + + + + 22 + + + + webViewFileViwer + + + + 23 + + + + view + + + + 24 + + + + scopeBar + + + + 26 + + + + + YES + + 0 + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 1 + + + YES + + + + + + + 20 + + + + + 21 + + + + + 25 + + + + + + + YES + + YES + 1.IBEditorWindowLastContentRect + 1.IBPluginDependency + 1.WindowOrigin + 1.editorWindowContentRectSynchronizationRect + 20.IBPluginDependency + 21.IBPluginDependency + 25.IBPluginDependency + + + YES + {{185, 62}, {800, 500}} + com.apple.InterfaceBuilder.CocoaPlugin + {628, 654} + {{217, 442}, {480, 272}} + com.apple.WebKitIBPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 26 + + + + YES + + FileViewerController + NSViewController + + YES + + YES + displayControl + scopeBar + webViewFileViwer + + + YES + NSSegmentedCell + MGScopeBar + WebView + + + + IBProjectSource + FileViewer/FileViewerController.h + + + + MGScopeBar + NSView + + delegate + id + + + IBProjectSource + MGScopeBar/MGScopeBar.h + + + + + YES + + NSActionCell + NSCell + + IBFrameworkSource + AppKit.framework/Headers/NSActionCell.h + + + + NSApplication + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSApplication.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSApplicationScripting.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSColorPanel.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSHelpManager.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSPageLayout.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSUserInterfaceItemSearching.h + + + + NSCell + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSCell.h + + + + NSFormatter + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFormatter.h + + + + NSMenu + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSMenu.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSAccessibility.h + + + + NSObject + + + + NSObject + + + + NSObject + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSControl.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSDictionaryController.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSDragging.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSFontManager.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSFontPanel.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSKeyValueBinding.h + + + + NSObject + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSNibLoading.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSOutlineView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSPasteboard.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSSavePanel.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSTableView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSToolbarItem.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSView.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSClassDescription.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObjectScripting.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSPortCoder.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptClassDescription.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptObjectSpecifiers.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptWhoseTests.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLDownload.h + + + + NSObject + + IBFrameworkSource + Sparkle.framework/Headers/SUAppcast.h + + + + NSObject + + IBFrameworkSource + Sparkle.framework/Headers/SUUpdater.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebDownload.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebEditingDelegate.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebFrameLoadDelegate.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebJavaPlugIn.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebPlugin.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebPluginContainer.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebPolicyDelegate.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebResourceLoadDelegate.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebScriptObject.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebUIDelegate.h + + + + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSInterfaceStyle.h + + + + NSResponder + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSResponder.h + + + + NSSegmentedCell + NSActionCell + + IBFrameworkSource + AppKit.framework/Headers/NSSegmentedCell.h + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSClipView.h + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSMenuItem.h + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSRulerView.h + + + + NSView + NSResponder + + + + NSViewController + NSResponder + + view + NSView + + + IBFrameworkSource + AppKit.framework/Headers/NSViewController.h + + + + WebView + NSView + + YES + + YES + goBack: + goForward: + makeTextLarger: + makeTextSmaller: + makeTextStandardSize: + reload: + reloadFromOrigin: + stopLoading: + takeStringURLFrom: + toggleContinuousSpellChecking: + toggleSmartInsertDelete: + + + YES + id + id + id + id + id + id + id + id + id + id + id + + + + IBFrameworkSource + WebKit.framework/Headers/WebView.h + + + + + 0 + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.macosx + + + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES + ../GitX.xcodeproj + 3 + + diff --git a/FileViewer/FileViewerController.h b/FileViewer/FileViewerController.h new file mode 100644 index 0000000..fe41175 --- /dev/null +++ b/FileViewer/FileViewerController.h @@ -0,0 +1,37 @@ +// +// FileViewerController.h +// GitX +// +// Created by German Laullon on 11/06/10. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import +#import +#import "MGScopeBar.h" +#import "PBGitRepository.h" + +@interface FileViewerController : NSViewController { + IBOutlet NSSegmentedCell *displayControl; + IBOutlet MGScopeBar *scopeBar; + IBOutlet WebView *webViewFileViwer; + + NSMutableArray *groups; + NSString *file; + NSString *sha; + + PBGitRepository *repository; + + bool commit; +} + +- (id)initWithRepository:(PBGitRepository *)theRepository; +- (void)showFile:(NSString *)file sha:(NSString *)sha; +- (NSString*)refSpec; + +-(NSString *)parseBlame:(NSString *)string; + +@property(retain) NSMutableArray *groups; +@property(readwrite) bool commit; + +@end diff --git a/FileViewer/FileViewerController.m b/FileViewer/FileViewerController.m new file mode 100644 index 0000000..2a4b219 --- /dev/null +++ b/FileViewer/FileViewerController.m @@ -0,0 +1,257 @@ +// +// FileViewerController.m +// GitX +// +// Created by German Laullon on 11/06/10. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import "FileViewerController.h" + +#define GROUP_LABEL @"Label" // string +#define GROUP_SEPARATOR @"HasSeparator" // BOOL as NSNumber +#define GROUP_SELECTION_MODE @"SelectionMode" // MGScopeBarGroupSelectionMode (int) as NSNumber +#define GROUP_ITEMS @"Items" // array of dictionaries, each containing the following keys: +#define ITEM_IDENTIFIER @"Identifier" // string +#define ITEM_NAME @"Name" // string + +@implementation FileViewerController + + +#pragma mark Setup and teardown + +- (id)initWithRepository:(PBGitRepository *)theRepository +{ + repository=theRepository; + return [self initWithNibName:@"FileViewer" bundle:[NSBundle mainBundle]]; +} + +- (void)awakeFromNib +{ + self.groups = [NSMutableArray arrayWithCapacity:0]; + scopeBar.delegate = self; + NSArray *items = [NSArray arrayWithObjects: + [NSDictionary dictionaryWithObjectsAndKeys: + @"source", ITEM_IDENTIFIER, + @"Source", ITEM_NAME, + nil], + [NSDictionary dictionaryWithObjectsAndKeys: + @"blame", ITEM_IDENTIFIER, + @"Blame", ITEM_NAME, + nil], + [NSDictionary dictionaryWithObjectsAndKeys: + (commit)?@"commit":@"diff", ITEM_IDENTIFIER, + @"Diff", ITEM_NAME, + nil], + nil]; + [self.groups addObject:[NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:NO], GROUP_SEPARATOR, + [NSNumber numberWithInt:MGRadioSelectionMode], GROUP_SELECTION_MODE, // single selection group. + items, GROUP_ITEMS, + nil]]; + [scopeBar reloadData]; + [webViewFileViwer setFrameLoadDelegate:self]; +} + + +- (void)dealloc +{ + self.groups = nil; + [super dealloc]; +} + + +#pragma mark MGScopeBarDelegate methods + + +- (int)numberOfGroupsInScopeBar:(MGScopeBar *)theScopeBar +{ + return [self.groups count]; +} + + +- (NSArray *)scopeBar:(MGScopeBar *)theScopeBar itemIdentifiersForGroup:(int)groupNumber +{ + return [[self.groups objectAtIndex:groupNumber] valueForKeyPath:[NSString stringWithFormat:@"%@.%@", GROUP_ITEMS, ITEM_IDENTIFIER]]; +} + + +- (NSString *)scopeBar:(MGScopeBar *)theScopeBar labelForGroup:(int)groupNumber +{ + return [[self.groups objectAtIndex:groupNumber] objectForKey:GROUP_LABEL]; // might be nil, which is fine (nil means no label). +} + + +- (NSString *)scopeBar:(MGScopeBar *)theScopeBar titleOfItem:(NSString *)identifier inGroup:(int)groupNumber +{ + NSArray *items = [[self.groups objectAtIndex:groupNumber] objectForKey:GROUP_ITEMS]; + if (items) { + for (NSDictionary *item in items) { + if ([[item objectForKey:ITEM_IDENTIFIER] isEqualToString:identifier]) { + return [item objectForKey:ITEM_NAME]; + break; + } + } + } + return nil; +} + + +- (MGScopeBarGroupSelectionMode)scopeBar:(MGScopeBar *)theScopeBar selectionModeForGroup:(int)groupNumber +{ + return [[[self.groups objectAtIndex:groupNumber] objectForKey:GROUP_SELECTION_MODE] intValue]; +} + +- (void)scopeBar:(MGScopeBar *)theScopeBar selectedStateChanged:(BOOL)selected forItem:(NSString *)identifier inGroup:(int)groupNumber +{ + NSString *path = [NSString stringWithFormat:@"html/views/%@", identifier]; + NSString *html = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:path]; + NSLog(@"[FileViewerController scopeBar:selectedStateChanged] -> file: '%@' (%@)",html,identifier); + NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:html]]; + [[webViewFileViwer mainFrame] loadRequest:request]; +} + +- (void)showFile:(NSString *)f sha:(NSString *)s{ + file=f; + sha=s; + NSString *show=[[[scopeBar selectedItems] objectAtIndex:0] objectAtIndex:0]; + NSLog(@"[showFile:sha] showFile:%@ sha:%@ (show=%@)",file,sha,show); + [self scopeBar:scopeBar selectedStateChanged:true forItem:show inGroup:0]; +} + + +- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame +{ + NSString *txt; + NSString *show=[[[scopeBar selectedItems] objectAtIndex:0] objectAtIndex:0]; + if(show==@"source") + txt=[repository outputForArguments:[NSArray arrayWithObjects:@"show", [self refSpec], nil]]; + else if(show==@"blame") + txt=[self parseBlame:[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"blame", @"-p", file, sha, nil]]]; + else if((show==@"diff") || (show==@"commit")) + txt=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff", (sha!=nil)?sha:file , (sha!=nil)?file:nil, nil]]; + else + return; // XXXX controlar mejor. + + NSLog(@"didFinishLoadForFrame -> txt: '%@'",[txt substringToIndex:80]); + + id script = [webViewFileViwer windowScriptObject]; + [script callWebScriptMethod:@"showFile" + withArguments:[NSArray arrayWithObjects:txt, nil]]; + + //NSLog(@"%@",[[[[sender mainFrame] DOMDocument] documentElement] outerHTML]); +} + +- (NSString*)refSpec +{ + return [NSString stringWithFormat:@"%@:%@", (sha!=nil)?sha:@"HEAD", file]; +} + + +-(NSString *)parseBlame:(NSString *)string +{ + string=[string stringByReplacingOccurrencesOfString:@"<" withString:@"<"]; + string=[string stringByReplacingOccurrencesOfString:@">" withString:@">"]; + + NSArray *lines = [string componentsSeparatedByString:@"\n"]; + NSString *line; + NSMutableDictionary *headers=[NSMutableDictionary dictionary]; + NSMutableString *res=[NSMutableString string]; + + [res appendString:@"\n"]; + int i=0; + while(i<[lines count]){ + line=[lines objectAtIndex:i]; + NSArray *header=[line componentsSeparatedByString:@" "]; + if([header count]==4){ + int nLines=[(NSString *)[header objectAtIndex:3] intValue]; + [res appendFormat:@"\n",nLines]; + line=[lines objectAtIndex:++i]; + if([[[line componentsSeparatedByString:@" "] objectAtIndex:0] isEqual:@"author"]){ + NSString *author=line; + NSString *summary=nil; + while(summary==nil){ + line=[lines objectAtIndex:i++]; + if([[[line componentsSeparatedByString:@" "] objectAtIndex:0] isEqual:@"summary"]){ + summary=line; + } + } + NSString *block=[NSString stringWithFormat:@"\n\n"]; + }else{ + break; + } + [res appendString:@"\n"]; + } + [res appendString:@"

%@

%@

\n",author,summary]; + [headers setObject:block forKey:[header objectAtIndex:0]]; + } + [res appendString:[headers objectForKey:[header objectAtIndex:0]]]; + + NSMutableString *code=[NSMutableString string]; + do{ + line=[lines objectAtIndex:i++]; + }while([line characterAtIndex:0]!='\t'); + line=[line stringByReplacingOccurrencesOfString:@"\t" withString:@"    "]; + [code appendString:line]; + [code appendString:@"\n"]; + + int n; + for(n=1;n%@",[header objectAtIndex:2],code]; + [res appendString:@"
\n"]; + //NSLog(@"%@",res); + + return (NSString *)res; +} + +#pragma mark Accessors and properties +/* + + - (IBAction)updateFileViwer:(id)sender + { + NSString *type + int option=[displayControl selectedSegment]; + if(option==0) + type=@"source"; + else if(option==1) + type=@"blame"; + else if(option==2) + type=@"diff"; + + } + + + - (void)webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame + { + NSString *messageString = [error localizedDescription]; + NSString *moreString = [error localizedFailureReason] ? + [error localizedFailureReason] : + NSLocalizedString(@"Try typing the URL again.", nil); + messageString = [NSString stringWithFormat:@"%@. %@", messageString, moreString]; + NSLog(@"ERROR!!!! - %@",messageString); + } + + /* + + NSArray *objects = [treeController selectedObjects]; + NSArray *content = [treeController content]; + + if ([objects count] && [content count]) { + PBGitTree *treeItem = [objects objectAtIndex:0]; + currentFileBrowserSelectionPath = [treeItem.fullPath componentsSeparatedByString:@"/"]; + + NSString *txt=[treeItem contents:[displayControl selectedSegment]]; + + */ +@synthesize groups; +@synthesize commit; + +@end diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index 7a18a69..f817c82 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -22,6 +22,13 @@ /* Begin PBXBuildFile section */ 056438B70ED0C40B00985397 /* DetailViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 056438B60ED0C40B00985397 /* DetailViewTemplate.png */; }; + 315CB97B11C3305F003B8DBE /* FileViewerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 315CB97A11C3305F003B8DBE /* FileViewerController.m */; }; + 315CB9B011C339DA003B8DBE /* FileViewer.xib in Resources */ = {isa = PBXBuildFile; fileRef = 315CB9AF11C339DA003B8DBE /* FileViewer.xib */; }; + 31A520AC11C6983900F604D0 /* test.html in Resources */ = {isa = PBXBuildFile; fileRef = 31A520AB11C6983900F604D0 /* test.html */; }; + 31D70AFB11C4006C00F4B199 /* MGRecessedPopUpButtonCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 31D70AF111C4006C00F4B199 /* MGRecessedPopUpButtonCell.m */; }; + 31D70AFC11C4006C00F4B199 /* MGScopeBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 31D70AF311C4006C00F4B199 /* MGScopeBar.m */; }; + 31D70AFD11C4006C00F4B199 /* ReadMe.txt in Resources */ = {isa = PBXBuildFile; fileRef = 31D70AF911C4006C00F4B199 /* ReadMe.txt */; }; + 31D70AFE11C4006C00F4B199 /* Source Code License.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 31D70AFA11C4006C00F4B199 /* Source Code License.rtf */; }; 3BC07F4C0ED5A5C5009A7768 /* HistoryViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 3BC07F4A0ED5A5C5009A7768 /* HistoryViewTemplate.png */; }; 3BC07F4D0ED5A5C5009A7768 /* CommitViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 3BC07F4B0ED5A5C5009A7768 /* CommitViewTemplate.png */; }; 47DBDB580E94EDE700671A1E /* DBPrefsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 47DBDB570E94EDE700671A1E /* DBPrefsWindowController.m */; }; @@ -296,6 +303,18 @@ 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; + 315CB97911C3305F003B8DBE /* FileViewerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileViewerController.h; path = FileViewer/FileViewerController.h; sourceTree = ""; }; + 315CB97A11C3305F003B8DBE /* FileViewerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FileViewerController.m; path = FileViewer/FileViewerController.m; sourceTree = ""; }; + 315CB9AF11C339DA003B8DBE /* FileViewer.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = FileViewer.xib; path = FileViewer/FileViewer.xib; sourceTree = ""; }; + 31A520AB11C6983900F604D0 /* test.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = test.html; sourceTree = ""; }; + 31D70AF011C4006C00F4B199 /* MGRecessedPopUpButtonCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGRecessedPopUpButtonCell.h; sourceTree = ""; }; + 31D70AF111C4006C00F4B199 /* MGRecessedPopUpButtonCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGRecessedPopUpButtonCell.m; sourceTree = ""; }; + 31D70AF211C4006C00F4B199 /* MGScopeBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGScopeBar.h; sourceTree = ""; }; + 31D70AF311C4006C00F4B199 /* MGScopeBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGScopeBar.m; sourceTree = ""; }; + 31D70AF711C4006C00F4B199 /* MGScopeBar_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGScopeBar_Prefix.pch; sourceTree = ""; }; + 31D70AF811C4006C00F4B199 /* MGScopeBarDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGScopeBarDelegateProtocol.h; sourceTree = ""; }; + 31D70AF911C4006C00F4B199 /* ReadMe.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadMe.txt; sourceTree = ""; }; + 31D70AFA11C4006C00F4B199 /* Source Code License.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = "Source Code License.rtf"; sourceTree = ""; }; 32CA4F630368D1EE00C91783 /* GitX_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GitX_Prefix.pch; sourceTree = ""; }; 3BC07F4A0ED5A5C5009A7768 /* HistoryViewTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = HistoryViewTemplate.png; path = Images/HistoryViewTemplate.png; sourceTree = ""; }; 3BC07F4B0ED5A5C5009A7768 /* CommitViewTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = CommitViewTemplate.png; path = Images/CommitViewTemplate.png; sourceTree = ""; }; @@ -665,6 +684,8 @@ 29B97314FDCFA39411CA2CEA /* GitTest */ = { isa = PBXGroup; children = ( + 31D70AEF11C4006C00F4B199 /* MGScopeBar */, + 315CB97811C32FC2003B8DBE /* FileViewer */, C3138B6211C2F39900BE6CBE /* html */, F5886A080ED5D26B0066E74C /* SpeedTest */, 913D5E420E5563FD00CECEA2 /* cli */, @@ -750,6 +771,31 @@ name = Frameworks; sourceTree = ""; }; + 315CB97811C32FC2003B8DBE /* FileViewer */ = { + isa = PBXGroup; + children = ( + 315CB97911C3305F003B8DBE /* FileViewerController.h */, + 315CB97A11C3305F003B8DBE /* FileViewerController.m */, + 315CB9AF11C339DA003B8DBE /* FileViewer.xib */, + ); + name = FileViewer; + sourceTree = ""; + }; + 31D70AEF11C4006C00F4B199 /* MGScopeBar */ = { + isa = PBXGroup; + children = ( + 31D70AF011C4006C00F4B199 /* MGRecessedPopUpButtonCell.h */, + 31D70AF111C4006C00F4B199 /* MGRecessedPopUpButtonCell.m */, + 31D70AF211C4006C00F4B199 /* MGScopeBar.h */, + 31D70AF311C4006C00F4B199 /* MGScopeBar.m */, + 31D70AF711C4006C00F4B199 /* MGScopeBar_Prefix.pch */, + 31D70AF811C4006C00F4B199 /* MGScopeBarDelegateProtocol.h */, + 31D70AF911C4006C00F4B199 /* ReadMe.txt */, + 31D70AFA11C4006C00F4B199 /* Source Code License.rtf */, + ); + path = MGScopeBar; + sourceTree = ""; + }; 47DBDB920E94F47200671A1E /* Preference Icons */ = { isa = PBXGroup; children = ( @@ -819,6 +865,7 @@ C3138B9311C2F48400BE6CBE /* commit.js */, C3138B9411C2F48400BE6CBE /* index.html */, C3138B9511C2F48400BE6CBE /* multipleSelection.js */, + 31A520AB11C6983900F604D0 /* test.html */, ); path = commit; sourceTree = ""; @@ -1434,6 +1481,10 @@ C3138C3111C2F48400BE6CBE /* diff.css in Resources */, C3138C3211C2F48400BE6CBE /* GitX.css in Resources */, C3138C3311C2F48400BE6CBE /* notification.css in Resources */, + 315CB9B011C339DA003B8DBE /* FileViewer.xib in Resources */, + 31D70AFD11C4006C00F4B199 /* ReadMe.txt in Resources */, + 31D70AFE11C4006C00F4B199 /* Source Code License.rtf in Resources */, + 31A520AC11C6983900F604D0 /* test.html in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1613,6 +1664,9 @@ C3138C1611C2F48400BE6CBE /* shLegacy.js in Sources */, C3138C1711C2F48400BE6CBE /* shCore.js in Sources */, C3138C1811C2F48400BE6CBE /* shLegacy.js in Sources */, + 315CB97B11C3305F003B8DBE /* FileViewerController.m in Sources */, + 31D70AFB11C4006C00F4B199 /* MGRecessedPopUpButtonCell.m in Sources */, + 31D70AFC11C4006C00F4B199 /* MGScopeBar.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1820,6 +1874,7 @@ 26FC0A890875C7B200E6366F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + GCC_C_LANGUAGE_STANDARD = c99; GCC_ENABLE_OBJC_GC = required; GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = DEBUG_BUILD; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -1837,6 +1892,7 @@ ppc, i386, ); + GCC_C_LANGUAGE_STANDARD = c99; GCC_ENABLE_OBJC_GC = required; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; diff --git a/PBGitCommitController.h b/PBGitCommitController.h index 0b39f05..ae26950 100644 --- a/PBGitCommitController.h +++ b/PBGitCommitController.h @@ -8,6 +8,7 @@ #import #import "PBViewController.h" +#import "FileViewerController.h" @class PBGitIndexController, PBIconAndTextCell, PBWebChangesController, PBGitIndex; @@ -21,6 +22,9 @@ IBOutlet NSArrayController *cachedFilesController; IBOutlet NSButton *commitButton; + IBOutlet NSView *fileViewer; + FileViewerController *fileViewerController; + IBOutlet PBGitIndexController *indexController; IBOutlet PBWebChangesController *webController; } diff --git a/PBGitCommitController.m b/PBGitCommitController.m index 37f5773..d9b70cd 100644 --- a/PBGitCommitController.m +++ b/PBGitCommitController.m @@ -62,6 +62,19 @@ [cachedFilesController setAutomaticallyRearrangesObjects:NO]; [unstagedFilesController setAutomaticallyRearrangesObjects:NO]; + + fileViewerController=[[FileViewerController alloc] retain]; + [fileViewerController setCommit:true]; + [fileViewerController initWithRepository:repository]; + [fileViewerController loadView]; + + // XXXX :( ? + NSMutableArray *sv=[NSMutableArray arrayWithArray:[[fileViewer superview] subviews]]; + [sv removeObjectAtIndex:0]; + [sv insertObject:[fileViewerController view] atIndex:0]; + [[fileViewer superview] setSubviews:sv]; + webController.fileViewerController=fileViewerController; + } - (void) removeView diff --git a/PBGitCommitView.xib b/PBGitCommitView.xib index 3af4a82..de74b2b 100644 --- a/PBGitCommitView.xib +++ b/PBGitCommitView.xib @@ -7,17 +7,8 @@ 1038.29 460.00 - YES - - YES - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.WebKitIBPlugin - - - YES - 762 - 762 - + com.apple.InterfaceBuilder.CocoaPlugin + 762 YES @@ -26,7 +17,6 @@ YES com.apple.InterfaceBuilder.CocoaPlugin - com.apple.WebKitIBPlugin YES @@ -53,157 +43,18 @@ 274 YES - - - 266 - - YES - - - 289 - {{862, 3}, {37, 25}} - - YES - - -2080244224 - 134217728 - QuickLook - - LucidaGrande - 13 - 1044 - - - -2033958657 - 163 - - NSImage - NSQuickLookTemplate - - - - 400 - 75 - - - - - 292 - {{20, 3}, {108, 25}} - - YES - - -2080244224 - 0 - - - - YES - - Diff - Detailed View - YES - 2 - - - Blame - Tree View - 9 - 2 - - - 2 - - - - - 10 - {{0, -2}, {909, 5}} - - {0, 0} - - 67239424 - 0 - Box - - - 6 - System - textBackgroundColor - - 3 - MQA - - - - 3 - MCAwLjgwMDAwMDAxMTkAA - - - 3 - 2 - 0 - NO - - - {{0, 511}, {909, 30}} - - PBGitGradientBarView - 274 YES - + - 274 - - YES - - YES - Apple HTML pasteboard type - Apple PDF pasteboard type - Apple PICT pasteboard type - Apple URL pasteboard type - Apple Web Archive pasteboard type - NSColor pasteboard type - NSFilenamesPboardType - NSStringPboardType - NeXT RTFD pasteboard type - NeXT Rich Text Format v1.0 pasteboard type - NeXT TIFF v4.0 pasteboard type - WebURLsWithTitlesPboardType - public.png - public.url - public.url-name - - - {909, 228} + 4370 + {1351, 234} - - - - - - - YES - - YES - WebKitDefaultFixedFontSize - WebKitDefaultFontSize - WebKitMinimumFontSize - - - YES - - - - - - - YES - YES + YES + NSView @@ -233,7 +84,7 @@ 4352 - {202, 251} + {302, 310} YES @@ -244,7 +95,7 @@ YES - 199 + 299 10 3.4028229999999999e+38 @@ -260,7 +111,10 @@ 6 System headerColor - + + 3 + MQA + 6 @@ -322,7 +176,7 @@ 0 - {{1, 1}, {202, 251}} + {{1, 1}, {302, 310}} @@ -349,7 +203,7 @@ 0.99470899999999995 - {{-1, -1}, {204, 253}} + {{-1, -1}, {304, 312}} 562 @@ -359,11 +213,11 @@ QSAAAEEgAABBiAAAQYgAAA - {203, 257} + {303, 316} - {203, 272} + {303, 331} {0, 0} @@ -371,7 +225,12 @@ 0 Unstaged Changes - + + 6 + System + textBackgroundColor + + 3 MCAwLjgwMDAwMDAxAA @@ -396,14 +255,18 @@ 289 - {{368, 0}, {96, 32}} + {{596, 0}, {96, 32}} YES 67239424 134217728 Commit - + + LucidaGrande + 13 + 1044 + -2038284033 301990017 @@ -449,7 +312,7 @@ public.url - {{0, 9}, {456, 14}} + {684, 15} @@ -467,7 +330,7 @@ - 456 + 684 1 @@ -519,11 +382,11 @@ 6 {1161, 1e+07} - {223, 0} + {216, 0} - {{1, 1}, {456, 214}} + {{1, 1}, {684, 273}} @@ -555,7 +418,7 @@ 0.94565220000000005 - {{0, 36}, {458, 216}} + {{0, 33}, {686, 275}} 530 @@ -593,7 +456,7 @@ 289 - {{272, 0}, {96, 32}} + {{500, 0}, {96, 32}} YES @@ -611,11 +474,11 @@ - {458, 257} + {686, 316} - {{212, 0}, {458, 272}} + {{312, 0}, {686, 331}} {0, 0} @@ -658,7 +521,7 @@ 4352 - {229, 251} + {343, 310} 1 YES @@ -670,7 +533,7 @@ YES - 226 + 340 10 3.4028229999999999e+38 @@ -711,7 +574,7 @@ 0 - {{1, 1}, {229, 251}} + {{1, 1}, {343, 310}} @@ -738,7 +601,7 @@ 0.90033220000000003 - {{0, -1}, {231, 253}} + {{0, -1}, {345, 312}} 562 @@ -748,11 +611,11 @@ QSAAAEEgAABBiAAAQYgAAA - {230, 257} + {344, 316} - {{679, 0}, {230, 272}} + {{1007, 0}, {344, 331}} {0, 0} @@ -773,17 +636,17 @@ NO - {{0, 237}, {909, 272}} + {{0, 243}, {1351, 331}} YES - {909, 509} + {1351, 574} CommitViewSplitView - {909, 541} + {1351, 574} NSView @@ -875,22 +738,6 @@ 122 - - - view - - - - 136 - - - - frameLoadDelegate - - - - 137 - value: arrangedObjects.path @@ -1117,27 +964,11 @@ - upperToolbarView - - + fileViewer + + - 356 - - - - displayControl - - - - 357 - - - - displayControlChanged: - - - - 358 + 361 @@ -1173,7 +1004,6 @@ YES - @@ -1206,7 +1036,7 @@ YES - + @@ -1235,10 +1065,10 @@ YES - + @@ -1413,54 +1243,13 @@ - 125 - + 360 + + + YES + - - - 322 - - - YES - - - - - - History Upper Toolbar - - - 323 - - - YES - - - - - - 324 - - - YES - - - - - - 330 - - - - - 336 - - - - - 337 - - + File viewer @@ -1479,7 +1268,6 @@ 113.IBPluginDependency 114.CustomClassName 114.IBPluginDependency - 125.IBPluginDependency 130.IBPluginDependency 131.IBPluginDependency 132.IBPluginDependency @@ -1497,14 +1285,7 @@ 248.IBPluginDependency 278.IBPluginDependency 279.IBPluginDependency - 322.IBPluginDependency - 323.IBPluginDependency - 324.IBAttributePlaceholdersKey - 324.IBPluginDependency - 330.IBPluginDependency - 336.IBPluginDependency - 337.IBPluginDependency - 337.IBSegmentedControlInspectorSelectedSegmentMetadataKey + 360.IBPluginDependency 45.IBPluginDependency 46.IBPluginDependency 47.IBPluginDependency @@ -1522,7 +1303,7 @@ YES com.apple.InterfaceBuilder.CocoaPlugin - {{615, 74}, {909, 541}} + {{54, 9}, {1351, 574}} com.apple.InterfaceBuilder.CocoaPlugin @@ -1532,7 +1313,6 @@ com.apple.InterfaceBuilder.CocoaPlugin PBIconAndTextCell com.apple.InterfaceBuilder.CocoaPlugin - com.apple.WebKitIBPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1552,20 +1332,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - - ToolTip - - ToolTip - - Quick Look - - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin PBFileChangesTableView @@ -1596,7 +1362,7 @@ - 358 + 363 @@ -1642,6 +1408,7 @@ cachedFilesController commitButton commitMessageView + fileViewer indexController unstagedFilesController webController @@ -1651,6 +1418,7 @@ NSArrayController NSButton NSTextView + NSView PBGitIndexController NSArrayController PBWebChangesController @@ -2300,14 +2068,6 @@ AppKit.framework/Headers/NSSegmentedCell.h - - NSSegmentedControl - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSSegmentedControl.h - - NSSplitView NSView @@ -2458,17 +2218,8 @@ GitX.xcodeproj 3 - YES - - YES - NSQuickLookTemplate - NSSwitch - - - YES - {19, 11} - {15, 15} - + NSSwitch + {15, 15} diff --git a/PBGitHistoryController.h b/PBGitHistoryController.h index 9af9c61..8d16cc2 100644 --- a/PBGitHistoryController.h +++ b/PBGitHistoryController.h @@ -12,6 +12,7 @@ #import "PBGitTree.h" #import "PBViewController.h" #import "PBCollapsibleSplitView.h" +#import "FileViewerController.h" @class PBGitSidebarController; @class PBGitGradientBarView; @@ -39,9 +40,9 @@ IBOutlet NSButton *localRemoteBranchesFilterItem; IBOutlet NSButton *selectedBranchFilterItem; - IBOutlet WebView *webViewFileViwer; - IBOutlet NSSegmentedCell *displayControl; - + IBOutlet NSSplitView *fileViewer; + FileViewerController *fileViewerController; + IBOutlet id webView; int selectedCommitDetailsIndex; BOOL forceSelectionUpdate; diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m index 51d5275..bade45e 100644 --- a/PBGitHistoryController.m +++ b/PBGitHistoryController.m @@ -79,7 +79,14 @@ //[scopeBarView setTopShade:207/255.0 bottomShade:180/255.0]; [self updateBranchFilterMatrix]; - [webViewFileViwer setFrameLoadDelegate:self]; +// [webViewFileViwer setFrameLoadDelegate:self]; + + fileViewerController=[[FileViewerController alloc] retain]; + [fileViewerController initWithRepository:repository]; + [fileViewerController loadView]; + + //[fileViewer setAutoresizesSubviews:YES]; + [fileViewer addSubview:[fileViewerController view]]; [super awakeFromNib]; } @@ -213,7 +220,15 @@ if ([(NSString *)context isEqualToString: @"treeChange"]) { [self updateQuicklookForce: NO]; [self saveFileBrowserSelection]; - [self updateFileViwer:nil]; + NSLog(@"---> %@",object); + NSArray *objects = [(NSTreeController *)object selectedObjects]; + if([objects count]){ + PBGitTree *tree=(PBGitTree *)[objects objectAtIndex:0]; + NSLog(@"---> %@",tree.fullPath); + [fileViewerController showFile:tree.fullPath sha:tree.sha]; + } + + //[self updateFileViwer:nil]; return; } @@ -691,48 +706,4 @@ return iconRect; } -- (IBAction)updateFileViwer:(id)sender -{ - NSString *type=@"source"; - if([displayControl selectedSegment]==1){ - type=@"blame"; - }else if([displayControl selectedSegment]==2){ - type=@"diff"; - } - - NSString *path = [NSString stringWithFormat:@"html/views/%@", type]; - NSString *file = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:path]; - NSLog(@"updateFileViwer -> file: '%@'",file); - NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:file]]; - [[webViewFileViwer mainFrame] loadRequest:request]; -} - -- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame -{ - NSArray *objects = [treeController selectedObjects]; - NSArray *content = [treeController content]; - - if ([objects count] && [content count]) { - PBGitTree *treeItem = [objects objectAtIndex:0]; - currentFileBrowserSelectionPath = [treeItem.fullPath componentsSeparatedByString:@"/"]; - - NSString *txt=[treeItem contents:[displayControl selectedSegment]]; - NSLog(@"didFinishLoadForFrame -> txt: '%@'",[txt substringToIndex:80]); - - id script = [webViewFileViwer windowScriptObject]; - [script callWebScriptMethod:@"showFile" - withArguments:[NSArray arrayWithObjects:txt, nil]]; - } -} - -- (void)webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame -{ - NSString *messageString = [error localizedDescription]; - NSString *moreString = [error localizedFailureReason] ? - [error localizedFailureReason] : - NSLocalizedString(@"Try typing the URL again.", nil); - messageString = [NSString stringWithFormat:@"%@. %@", messageString, moreString]; - NSLog(@"ERROR!!!! - %@",messageString); -} - @end diff --git a/PBGitHistoryView.xib b/PBGitHistoryView.xib index 5427e7d..918d76f 100644 --- a/PBGitHistoryView.xib +++ b/PBGitHistoryView.xib @@ -21,7 +21,7 @@ YES - + YES @@ -111,7 +111,7 @@ 289 - {{848, 3}, {37, 25}} + {{906, 3}, {37, 25}} YES @@ -126,7 +126,7 @@ -2033958657 163 - + NSImage NSQuickLookTemplate @@ -297,7 +297,7 @@ 10 - {{0, -2}, {895, 5}} + {{0, -2}, {953, 5}} {0, 0} @@ -325,7 +325,7 @@ NO - {{0, 583}, {895, 30}} + {{0, 587}, {953, 30}} PBGitGradientBarView @@ -342,7 +342,7 @@ 10 - {{0, 116}, {895, 5}} + {{0, 117}, {953, 5}} {0, 0} @@ -374,13 +374,13 @@ 4352 - {895, 102} + {953, 103} YES 256 - {895, 17} + {953, 17} @@ -394,7 +394,7 @@ YES SubjectColumn - 592 + 650 40 1000 @@ -559,7 +559,7 @@ 0 - {{0, 17}, {895, 102}} + {{0, 17}, {953, 103}} @@ -592,7 +592,7 @@ YES - {895, 17} + {953, 17} @@ -601,7 +601,7 @@ - {895, 119} + {953, 120} 560 @@ -645,7 +645,7 @@ 265 - {{705, 2}, {180, 19}} + {{763, 2}, {180, 19}} YES @@ -745,12 +745,12 @@ - {{0, 119}, {895, 24}} + {{0, 120}, {953, 24}} PBGitGradientBarView - {895, 143} + {953, 144} NSView @@ -762,7 +762,7 @@ 18 - {895, 440} + {953, 443} YES @@ -802,7 +802,7 @@ - + YES @@ -860,7 +860,7 @@ 4368 - {159, 425} + {938, 428} YES @@ -871,7 +871,7 @@ YES - 156 + 935 16 1000 @@ -904,7 +904,7 @@ 17 - -624951296 + -759169024 4 @@ -914,7 +914,7 @@ 0 - {{1, 1}, {159, 425}} + {{1, 1}, {938, 428}} @@ -924,7 +924,7 @@ 256 - {{160, 1}, {15, 425}} + {{939, 1}, {15, 428}} _doScroller: @@ -933,16 +933,15 @@ 256 - {{1, 426}, {159, 15}} + {{1, 429}, {938, 15}} 1 _doScroller: - 0.0045045049999999998 - 0.99801189999999995 + 0.93923240938166308 - {176, 442} + {955, 445} 50 @@ -951,143 +950,14 @@ QSAAAEEgAABBmAAAQZgAAA - - - 268 - - YES - - - 274 - - YES - - YES - Apple HTML pasteboard type - Apple PDF pasteboard type - Apple PICT pasteboard type - Apple URL pasteboard type - Apple Web Archive pasteboard type - NSColor pasteboard type - NSFilenamesPboardType - NSStringPboardType - NeXT RTFD pasteboard type - NeXT Rich Text Format v1.0 pasteboard type - NeXT TIFF v4.0 pasteboard type - WebURLsWithTitlesPboardType - public.png - public.url - public.url-name - - - {720, 411} - - - - - - YES - YES - - - - 266 - - YES - - - 289 - {{673, 3}, {37, 25}} - - YES - - -2080244224 - 134217728 - QuickLook - - - -2033958657 - 163 - - - - 400 - 75 - - - - - 292 - {{20, 3}, {162, 25}} - - YES - - -2080244224 - 0 - - - - YES - - Show - Detailed View - YES - 2 - - - Blame - Tree View - 9 - 2 - - - Diff - 0 - - - 2 - - - - - 10 - {{0, -2}, {720, 5}} - - {0, 0} - - 67239424 - 0 - Box - - - - 3 - MCAwLjgwMDAwMDAxMTkAA - - - 3 - 2 - 0 - NO - - - {{0, 412}, {720, 30}} - - NSView - - - {{177, 0}, {720, 442}} - - NSView - - {{-1, -1}, {897, 442}} + {{-1, -1}, {955, 445}} YES 2 - {895, 440} + {953, 443} Tree @@ -1106,24 +976,25 @@ - {{0, 144}, {895, 440}} + {{0, 145}, {953, 443}} NSView - {895, 584} + {953, 588} 2 HistoryViewSplitView - {895, 613} + {953, 617} NSView PBRefController + @@ -1753,53 +1624,13 @@ 398 - - - enabled: selectedCommitDetailsIndex - - - - - - enabled: selectedCommitDetailsIndex - enabled - selectedCommitDetailsIndex - 2 - - - 416 - - - - toggleQLPreviewPanel: - - - - 419 - - webViewFileViwer + fileViewer - + - 425 - - - - displayControl - - - - 426 - - - - updateFileViwer: - - - - 429 + 438 @@ -2051,7 +1882,6 @@ YES - @@ -2295,64 +2125,9 @@ - 399 - - - YES - - - - - - - 400 - - - YES - - - - - - File Show Control Toolbar - - - 401 - - - YES - - - - - - 402 - - - YES - - - - - - 408 - - - - - 414 - - - - - 415 - - - - - 424 - - + 435 + + @@ -2439,18 +2214,9 @@ 388.IBPluginDependency 39.IBPluginDependency 39.ImportedFromIB2 - 399.IBPluginDependency 4.IBAttributePlaceholdersKey 4.IBPluginDependency - 400.IBPluginDependency - 401.IBPluginDependency - 402.IBAttributePlaceholdersKey - 402.IBPluginDependency - 408.IBPluginDependency - 414.IBPluginDependency - 415.IBPluginDependency - 415.IBSegmentedControlInspectorSelectedSegmentMetadataKey - 424.IBPluginDependency + 435.IBPluginDependency 46.IBEditorWindowLastContentRect 46.IBPluginDependency 48.IBPluginDependency @@ -2606,7 +2372,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin YES @@ -2616,22 +2381,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - ToolTip - - ToolTip - - Quick Look - - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.WebKitIBPlugin - {{1414, 293}, {895, 613}} + {{110, 110}, {953, 617}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -2667,7 +2417,7 @@ - 429 + 438 @@ -2778,8 +2528,8 @@ cherryPickButton commitController commitList - displayControl fileBrowser + fileViewer historySplitView localRemoteBranchesFilterItem mergeButton @@ -2791,7 +2541,6 @@ treeController upperToolbarView webView - webViewFileViwer YES @@ -2799,8 +2548,8 @@ NSButton NSArrayController NSTableView - NSSegmentedCell NSOutlineView + NSSplitView PBCollapsibleSplitView NSButton NSButton @@ -2812,7 +2561,6 @@ NSTreeController PBGitGradientBarView id - WebView diff --git a/PBGitTree.m b/PBGitTree.m index 8898137..88f8e25 100644 --- a/PBGitTree.m +++ b/PBGitTree.m @@ -128,13 +128,6 @@ if ([self fileSize] > 52428800) // ~50MB return [NSString stringWithFormat:@"%@ is too big to be displayed (%d bytes)", [self fullPath], [self fileSize]]; - if(option==0) - contents=[repository outputForArguments:[NSArray arrayWithObjects:@"show", [self refSpec], nil]]; - else if(option==1) - contents=[PBGitTree parseBlame:[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"blame", @"-p", self.fullPath, self.sha, nil]]]; - else if(option==2) - contents=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff", self.sha, self.fullPath, nil]]; - if ([self hasBinaryHeader:contents]) return [NSString stringWithFormat:@"%@ appears to be a binary file of %d bytes", [self fullPath], [self fileSize]]; diff --git a/PBWebChangesController.h b/PBWebChangesController.h index ac82a5a..e416fea 100644 --- a/PBWebChangesController.h +++ b/PBWebChangesController.h @@ -22,7 +22,11 @@ PBChangedFile *selectedFile; BOOL selectedFileIsCached; + FileViewerController *fileViewerController; } + +@property(readwrite) FileViewerController *fileViewerController; + -(IBAction)displayControlChanged:(id)sender; - (void) refresh; diff --git a/PBWebChangesController.m b/PBWebChangesController.m index 1b2c079..be8d76e 100644 --- a/PBWebChangesController.m +++ b/PBWebChangesController.m @@ -12,6 +12,8 @@ @implementation PBWebChangesController +@synthesize fileViewerController; + - (void) awakeFromNib { selectedFile = nil; @@ -72,8 +74,11 @@ - (void) refresh { - if (!finishedLoading) + [fileViewerController showFile:[selectedFile path] sha:nil]; + /*if (!finishedLoading) return; + + [fileViewerController showFile:selectedFile sha:@""]; id script = [view windowScriptObject]; @@ -85,7 +90,7 @@ [script callWebScriptMethod:@"showFileBlame" withArguments:[NSArray arrayWithObjects:selectedFile ?: (id)[NSNull null], [NSNumber numberWithBool:selectedFileIsCached], nil]]; - } + }*/ } - (void)stageHunk:(NSString *)hunk reverse:(BOOL)reverse diff --git a/html/views/commit/commit.js b/html/views/commit/commit.js index 11d947d..7dedda5 100644 --- a/html/views/commit/commit.js +++ b/html/views/commit/commit.js @@ -179,6 +179,10 @@ var diffHeader; var originalDiff; var originalCached; +var showFile = function(diff) { + displayDiff(diff,false); +} + var displayDiff = function(diff, cached) { diffHeader = diff.split("\n").slice(0,4).join("\n"); diff --git a/html/views/commit/test.html b/html/views/commit/test.html new file mode 100644 index 0000000..4f87000 --- /dev/null +++ b/html/views/commit/test.html @@ -0,0 +1,95 @@ + + Diff for file + + + + + + + + + + +

+ + Context: + Nothing to commit + +

+ + + + +
+ Nothing to commit (working directory clean) +
+
PBWebChangesController.m
... +12 +13 +14 + + +15 +16 +17 +... +72 +73 +74 +75 + + +76 + + +77 +78 +79 +... +85 +86 +87 +88 + +89 +90 +91 +
... +12 +13 +14 +15 +16 +17 +18 +19 +... +74 +75 +76 + +77 +78 +79 +80 +81 +82 +83 +84 +... +90 +91 +92 + +93 +94 +95 +96 +
DiscardStage@@ -12,6 +12,8 @@
@implementation PBWebChangesController
+@synthesize fileViewerController;
+
- (void) awakeFromNib
{
selectedFile = nil;
DiscardStage@@ -72,8 +74,11 @@ -(IBAction)displayControlChanged:(id)sender{
- (void) refresh
{
- if (!finishedLoading)
+ [fileViewerController showFile:[selectedFile path] sha:nil];
+ /*if (!finishedLoading)
return;
+
+ [fileViewerController showFile:selectedFile sha:@""];
id script = [view windowScriptObject];
DiscardStage@@ -85,7 +90,7 @@ - (void) refresh
[script callWebScriptMethod:@"showFileBlame"
withArguments:[NSArray arrayWithObjects:selectedFile ?: (id)[NSNull null],
[NSNumber numberWithBool:selectedFileIsCached], nil]];
- }
+ }*/
}
- (void)stageHunk:(NSString *)hunk reverse:(BOOL)reverse
+ + \ No newline at end of file