Merge branch 'refs/heads/pb/sidebar'

Conflicts:
	GitX.xcodeproj/project.pbxproj
	PBGitHistoryController.m
	PBGitWindowController.m
This commit is contained in:
Nathan Kinsinger
2010-03-13 22:11:47 -07:00
21 changed files with 1052 additions and 11 deletions
+58
View File
@@ -65,6 +65,8 @@
F513085B0E0740F2000C8BCD /* PBQLOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = F513085A0E0740F2000C8BCD /* PBQLOutlineView.m */; };
F5140DC90E8A8EB20091E9F3 /* RoundedRectangle.m in Sources */ = {isa = PBXBuildFile; fileRef = F5140DC80E8A8EB20091E9F3 /* RoundedRectangle.m */; };
F523CEB60ED3399200DDD714 /* PBGitIndexController.m in Sources */ = {isa = PBXBuildFile; fileRef = F523CEB50ED3399200DDD714 /* PBGitIndexController.m */; };
F528210A1056A7C1001D1511 /* PBSourceViewRemote.m in Sources */ = {isa = PBXBuildFile; fileRef = F52821091056A7C1001D1511 /* PBSourceViewRemote.m */; };
F528210D1056A7EB001D1511 /* PBSourceViewAction.m in Sources */ = {isa = PBXBuildFile; fileRef = F528210C1056A7EB001D1511 /* PBSourceViewAction.m */; };
F52BCE030E84208300AA3741 /* PBGitHistoryView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F52BCE020E84208300AA3741 /* PBGitHistoryView.xib */; };
F52BCE070E84211300AA3741 /* PBGitHistoryController.m in Sources */ = {isa = PBXBuildFile; fileRef = F52BCE060E84211300AA3741 /* PBGitHistoryController.m */; };
F53C4DF70E97FC630022AD59 /* PBGitBinary.m in Sources */ = {isa = PBXBuildFile; fileRef = F53C4DF60E97FC630022AD59 /* PBGitBinary.m */; };
@@ -78,6 +80,7 @@
F56524F00E02D45200F03B52 /* PBGitCommit.m in Sources */ = {isa = PBXBuildFile; fileRef = F56524EF0E02D45200F03B52 /* PBGitCommit.m */; };
F56526240E03D85900F03B52 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F56526230E03D85900F03B52 /* WebKit.framework */; };
F565262B0E03D89B00F03B52 /* PBWebHistoryController.m in Sources */ = {isa = PBXBuildFile; fileRef = F565262A0E03D89B00F03B52 /* PBWebHistoryController.m */; };
F567B88D1057FA9F000DB976 /* NSOutlineViewExt.m in Sources */ = {isa = PBXBuildFile; fileRef = F567B88C1057FA9F000DB976 /* NSOutlineViewExt.m */; };
F567CC64106E6BC80059BB9D /* PBGitRepository.m in Sources */ = {isa = PBXBuildFile; fileRef = F5945E160E02B0C200706420 /* PBGitRepository.m */; };
F567CC65106E6BC90059BB9D /* PBGitBinary.m in Sources */ = {isa = PBXBuildFile; fileRef = F53C4DF60E97FC630022AD59 /* PBGitBinary.m */; };
F567CC66106E6BC90059BB9D /* PBGitConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 93FCCBA80EA8AF450061B02B /* PBGitConfig.m */; };
@@ -115,6 +118,13 @@
F5886A330ED5D5580066E74C /* PBGitRevSpecifier.m in Sources */ = {isa = PBXBuildFile; fileRef = F53FF2040E7ABB5300389171 /* PBGitRevSpecifier.m */; };
F5886A340ED5D55D0066E74C /* PBGitBinary.m in Sources */ = {isa = PBXBuildFile; fileRef = F53C4DF60E97FC630022AD59 /* PBGitBinary.m */; };
F5886A360ED5D56E0066E74C /* PBGitTree.m in Sources */ = {isa = PBXBuildFile; fileRef = F56174560E058893001DCD79 /* PBGitTree.m */; };
F58DB55910566D3500CFDF4A /* PBGitSidebarController.m in Sources */ = {isa = PBXBuildFile; fileRef = F58DB55810566D3500CFDF4A /* PBGitSidebarController.m */; };
F58DB56010566E3900CFDF4A /* PBGitSidebarView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F58DB55F10566E3900CFDF4A /* PBGitSidebarView.xib */; };
F58DB5E8105671B600CFDF4A /* PBSourceViewItem.m in Sources */ = {isa = PBXBuildFile; fileRef = F58DB5E7105671B600CFDF4A /* PBSourceViewItem.m */; };
F58DB7711056860900CFDF4A /* branch.tiff in Resources */ = {isa = PBXBuildFile; fileRef = F58DB76D1056860900CFDF4A /* branch.tiff */; };
F58DB7721056860900CFDF4A /* remote.tiff in Resources */ = {isa = PBXBuildFile; fileRef = F58DB76E1056860900CFDF4A /* remote.tiff */; };
F58DB7731056860900CFDF4A /* folder.tiff in Resources */ = {isa = PBXBuildFile; fileRef = F58DB76F1056860900CFDF4A /* folder.tiff */; };
F58DB7741056860900CFDF4A /* tag.tiff in Resources */ = {isa = PBXBuildFile; fileRef = F58DB7701056860900CFDF4A /* tag.tiff */; };
F59116E60E843BB50072CCB1 /* PBGitCommitView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F59116E50E843BB50072CCB1 /* PBGitCommitView.xib */; };
F59116E90E843BCB0072CCB1 /* PBGitCommitController.m in Sources */ = {isa = PBXBuildFile; fileRef = F59116E80E843BCB0072CCB1 /* PBGitCommitController.m */; };
F593DF780E9E636C003A8559 /* PBFileChangesTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = F593DF770E9E636C003A8559 /* PBFileChangesTableView.m */; };
@@ -256,6 +266,10 @@
F5140DC80E8A8EB20091E9F3 /* RoundedRectangle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoundedRectangle.m; sourceTree = "<group>"; };
F523CEB40ED3399100DDD714 /* PBGitIndexController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitIndexController.h; sourceTree = "<group>"; };
F523CEB50ED3399200DDD714 /* PBGitIndexController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitIndexController.m; sourceTree = "<group>"; };
F52821081056A7C1001D1511 /* PBSourceViewRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBSourceViewRemote.h; sourceTree = "<group>"; };
F52821091056A7C1001D1511 /* PBSourceViewRemote.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBSourceViewRemote.m; sourceTree = "<group>"; };
F528210B1056A7EB001D1511 /* PBSourceViewAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBSourceViewAction.h; sourceTree = "<group>"; };
F528210C1056A7EB001D1511 /* PBSourceViewAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBSourceViewAction.m; sourceTree = "<group>"; };
F52BCE020E84208300AA3741 /* PBGitHistoryView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PBGitHistoryView.xib; sourceTree = "<group>"; };
F52BCE050E84211300AA3741 /* PBGitHistoryController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitHistoryController.h; sourceTree = "<group>"; };
F52BCE060E84211300AA3741 /* PBGitHistoryController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitHistoryController.m; sourceTree = "<group>"; };
@@ -277,6 +291,8 @@
F56526230E03D85900F03B52 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = /System/Library/Frameworks/WebKit.framework; sourceTree = "<absolute>"; };
F56526290E03D89B00F03B52 /* PBWebHistoryController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBWebHistoryController.h; sourceTree = "<group>"; };
F565262A0E03D89B00F03B52 /* PBWebHistoryController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBWebHistoryController.m; sourceTree = "<group>"; };
F567B88B1057FA9F000DB976 /* NSOutlineViewExt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSOutlineViewExt.h; sourceTree = "<group>"; };
F567B88C1057FA9F000DB976 /* NSOutlineViewExt.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSOutlineViewExt.m; sourceTree = "<group>"; };
F567CC39106E6B910059BB9D /* GitXTesting.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GitXTesting.framework; sourceTree = BUILT_PRODUCTS_DIR; };
F567CC3A106E6B910059BB9D /* GitXTesting-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GitXTesting-Info.plist"; sourceTree = "<group>"; };
F569AE920F2CBD7C00C2FFA7 /* Credits.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = Credits.html; sourceTree = "<group>"; };
@@ -296,6 +312,15 @@
F5886A0A0ED5D27A0066E74C /* speedtest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = speedtest.m; sourceTree = "<group>"; };
F5886A100ED5D33D0066E74C /* SpeedTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SpeedTest.app; sourceTree = BUILT_PRODUCTS_DIR; };
F5886A120ED5D33D0066E74C /* SpeedTest-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SpeedTest-Info.plist"; sourceTree = "<group>"; };
F58DB55710566D3500CFDF4A /* PBGitSidebarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitSidebarController.h; sourceTree = "<group>"; };
F58DB55810566D3500CFDF4A /* PBGitSidebarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitSidebarController.m; sourceTree = "<group>"; };
F58DB55F10566E3900CFDF4A /* PBGitSidebarView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PBGitSidebarView.xib; sourceTree = "<group>"; };
F58DB5E6105671B600CFDF4A /* PBSourceViewItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBSourceViewItem.h; sourceTree = "<group>"; };
F58DB5E7105671B600CFDF4A /* PBSourceViewItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBSourceViewItem.m; sourceTree = "<group>"; };
F58DB76D1056860900CFDF4A /* branch.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = branch.tiff; path = Images/branch.tiff; sourceTree = "<group>"; };
F58DB76E1056860900CFDF4A /* remote.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = remote.tiff; path = Images/remote.tiff; sourceTree = "<group>"; };
F58DB76F1056860900CFDF4A /* folder.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = folder.tiff; path = Images/folder.tiff; sourceTree = "<group>"; };
F58DB7701056860900CFDF4A /* tag.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = tag.tiff; path = Images/tag.tiff; sourceTree = "<group>"; };
F59116E50E843BB50072CCB1 /* PBGitCommitView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PBGitCommitView.xib; sourceTree = "<group>"; };
F59116E70E843BCB0072CCB1 /* PBGitCommitController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitCommitController.h; sourceTree = "<group>"; };
F59116E80E843BCB0072CCB1 /* PBGitCommitController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitCommitController.m; sourceTree = "<group>"; };
@@ -453,6 +478,10 @@
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
isa = PBXGroup;
children = (
F58DB76D1056860900CFDF4A /* branch.tiff */,
F58DB76E1056860900CFDF4A /* remote.tiff */,
F58DB76F1056860900CFDF4A /* folder.tiff */,
F58DB7701056860900CFDF4A /* tag.tiff */,
3BC07F4A0ED5A5C5009A7768 /* HistoryViewTemplate.png */,
3BC07F4B0ED5A5C5009A7768 /* CommitViewTemplate.png */,
F56ADDD70ED19F9E002AC78F /* AddBranchTemplate.png */,
@@ -488,6 +517,7 @@
D8FDD9F511432A12005647F6 /* PBCloneRepositoryPanel.xib */,
47DBDB680E94EF6500671A1E /* Preferences.xib */,
F569AE920F2CBD7C00C2FFA7 /* Credits.html */,
F58DB55F10566E3900CFDF4A /* PBGitSidebarView.xib */,
);
name = Resources;
sourceTree = "<group>";
@@ -575,6 +605,7 @@
F57CC3850E05DDC1000472E2 /* Controllers */ = {
isa = PBXGroup;
children = (
F58DB55610566D1F00CFDF4A /* Sidebar */,
F5B161BB0EAB6E0C005A1DE1 /* Diff */,
F5EF8C880E9D498F0050906B /* History */,
F5E927F90E883EF600056E75 /* Commit */,
@@ -632,6 +663,8 @@
F5FC41F20EBCBD4300191D80 /* PBGitXProtocol.h */,
F5FC41F30EBCBD4300191D80 /* PBGitXProtocol.m */,
D823487410CB382C00944BDE /* Terminal.h */,
F567B88B1057FA9F000DB976 /* NSOutlineViewExt.h */,
F567B88C1057FA9F000DB976 /* NSOutlineViewExt.m */,
);
name = Aux;
sourceTree = "<group>";
@@ -644,6 +677,21 @@
name = SpeedTest;
sourceTree = "<group>";
};
F58DB55610566D1F00CFDF4A /* Sidebar */ = {
isa = PBXGroup;
children = (
F58DB55710566D3500CFDF4A /* PBGitSidebarController.h */,
F58DB55810566D3500CFDF4A /* PBGitSidebarController.m */,
F58DB5E6105671B600CFDF4A /* PBSourceViewItem.h */,
F58DB5E7105671B600CFDF4A /* PBSourceViewItem.m */,
F52821081056A7C1001D1511 /* PBSourceViewRemote.h */,
F52821091056A7C1001D1511 /* PBSourceViewRemote.m */,
F528210B1056A7EB001D1511 /* PBSourceViewAction.h */,
F528210C1056A7EB001D1511 /* PBSourceViewAction.m */,
);
name = Sidebar;
sourceTree = "<group>";
};
F59F1DD2105C4FDE00115F88 /* Index */ = {
isa = PBXGroup;
children = (
@@ -889,6 +937,11 @@
D8083C47111F136400337480 /* PBAddRemoteSheet.xib in Resources */,
D8083DCD111F918900337480 /* PBCloneRepsitoryToSheet.xib in Resources */,
D8FDD9F711432A12005647F6 /* PBCloneRepositoryPanel.xib in Resources */,
F58DB56010566E3900CFDF4A /* PBGitSidebarView.xib in Resources */,
F58DB7711056860900CFDF4A /* branch.tiff in Resources */,
F58DB7721056860900CFDF4A /* remote.tiff in Resources */,
F58DB7731056860900CFDF4A /* folder.tiff in Resources */,
F58DB7741056860900CFDF4A /* tag.tiff in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1014,6 +1067,11 @@
D8083C44111F106800337480 /* PBAddRemoteSheet.m in Sources */,
D8083DC4111F90F300337480 /* PBCloneRepsitoryToSheet.m in Sources */,
D8083E03111FA33700337480 /* PBCloneRepositoryPanel.m in Sources */,
F58DB55910566D3500CFDF4A /* PBGitSidebarController.m in Sources */,
F58DB5E8105671B600CFDF4A /* PBSourceViewItem.m in Sources */,
F567B88D1057FA9F000DB976 /* NSOutlineViewExt.m in Sources */,
F528210A1056A7C1001D1511 /* PBSourceViewRemote.m in Sources */,
F528210D1056A7EB001D1511 /* PBSourceViewAction.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
+15
View File
@@ -0,0 +1,15 @@
//
// NSOutlineViewExit.h
// GitX
//
// Created by Pieter de Bie on 9/9/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface NSOutlineView (PBExpandParents)
- (void)PBExpandItem:(id)item expandParents:(BOOL)expand;
@end
+25
View File
@@ -0,0 +1,25 @@
//
// NSOutlineViewExit.m
// GitX
//
// Created by Pieter de Bie on 9/9/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "NSOutlineViewExt.h"
@implementation NSOutlineView (PBExpandParents)
- (void)PBExpandItem:(id)item expandParents:(BOOL)expand
{
NSMutableArray *parents = [NSMutableArray array];
while (item) {
[parents insertObject:item atIndex:0];
item = [item parent];
}
for (id p in parents)
[self expandItem:p];
}
@end
+3
View File
@@ -12,7 +12,10 @@
#import "PBViewController.h"
#import "PBCollapsibleSplitView.h"
@class PBGitSidebarController;
@interface PBGitHistoryController : PBViewController {
PBGitSidebarController *sidebarController;
IBOutlet NSSearchField *searchField;
IBOutlet NSArrayController* commitController;
IBOutlet NSTreeController* treeController;
+14
View File
@@ -14,6 +14,7 @@
#import "PBCreateBranchSheet.h"
#import "PBCreateTagSheet.h"
#import "PBAddRemoteSheet.h"
#import "PBGitSidebarController.h"
#define QLPreviewPanel NSClassFromString(@"QLPreviewPanel")
@@ -32,6 +33,19 @@
[fileBrowser setTarget:self];
[fileBrowser setDoubleAction:@selector(openSelectedFile:)];
[historySplitView removeFromSuperview];
NSSplitView *newView = [[NSSplitView alloc] initWithFrame:[historySplitView frame]];
sidebarController = [[PBGitSidebarController alloc] initWithRepository:repository superController:superController];
[newView setDividerStyle:NSSplitViewDividerStyleThin];
[newView addSubview:[sidebarController view]];
[newView addSubview:historySplitView];
[newView setVertical:YES];
[newView adjustSubviews];
[newView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
[[self view] addSubview:newView];
if (!repository.currentBranch) {
[repository reloadRefs];
[repository readCurrentBranch];
+11 -1
View File
@@ -47,9 +47,19 @@
[revspec setDescription:@"Local branches"];
return revspec;
}
- (BOOL) isSimpleRef
{
return ([parameters count] == 1 && ![[parameters objectAtIndex:0] hasPrefix:@"-"]);
if ([parameters count] > 1)
return NO;
NSString *param = [parameters objectAtIndex:0];
if ([param hasPrefix:@"-"] ||
[param rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"^@{}~:"]].location != NSNotFound ||
[param rangeOfString:@".."].location != NSNotFound)
return NO;
return YES;
}
- (NSString*) simpleRef
+27
View File
@@ -0,0 +1,27 @@
//
// PBGitSidebar.h
// GitX
//
// Created by Pieter de Bie on 9/8/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "PBViewController.h"
@class PBSourceViewAction, PBSourceViewItem;
@interface PBGitSidebarController : PBViewController {
IBOutlet NSWindow *window;
IBOutlet NSOutlineView *sourceView;
NSMutableArray *items;
/* Specific things */
PBSourceViewAction *commitAction;
PBSourceViewItem *branches, *remotes, *tags, *custom;
}
@property(readonly) NSMutableArray *items;
@end
+207
View File
@@ -0,0 +1,207 @@
//
// PBGitSidebar.m
// GitX
//
// Created by Pieter de Bie on 9/8/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "PBGitSidebarController.h"
#import "PBSourceViewItem.h"
#import "NSOutlineViewExt.h"
#import "PBSourceViewAction.h"
@interface PBGitSidebarController ()
- (void)populateList;
- (void)updateSelection;
- (void)addRevSpec:(PBGitRevSpecifier *)revSpec;
@end
@implementation PBGitSidebarController
@synthesize items;
- (id)initWithRepository:(PBGitRepository *)theRepository superController:(PBGitWindowController *)controller
{
self = [super initWithRepository:theRepository superController:controller];
[sourceView setDelegate:self];
items = [NSMutableArray array];
return self;
}
- (void)awakeFromNib
{
[super awakeFromNib];
window.contentView = self.view;
[self populateList];
[repository addObserver:self forKeyPath:@"currentBranch" options:0 context:@"currentBranchChange"];
[self updateSelection];
}
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if ([@"currentBranchChange" isEqualTo:context])
[self updateSelection];
}
- (void)updateSelection
{
PBGitRevSpecifier *rev = repository.currentBranch;
if (!rev)
return;
PBSourceViewItem *item = nil;
for (PBSourceViewItem *it in items)
if (item = [it findRev:rev])
break;
if (!item) {
[self addRevSpec:rev];
// Try to find the just added item again.
// TODO: refactor with above.
for (PBSourceViewItem *it in items)
if (item = [it findRev:rev])
break;
}
[sourceView PBExpandItem:item expandParents:YES];
NSInteger index = [sourceView rowForItem:item];
[sourceView selectRow:index byExtendingSelection:NO];
}
- (void)addRevSpec:(PBGitRevSpecifier *)rev
{
if (![rev isSimpleRef]) {
[custom addChild:[PBSourceViewItem itemWithRevSpec:rev]];
return;
}
NSArray *pathComponents = [[rev simpleRef] componentsSeparatedByString:@"/"];
if ([pathComponents count] < 2)
[branches addChild:[PBSourceViewItem itemWithRevSpec:rev]];
else if ([[pathComponents objectAtIndex:1] isEqualToString:@"heads"])
[branches addRev:rev toPath:[pathComponents subarrayWithRange:NSMakeRange(2, [pathComponents count] - 2)]];
else if ([[rev simpleRef] hasPrefix:@"refs/tags/"])
[tags addRev:rev toPath:[pathComponents subarrayWithRange:NSMakeRange(2, [pathComponents count] - 2)]];
else if ([[rev simpleRef] hasPrefix:@"refs/remotes/"])
[remotes addRev:rev toPath:[pathComponents subarrayWithRange:NSMakeRange(2, [pathComponents count] - 2)]];
}
#pragma mark NSOutlineView delegate methods
- (void)outlineViewSelectionDidChange:(NSNotification *)notification
{
NSInteger index = [sourceView selectedRow];
PBSourceViewItem *item = [sourceView itemAtRow:index];
if ([item revSpecifier]) {
[[repository windowController] showHistoryView:self];
repository.currentBranch = [item revSpecifier];
return;
}
if (item == commitAction)
[[repository windowController] showCommitView:self];
/* ... */
/* Handle Remotes */
}
#pragma mark NSOutlineView delegate methods
- (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item
{
return [item isGroupItem];
}
- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
[cell setImage:[item icon]];
}
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item
{
return ![item isGroupItem];
}
//
// The next two methods are necessary to hide the triangle for uncollapsible items
// That is, items which should always be displayed, such as the action items.
//
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldCollapseItem:(id)item
{
return !([item isUncollapsible]);
}
- (void)outlineView:(NSOutlineView *)outlineView willDisplayOutlineCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
[cell setTransparent:[item isUncollapsible]];
}
- (void)populateList
{
PBSourceViewItem *actions = [PBSourceViewItem groupItemWithTitle:@"Actions"];
actions.isUncollapsible = YES;
commitAction = [PBSourceViewAction itemWithTitle:@"Index / Commit"];
commitAction.icon = [NSImage imageNamed:@"CommitViewTemplate"];
[actions addChild:commitAction];
branches = [PBSourceViewItem groupItemWithTitle:@"Branches"];
remotes = [PBSourceViewItem groupItemWithTitle:@"Remotes"];
tags = [PBSourceViewItem groupItemWithTitle:@"Tags"];
custom = [PBSourceViewItem groupItemWithTitle:@"Custom"];
for (PBGitRevSpecifier *rev in repository.branches)
[self addRevSpec:rev];
//[items addObject:actions];
[items addObject:branches];
[items addObject:remotes];
[items addObject:tags];
[items addObject:custom];
[sourceView reloadData];
[sourceView expandItem:branches expandChildren:YES];
[sourceView expandItem:actions];
NSAssert(branches == [sourceView itemAtRow:0], @"First item is not the Branches");
[sourceView reloadItem:nil reloadChildren:YES];
}
#pragma mark NSOutlineView Datasource methods
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
{
if (!item)
return [items objectAtIndex:index];
return [[(PBSourceViewItem *)item children] objectAtIndex:index];
}
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
{
return [[(PBSourceViewItem *)item children] count];
}
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
{
if (!item)
return [items count];
return [[(PBSourceViewItem *)item children] count];
}
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
return [(PBSourceViewItem *)item title];
}
@end
+459
View File
@@ -0,0 +1,459 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
<data>
<int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">9L31a</string>
<string key="IBDocument.InterfaceBuilderVersion">677</string>
<string key="IBDocument.AppKitVersion">949.54</string>
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="3"/>
<integer value="13"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilderKit</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSCustomObject" id="1001">
<string key="NSClassName">PBGitSidebarController</string>
</object>
<object class="NSCustomObject" id="1003">
<string key="NSClassName">FirstResponder</string>
</object>
<object class="NSCustomObject" id="1004">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSWindowTemplate" id="409430441">
<int key="NSWindowStyleMask">15</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{196, 106}, {186, 404}}</string>
<int key="NSWTFlags">603979776</int>
<string key="NSWindowTitle">Window</string>
<string key="NSWindowClass">NSWindow</string>
<nil key="NSViewClass"/>
<string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
<object class="NSView" key="NSWindowView" id="568708892">
<reference key="NSNextResponder"/>
<int key="NSvFlags">274</int>
<string key="NSFrameSize">{186, 404}</string>
<reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1280, 1002}}</string>
<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
</object>
<object class="NSScrollView" id="631607481">
<reference key="NSNextResponder"/>
<int key="NSvFlags">4370</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSClipView" id="973377808">
<reference key="NSNextResponder" ref="631607481"/>
<int key="NSvFlags">2304</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSOutlineView" id="971239525">
<reference key="NSNextResponder" ref="973377808"/>
<int key="NSvFlags">4352</int>
<string key="NSFrameSize">{151, 352}</string>
<reference key="NSSuperview" ref="973377808"/>
<bool key="NSEnabled">YES</bool>
<object class="_NSCornerView" key="NSCornerView">
<nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<string key="NSFrame">{{197, 0}, {16, 17}}</string>
</object>
<object class="NSMutableArray" key="NSTableColumns">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSTableColumn" id="408114397">
<double key="NSWidth">1.500000e+02</double>
<double key="NSMinWidth">1.600000e+01</double>
<double key="NSMaxWidth">1.000000e+03</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
<int key="NSCellFlags">75628032</int>
<int key="NSCellFlags2">0</int>
<string key="NSContents"/>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">1.100000e+01</double>
<int key="NSfFlags">3100</int>
</object>
<object class="NSColor" key="NSBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC4zMzMzMzI5OQA</bytes>
</object>
<object class="NSColor" key="NSTextColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">headerTextColor</string>
<object class="NSColor" key="NSColor" id="975423506">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
</object>
</object>
<object class="NSTextFieldCell" key="NSDataCell" id="247185217">
<int key="NSCellFlags">337772096</int>
<int key="NSCellFlags2">2048</int>
<string key="NSContents">Text Cell</string>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">1.300000e+01</double>
<int key="NSfFlags">1044</int>
</object>
<reference key="NSControlView" ref="971239525"/>
<object class="NSColor" key="NSBackgroundColor" id="272980874">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlBackgroundColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC42NjY2NjY2OQA</bytes>
</object>
</object>
<object class="NSColor" key="NSTextColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlTextColor</string>
<reference key="NSColor" ref="975423506"/>
</object>
</object>
<int key="NSResizingMask">3</int>
<bool key="NSIsResizeable">YES</bool>
<bool key="NSIsEditable">YES</bool>
<reference key="NSTableView" ref="971239525"/>
</object>
</object>
<double key="NSIntercellSpacingWidth">3.000000e+00</double>
<object class="NSColor" key="NSBackgroundColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">_sourceListBackgroundColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC44MzkyMTU3IDAuODY2NjY2NjcgMC44OTgwMzkyMgA</bytes>
</object>
</object>
<object class="NSColor" key="NSGridColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">gridColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC41AA</bytes>
</object>
</object>
<double key="NSRowHeight">2.000000e+01</double>
<int key="NSTvFlags">-767557632</int>
<int key="NSColumnAutoresizingStyle">4</int>
<int key="NSDraggingSourceMaskForLocal">15</int>
<int key="NSDraggingSourceMaskForNonLocal">0</int>
<bool key="NSAllowsTypeSelect">YES</bool>
<int key="NSTableViewSelectionHighlightStyle">1</int>
<float key="NSOutlineViewIndentationPerLevelKey">1.400000e+01</float>
</object>
</object>
<string key="NSFrameSize">{153, 354}</string>
<reference key="NSSuperview" ref="631607481"/>
<reference key="NSNextKeyView" ref="971239525"/>
<reference key="NSDocView" ref="971239525"/>
<reference key="NSBGColor" ref="272980874"/>
<int key="NScvFlags">4</int>
</object>
<object class="NSScroller" id="636071848">
<reference key="NSNextResponder" ref="631607481"/>
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{137, 1}, {15, 338}}</string>
<reference key="NSSuperview" ref="631607481"/>
<reference key="NSTarget" ref="631607481"/>
<string key="NSAction">_doScroller:</string>
<double key="NSPercent">9.969879e-01</double>
</object>
<object class="NSScroller" id="46429660">
<reference key="NSNextResponder" ref="631607481"/>
<int key="NSvFlags">256</int>
<string key="NSFrame">{{-100, -100}, {196, 15}}</string>
<reference key="NSSuperview" ref="631607481"/>
<int key="NSsFlags">1</int>
<reference key="NSTarget" ref="631607481"/>
<string key="NSAction">_doScroller:</string>
<double key="NSPercent">5.714286e-01</double>
</object>
</object>
<string key="NSFrameSize">{153, 354}</string>
<reference key="NSSuperview"/>
<reference key="NSNextKeyView" ref="973377808"/>
<int key="NSsFlags">528</int>
<reference key="NSVScroller" ref="636071848"/>
<reference key="NSHScroller" ref="46429660"/>
<reference key="NSContentView" ref="973377808"/>
<bytes key="NSScrollAmts">QSAAAEEgAABBoAAAQaAAAA</bytes>
</object>
<object class="NSUserDefaultsController" id="1030583199">
<bool key="NSSharedInstance">YES</bool>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">window</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="409430441"/>
</object>
<int key="connectionID">5</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">view</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="631607481"/>
</object>
<int key="connectionID">25</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">sourceView</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="971239525"/>
</object>
<int key="connectionID">26</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">dataSource</string>
<reference key="source" ref="971239525"/>
<reference key="destination" ref="1001"/>
</object>
<int key="connectionID">34</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="971239525"/>
<reference key="destination" ref="1001"/>
</object>
<int key="connectionID">35</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<object class="NSArray" key="object" id="1002">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="1001"/>
<reference key="parent" ref="1002"/>
<string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="1003"/>
<reference key="parent" ref="1002"/>
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="1004"/>
<reference key="parent" ref="1002"/>
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">2</int>
<reference key="object" ref="409430441"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="568708892"/>
</object>
<reference key="parent" ref="1002"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">3</int>
<reference key="object" ref="568708892"/>
<reference key="parent" ref="409430441"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">8</int>
<reference key="object" ref="631607481"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="636071848"/>
<reference ref="46429660"/>
<reference ref="971239525"/>
</object>
<reference key="parent" ref="1002"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">9</int>
<reference key="object" ref="636071848"/>
<reference key="parent" ref="631607481"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">10</int>
<reference key="object" ref="46429660"/>
<reference key="parent" ref="631607481"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">11</int>
<reference key="object" ref="971239525"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="408114397"/>
</object>
<reference key="parent" ref="631607481"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">13</int>
<reference key="object" ref="408114397"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="247185217"/>
</object>
<reference key="parent" ref="971239525"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">16</int>
<reference key="object" ref="247185217"/>
<reference key="parent" ref="408114397"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">21</int>
<reference key="object" ref="1030583199"/>
<reference key="parent" ref="1002"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.IBPluginDependency</string>
<string>-2.IBPluginDependency</string>
<string>-3.IBPluginDependency</string>
<string>10.IBPluginDependency</string>
<string>11.IBPluginDependency</string>
<string>13.IBPluginDependency</string>
<string>16.CustomClassName</string>
<string>16.IBPluginDependency</string>
<string>2.IBEditorWindowLastContentRect</string>
<string>2.IBPluginDependency</string>
<string>2.IBWindowTemplateEditedContentRect</string>
<string>2.NSWindowTemplate.visibleAtLaunch</string>
<string>3.IBPluginDependency</string>
<string>8.IBEditorWindowLastContentRect</string>
<string>8.IBPluginDependency</string>
<string>9.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilderKit</string>
<string>com.apple.InterfaceBuilderKit</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>PBIconAndTextCell</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{297, 477}, {186, 404}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{297, 477}, {186, 404}}</string>
<boolean value="NO"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{105, 545}, {153, 354}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">35</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">PBGitSidebarController</string>
<string key="superclassName">PBViewController</string>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>sourceView</string>
<string>window</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSOutlineView</string>
<string>NSWindow</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">PBGitSidebarController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">PBIconAndTextCell</string>
<string key="superclassName">NSTextFieldCell</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">PBIconAndTextCell.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">PBViewController</string>
<string key="superclassName">NSViewController</string>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">viewToolbar</string>
<string key="NS.object.0">NSToolbar</string>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">PBViewController.h</string>
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.LastKnownRelativeProjectPath">GitX.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
</archive>
+2 -1
View File
@@ -9,7 +9,8 @@
#import <Cocoa/Cocoa.h>
#import "PBGitRepository.h"
@class PBViewController;
@class PBViewController, PBGitSidebarController;
@interface PBGitWindowController : NSWindowController {
__weak PBGitRepository* repository;
int selectedViewIndex;
+9 -9
View File
@@ -11,6 +11,7 @@
#import "PBGitCommitController.h"
#import "Terminal.h"
#import "PBCloneRepsitoryToSheet.h"
#import "PBGitSidebarController.h"
@implementation PBGitWindowController
@@ -19,17 +20,16 @@
- (id)initWithRepository:(PBGitRepository*)theRepository displayDefault:(BOOL)displayDefault
{
if(self = [self initWithWindowNibName:@"RepositoryWindow"])
{
self.repository = theRepository;
[self showWindow:nil];
}
if (displayDefault) {
if (!(self = [self initWithWindowNibName:@"RepositoryWindow"]))
return nil;
self.repository = theRepository;
[self showWindow:nil];
if (displayDefault)
self.selectedViewIndex = [[NSUserDefaults standardUserDefaults] integerForKey:@"selectedViewIndex"];
} else {
else
self.selectedViewIndex = -1;
}
return self;
}
+17
View File
@@ -0,0 +1,17 @@
//
// PBSourceViewAction.h
// GitX
//
// Created by Pieter de Bie on 9/8/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "PBSourceViewItem.h"
@interface PBSourceViewAction : PBSourceViewItem {
NSImage *icon;
}
@property(retain) NSImage *icon;
@end
+15
View File
@@ -0,0 +1,15 @@
//
// PBSourceViewAction.m
// GitX
//
// Created by Pieter de Bie on 9/8/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "PBSourceViewAction.h"
@implementation PBSourceViewAction
@synthesize icon;
@end
+43
View File
@@ -0,0 +1,43 @@
//
// PBSourceViewItem.h
// GitX
//
// Created by Pieter de Bie on 9/8/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@class PBGitRevSpecifier;
@interface PBSourceViewItem : NSObject {
NSMutableArray *children;
NSString *title;
PBGitRevSpecifier *revSpecifier;
PBSourceViewItem *parent;
BOOL isGroupItem;
BOOL isUncollapsible;
}
+ (id)groupItemWithTitle:(NSString *)title;
+ (id)itemWithRevSpec:(PBGitRevSpecifier *)revSpecifier;
+ (id)itemWithTitle:(NSString *)title;
- (void)addChild:(PBSourceViewItem *)child;
// This adds the ref to the path, which should match the item's title,
// so "refs/heads/pu/pb/sidebar" would have the path [@"pu", @"pb", @"sidebare"]
// to the 'local' branch thing
- (void)addRev:(PBGitRevSpecifier *)revSpecifier toPath:(NSArray *)path;
- (PBSourceViewItem *)findRev:(PBGitRevSpecifier *)rev;
- (NSImage *)icon;
@property(retain) NSString *title;
@property(readonly) NSMutableArray *children;
@property(assign) BOOL isGroupItem, isUncollapsible;
@property(retain) PBGitRevSpecifier *revSpecifier;
@property(retain) PBSourceViewItem *parent;
@end
+113
View File
@@ -0,0 +1,113 @@
//
// PBSourceViewItem.m
// GitX
//
// Created by Pieter de Bie on 9/8/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "PBSourceViewItem.h"
#import "PBGitRevSpecifier.h"
@implementation PBSourceViewItem
@synthesize parent, title, isGroupItem, children, revSpecifier, isUncollapsible;
- (id)init
{
if (!(self = [super init]))
return nil;
children = [NSMutableArray array];
return self;
}
+ (id)groupItemWithTitle:(NSString *)title
{
PBSourceViewItem *item = [[[self class] alloc] init];
item.title = title;
item.isGroupItem = YES;
return item;
}
+ (id)itemWithRevSpec:(PBGitRevSpecifier *)revSpecifier
{
PBSourceViewItem *item = [[[self class] alloc] init];
item.revSpecifier = revSpecifier;
return item;
}
+ (id)itemWithTitle:(NSString *)title;
{
PBSourceViewItem *item = [[[self class] alloc] init];
item.title = title;
return item;
}
- (void)addChild:(PBSourceViewItem *)child
{
[self.children addObject:child];
child.parent = self;
}
- (void)addRev:(PBGitRevSpecifier *)theRevSpecifier toPath:(NSArray *)path
{
if ([path count] == 1) {
PBSourceViewItem *item = [PBSourceViewItem itemWithRevSpec:theRevSpecifier];
[self addChild:item];
return;
}
NSString *firstTitle = [path objectAtIndex:0];
PBSourceViewItem *node = nil;
for (PBSourceViewItem *child in [self children])
if ([child.title isEqualToString:firstTitle])
node = child;
if (!node) {
node = [PBSourceViewItem itemWithTitle:firstTitle];
[self addChild:node];
}
[node addRev:theRevSpecifier toPath:[path subarrayWithRange:NSMakeRange(1, [path count] - 1)]];
}
- (PBSourceViewItem *)findRev:(PBGitRevSpecifier *)rev
{
if (rev == revSpecifier)
return self;
PBSourceViewItem *item = nil;
for (PBSourceViewItem *child in children)
if (item = [child findRev:rev])
return item;
return nil;
}
- (NSString *)title
{
if (title)
return title;
return [[revSpecifier description] lastPathComponent];
}
- (NSImage *)icon
{
if ([self isGroupItem])
return nil;
if (self.parent && !self.parent.parent && [self.parent.title isEqualToString:@"Remotes"])
return [NSImage imageNamed:@"remote"];
if (self.parent && !self.parent.parent && [self.parent.title isEqualToString:@"Tags"])
return [NSImage imageNamed:@"tag"];
if ([[self children] count])
return [NSImage imageNamed:@"folder"];
return [NSImage imageNamed:@"branch"];
}
@end
+16
View File
@@ -0,0 +1,16 @@
//
// PBSourceViewRemote.h
// GitX
//
// Created by Pieter de Bie on 9/8/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "PBSourceViewItem.h"
@interface PBSourceViewRemote : PBSourceViewItem {
}
@end
+18
View File
@@ -0,0 +1,18 @@
//
// PBSourceViewRemote.m
// GitX
//
// Created by Pieter de Bie on 9/8/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "PBSourceViewRemote.h"
@implementation PBSourceViewRemote
- (NSImage *)icon
{
return [NSImage imageNamed:@"remote"];
}
@end