diff --git a/.gitignore b/.gitignore index 94061ea..6492eef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ build build/revision +._* *.xcodeproj/ !*.xcodeproj/project.pbxproj Nightly.app.zip diff --git a/ApplicationController.h b/ApplicationController.h index f368344..d611acb 100644 --- a/ApplicationController.h +++ b/ApplicationController.h @@ -32,7 +32,8 @@ - (IBAction)installCliTool:(id)sender; - (IBAction)saveAction:sender; -- (IBAction) showHelp:(id) sender; +- (IBAction)showHelp:(id)sender; +- (IBAction)reportAProblem:(id)sender; -- (IBAction) showCloneRepository:(id)sender; +- (IBAction)showCloneRepository:(id)sender; @end diff --git a/ApplicationController.m b/ApplicationController.m index c73b524..6794b14 100644 --- a/ApplicationController.m +++ b/ApplicationController.m @@ -64,6 +64,7 @@ - (void)applicationDidFinishLaunching:(NSNotification*)notification { [[SUUpdater sharedUpdater] setSendsSystemProfile:YES]; + [[SUUpdater sharedUpdater] setDelegate:self]; // Make sure Git's SSH password requests get forwarded to our little UI tool: setenv( "SSH_ASKPASS", [[[NSBundle mainBundle] pathForResource: @"gitx_askpasswd" ofType: @""] UTF8String], 1 ); @@ -196,11 +197,6 @@ former cannot be found), the system's temporary directory. */ -- (IBAction) showHelp:(id) sender -{ - [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://gitx.frim.nl/user_manual.html"]]; -} - - (NSString *)applicationSupportFolder { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); @@ -380,4 +376,44 @@ [managedObjectModel release], managedObjectModel = nil; [super dealloc]; } + + +#pragma mark Sparkle delegate methods + +- (NSArray *)feedParametersForUpdater:(SUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile +{ + NSArray *keys = [NSArray arrayWithObjects:@"key", @"displayKey", @"value", @"displayValue", nil]; + NSMutableArray *feedParameters = [NSMutableArray array]; + + // only add parameters if the profile is being sent this time + if (sendingProfile) { + NSString *CFBundleGitVersion = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleGitVersion"]; + if (CFBundleGitVersion) + [feedParameters addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"CFBundleGitVersion", @"Full Version", CFBundleGitVersion, CFBundleGitVersion, nil] + forKeys:keys]]; + + NSString *gitVersion = [PBGitBinary version]; + if (gitVersion) + [feedParameters addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"gitVersion", @"git Version", gitVersion, gitVersion, nil] + forKeys:keys]]; + } + + return feedParameters; +} + + +#pragma mark Help menu + +- (IBAction)showHelp:(id)sender +{ + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://gitx.frim.nl/user_manual.html"]]; +} + +- (IBAction)reportAProblem:(id)sender +{ + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://gitx.lighthouseapp.com/tickets"]]; +} + + + @end diff --git a/Commands/PBCommand.h b/Commands/PBCommand.h index ee92b27..8e3c1ae 100644 --- a/Commands/PBCommand.h +++ b/Commands/PBCommand.h @@ -7,22 +7,30 @@ // #import - +#import "PBGitRepository.h" @interface PBCommand : NSObject { + PBGitRepository *repository; + // for the user to see what it triggers NSString *displayName; // shown during command execution NSString *commandTitle; NSString *commandDescription; - NSArray *parameters; + NSMutableArray *parameters; + BOOL canBeFired; } +@property (nonatomic) BOOL canBeFired; +@property (nonatomic, retain, readonly) PBGitRepository *repository; @property (nonatomic, retain) NSString *commandTitle; @property (nonatomic, retain) NSString *commandDescription; @property (nonatomic, copy) NSString *displayName; -@property (nonatomic, retain, readonly) NSArray *parameters; -- (id) initWithDisplayName:(NSString *) aDisplayName parameters:(NSArray *) params; +- (id) initWithDisplayName:(NSString *) aDisplayName parameters:(NSArray *) params repository:(PBGitRepository *) repo; + - (void) invoke; + +- (NSArray *) allParameters; +- (void) appendParameters:(NSArray *) params; @end diff --git a/Commands/PBCommand.m b/Commands/PBCommand.m index db7a563..a36364c 100644 --- a/Commands/PBCommand.m +++ b/Commands/PBCommand.m @@ -7,29 +7,41 @@ // #import "PBCommand.h" +#import "PBRemoteProgressSheet.h" +@interface PBCommand() +@property (nonatomic, retain) PBGitRepository *repository; +@end @implementation PBCommand @synthesize displayName; -@synthesize parameters; @synthesize commandDescription; @synthesize commandTitle; +@synthesize repository; +@synthesize canBeFired; - (id) initWithDisplayName:(NSString *) aDisplayName parameters:(NSArray *) params { + return [self initWithDisplayName:aDisplayName parameters:params repository:nil]; +} + +- (id) initWithDisplayName:(NSString *) aDisplayName parameters:(NSArray *) params repository:(PBGitRepository *) repo { self = [super init]; if (self != nil) { self.displayName = aDisplayName; - parameters = [params retain]; + parameters = [[NSMutableArray alloc] initWithArray:params]; // default values self.commandTitle = @""; self.commandDescription = @""; + self.repository = repo; + self.canBeFired = YES; } return self; } - (void) dealloc { + [repository release]; [commandDescription release]; [commandTitle release]; [parameters release]; @@ -37,8 +49,16 @@ [super dealloc]; } +- (NSArray *) allParameters { + return parameters; +} + +- (void) appendParameters:(NSArray *) params { + [parameters addObjectsFromArray:params]; +} + - (void) invoke { - NSLog(@"Warning: Empty/abstrac command has been fired!"); + [PBRemoteProgressSheet beginRemoteProgressSheetForArguments:[self allParameters] title:self.commandTitle description:self.commandDescription inRepository:self.repository]; } @end diff --git a/Commands/PBCommandWithParameter.h b/Commands/PBCommandWithParameter.h new file mode 100644 index 0000000..dea7830 --- /dev/null +++ b/Commands/PBCommandWithParameter.h @@ -0,0 +1,23 @@ +// +// PBCommandWithParameter.h +// GitX +// +// Created by Tomasz Krasnyk on 10-11-06. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import +#import "PBCommand.h" + + +@interface PBCommandWithParameter : PBCommand { + PBCommand *command; + NSString *parameterName; + NSString *parameterDisplayName; +} +@property (nonatomic, retain, readonly) PBCommand *command; +@property (nonatomic, retain, readonly) NSString *parameterName; +@property (nonatomic, retain, readonly) NSString *parameterDisplayName; + +- initWithCommand:(PBCommand *) command parameterName:(NSString *) param parameterDisplayName:(NSString *) paramDisplayName; +@end diff --git a/Commands/PBCommandWithParameter.m b/Commands/PBCommandWithParameter.m new file mode 100644 index 0000000..9f50b51 --- /dev/null +++ b/Commands/PBCommandWithParameter.m @@ -0,0 +1,40 @@ +// +// PBCommandWithParameter.m +// GitX +// +// Created by Tomasz Krasnyk on 10-11-06. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import "PBCommandWithParameter.h" +#import "PBArgumentPickerController.h" + + +@implementation PBCommandWithParameter +@synthesize command; +@synthesize parameterName; +@synthesize parameterDisplayName; + +- initWithCommand:(PBCommand *) aCommand parameterName:(NSString *) param parameterDisplayName:(NSString *) paramDisplayName { + if (self = [super initWithDisplayName:[aCommand displayName] parameters:nil repository:[aCommand repository]]) { + command = [aCommand retain]; + parameterName = [param retain]; + parameterDisplayName = [paramDisplayName retain]; + } + return self; +} + +- (void) dealloc { + [command release]; + [parameterName release]; + [parameterDisplayName release]; + [super dealloc]; +} + + +- (void) invoke { + PBArgumentPickerController *controller = [[PBArgumentPickerController alloc] initWithCommandWithParameter:self]; + [NSApp beginSheet:[controller window] modalForWindow:[command.repository.windowController window] modalDelegate:controller didEndSelector:nil contextInfo:NULL]; + [controller release]; +} +@end diff --git a/Commands/PBOpenDocumentCommand.h b/Commands/PBOpenDocumentCommand.h new file mode 100644 index 0000000..1f51487 --- /dev/null +++ b/Commands/PBOpenDocumentCommand.h @@ -0,0 +1,17 @@ +// +// PBOpenDocumentCommand.h +// GitX +// +// Created by Tomasz Krasnyk on 10-11-07. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import +#import "PBCommand.h" + +@interface PBOpenDocumentCommand : PBCommand { + NSURL *documentURL; +} + +- (id) initWithDocumentAbsolutePath:(NSString *) path; +@end diff --git a/Commands/PBOpenDocumentCommand.m b/Commands/PBOpenDocumentCommand.m new file mode 100644 index 0000000..16f6906 --- /dev/null +++ b/Commands/PBOpenDocumentCommand.m @@ -0,0 +1,26 @@ +// +// PBOpenDocumentCommand.m +// GitX +// +// Created by Tomasz Krasnyk on 10-11-07. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import "PBOpenDocumentCommand.h" +#import "PBRepositoryDocumentController.h" +#import "PBGitRepository.h" + +@implementation PBOpenDocumentCommand + +- (id) initWithDocumentAbsolutePath:(NSString *) path { + if (self = [super initWithDisplayName:@"Open" parameters:nil repository:nil]) { + documentURL = [[NSURL alloc] initWithString:path]; + } + return self; +} + +- (void) invoke { + [[PBRepositoryDocumentController sharedDocumentController] documentForLocation:documentURL]; +} + +@end diff --git a/Commands/PBRemoteCommandFactory.h b/Commands/PBRemoteCommandFactory.h new file mode 100644 index 0000000..b249e73 --- /dev/null +++ b/Commands/PBRemoteCommandFactory.h @@ -0,0 +1,17 @@ +// +// PBRemoteCommandFactory.h +// GitX +// +// Created by Tomasz Krasnyk on 10-11-07. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import +#import "PBCommandFactory.h" + + +@interface PBRemoteCommandFactory : NSObject { + +} + +@end diff --git a/Commands/PBRemoteCommandFactory.m b/Commands/PBRemoteCommandFactory.m new file mode 100644 index 0000000..2b02524 --- /dev/null +++ b/Commands/PBRemoteCommandFactory.m @@ -0,0 +1,68 @@ +// +// PBRemoteCommandFactory.m +// GitX +// +// Created by Tomasz Krasnyk on 10-11-07. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import "PBRemoteCommandFactory.h" +#import "PBOpenDocumentCommand.h" +#import "PBGitSubmodule.h" +#import "PBRevealWithFinderCommand.h" + + +@implementation PBRemoteCommandFactory + ++ (NSArray *) commandsForSubmodule:(PBGitSubmodule *) submodule inRepository:(PBGitRepository *) repository { + NSMutableArray *commands = [[NSMutableArray alloc] init]; + + NSString *repoPath = [repository workingDirectory]; + NSString *path = [repoPath stringByAppendingPathComponent:[submodule path]]; + NSString *submodulePath = [submodule path]; + + if ([submodule submoduleState] == PBGitSubmoduleStateNotInitialized) { + NSArray *params = [NSArray arrayWithObjects:@"submodule", @"init", submodulePath, nil]; + PBCommand *initCmd = [[PBCommand alloc] initWithDisplayName:@"Init" parameters:params repository:repository]; + initCmd.commandTitle = initCmd.displayName; + initCmd.commandDescription = [NSString stringWithFormat:@"Initializing submodule %@", submodulePath]; + [commands addObject:initCmd]; + } + + // update + NSArray *params = [NSArray arrayWithObjects:@"submodule", @"update", submodulePath, nil]; + PBCommand *updateCmd = [[PBCommand alloc] initWithDisplayName:@"Update" parameters:params repository:repository]; + updateCmd.commandTitle = updateCmd.displayName; + updateCmd.commandDescription = [NSString stringWithFormat:@"Updating submodule %@", submodulePath]; + [commands addObject:updateCmd]; + + if ([[submodule submodules] count] > 0) { + // update recursively + NSArray *recursiveUpdate = [NSArray arrayWithObjects:@"submodule", @"update", @"--recursive", submodulePath, nil]; + PBCommand *updateRecursively = [[PBCommand alloc] initWithDisplayName:@"Update recursively" parameters:recursiveUpdate repository:repository]; + updateRecursively.commandTitle = updateRecursively.displayName; + updateRecursively.commandDescription = [NSString stringWithFormat:@"Updating submodule %@ (recursively)", submodulePath]; + [commands addObject:updateRecursively]; + } + + if ([submodule submoduleState] != PBGitSubmoduleStateNotInitialized) { + // open + PBOpenDocumentCommand *command = [[PBOpenDocumentCommand alloc] initWithDocumentAbsolutePath:path]; + command.commandTitle = command.displayName; + command.commandDescription = @"Opening document"; + [commands addObject:command]; + + [commands addObject:[[PBRevealWithFinderCommand alloc] initWithDocumentAbsolutePath:path]]; + } + + return commands; +} + ++ (NSArray *) commandsForObject:(NSObject *) object repository:(PBGitRepository *) repository { + if ([object isKindOfClass:[PBGitSubmodule class]]) { + return [PBRemoteCommandFactory commandsForSubmodule:(id)object inRepository:repository]; + } + return nil; +} + +@end diff --git a/Commands/PBRevealWithFinderCommand.h b/Commands/PBRevealWithFinderCommand.h new file mode 100644 index 0000000..a97f6f1 --- /dev/null +++ b/Commands/PBRevealWithFinderCommand.h @@ -0,0 +1,17 @@ +// +// PBRevealWithFinder.h +// GitX +// +// Created by Tomasz Krasnyk on 10-11-27. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import +#import "PBOpenDocumentCommand.h" + +@interface PBRevealWithFinderCommand : PBOpenDocumentCommand { + +} + + +@end diff --git a/Commands/PBRevealWithFinderCommand.m b/Commands/PBRevealWithFinderCommand.m new file mode 100644 index 0000000..2f94a58 --- /dev/null +++ b/Commands/PBRevealWithFinderCommand.m @@ -0,0 +1,31 @@ +// +// PBRevealWithFinder.m +// GitX +// +// Created by Tomasz Krasnyk on 10-11-27. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import "PBRevealWithFinderCommand.h" + + +@implementation PBRevealWithFinderCommand + +- (id) initWithDocumentAbsolutePath:(NSString *) path { + if (!path) { + [self autorelease]; + return nil; + } + + if (self = [super initWithDisplayName:@"Reveal in Finder" parameters:nil repository:nil]) { + documentURL = [[NSURL alloc] initWithString:path]; + } + return self; +} + +- (void) invoke { + NSWorkspace *ws = [NSWorkspace sharedWorkspace]; + [ws selectFile:[documentURL absoluteString] inFileViewerRootedAtPath:nil]; +} + +@end diff --git a/Commands/PBStashCommand.h b/Commands/PBStashCommand.h deleted file mode 100644 index bf9d40d..0000000 --- a/Commands/PBStashCommand.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// PBStashCommand.h -// GitX -// -// Created by Tomasz Krasnyk on 10-11-06. -// Copyright 2010 __MyCompanyName__. All rights reserved. -// - -#import -#import "PBCommand.h" -#import "PBGitRepository.h" - -@interface PBStashCommand : PBCommand { - PBGitRepository *repository; - NSArray *arguments; -} - -- initWithDisplayName:(NSString *) aDisplayName arguments:(NSArray *) args repository:(PBGitRepository *) repo; -@end diff --git a/Commands/PBStashCommand.m b/Commands/PBStashCommand.m deleted file mode 100644 index 53f9839..0000000 --- a/Commands/PBStashCommand.m +++ /dev/null @@ -1,44 +0,0 @@ -// -// PBStashCommand.m -// GitX -// -// Created by Tomasz Krasnyk on 10-11-06. -// Copyright 2010 __MyCompanyName__. All rights reserved. -// - -#import "PBStashCommand.h" -#import "PBRemoteProgressSheet.h" - -@interface PBStashCommand() -@property (nonatomic, retain) PBGitRepository *repository; -@property (nonatomic, retain) NSArray *arguments; -@end - - -@implementation PBStashCommand -@synthesize repository; -@synthesize arguments; - -- initWithDisplayName:(NSString *) aDisplayName arguments:(NSArray *) args repository:(PBGitRepository *) repo { - if (self = [super initWithDisplayName:aDisplayName parameters:[NSArray arrayWithObject:@"stash"]]) { - self.arguments = args; - self.repository = repo; - } - return self; -} - -- (void) dealloc { - [parameters release]; - [repository release]; - [super dealloc]; -} - - -- (void) invoke { - NSMutableArray *args = [[NSMutableArray alloc] initWithArray:super.parameters]; - [args addObjectsFromArray:self.arguments]; - [PBRemoteProgressSheet beginRemoteProgressSheetForArguments:args title:self.commandTitle description:self.commandDescription inRepository:self.repository]; - [args release]; -} - -@end diff --git a/Commands/PBStashCommandFactory.h b/Commands/PBStashCommandFactory.h index 291c47b..d4e0983 100644 --- a/Commands/PBStashCommandFactory.h +++ b/Commands/PBStashCommandFactory.h @@ -9,6 +9,7 @@ #import #import "PBCommandFactory.h" + @interface PBStashCommandFactory : NSObject { } diff --git a/Commands/PBStashCommandFactory.m b/Commands/PBStashCommandFactory.m index 83f8e0f..195cd7b 100644 --- a/Commands/PBStashCommandFactory.m +++ b/Commands/PBStashCommandFactory.m @@ -7,39 +7,81 @@ // #import "PBStashCommandFactory.h" -#import "PBStashCommand.h" +#import "PBCommand.h" +#import "PBCommandWithParameter.h" // model #import "PBGitStash.h" +#import "PBGitRef.h" + +@interface PBStashCommandFactory() ++ (NSArray *) commandsForStash:(PBGitStash *) stash repository:(PBGitRepository *) repository; ++ (NSArray *) commandsForRef:(PBGitRef *) ref repository:(PBGitRepository *) repository; +@end + @implementation PBStashCommandFactory + (NSArray *) commandsForObject:(NSObject *) object repository:(PBGitRepository *) repository { - if (![object isKindOfClass:[PBGitStash class]]) { - return nil; + NSArray *cmds = nil; + if ([object isKindOfClass:[PBGitStash class]]) { + cmds = [PBStashCommandFactory commandsForStash:(id)object repository:repository]; + } else if ([object isKindOfClass:[PBGitRef class]]) { + cmds = [PBStashCommandFactory commandsForRef:(id)object repository:repository]; } - PBGitStash *stash = (PBGitStash *) object; + + + return cmds; +} + ++ (NSArray *) commandsForRef:(PBGitRef *) ref repository:(PBGitRepository *) repository { NSMutableArray *commands = [[NSMutableArray alloc] init]; - NSArray *args = [NSArray arrayWithObjects:@"apply", [stash name], nil]; - PBStashCommand *command = [[PBStashCommand alloc] initWithDisplayName:@"Apply" arguments:args repository:repository]; + PBGitRef *headRef = [[repository headRef] ref]; + BOOL isHead = [ref isEqualToRef:headRef]; + + if (isHead) { + NSArray *args = [NSArray arrayWithObject:@"stash"]; + PBCommand *command = [[PBCommand alloc] initWithDisplayName:@"Stash local changes..." parameters:args repository:repository]; + command.commandTitle = command.displayName; + command.commandDescription = @"Stashing local changes"; + + PBCommandWithParameter *cmd = [[PBCommandWithParameter alloc] initWithCommand:command parameterName:@"save" parameterDisplayName:@"Stash message (optional)"]; + [command release]; + [commands addObject:cmd]; + [cmd release]; + + command = [[PBCommand alloc] initWithDisplayName:@"Clear stashes" parameters:[NSArray arrayWithObjects:@"stash", @"clear", nil] repository:repository]; + command.commandTitle = command.displayName; + command.commandDescription = @"Clearing stashes"; + [commands addObject:command]; + [command release]; + } + + return [commands autorelease]; +} + ++ (NSArray *) commandsForStash:(PBGitStash *) stash repository:(PBGitRepository *) repository { + NSMutableArray *commands = [[NSMutableArray alloc] init]; + + NSArray *args = [NSArray arrayWithObjects:@"stash", @"apply", [stash name], nil]; + PBCommand *command = [[PBCommand alloc] initWithDisplayName:@"Apply" parameters:args repository:repository]; command.commandTitle = command.displayName; command.commandDescription = [NSString stringWithFormat:@"Applying stash: '%@'", stash]; [commands addObject:command]; - args = [NSArray arrayWithObjects:@"pop", [stash name], nil]; - command = [[PBStashCommand alloc] initWithDisplayName:@"Pop" arguments:args repository:repository]; + args = [NSArray arrayWithObjects:@"stash", @"pop", [stash name], nil]; + command = [[PBCommand alloc] initWithDisplayName:@"Pop" parameters:args repository:repository]; command.commandTitle = command.displayName; command.commandDescription = [NSString stringWithFormat:@"Poping stash: '%@'", stash]; [commands addObject:command]; - args = [NSArray arrayWithObjects:@"drop", [stash name], nil]; - command = [[PBStashCommand alloc] initWithDisplayName:@"Drop" arguments:args repository:repository]; + args = [NSArray arrayWithObjects:@"stash", @"drop", [stash name], nil]; + command = [[PBCommand alloc] initWithDisplayName:@"Drop" parameters:args repository:repository]; command.commandTitle = command.displayName; command.commandDescription = [NSString stringWithFormat:@"Dropping stash: '%@'", stash]; [commands addObject:command]; - return [commands autorelease]; } diff --git a/Controller/PBArgumentPickerController.h b/Controller/PBArgumentPickerController.h new file mode 100644 index 0000000..3811baa --- /dev/null +++ b/Controller/PBArgumentPickerController.h @@ -0,0 +1,25 @@ +// +// PBArgumentPickerController.h +// GitX +// +// Created by Tomasz Krasnyk on 10-11-06. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import +#import "PBCommand.h" +#import "PBArgumentPicker.h" + +@class PBCommandWithParameter; + +@interface PBArgumentPickerController : NSWindowController { + IBOutlet PBArgumentPicker *view; + + PBCommandWithParameter *cmdWithParameter; +} + +- initWithCommandWithParameter:(PBCommandWithParameter *) command; + +- (IBAction) okClicked:sender; +- (IBAction) cancelClicked:sender; +@end diff --git a/Controller/PBArgumentPickerController.m b/Controller/PBArgumentPickerController.m new file mode 100644 index 0000000..51d542e --- /dev/null +++ b/Controller/PBArgumentPickerController.m @@ -0,0 +1,50 @@ +// +// PBArgumentPickerController.m +// GitX +// +// Created by Tomasz Krasnyk on 10-11-06. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import "PBArgumentPickerController.h" +#import "PBCommandWithParameter.h" + + +@implementation PBArgumentPickerController + +- initWithCommandWithParameter:(PBCommandWithParameter *) aCommand { + if (self = [super initWithWindowNibName:@"PBArgumentPicker" owner:self]) { + cmdWithParameter = [aCommand retain]; + } + return self; +} + +- (void) dealloc { + [cmdWithParameter release]; + + [super dealloc]; +} + +- (void) awakeFromNib { + NSString *stringToDisplay = [NSString stringWithFormat:@"%@:", [cmdWithParameter parameterDisplayName]]; + [view.label setTitleWithMnemonic:stringToDisplay]; +} + +- (IBAction) okClicked:sender { + NSString *userText = [view.textField stringValue]; + if ([userText length] > 0) { + NSString *paramName = [cmdWithParameter parameterName]; + [cmdWithParameter.command appendParameters:[NSArray arrayWithObjects:paramName, userText, nil]]; + } + [self cancelClicked:sender]; + + [cmdWithParameter.command invoke]; +} + +- (IBAction) cancelClicked:sender { + [NSApp endSheet:[self window]]; + [[self window] orderOut:self]; +} + + +@end diff --git a/Controller/PBGitResetController.h b/Controller/PBGitResetController.h new file mode 100644 index 0000000..b7a8d30 --- /dev/null +++ b/Controller/PBGitResetController.h @@ -0,0 +1,24 @@ +// +// PBGitResetController.h +// GitX +// +// Created by Tomasz Krasnyk on 10-11-27. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import + +@class PBGitRepository; + +@interface PBGitResetController : NSObject { + PBGitRepository *repository; +} +- (id) initWithRepository:(PBGitRepository *) repo; + +- (NSArray *) menuItems; + + +// actions +- (void) resetHardToHead; + +@end diff --git a/Controller/PBGitResetController.m b/Controller/PBGitResetController.m new file mode 100644 index 0000000..773a74d --- /dev/null +++ b/Controller/PBGitResetController.m @@ -0,0 +1,87 @@ +// +// PBGitResetController.m +// GitX +// +// Created by Tomasz Krasnyk on 10-11-27. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import "PBGitResetController.h" +#import "PBGitRepository.h" +#import "PBCommand.h" + +static NSString * const kCommandKey = @"command"; + +@implementation PBGitResetController + +- (id) initWithRepository:(PBGitRepository *) repo { + if (self = [super init]){ + repository = [repo retain]; + } + return self; +} + +- (void) resetHardToHead { + NSAlert *alert = [NSAlert alertWithMessageText:@"Reseting working copy and index" + defaultButton:@"Cancel" + alternateButton:nil + otherButton:@"Reset" + informativeTextWithFormat:@"Are you sure you want to reset your working copy and index? All changes to them will be gone!"]; + + NSArray *arguments = [NSArray arrayWithObjects:@"reset", @"--hard", @"HEAD", nil]; + PBCommand *cmd = [[PBCommand alloc] initWithDisplayName:@"Reset hard to HEAD" parameters:arguments repository:repository]; + cmd.commandTitle = cmd.displayName; + cmd.commandDescription = @"Reseting head"; + + NSMutableDictionary *info = [NSMutableDictionary dictionaryWithObject:cmd forKey:kCommandKey]; + + [alert beginSheetModalForWindow:[repository.windowController window] + modalDelegate:self + didEndSelector:@selector(confirmResetSheetDidEnd:returnCode:contextInfo:) + contextInfo:info]; +} + +- (void) reset { + //TODO missing implementation +} + +- (NSArray *) menuItems { + NSMenuItem *resetHeadHardly = [[NSMenuItem alloc] initWithTitle:@"Reset hard to HEAD" action:@selector(resetHardToHead) keyEquivalent:@""]; + [resetHeadHardly setTarget:self]; + + NSMenuItem *reset = [[NSMenuItem alloc] initWithTitle:@"Reset..." action:@selector(reset) keyEquivalent:@""]; + [reset setTarget:self]; + + return [NSArray arrayWithObjects:resetHeadHardly, reset, nil]; +} + +- (BOOL) validateMenuItem:(NSMenuItem *)menuItem { + BOOL shouldBeEnabled = YES; + SEL action = [menuItem action]; + if (action == @selector(reset)) { + shouldBeEnabled = NO; + //TODO missing implementation + } + return shouldBeEnabled; +} + +- (void) dealloc { + [repository release]; + [super dealloc]; +} + +#pragma mark - +#pragma mark Confirm Window + +- (void) confirmResetSheetDidEnd:(NSAlert *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo +{ + [[sheet window] orderOut:nil]; + + if (returnCode != NSAlertDefaultReturn) { + PBCommand *cmd = [(NSDictionary *)contextInfo objectForKey:kCommandKey]; + [cmd invoke]; + } +} + + +@end diff --git a/Controller/PBSubmoduleController.h b/Controller/PBSubmoduleController.h new file mode 100644 index 0000000..65294eb --- /dev/null +++ b/Controller/PBSubmoduleController.h @@ -0,0 +1,37 @@ +// +// PBSubmoduleController.h +// GitX +// +// Created by Tomasz Krasnyk on 10-11-27. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import +#import "PBGitSubmodule.h" + +@class PBGitRepository; +@class PBCommand; + +@interface PBSubmoduleController : NSObject { + NSArray *submodules; +@private + PBGitRepository *repository; +} +@property (nonatomic, retain, readonly) NSArray *submodules; + +- (id) initWithRepository:(PBGitRepository *) repo; + +- (void) reload; + +- (NSArray *) menuItems; + + +// actions + +- (void) addNewSubmodule; +- (void) initializeAllSubmodules; +- (void) updateAllSubmodules; + +- (PBCommand *) commandForOpeningSubmodule:(PBGitSubmodule *) submodule; +- (PBCommand *) defaultCommandForSubmodule:(PBGitSubmodule *) submodule; +@end diff --git a/Controller/PBSubmoduleController.m b/Controller/PBSubmoduleController.m new file mode 100644 index 0000000..7da580b --- /dev/null +++ b/Controller/PBSubmoduleController.m @@ -0,0 +1,133 @@ +// +// PBSubmoduleController.m +// GitX +// +// Created by Tomasz Krasnyk on 10-11-27. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import "PBSubmoduleController.h" +#import "PBGitRepository.h" +#import "PBOpenDocumentCommand.h" + +@interface PBSubmoduleController() +@property (nonatomic, retain) NSArray *submodules; +@end + + +@implementation PBSubmoduleController +@synthesize submodules; + +- (id) initWithRepository:(PBGitRepository *) repo { + if (self = [super init]){ + repository = [repo retain]; + } + return self; +} + +- (void)dealloc { + [repository release]; + [submodules release]; + [super dealloc]; +} + +- (void) reload { + NSArray *arguments = [NSArray arrayWithObjects:@"submodule", @"status", @"--recursive", nil]; + NSString *output = [repository outputInWorkdirForArguments:arguments]; + NSArray *lines = [output componentsSeparatedByString:@"\n"]; + + NSMutableArray *loadedSubmodules = [[NSMutableArray alloc] initWithCapacity:[lines count]]; + + for (NSString *submoduleLine in lines) { + if ([submoduleLine length] == 0) + continue; + PBGitSubmodule *submodule = [[PBGitSubmodule alloc] initWithRawSubmoduleStatusString:submoduleLine]; + [loadedSubmodules addObject:submodule]; + } + + NSMutableArray *groupedSubmodules = [[NSMutableArray alloc] init]; + for (PBGitSubmodule *submodule in loadedSubmodules) { + BOOL added = NO; + for (PBGitSubmodule *addedItem in groupedSubmodules) { + if ([[submodule path] hasPrefix:[addedItem path]]) { + [addedItem addSubmodule:submodule]; + added = YES; + } + } + if (!added) { + [groupedSubmodules addObject:submodule]; + } + } + + + self.submodules = loadedSubmodules; +} + +#pragma mark - +#pragma mark Actions + +- (void) addNewSubmodule { + //TODO implement +} + +- (void) initializeAllSubmodules { + NSArray *parameters = [NSArray arrayWithObjects:@"submodule", @"init", nil]; + PBCommand *initializeSubmodules = [[PBCommand alloc] initWithDisplayName:@"Initialize All Submodules" parameters:parameters repository:repository]; + initializeSubmodules.commandTitle = initializeSubmodules.displayName; + initializeSubmodules.commandDescription = @"Initializing submodules"; + [initializeSubmodules invoke]; + [initializeSubmodules release]; +} + +- (void) updateAllSubmodules { + NSArray *parameters = [NSArray arrayWithObjects:@"submodule", @"update", nil]; + PBCommand *initializeSubmodules = [[PBCommand alloc] initWithDisplayName:@"Update All Submodules" parameters:parameters repository:repository]; + initializeSubmodules.commandTitle = initializeSubmodules.displayName; + initializeSubmodules.commandDescription = @"Updating submodules"; + [initializeSubmodules invoke]; + [initializeSubmodules release]; +} + +- (NSArray *) menuItems { + NSMutableArray *items = [[NSMutableArray alloc] init]; + [items addObject:[[NSMenuItem alloc] initWithTitle:@"Add Submodule..." action:@selector(addNewSubmodule) keyEquivalent:@""]]; + [items addObject:[[NSMenuItem alloc] initWithTitle:@"Initialize All Submodules" action:@selector(initializeAllSubmodules) keyEquivalent:@""]]; + [items addObject:[[NSMenuItem alloc] initWithTitle:@"Update All Submodules" action:@selector(updateAllSubmodules) keyEquivalent:@""]]; + + for (NSMenuItem *item in items) { + [item setTarget:self]; + } + + return items; +} + +- (PBCommand *) defaultCommandForSubmodule:(PBGitSubmodule *) submodule { + return [self commandForOpeningSubmodule:submodule]; +} + +- (PBCommand *) commandForOpeningSubmodule:(PBGitSubmodule *) submodule { + if (!([submodule path] && [submodule submoduleState] != PBGitSubmoduleStateNotInitialized)) { + return nil; + } + NSString *repoPath = [repository workingDirectory]; + NSString *path = [repoPath stringByAppendingPathComponent:[submodule path]]; + + PBOpenDocumentCommand *command = [[PBOpenDocumentCommand alloc] initWithDocumentAbsolutePath:path]; + command.commandTitle = command.displayName; + command.commandDescription = @"Opening document"; + return [command autorelease]; +} + +- (BOOL) validateMenuItem:(NSMenuItem *)menuItem { + BOOL shouldBeEnabled = YES; + SEL action = [menuItem action]; + if (action == @selector(addNewSubmodule)) { + shouldBeEnabled = NO; + //TODO implementation missing + } else { + shouldBeEnabled = [self.submodules count] > 0; + } + return shouldBeEnabled; +} + +@end diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib index dd75fb2..9b8ab97 100644 --- a/English.lproj/MainMenu.xib +++ b/English.lproj/MainMenu.xib @@ -12,6 +12,7 @@ YES + YES @@ -921,6 +922,22 @@ + + + Report a problem + + 2147483647 + + + + + + Discuss GitX + + 2147483647 + + + @@ -1367,6 +1384,22 @@ 968 + + + reportAProblem: + + + + 971 + + + + discussGitX: + + + + 973 + @@ -1625,6 +1658,8 @@ YES + + @@ -2078,6 +2113,16 @@ + + 969 + + + + + 972 + + + @@ -2280,6 +2325,8 @@ 956.IBPluginDependency 964.IBPluginDependency 964.ImportedFromIB2 + 969.IBPluginDependency + 972.IBPluginDependency YES @@ -2287,7 +2334,7 @@ com.apple.InterfaceBuilder.CocoaPlugin - {{880, 713}, {135, 23}} + {{778, 967}, {190, 63}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -2398,7 +2445,7 @@ com.apple.InterfaceBuilder.CocoaPlugin - {{809, 663}, {194, 73}} + {{707, 957}, {194, 73}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -2479,6 +2526,8 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin @@ -2497,7 +2546,7 @@ - 968 + 973 @@ -2509,8 +2558,10 @@ YES YES + discussGitX: installCliTool: openPreferencesWindow: + reportAProblem: saveAction: showAboutPanel: showCloneRepository: @@ -2524,14 +2575,18 @@ id id id + id + id YES YES + discussGitX: installCliTool: openPreferencesWindow: + reportAProblem: saveAction: showAboutPanel: showCloneRepository: @@ -2539,6 +2594,10 @@ YES + + discussGitX: + id + installCliTool: id @@ -2547,6 +2606,10 @@ openPreferencesWindow: id + + reportAProblem: + id + saveAction: id @@ -2913,6 +2976,7 @@ YES commit: + forceCommit: refresh: signOff: @@ -2921,6 +2985,7 @@ id id id + id @@ -2928,6 +2993,7 @@ YES commit: + forceCommit: refresh: signOff: @@ -2937,6 +3003,10 @@ commit: id + + forceCommit: + id + refresh: id @@ -3035,6 +3105,8 @@ openSelectedFile: rebase: refresh: + selectNext: + selectPrevious: setBranchFilter: setDetailedView: setTreeView: @@ -3060,6 +3132,8 @@ id id id + id + id @@ -3074,6 +3148,8 @@ openSelectedFile: rebase: refresh: + selectNext: + selectPrevious: setBranchFilter: setDetailedView: setTreeView: @@ -3116,6 +3192,14 @@ refresh: id + + selectNext: + id + + + selectPrevious: + id + setBranchFilter: id @@ -3641,14 +3725,42 @@ PBHistorySearchController NSObject - stepperPressed: - id + YES + + YES + selectSearchMode: + stepperPressed: + updateSearch: + + + YES + id + id + id + - stepperPressed: - - stepperPressed: - id + YES + + YES + selectSearchMode: + stepperPressed: + updateSearch: + + + YES + + selectSearchMode: + id + + + stepperPressed: + id + + + updateSearch: + id + @@ -3658,6 +3770,7 @@ commitController historyController numberOfMatchesField + progressIndicator searchField stepper @@ -3666,6 +3779,7 @@ NSArrayController PBGitHistoryController NSTextField + NSProgressIndicator NSSearchField NSSegmentedControl @@ -3677,6 +3791,7 @@ commitController historyController numberOfMatchesField + progressIndicator searchField stepper @@ -3694,6 +3809,10 @@ numberOfMatchesField NSTextField + + progressIndicator + NSProgressIndicator + searchField NSSearchField @@ -4655,13 +4774,6 @@ QuartzCore.framework/Headers/CIImageProvider.h - - NSObject - - IBFrameworkSource - ScriptingBridge.framework/Headers/SBApplication.h - - NSObject diff --git a/English.lproj/Preferences.xib b/English.lproj/Preferences.xib index e90280b..6aba53d 100644 --- a/English.lproj/Preferences.xib +++ b/English.lproj/Preferences.xib @@ -2,18 +2,16 @@ 1050 - 10C540 - 759 - 1038.25 - 458.00 + 10H574 + 804 + 1038.35 + 461.00 com.apple.InterfaceBuilder.CocoaPlugin - 759 + 804 YES - - @@ -45,21 +43,74 @@ 268 YES + + + 268 + {{17, 22}, {166, 17}} + + YES + + 68288064 + 272630784 + Reset all dialog warnings: + + LucidaGrande + 13 + 1044 + + + + 6 + System + controlColor + + 3 + MC42NjY2NjY2NjY3AA + + + + 6 + System + controlTextColor + + 3 + MAA + + + + + + + 268 + {{182, 12}, {137, 32}} + + YES + + -2080244224 + 134217728 + Reset Warnings + + + -2038021889 + 129 + + + + 400 + 75 + + 268 - {{248, 100}, {41, 22}} + {{248, 118}, {41, 22}} YES -1804468671 272630784 - - LucidaGrande - 13 - 1044 - + YES @@ -75,17 +126,14 @@ 6 System textColor - - 3 - MAA - + 268 - {{121, 102}, {122, 17}} + {{121, 120}, {122, 17}} YES @@ -94,27 +142,14 @@ Display at column: - - 6 - System - controlColor - - 3 - MC42NjY2NjY2NjY3AA - - - - 6 - System - controlTextColor - - + + 268 - {{18, 125}, {273, 18}} + {{18, 143}, {273, 18}} YES @@ -141,7 +176,7 @@ 268 - {{17, 74}, {99, 17}} + {{17, 92}, {99, 17}} YES @@ -165,7 +200,7 @@ NSFilenamesPboardType - {{121, 70}, {179, 22}} + {{121, 88}, {179, 22}} YES @@ -187,7 +222,7 @@ 268 - {{118, 20}, {192, 42}} + {{118, 52}, {192, 28}} YES @@ -203,7 +238,7 @@ 268 - {{306, 74}, {54, 14}} + {{306, 92}, {54, 14}} YES @@ -228,7 +263,7 @@ 268 - {{18, 150}, {203, 18}} + {{18, 168}, {203, 18}} YES @@ -250,7 +285,7 @@ 268 - {{18, 175}, {279, 18}} + {{18, 193}, {279, 18}} YES @@ -272,7 +307,7 @@ 268 - {{18, 200}, {207, 18}} + {{18, 218}, {207, 18}} YES @@ -292,12 +327,12 @@ - {400, 236} + {400, 254} NSView - + 268 YES @@ -306,7 +341,6 @@ 268 {{39, 45}, {82, 14}} - YES 68288064 @@ -323,7 +357,6 @@ 268 {{18, 103}, {260, 18}} - YES -2080244224 @@ -346,7 +379,6 @@ 268 {{130, 78}, {102, 22}} - YES -2076049856 @@ -434,7 +466,6 @@ 268 {{39, 80}, {89, 17}} - YES 68288064 @@ -451,7 +482,6 @@ 268 {{130, 45}, {251, 14}} - YES 68288064 @@ -489,7 +519,6 @@ 268 {{128, 13}, {96, 28}} - YES 67239424 @@ -507,12 +536,10 @@ {400, 139} - - NSView - + 268 YES @@ -540,22 +567,16 @@ {239, 54} - NSView SUUpdater - - YES - PBCommitMessageViewHasVerticalLine - PBCommitMessageViewVerticalLineLength - YES - + 268 YES @@ -649,7 +670,6 @@ {400, 116} - NSView @@ -1051,6 +1071,14 @@ 135 + + + resetAllDialogWarnings: + + + + 140 + @@ -1094,6 +1122,8 @@ + + General @@ -1485,6 +1515,34 @@ + + 136 + + + YES + + + + + + 137 + + + YES + + + + + + 138 + + + + + 139 + + + @@ -1515,6 +1573,13 @@ 13.IBPluginDependency 130.IBPluginDependency 131.IBPluginDependency + 136.IBAttributePlaceholdersKey + 136.IBPluginDependency + 136.IBViewBoundsToFrameTransform + 137.IBPluginDependency + 137.IBViewBoundsToFrameTransform + 138.IBPluginDependency + 139.IBPluginDependency 14.IBPluginDependency 15.IBEditorWindowLastContentRect 15.IBPluginDependency @@ -1558,7 +1623,7 @@ YES com.apple.InterfaceBuilder.CocoaPlugin - {{845, 648}, {400, 236}} + {{845, 630}, {400, 254}} com.apple.InterfaceBuilder.CocoaPlugin YES @@ -1588,6 +1653,24 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + + ToolTip + + ToolTip + + Resets the of the "Don't show this again" preferences. + + + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABDXwAAwggAAA + + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABCaAAAwegAAA + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin {{443, 712}, {103, 71}} com.apple.InterfaceBuilder.CocoaPlugin @@ -1652,7 +1735,7 @@ - 135 + 140 @@ -1665,6 +1748,13 @@ DBPrefsWindowController.h + + NSApplication + + IBProjectSource + NSApplication+GitXScripting.h + + PBPrefsWindowController DBPrefsWindowController @@ -1673,6 +1763,7 @@ YES checkGitValidity: + resetAllDialogWarnings: resetGitPath: showHideAllFiles: @@ -1681,6 +1772,36 @@ id id id + id + + + + YES + + YES + checkGitValidity: + resetAllDialogWarnings: + resetGitPath: + showHideAllFiles: + + + YES + + checkGitValidity: + id + + + resetAllDialogWarnings: + id + + + resetGitPath: + id + + + showHideAllFiles: + id + @@ -1704,6 +1825,45 @@ NSView + + YES + + YES + badGitPathIcon + generalPrefsView + gitPathController + gitPathOpenAccessory + integrationPrefsView + updatesPrefsView + + + YES + + badGitPathIcon + NSImageView + + + generalPrefsView + NSView + + + gitPathController + NSPathControl + + + gitPathOpenAccessory + NSView + + + integrationPrefsView + NSView + + + updatesPrefsView + NSView + + + IBProjectSource PBPrefsWindowController.h @@ -1733,10 +1893,24 @@ checkForUpdates: id + + checkForUpdates: + + checkForUpdates: + id + + delegate id + + delegate + + delegate + id + + @@ -2125,6 +2299,27 @@ Foundation.framework/Headers/NSURLDownload.h + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CIImageProvider.h + + NSObject @@ -2332,6 +2527,13 @@ showWindow: id + + showWindow: + + showWindow: + id + + IBFrameworkSource AppKit.framework/Headers/NSWindowController.h @@ -2344,10 +2546,24 @@ checkForUpdates: id + + checkForUpdates: + + checkForUpdates: + id + + delegate id + + delegate + + delegate + id + + @@ -2370,8 +2586,21 @@ ../GitX.xcodeproj 3 - NSStopProgressFreestandingTemplate - {83, 83} + YES + + YES + NSMenuCheckmark + NSMenuMixedState + NSStopProgressFreestandingTemplate + NSSwitch + + + YES + {9, 8} + {7, 2} + {83, 83} + {15, 15} + diff --git a/File Markers/added_file.png b/File Markers/added_file.png new file mode 100644 index 0000000..ad08fae Binary files /dev/null and b/File Markers/added_file.png differ diff --git a/File Markers/conflicted_file.png b/File Markers/conflicted_file.png new file mode 100644 index 0000000..a633ecf Binary files /dev/null and b/File Markers/conflicted_file.png differ diff --git a/File Markers/deleted_file.png b/File Markers/deleted_file.png new file mode 100644 index 0000000..390d96b Binary files /dev/null and b/File Markers/deleted_file.png differ diff --git a/File Markers/ignored_file.png b/File Markers/ignored_file.png new file mode 100644 index 0000000..c4813fb Binary files /dev/null and b/File Markers/ignored_file.png differ diff --git a/File Markers/modified_file.png b/File Markers/modified_file.png new file mode 100644 index 0000000..d5abd30 Binary files /dev/null and b/File Markers/modified_file.png differ diff --git a/File Markers/renamed_file.png b/File Markers/renamed_file.png new file mode 100644 index 0000000..4c294e9 Binary files /dev/null and b/File Markers/renamed_file.png differ diff --git a/File Markers/unversioned_file.png b/File Markers/unversioned_file.png new file mode 100644 index 0000000..62a9361 Binary files /dev/null and b/File Markers/unversioned_file.png differ diff --git a/GLFileView.h b/GLFileView.h index 79b3707..fa23859 100644 --- a/GLFileView.h +++ b/GLFileView.h @@ -21,6 +21,7 @@ NSMutableArray *groups; NSString *logFormat; IBOutlet NSView *accessoryView; + IBOutlet NSSplitView *fileListSplitView; } - (void)showFile; diff --git a/GLFileView.m b/GLFileView.m index 90b05ec..bec36c6 100644 --- a/GLFileView.m +++ b/GLFileView.m @@ -16,6 +16,14 @@ #define ITEM_IDENTIFIER @"Identifier" // string #define ITEM_NAME @"Name" // string + +@interface GLFileView () + +- (void)saveSplitViewPosition; + +@end + + @implementation GLFileView - (void) awakeFromNib @@ -52,6 +60,9 @@ items, GROUP_ITEMS, nil]]; [typeBar reloadData]; + + [fileListSplitView setHidden:YES]; + [self performSelector:@selector(restoreSplitViewPositiion) withObject:nil afterDelay:0]; } - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context @@ -78,7 +89,7 @@ [script callWebScriptMethod:@"showFile" withArguments:[NSArray arrayWithObject:fileTxt]]; } -#ifdef DEBUG +#if 0 NSString *dom=[[[[view mainFrame] DOMDocument] documentElement] outerHTML]; NSString *tmpFile=@"~/tmp/test.html"; [dom writeToFile:[tmpFile stringByExpandingTildeInPath] atomically:true encoding:NSUTF8StringEncoding error:nil]; @@ -151,6 +162,14 @@ [self showFile]; } +- (void)closeView +{ + [historyController.treeController removeObserver:self forKeyPath:@"selection"]; + [self saveSplitViewPosition]; + + [super closeView]; +} + - (NSString *) parseHTML:(NSString *)txt { txt=[txt stringByReplacingOccurrencesOfString:@"&" withString:@"&"]; @@ -234,6 +253,71 @@ return (NSString *)res; } + + +#pragma mark NSSplitView delegate methods + +#define kFileListSplitViewLeftMin 120 +#define kFileListSplitViewRightMin 180 +#define kHFileListSplitViewPositionDefault @"File List SplitView Position" + +- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)dividerIndex +{ + return kFileListSplitViewLeftMin; +} + +- (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)dividerIndex +{ + return [splitView frame].size.width - [splitView dividerThickness] - kFileListSplitViewRightMin; +} + +// while the user resizes the window keep the left (file list) view constant and just resize the right view +// unless the right view gets too small +- (void)splitView:(NSSplitView *)splitView resizeSubviewsWithOldSize:(NSSize)oldSize +{ + NSRect newFrame = [splitView frame]; + + float dividerThickness = [splitView dividerThickness]; + + NSView *leftView = [[splitView subviews] objectAtIndex:0]; + NSRect leftFrame = [leftView frame]; + leftFrame.size.height = newFrame.size.height; + + if ((newFrame.size.width - leftFrame.size.width - dividerThickness) < kFileListSplitViewRightMin) { + leftFrame.size.width = newFrame.size.width - kFileListSplitViewRightMin - dividerThickness; + } + + NSView *rightView = [[splitView subviews] objectAtIndex:1]; + NSRect rightFrame = [rightView frame]; + rightFrame.origin.x = leftFrame.size.width + dividerThickness; + rightFrame.size.width = newFrame.size.width - rightFrame.origin.x; + rightFrame.size.height = newFrame.size.height; + + [leftView setFrame:leftFrame]; + [rightView setFrame:rightFrame]; +} + +// NSSplitView does not save and restore the position of the SplitView correctly so do it manually +- (void)saveSplitViewPosition +{ + float position = [[[fileListSplitView subviews] objectAtIndex:0] frame].size.width; + [[NSUserDefaults standardUserDefaults] setFloat:position forKey:kHFileListSplitViewPositionDefault]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} + +// make sure this happens after awakeFromNib +- (void)restoreSplitViewPositiion +{ + float position = [[NSUserDefaults standardUserDefaults] floatForKey:kHFileListSplitViewPositionDefault]; + if (position < 1.0) + position = 200; + + [fileListSplitView setPosition:position ofDividerAtIndex:0]; + [fileListSplitView setHidden:NO]; +} + + + @synthesize groups; @synthesize logFormat; diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index 015e0f1..dae5822 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -24,13 +24,36 @@ 02B41A5E123E307200DFC531 /* PBCommitHookFailedSheet.m in Sources */ = {isa = PBXBuildFile; fileRef = 02B41A5D123E307200DFC531 /* PBCommitHookFailedSheet.m */; }; 02B41A60123E307F00DFC531 /* PBCommitHookFailedSheet.xib in Resources */ = {isa = PBXBuildFile; fileRef = 02B41A5F123E307F00DFC531 /* PBCommitHookFailedSheet.xib */; }; 056438B70ED0C40B00985397 /* DetailViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 056438B60ED0C40B00985397 /* DetailViewTemplate.png */; }; - 21230CB11284B26A0046E5A1 /* PBGitSVStashItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 21230CB01284B26A0046E5A1 /* PBGitSVStashItem.m */; }; + 21025C1212947AB200D87200 /* sourceListAction.png in Resources */ = {isa = PBXBuildFile; fileRef = 21025C1012947AB200D87200 /* sourceListAction.png */; }; + 21025C1312947AB200D87200 /* sourceListActionOver.png in Resources */ = {isa = PBXBuildFile; fileRef = 21025C1112947AB200D87200 /* sourceListActionOver.png */; }; + 21230CB11284B26A0046E5A1 /* PBGitMenuItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 21230CB01284B26A0046E5A1 /* PBGitMenuItem.m */; }; 21230D351284C5080046E5A1 /* PBGitStash.m in Sources */ = {isa = PBXBuildFile; fileRef = 21230D341284C5080046E5A1 /* PBGitStash.m */; }; 21230D821284D1CC0046E5A1 /* stash-icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 21230D811284D1CC0046E5A1 /* stash-icon.png */; }; 21230D9C128552720046E5A1 /* PBCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 21230D9B128552720046E5A1 /* PBCommand.m */; }; 21230D9F128552FA0046E5A1 /* PBStashCommandFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 21230D9E128552FA0046E5A1 /* PBStashCommandFactory.m */; }; 21230DAA1285550B0046E5A1 /* PBCommandMenuItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 21230DA91285550B0046E5A1 /* PBCommandMenuItem.m */; }; - 21230DEE12855A990046E5A1 /* PBStashCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 21230DED12855A990046E5A1 /* PBStashCommand.m */; }; + 21230ED21285EB5A0046E5A1 /* PBArgumentPicker.xib in Resources */ = {isa = PBXBuildFile; fileRef = 21230ED11285EB5A0046E5A1 /* PBArgumentPicker.xib */; }; + 21230ED91285EDAF0046E5A1 /* PBArgumentPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 21230ED81285EDAF0046E5A1 /* PBArgumentPicker.m */; }; + 21230EE21285EFB20046E5A1 /* PBArgumentPickerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 21230EE11285EFB20046E5A1 /* PBArgumentPickerController.m */; }; + 21230F7D1285FC6A0046E5A1 /* PBCommandWithParameter.m in Sources */ = {isa = PBXBuildFile; fileRef = 21230F7C1285FC6A0046E5A1 /* PBCommandWithParameter.m */; }; + 212311DD12872BF20046E5A1 /* PBGitSubmodule.m in Sources */ = {isa = PBXBuildFile; fileRef = 212311DC12872BF20046E5A1 /* PBGitSubmodule.m */; }; + 2123121E128735E90046E5A1 /* submodule-notmatching-index.png in Resources */ = {isa = PBXBuildFile; fileRef = 2123121B128735E90046E5A1 /* submodule-notmatching-index.png */; }; + 2123121F128735E90046E5A1 /* submodule-matching-index.png in Resources */ = {isa = PBXBuildFile; fileRef = 2123121C128735E90046E5A1 /* submodule-matching-index.png */; }; + 21231220128735E90046E5A1 /* submodule-empty.png in Resources */ = {isa = PBXBuildFile; fileRef = 2123121D128735E90046E5A1 /* submodule-empty.png */; }; + 2123138A128756ED0046E5A1 /* PBRemoteCommandFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 21231389128756ED0046E5A1 /* PBRemoteCommandFactory.m */; }; + 212313B5128759C00046E5A1 /* PBOpenDocumentCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 212313B4128759C00046E5A1 /* PBOpenDocumentCommand.m */; }; + 212A49A312A31292009DAFAD /* renamed_file.png in Resources */ = {isa = PBXBuildFile; fileRef = 212A49A212A31292009DAFAD /* renamed_file.png */; }; + 212A49A512A312B2009DAFAD /* unversioned_file.png in Resources */ = {isa = PBXBuildFile; fileRef = 212A49A412A312B2009DAFAD /* unversioned_file.png */; }; + 212A49A712A312BE009DAFAD /* added_file.png in Resources */ = {isa = PBXBuildFile; fileRef = 212A49A612A312BE009DAFAD /* added_file.png */; }; + 212A49AA12A31328009DAFAD /* conflicted_file.png in Resources */ = {isa = PBXBuildFile; fileRef = 212A49A812A31328009DAFAD /* conflicted_file.png */; }; + 212A49AB12A31328009DAFAD /* deleted_file.png in Resources */ = {isa = PBXBuildFile; fileRef = 212A49A912A31328009DAFAD /* deleted_file.png */; }; + 212A49AD12A31350009DAFAD /* ignored_file.png in Resources */ = {isa = PBXBuildFile; fileRef = 212A49AC12A31350009DAFAD /* ignored_file.png */; }; + 212A49AF12A3135C009DAFAD /* modified_file.png in Resources */ = {isa = PBXBuildFile; fileRef = 212A49AE12A3135C009DAFAD /* modified_file.png */; }; + 217FF0B912A1CB3300785A65 /* PBStashController.m in Sources */ = {isa = PBXBuildFile; fileRef = 217FF0B312A1CB3300785A65 /* PBStashController.m */; }; + 217FF0BA12A1CB3300785A65 /* PBSubmoduleController.m in Sources */ = {isa = PBXBuildFile; fileRef = 217FF0B512A1CB3300785A65 /* PBSubmoduleController.m */; }; + 217FF0BB12A1CB3300785A65 /* PBGitResetController.m in Sources */ = {isa = PBXBuildFile; fileRef = 217FF0B712A1CB3300785A65 /* PBGitResetController.m */; }; + 217FF0BE12A1CB3E00785A65 /* PBRevealWithFinderCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 217FF0BC12A1CB3E00785A65 /* PBRevealWithFinderCommand.m */; }; + 21CF0B24129C7ED90065B37C /* TrackableOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = 21CF0B23129C7ED90065B37C /* TrackableOutlineView.m */; }; 310DC1D81240599E0017A0F7 /* GLFileView.m in Sources */ = {isa = PBXBuildFile; fileRef = 310DC1D71240599E0017A0F7 /* GLFileView.m */; }; 31460CD2124185BA00B90AED /* MGRecessedPopUpButtonCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 31460CA7124185BA00B90AED /* MGRecessedPopUpButtonCell.m */; }; 31460CD3124185BA00B90AED /* MGScopeBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 31460CA9124185BA00B90AED /* MGScopeBar.m */; }; @@ -144,7 +167,6 @@ F56ADDD90ED19F9E002AC78F /* AddBranchTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = F56ADDD70ED19F9E002AC78F /* AddBranchTemplate.png */; }; F56ADDDA0ED19F9E002AC78F /* AddLabelTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = F56ADDD80ED19F9E002AC78F /* AddLabelTemplate.png */; }; F56CC7320E65E0E5004307B4 /* PBGraphCellInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = F56CC7310E65E0E5004307B4 /* PBGraphCellInfo.m */; }; - F57240BB0E9678EA00D8EE66 /* deleted_file.png in Resources */ = {isa = PBXBuildFile; fileRef = F57240BA0E9678EA00D8EE66 /* deleted_file.png */; }; F574A2850EAE2EAC003F2CB1 /* PBRefController.m in Sources */ = {isa = PBXBuildFile; fileRef = F574A2840EAE2EAC003F2CB1 /* PBRefController.m */; }; F574A2910EAE2FF4003F2CB1 /* PBGitConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 93FCCBA80EA8AF450061B02B /* PBGitConfig.m */; }; F57CC3910E05DDF2000472E2 /* PBEasyPipe.m in Sources */ = {isa = PBXBuildFile; fileRef = F57CC3900E05DDF2000472E2 /* PBEasyPipe.m */; }; @@ -258,8 +280,10 @@ 056438B60ED0C40B00985397 /* DetailViewTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = DetailViewTemplate.png; path = Images/DetailViewTemplate.png; sourceTree = ""; }; 089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; - 21230CAF1284B26A0046E5A1 /* PBGitSVStashItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitSVStashItem.h; sourceTree = ""; }; - 21230CB01284B26A0046E5A1 /* PBGitSVStashItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitSVStashItem.m; sourceTree = ""; }; + 21025C1012947AB200D87200 /* sourceListAction.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = sourceListAction.png; sourceTree = ""; }; + 21025C1112947AB200D87200 /* sourceListActionOver.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = sourceListActionOver.png; sourceTree = ""; }; + 21230CAF1284B26A0046E5A1 /* PBGitMenuItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitMenuItem.h; sourceTree = ""; }; + 21230CB01284B26A0046E5A1 /* PBGitMenuItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitMenuItem.m; sourceTree = ""; }; 21230D331284C5080046E5A1 /* PBGitStash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitStash.h; sourceTree = ""; }; 21230D341284C5080046E5A1 /* PBGitStash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitStash.m; sourceTree = ""; }; 21230D4D1284C92E0046E5A1 /* PBPresentable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBPresentable.h; sourceTree = ""; }; @@ -271,8 +295,40 @@ 21230DA0128553120046E5A1 /* PBCommandFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBCommandFactory.h; sourceTree = ""; }; 21230DA81285550B0046E5A1 /* PBCommandMenuItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBCommandMenuItem.h; sourceTree = ""; }; 21230DA91285550B0046E5A1 /* PBCommandMenuItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBCommandMenuItem.m; sourceTree = ""; }; - 21230DEC12855A990046E5A1 /* PBStashCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBStashCommand.h; sourceTree = ""; }; - 21230DED12855A990046E5A1 /* PBStashCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBStashCommand.m; sourceTree = ""; }; + 21230ED11285EB5A0046E5A1 /* PBArgumentPicker.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PBArgumentPicker.xib; sourceTree = ""; }; + 21230ED71285EDAF0046E5A1 /* PBArgumentPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBArgumentPicker.h; sourceTree = ""; }; + 21230ED81285EDAF0046E5A1 /* PBArgumentPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBArgumentPicker.m; sourceTree = ""; }; + 21230EE01285EFB20046E5A1 /* PBArgumentPickerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBArgumentPickerController.h; sourceTree = ""; }; + 21230EE11285EFB20046E5A1 /* PBArgumentPickerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBArgumentPickerController.m; sourceTree = ""; }; + 21230F7B1285FC6A0046E5A1 /* PBCommandWithParameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBCommandWithParameter.h; sourceTree = ""; }; + 21230F7C1285FC6A0046E5A1 /* PBCommandWithParameter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBCommandWithParameter.m; sourceTree = ""; }; + 212311DB12872BF20046E5A1 /* PBGitSubmodule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitSubmodule.h; sourceTree = ""; }; + 212311DC12872BF20046E5A1 /* PBGitSubmodule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitSubmodule.m; sourceTree = ""; }; + 2123121B128735E90046E5A1 /* submodule-notmatching-index.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "submodule-notmatching-index.png"; sourceTree = ""; }; + 2123121C128735E90046E5A1 /* submodule-matching-index.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "submodule-matching-index.png"; sourceTree = ""; }; + 2123121D128735E90046E5A1 /* submodule-empty.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "submodule-empty.png"; sourceTree = ""; }; + 21231388128756ED0046E5A1 /* PBRemoteCommandFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBRemoteCommandFactory.h; sourceTree = ""; }; + 21231389128756ED0046E5A1 /* PBRemoteCommandFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBRemoteCommandFactory.m; sourceTree = ""; }; + 212313B3128759C00046E5A1 /* PBOpenDocumentCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBOpenDocumentCommand.h; sourceTree = ""; }; + 212313B4128759C00046E5A1 /* PBOpenDocumentCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBOpenDocumentCommand.m; sourceTree = ""; }; + 212A49A212A31292009DAFAD /* renamed_file.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = renamed_file.png; sourceTree = ""; }; + 212A49A412A312B2009DAFAD /* unversioned_file.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = unversioned_file.png; sourceTree = ""; }; + 212A49A612A312BE009DAFAD /* added_file.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = added_file.png; sourceTree = ""; }; + 212A49A812A31328009DAFAD /* conflicted_file.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = conflicted_file.png; sourceTree = ""; }; + 212A49A912A31328009DAFAD /* deleted_file.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = deleted_file.png; sourceTree = ""; }; + 212A49AC12A31350009DAFAD /* ignored_file.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ignored_file.png; sourceTree = ""; }; + 212A49AE12A3135C009DAFAD /* modified_file.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = modified_file.png; sourceTree = ""; }; + 217FF0B312A1CB3300785A65 /* PBStashController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBStashController.m; sourceTree = SOURCE_ROOT; }; + 217FF0B412A1CB3300785A65 /* PBStashController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBStashController.h; sourceTree = SOURCE_ROOT; }; + 217FF0B512A1CB3300785A65 /* PBSubmoduleController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBSubmoduleController.m; sourceTree = ""; }; + 217FF0B612A1CB3300785A65 /* PBSubmoduleController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBSubmoduleController.h; sourceTree = ""; }; + 217FF0B712A1CB3300785A65 /* PBGitResetController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitResetController.m; sourceTree = ""; }; + 217FF0B812A1CB3300785A65 /* PBGitResetController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitResetController.h; sourceTree = ""; }; + 217FF0BC12A1CB3E00785A65 /* PBRevealWithFinderCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBRevealWithFinderCommand.m; sourceTree = ""; }; + 217FF0BD12A1CB3E00785A65 /* PBRevealWithFinderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBRevealWithFinderCommand.h; sourceTree = ""; }; + 21CF0B22129C7ED90065B37C /* TrackableOutlineView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TrackableOutlineView.h; sourceTree = ""; }; + 21CF0B23129C7ED90065B37C /* TrackableOutlineView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TrackableOutlineView.m; sourceTree = ""; }; + 21CF0B36129C80100065B37C /* CellTrackingRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CellTrackingRect.h; sourceTree = ""; }; 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 = ""; }; @@ -376,7 +432,7 @@ D8E3B38110DD4E2C001096A3 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/PBCreateTagSheet.xib; sourceTree = ""; }; D8EB6168122F643E00FCCAF4 /* GitXRelativeDateFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GitXRelativeDateFormatter.h; sourceTree = ""; }; D8EB6169122F643E00FCCAF4 /* GitXRelativeDateFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GitXRelativeDateFormatter.m; sourceTree = ""; }; - D8F01C4A12182F19007F729F /* GitX.sdef */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.sdef; path = GitX.sdef; sourceTree = ""; }; + D8F01C4A12182F19007F729F /* GitX.sdef */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = GitX.sdef; sourceTree = ""; }; D8F01D511218A164007F729F /* NSApplication+GitXScripting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSApplication+GitXScripting.h"; sourceTree = ""; }; D8F01D521218A164007F729F /* NSApplication+GitXScripting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSApplication+GitXScripting.m"; sourceTree = ""; }; D8F01D841218A406007F729F /* GitX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GitX.h; sourceTree = ""; }; @@ -566,6 +622,8 @@ 080E96DDFE201D6D7F000001 /* Classes */ = { isa = PBXGroup; children = ( + 21230EDF1285EF880046E5A1 /* Controller */, + 21230ED41285ED760046E5A1 /* View */, 21230D991285524C0046E5A1 /* Commands */, 21230D321284C4F10046E5A1 /* Model */, ); @@ -614,6 +672,8 @@ 21230D331284C5080046E5A1 /* PBGitStash.h */, 21230D341284C5080046E5A1 /* PBGitStash.m */, 21230D4D1284C92E0046E5A1 /* PBPresentable.h */, + 212311DB12872BF20046E5A1 /* PBGitSubmodule.h */, + 212311DC12872BF20046E5A1 /* PBGitSubmodule.m */, ); path = Model; sourceTree = ""; @@ -621,17 +681,64 @@ 21230D991285524C0046E5A1 /* Commands */ = { isa = PBXGroup; children = ( + 217FF0BC12A1CB3E00785A65 /* PBRevealWithFinderCommand.m */, + 217FF0BD12A1CB3E00785A65 /* PBRevealWithFinderCommand.h */, 21230D9A128552720046E5A1 /* PBCommand.h */, 21230D9B128552720046E5A1 /* PBCommand.m */, - 21230DEC12855A990046E5A1 /* PBStashCommand.h */, - 21230DED12855A990046E5A1 /* PBStashCommand.m */, 21230D9D128552FA0046E5A1 /* PBStashCommandFactory.h */, 21230D9E128552FA0046E5A1 /* PBStashCommandFactory.m */, 21230DA0128553120046E5A1 /* PBCommandFactory.h */, + 21230F7B1285FC6A0046E5A1 /* PBCommandWithParameter.h */, + 21230F7C1285FC6A0046E5A1 /* PBCommandWithParameter.m */, + 21231388128756ED0046E5A1 /* PBRemoteCommandFactory.h */, + 21231389128756ED0046E5A1 /* PBRemoteCommandFactory.m */, + 212313B3128759C00046E5A1 /* PBOpenDocumentCommand.h */, + 212313B4128759C00046E5A1 /* PBOpenDocumentCommand.m */, ); path = Commands; sourceTree = ""; }; + 21230ED41285ED760046E5A1 /* View */ = { + isa = PBXGroup; + children = ( + 21230ED71285EDAF0046E5A1 /* PBArgumentPicker.h */, + 21230ED81285EDAF0046E5A1 /* PBArgumentPicker.m */, + 21CF0B22129C7ED90065B37C /* TrackableOutlineView.h */, + 21CF0B23129C7ED90065B37C /* TrackableOutlineView.m */, + 21CF0B36129C80100065B37C /* CellTrackingRect.h */, + ); + path = View; + sourceTree = ""; + }; + 21230EDF1285EF880046E5A1 /* Controller */ = { + isa = PBXGroup; + children = ( + 217FF0B312A1CB3300785A65 /* PBStashController.m */, + 217FF0B412A1CB3300785A65 /* PBStashController.h */, + 217FF0B512A1CB3300785A65 /* PBSubmoduleController.m */, + 217FF0B612A1CB3300785A65 /* PBSubmoduleController.h */, + 217FF0B712A1CB3300785A65 /* PBGitResetController.m */, + 217FF0B812A1CB3300785A65 /* PBGitResetController.h */, + 21230EE01285EFB20046E5A1 /* PBArgumentPickerController.h */, + 21230EE11285EFB20046E5A1 /* PBArgumentPickerController.m */, + ); + path = Controller; + sourceTree = ""; + }; + 212A499412A3121D009DAFAD /* File Markers */ = { + isa = PBXGroup; + children = ( + 212A49A812A31328009DAFAD /* conflicted_file.png */, + 212A49A912A31328009DAFAD /* deleted_file.png */, + 212A49A612A312BE009DAFAD /* added_file.png */, + 212A49A412A312B2009DAFAD /* unversioned_file.png */, + 212A49A212A31292009DAFAD /* renamed_file.png */, + 212A49AC12A31350009DAFAD /* ignored_file.png */, + 212A49AE12A3135C009DAFAD /* modified_file.png */, + ); + path = "File Markers"; + sourceTree = ""; + }; 29B97314FDCFA39411CA2CEA /* GitTest */ = { isa = PBXGroup; children = ( @@ -659,6 +766,10 @@ 29B97315FDCFA39411CA2CEA /* Other Sources */ = { isa = PBXGroup; children = ( + 212A499412A3121D009DAFAD /* File Markers */, + 2123121B128735E90046E5A1 /* submodule-notmatching-index.png */, + 2123121C128735E90046E5A1 /* submodule-matching-index.png */, + 2123121D128735E90046E5A1 /* submodule-empty.png */, D858108011274D28007F254B /* Branch.png */, D858108111274D28007F254B /* RemoteBranch.png */, D858108211274D28007F254B /* Tag.png */, @@ -691,6 +802,8 @@ 29B97317FDCFA39411CA2CEA /* Resources */ = { isa = PBXGroup; children = ( + 21025C1012947AB200D87200 /* sourceListAction.png */, + 21025C1112947AB200D87200 /* sourceListActionOver.png */, 02B41A5F123E307F00DFC531 /* PBCommitHookFailedSheet.xib */, F5F7D0641062E7940072C81C /* UpdateKey.pem */, F50A41130EBB872D00208746 /* Widgets */, @@ -712,6 +825,7 @@ D8FDD9F511432A12005647F6 /* PBCloneRepositoryPanel.xib */, 47DBDB680E94EF6500671A1E /* Preferences.xib */, F569AE920F2CBD7C00C2FFA7 /* Credits.html */, + 21230ED11285EB5A0046E5A1 /* PBArgumentPicker.xib */, F58DB55F10566E3900CFDF4A /* PBGitSidebarView.xib */, D8022FE711E124A0003C21F6 /* PBGitXMessageSheet.xib */, ); @@ -835,8 +949,8 @@ D8FDDA63114335E8005647F6 /* PBGitSVRemoteBranchItem.m */, D8FDDA68114335E8005647F6 /* PBGitSVTagItem.h */, D8FDDA69114335E8005647F6 /* PBGitSVTagItem.m */, - 21230CAF1284B26A0046E5A1 /* PBGitSVStashItem.h */, - 21230CB01284B26A0046E5A1 /* PBGitSVStashItem.m */, + 21230CAF1284B26A0046E5A1 /* PBGitMenuItem.h */, + 21230CB01284B26A0046E5A1 /* PBGitMenuItem.m */, D8FDDA60114335E8005647F6 /* PBGitSVOtherRevItem.h */, D8FDDA61114335E8005647F6 /* PBGitSVOtherRevItem.m */, D8FDDA5E114335E8005647F6 /* PBGitSVFolderItem.h */, @@ -1249,7 +1363,6 @@ F52BCE030E84208300AA3741 /* PBGitHistoryView.xib in Resources */, F59116E60E843BB50072CCB1 /* PBGitCommitView.xib in Resources */, F5E92A230E88569500056E75 /* new_file.png in Resources */, - F57240BB0E9678EA00D8EE66 /* deleted_file.png in Resources */, F5E424110EA3E4D60046E362 /* PBDiffWindow.xib in Resources */, F50A411F0EBB874C00208746 /* mainSplitterBar.tiff in Resources */, F50A41200EBB874C00208746 /* mainSplitterDimple.tiff in Resources */, @@ -1289,6 +1402,19 @@ 31460CD6124185BA00B90AED /* TODO in Resources */, 02B41A60123E307F00DFC531 /* PBCommitHookFailedSheet.xib in Resources */, 21230D821284D1CC0046E5A1 /* stash-icon.png in Resources */, + 21230ED21285EB5A0046E5A1 /* PBArgumentPicker.xib in Resources */, + 2123121E128735E90046E5A1 /* submodule-notmatching-index.png in Resources */, + 2123121F128735E90046E5A1 /* submodule-matching-index.png in Resources */, + 21231220128735E90046E5A1 /* submodule-empty.png in Resources */, + 21025C1212947AB200D87200 /* sourceListAction.png in Resources */, + 21025C1312947AB200D87200 /* sourceListActionOver.png in Resources */, + 212A49A312A31292009DAFAD /* renamed_file.png in Resources */, + 212A49A512A312B2009DAFAD /* unversioned_file.png in Resources */, + 212A49A712A312BE009DAFAD /* added_file.png in Resources */, + 212A49AA12A31328009DAFAD /* conflicted_file.png in Resources */, + 212A49AB12A31328009DAFAD /* deleted_file.png in Resources */, + 212A49AD12A31350009DAFAD /* ignored_file.png in Resources */, + 212A49AF12A3135C009DAFAD /* modified_file.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1442,12 +1568,22 @@ 31460CD2124185BA00B90AED /* MGRecessedPopUpButtonCell.m in Sources */, 31460CD3124185BA00B90AED /* MGScopeBar.m in Sources */, 02B41A5E123E307200DFC531 /* PBCommitHookFailedSheet.m in Sources */, - 21230CB11284B26A0046E5A1 /* PBGitSVStashItem.m in Sources */, + 21230CB11284B26A0046E5A1 /* PBGitMenuItem.m in Sources */, 21230D351284C5080046E5A1 /* PBGitStash.m in Sources */, 21230D9C128552720046E5A1 /* PBCommand.m in Sources */, 21230D9F128552FA0046E5A1 /* PBStashCommandFactory.m in Sources */, 21230DAA1285550B0046E5A1 /* PBCommandMenuItem.m in Sources */, - 21230DEE12855A990046E5A1 /* PBStashCommand.m in Sources */, + 21230ED91285EDAF0046E5A1 /* PBArgumentPicker.m in Sources */, + 21230EE21285EFB20046E5A1 /* PBArgumentPickerController.m in Sources */, + 21230F7D1285FC6A0046E5A1 /* PBCommandWithParameter.m in Sources */, + 212311DD12872BF20046E5A1 /* PBGitSubmodule.m in Sources */, + 2123138A128756ED0046E5A1 /* PBRemoteCommandFactory.m in Sources */, + 212313B5128759C00046E5A1 /* PBOpenDocumentCommand.m in Sources */, + 21CF0B24129C7ED90065B37C /* TrackableOutlineView.m in Sources */, + 217FF0B912A1CB3300785A65 /* PBStashController.m in Sources */, + 217FF0BA12A1CB3300785A65 /* PBSubmoduleController.m in Sources */, + 217FF0BB12A1CB3300785A65 /* PBGitResetController.m in Sources */, + 217FF0BE12A1CB3E00785A65 /* PBRevealWithFinderCommand.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Model/PBGitStash.m b/Model/PBGitStash.m index e2f08c6..a042413 100644 --- a/Model/PBGitStash.m +++ b/Model/PBGitStash.m @@ -41,11 +41,15 @@ #pragma mark Presentable - (NSString *) displayDescription { - return self.name; + return [NSString stringWithFormat:@"%@ (%@)", self.message, self.name]; } - (NSString *) popupDescription { return [self description]; } +- (NSImage *) icon { + return [NSImage imageNamed:@"stash-icon.png"]; +} + @end diff --git a/Model/PBGitSubmodule.h b/Model/PBGitSubmodule.h new file mode 100644 index 0000000..5d1db18 --- /dev/null +++ b/Model/PBGitSubmodule.h @@ -0,0 +1,39 @@ +// +// PBGitSubmodule.h +// GitX +// +// Created by Tomasz Krasnyk on 10-11-07. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import +#import "PBPresentable.h" + +typedef enum { + PBGitSubmoduleStateNotInitialized, + PBGitSubmoduleStateMatchingIndex, + PBGitSubmoduleStateDoesNotMatchIndex, +} PBGitSubmoduleState; + +@interface PBGitSubmodule : NSObject { + NSString *name; + NSString *path; + NSString *checkedOutCommit; + + PBGitSubmoduleState submoduleState; + + NSMutableArray *submodules; +} +@property (nonatomic, retain, readonly) NSMutableArray *submodules; +@property (nonatomic, assign, readonly) PBGitSubmoduleState submoduleState; +@property (nonatomic, retain, readonly) NSString *name; +@property (nonatomic, retain, readonly) NSString *path; +@property (nonatomic, retain, readonly) NSString *checkedOutCommit; + +- (id) initWithRawSubmoduleStatusString:(NSString *) submoduleStatusString; + ++ (NSImage *) imageForSubmoduleState:(PBGitSubmoduleState) state; ++ (PBGitSubmoduleState) submoduleStateFromCharacter:(unichar) character; + +- (void) addSubmodule:(PBGitSubmodule *) submodule; +@end diff --git a/Model/PBGitSubmodule.m b/Model/PBGitSubmodule.m new file mode 100644 index 0000000..cea00d0 --- /dev/null +++ b/Model/PBGitSubmodule.m @@ -0,0 +1,126 @@ +// +// PBGitSubmodule.m +// GitX +// +// Created by Tomasz Krasnyk on 10-11-07. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import "PBGitSubmodule.h" + +@interface PBGitSubmodule() +@property (nonatomic, retain) NSString *name; +@property (nonatomic, retain) NSString *path; +@property (nonatomic, retain) NSString *checkedOutCommit; +@end + + +@implementation PBGitSubmodule +@synthesize name; +@synthesize path; +@synthesize checkedOutCommit; +@synthesize submoduleState; +@synthesize submodules; + +- (NSMutableArray *) submodules { + if (!submodules) { + submodules = [[NSMutableArray alloc] init]; + } + return submodules; +} + +- (id) initWithRawSubmoduleStatusString:(NSString *) submoduleStatusString { + NSParameterAssert([submoduleStatusString length] > 0); + + if (self = [super init]) { + unichar status = [submoduleStatusString characterAtIndex:0]; + submoduleState = [PBGitSubmodule submoduleStateFromCharacter:status]; + NSScanner *scanner = [NSScanner scannerWithString:[submoduleStatusString substringFromIndex:1]]; + NSString *sha1 = nil; + NSString *fullPath = nil; + NSString *coName = nil; + BOOL shouldContinue = [scanner scanUpToString:@" " intoString:&sha1]; + if (shouldContinue) { + shouldContinue = [scanner scanUpToString:@"(" intoString:&fullPath]; + } + if (shouldContinue) { + shouldContinue = [scanner scanString:@"(" intoString:NULL]; + } + if (shouldContinue) { + shouldContinue = [scanner scanUpToString:@")" intoString:&coName]; + } + self.path = [fullPath stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + coName = [coName stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + self.checkedOutCommit = [coName length] > 0 ? coName : nil; + self.name = [self.path lastPathComponent]; + + } + return self; +} + +- (void) dealloc { + [submodules release]; + [name release]; + [path release]; + [checkedOutCommit release]; + [super dealloc]; +} + +- (void) addSubmodule:(PBGitSubmodule *) submodule { + [self.submodules addObject:submodule]; +} + +#pragma mark - +#pragma mark Presentable + +- (NSImage *) icon { + return [PBGitSubmodule imageForSubmoduleState:self.submoduleState]; +} + +- (NSString *) displayDescription { + NSMutableString *result = [[NSMutableString alloc] initWithString:self.name]; + if (self.checkedOutCommit) { + [result appendFormat:@" (%@)", self.checkedOutCommit]; + } + return [result autorelease]; +} + +- (NSString *) popupDescription { + return [self description]; +} + + +#pragma mark - +#pragma mark Private + ++ (NSImage *) imageForSubmoduleState:(PBGitSubmoduleState) state { + NSString *imageName = nil; + + if (state == PBGitSubmoduleStateMatchingIndex) { + imageName = @"submodule-matching-index.png"; + } else if (state == PBGitSubmoduleStateNotInitialized) { + imageName = @"submodule-empty.png"; + } else if (state == PBGitSubmoduleStateDoesNotMatchIndex) { + imageName = @"submodule-notmatching-index.png"; + } + + return [NSImage imageNamed:imageName]; +} + ++ (PBGitSubmoduleState) submoduleStateFromCharacter:(unichar) character { + PBGitSubmoduleState state = PBGitSubmoduleStateMatchingIndex; + if (character == '-') { + state = PBGitSubmoduleStateNotInitialized; + } else if (character == '+') { + state = PBGitSubmoduleStateDoesNotMatchIndex; + } else if (character != ' ') { + NSAssert1(NO, @"Ooops unsupported submodule status character: %c", character); + } + + return state; +} + +- (NSString *) description { + return [NSString stringWithFormat:@"[SUBMODULE] %@(%@) %@", self.name, self.path, self.checkedOutCommit]; +} +@end diff --git a/Model/PBPresentable.h b/Model/PBPresentable.h index 299d208..4c6cf70 100644 --- a/Model/PBPresentable.h +++ b/Model/PBPresentable.h @@ -7,7 +7,8 @@ // -@protocol PBPresentable +@protocol PBPresentable +- (NSImage *) icon; - (NSString *) displayDescription; - (NSString *) popupDescription; @end diff --git a/PBArgumentPicker.xib b/PBArgumentPicker.xib new file mode 100644 index 0000000..aae90bc --- /dev/null +++ b/PBArgumentPicker.xib @@ -0,0 +1,1110 @@ + + + + 1050 + 10F569 + 804 + 1038.29 + 461.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 804 + + + YES + + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + + + YES + + YES + + + YES + + + + YES + + PBArgumentPickerController + + + FirstResponder + + + NSApplication + + + 1 + 2 + {{716, 798}, {297, 125}} + 611845120 + Window + NSWindow + + {1.79769e+308, 1.79769e+308} + + + 256 + + YES + + + 268 + {{187, 8}, {96, 32}} + + YES + + 67239424 + 134217728 + OK + + LucidaGrande + 13 + 1044 + + + -2034876161 + 65 + + + DQ + 200 + 25 + + + + + 268 + {{25, 67}, {252, 22}} + + YES + + -1804468671 + 272630784 + + + + YES + + 6 + System + textBackgroundColor + + 3 + MQA + + + + 6 + System + textColor + + 3 + MAA + + + + + + + 268 + {{91, 8}, {96, 32}} + + YES + + 67239424 + 134217728 + Cancel + + + -2038284033 + 129 + + Gw + 200 + 25 + + + + + 268 + {{22, 97}, {258, 17}} + + YES + + 68288064 + 272630784 + Provide stash message: + + + + 6 + System + controlColor + + 3 + MC42NjY2NjY2NjY3AA + + + + 6 + System + controlTextColor + + + + + + {297, 125} + + + {{0, 0}, {1680, 1028}} + {1.79769e+308, 1.79769e+308} + + + + + YES + + + okClicked: + + + + 34 + + + + window + + + + 37 + + + + cancelButton + + + + 38 + + + + label + + + + 39 + + + + okButton + + + + 40 + + + + textField + + + + 41 + + + + view + + + + 42 + + + + cancelClicked: + + + + 43 + + + + + YES + + 0 + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 35 + + + YES + + + + + + 36 + + + YES + + + + + + + + + 16 + + + YES + + + + + + 17 + + + + + 18 + + + YES + + + + + + 19 + + + + + 24 + + + YES + + + + + + 25 + + + + + 26 + + + YES + + + + + + 27 + + + + + + + YES + + YES + 16.IBPluginDependency + 16.IBViewBoundsToFrameTransform + 17.IBPluginDependency + 18.IBPluginDependency + 18.IBViewBoundsToFrameTransform + 19.IBPluginDependency + 24.IBPluginDependency + 24.IBViewBoundsToFrameTransform + 25.IBPluginDependency + 26.IBPluginDependency + 26.IBViewBoundsToFrameTransform + 27.IBPluginDependency + 35.IBEditorWindowLastContentRect + 35.IBPluginDependency + 35.IBWindowTemplateEditedContentRect + 35.NSWindowTemplate.visibleAtLaunch + 35.windowTemplate.hasMaxSize + 35.windowTemplate.hasMinSize + 35.windowTemplate.maxSize + 35.windowTemplate.minSize + 36.CustomClassName + 36.IBPluginDependency + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABDOwAAwiAAAA + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABByAAAwrIAAA + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABCtgAAwiAAAA + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABBsAAAwuQAAA + + com.apple.InterfaceBuilder.CocoaPlugin + {{716, 798}, {297, 125}} + com.apple.InterfaceBuilder.CocoaPlugin + {{716, 798}, {297, 125}} + + + + {297, 125} + {297, 125} + PBArgumentPicker + com.apple.InterfaceBuilder.CocoaPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 43 + + + + YES + + NSApplication + + IBProjectSource + NSApplication+GitXScripting.h + + + + PBArgumentPicker + NSView + + YES + + YES + cancelButton + label + okButton + textField + + + YES + NSButton + NSTextField + NSButton + NSTextField + + + + YES + + YES + cancelButton + label + okButton + textField + + + YES + + cancelButton + NSButton + + + label + NSTextField + + + okButton + NSButton + + + textField + NSTextField + + + + + IBProjectSource + View/PBArgumentPicker.h + + + + PBArgumentPickerController + NSWindowController + + YES + + YES + cancelClicked: + okClicked: + + + YES + id + id + + + + YES + + YES + cancelClicked: + okClicked: + + + YES + + cancelClicked: + id + + + okClicked: + id + + + + + view + PBArgumentPicker + + + view + + view + PBArgumentPicker + + + + IBProjectSource + Controller/PBArgumentPickerController.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 + + + + NSButton + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSButton.h + + + + NSButtonCell + NSActionCell + + IBFrameworkSource + AppKit.framework/Headers/NSButtonCell.h + + + + NSCell + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSCell.h + + + + NSControl + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSControl.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 + + + + 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 + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CIImageProvider.h + + + + NSObject + + IBFrameworkSource + ScriptingBridge.framework/Headers/SBApplication.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 + + + + NSTextField + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSTextField.h + + + + NSTextFieldCell + NSActionCell + + IBFrameworkSource + AppKit.framework/Headers/NSTextFieldCell.h + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSClipView.h + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSMenuItem.h + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSRulerView.h + + + + NSView + NSResponder + + + + NSWindow + + IBFrameworkSource + AppKit.framework/Headers/NSDrawer.h + + + + NSWindow + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSWindow.h + + + + NSWindow + + IBFrameworkSource + AppKit.framework/Headers/NSWindowScripting.h + + + + NSWindowController + NSResponder + + showWindow: + id + + + showWindow: + + showWindow: + id + + + + IBFrameworkSource + AppKit.framework/Headers/NSWindowController.h + + + + + 0 + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.macosx + + + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES + GitX.xcodeproj + 3 + + diff --git a/PBChangedFile.h b/PBChangedFile.h index bffc110..ca3e160 100644 --- a/PBChangedFile.h +++ b/PBChangedFile.h @@ -12,7 +12,8 @@ typedef enum { NEW, MODIFIED, - DELETED + DELETED, + ADDED } PBChangedFileStatus; @interface PBChangedFile : NSObject { @@ -35,5 +36,6 @@ typedef enum { - (NSImage *)icon; - (NSString *)indexInfo; ++ (NSImage *) iconForStatus:(PBChangedFileStatus) aStatus; - (id) initWithPath:(NSString *)p; @end diff --git a/PBChangedFile.m b/PBChangedFile.m index ac9b4d3..5a7492e 100644 --- a/PBChangedFile.m +++ b/PBChangedFile.m @@ -31,24 +31,31 @@ return [NSString stringWithFormat:@"%@ %@\t%@\0", self.commitBlobMode, self.commitBlobSHA, self.path]; } -- (NSImage *) icon -{ ++ (NSImage *) iconForStatus:(PBChangedFileStatus) aStatus { NSString *filename; - switch (status) { + switch (aStatus) { case NEW: - filename = @"new_file"; + filename = @"unversioned_file"; break; case DELETED: filename = @"deleted_file"; break; + case ADDED: + filename = @"added_file"; + break; default: - filename = @"empty_file"; + filename = @"modified_file"; break; } NSString *p = [[NSBundle mainBundle] pathForResource:filename ofType:@"png"]; return [[NSImage alloc] initByReferencingFile: p]; } +- (NSImage *) icon +{ + return [PBChangedFile iconForStatus:status]; +} + + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector { return NO; diff --git a/PBCommandMenuItem.m b/PBCommandMenuItem.m index 3a080dd..50becd2 100644 --- a/PBCommandMenuItem.m +++ b/PBCommandMenuItem.m @@ -23,6 +23,7 @@ super.title = [aCommand displayName]; [self setTarget:aCommand]; [self setAction:@selector(invoke)]; + [self setEnabled:[aCommand canBeFired]]; } return self; } diff --git a/PBCommitMessageView.m b/PBCommitMessageView.m index c9c8c43..da24242 100644 --- a/PBCommitMessageView.m +++ b/PBCommitMessageView.m @@ -22,13 +22,12 @@ float lineWidth = characterWidth * [PBGitDefaults commitMessageViewVerticalLineLength]; [[NSColor lightGrayColor] set]; - // This depends upon the fact that NSTextView always redraws complete lines. float padding = [[self textContainer] lineFragmentPadding]; NSRect line; - line.origin.x = padding + aRect.origin.x + lineWidth; - line.origin.y = aRect.origin.y; + line.origin.x = padding + lineWidth; + line.origin.y = 0; line.size.width = 1; - line.size.height = aRect.size.height; + line.size.height = [self bounds].size.height; NSRectFill(line); } } diff --git a/PBDiffWindowController.m b/PBDiffWindowController.m index 06403d5..ae545d9 100644 --- a/PBDiffWindowController.m +++ b/PBDiffWindowController.m @@ -34,7 +34,7 @@ diffCommit = [startCommit.repository headCommit]; NSString *commitSelector = [NSString stringWithFormat:@"%@..%@", [startCommit realSha], [diffCommit realSha]]; - NSMutableArray *arguments = [NSMutableArray arrayWithObjects:@"diff", commitSelector, nil]; + NSMutableArray *arguments = [NSMutableArray arrayWithObjects:@"diff", @"--no-ext-diff", commitSelector, nil]; if (![PBGitDefaults showWhitespaceDifferences]) [arguments insertObject:@"-w" atIndex:1]; diff --git a/PBEasyPipe.m b/PBEasyPipe.m index 8506daf..fe8efa8 100644 --- a/PBEasyPipe.m +++ b/PBEasyPipe.m @@ -18,9 +18,17 @@ + (NSTask *) taskForCommand:(NSString *)cmd withArgs:(NSArray *)args inDir:(NSString *)dir { + NSMutableArray *filteredArguments = [[NSMutableArray alloc] init]; + for (NSString *param in args) { + if ([param length] > 0) { + [filteredArguments addObject:param]; + } + } + NSTask* task = [[NSTask alloc] init]; [task setLaunchPath:cmd]; - [task setArguments:args]; + [task setArguments:filteredArguments]; + [filteredArguments release]; if (dir) [task setCurrentDirectoryPath:dir]; diff --git a/PBGitCommitController.h b/PBGitCommitController.h index ac852a3..aac727f 100644 --- a/PBGitCommitController.h +++ b/PBGitCommitController.h @@ -10,6 +10,7 @@ #import "PBViewController.h" @class PBGitIndexController, PBIconAndTextCell, PBWebChangesController, PBGitIndex; +@class PBNiceSplitView; @interface PBGitCommitController : PBViewController { // This might have to transfer over to the PBGitRepository @@ -23,6 +24,7 @@ IBOutlet PBGitIndexController *indexController; IBOutlet PBWebChangesController *webController; + IBOutlet PBNiceSplitView *commitSplitView; } @property(readonly) PBGitIndex *index; diff --git a/PBGitCommitController.m b/PBGitCommitController.m index 9f0eca1..4d236ac 100644 --- a/PBGitCommitController.m +++ b/PBGitCommitController.m @@ -11,6 +11,10 @@ #import "PBChangedFile.h" #import "PBWebChangesController.h" #import "PBGitIndex.h" +#import "PBNiceSplitView.h" + + +#define kCommitSplitViewPositionDefault @"Commit SplitView Position" @interface PBGitCommitController () - (void)refreshFinished:(NSNotification *)notification; @@ -22,6 +26,7 @@ - (void)amendCommit:(NSNotification *)notification; - (void)indexChanged:(NSNotification *)notification; - (void)indexOperationFailed:(NSNotification *)notification; +- (void)saveCommitSplitViewPosition; @end @implementation PBGitCommitController @@ -65,10 +70,14 @@ [cachedFilesController setAutomaticallyRearrangesObjects:NO]; [unstagedFilesController setAutomaticallyRearrangesObjects:NO]; + + [commitSplitView setHidden:YES]; + [self performSelector:@selector(restoreCommitSplitViewPositiion) withObject:nil afterDelay:0]; } - (void)closeView { + [self saveCommitSplitViewPosition]; [webController closeView]; } @@ -211,4 +220,78 @@ [[repository windowController] showMessageSheet:@"Index operation failed" infoText:[[notification userInfo] objectForKey:@"description"]]; } + +#pragma mark NSSplitView delegate methods + +#define kCommitSplitViewTopViewMin 150 +#define kCommitSplitViewBottomViewMin 100 + +- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)dividerIndex +{ + if (splitView == commitSplitView) + return kCommitSplitViewTopViewMin; + + return proposedMin; +} + +- (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)dividerIndex +{ + if (splitView == commitSplitView) + return [splitView frame].size.height - [splitView dividerThickness] - kCommitSplitViewBottomViewMin; + + return proposedMax; +} + +// while the user resizes the window keep the lower (changes/message) view constant and just resize the upper view +// unless the upper view gets too small +- (void)resizeCommitSplitView +{ + NSRect newFrame = [commitSplitView frame]; + + float dividerThickness = [commitSplitView dividerThickness]; + + NSView *upperView = [[commitSplitView subviews] objectAtIndex:0]; + NSRect upperFrame = [upperView frame]; + upperFrame.size.width = newFrame.size.width; + + NSView *lowerView = [[commitSplitView subviews] objectAtIndex:1]; + NSRect lowerFrame = [lowerView frame]; + lowerFrame.size.width = newFrame.size.width; + + upperFrame.size.height = newFrame.size.height - lowerFrame.size.height - dividerThickness; + if (upperFrame.size.height < kCommitSplitViewTopViewMin) + upperFrame.size.height = kCommitSplitViewTopViewMin; + + lowerFrame.size.height = newFrame.size.height - upperFrame.size.height - dividerThickness; + lowerFrame.origin.y = newFrame.size.height - lowerFrame.size.height; + + [upperView setFrame:upperFrame]; + [lowerView setFrame:lowerFrame]; +} + +- (void)splitView:(NSSplitView *)splitView resizeSubviewsWithOldSize:(NSSize)oldSize +{ + if (splitView == commitSplitView) + [self resizeCommitSplitView]; +} + +// NSSplitView does not save and restore the position of the splitView correctly so do it manually +- (void)saveCommitSplitViewPosition +{ + float position = [[[commitSplitView subviews] objectAtIndex:0] frame].size.height; + [[NSUserDefaults standardUserDefaults] setFloat:position forKey:kCommitSplitViewPositionDefault]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} + +// make sure this happens after awakeFromNib +- (void)restoreCommitSplitViewPositiion +{ + float position = [[NSUserDefaults standardUserDefaults] floatForKey:kCommitSplitViewPositionDefault]; + if (position < 1.0) + position = [commitSplitView frame].size.height - 225; + + [commitSplitView setPosition:position ofDividerAtIndex:0]; + [commitSplitView setHidden:NO]; +} + @end diff --git a/PBGitCommitView.xib b/PBGitCommitView.xib index 96cec64..9d1f889 100644 --- a/PBGitCommitView.xib +++ b/PBGitCommitView.xib @@ -2,10 +2,10 @@ 1050 - 10C540 - 762 - 1038.25 - 458.00 + 10H574 + 804 + 1038.35 + 461.00 YES @@ -15,13 +15,12 @@ YES - 762 - 762 + 804 + 804 YES - YES @@ -84,6 +83,7 @@ {852, 181} + @@ -138,6 +138,7 @@ 4352 {189, 221} + YES @@ -230,6 +231,7 @@ {{1, 1}, {189, 221}} + @@ -240,6 +242,7 @@ -2147483392 {{174, 1}, {15, 178}} + _doScroller: 0.99337750000000002 @@ -249,6 +252,7 @@ -2147483392 {{1, 179}, {173, 15}} + 1 _doScroller: @@ -257,6 +261,7 @@ {{-1, -1}, {191, 223}} + 562 @@ -267,10 +272,12 @@ {190, 227} + {190, 242} + {0, 0} 67239424 @@ -309,6 +316,7 @@ 289 {{339, 0}, {96, 32}} + YES 67239424 @@ -321,7 +329,7 @@ -2038284033 - 301990017 + 268435585 DQ 200 @@ -365,8 +373,9 @@ public.url - {427, 41} + {{0, 27}, {427, 14}} + @@ -441,6 +450,7 @@ {{1, 1}, {427, 184}} + @@ -455,6 +465,7 @@ -2147483392 {{346, 1}, {15, 164}} + _doScroller: 0.99166670000000001 @@ -464,6 +475,7 @@ -2147483392 {{-100, -100}, {87, 18}} + 1 _doScroller: @@ -473,6 +485,7 @@ {{0, 36}, {429, 186}} + 530 @@ -484,6 +497,7 @@ 292 {{-2, 9}, {82, 18}} + YES -2080244224 @@ -511,6 +525,7 @@ 289 {{243, 0}, {96, 32}} + YES 67239424 @@ -529,10 +544,12 @@ {429, 227} + {{199, 0}, {429, 242}} + {0, 0} 67239424 @@ -576,6 +593,7 @@ 4352 {214, 221} + 1 YES @@ -629,6 +647,7 @@ {{1, 1}, {214, 221}} + @@ -639,6 +658,7 @@ -2147483392 {{257, 1}, {15, 246}} + _doScroller: 0.99519230000000003 @@ -648,6 +668,7 @@ -2147483392 {{1, 247}, {256, 15}} + 1 _doScroller: @@ -656,6 +677,7 @@ {{0, -1}, {216, 223}} + 562 @@ -666,10 +688,12 @@ {215, 227} + {{637, 0}, {215, 242}} + {0, 0} 67239424 @@ -691,16 +715,17 @@ {{0, 190}, {852, 242}} + YES {852, 432} - CommitViewSplitView {852, 432} + NSView @@ -1031,6 +1056,22 @@ 307 + + + delegate + + + + 313 + + + + commitSplitView + + + + 314 + @@ -1360,7 +1401,7 @@ YES com.apple.InterfaceBuilder.CocoaPlugin - {{1091, 655}, {852, 432}} + {{393, 574}, {852, 432}} com.apple.InterfaceBuilder.CocoaPlugin @@ -1419,11 +1460,18 @@ - 311 + 314 YES + + NSApplication + + IBProjectSource + NSApplication+GitXScripting.h + + PBCommitMessageView NSTextView @@ -1448,6 +1496,7 @@ YES commit: + forceCommit: refresh: signOff: @@ -1456,6 +1505,36 @@ id id id + id + + + + YES + + YES + commit: + forceCommit: + refresh: + signOff: + + + YES + + commit: + id + + + forceCommit: + id + + + refresh: + id + + + signOff: + id + @@ -1465,6 +1544,7 @@ cachedFilesController commitButton commitMessageView + commitSplitView indexController unstagedFilesController webController @@ -1474,11 +1554,56 @@ NSArrayController NSButton NSTextView + PBNiceSplitView PBGitIndexController NSArrayController PBWebChangesController + + YES + + YES + cachedFilesController + commitButton + commitMessageView + commitSplitView + indexController + unstagedFilesController + webController + + + YES + + cachedFilesController + NSArrayController + + + commitButton + NSButton + + + commitMessageView + NSTextView + + + commitSplitView + PBNiceSplitView + + + indexController + PBGitIndexController + + + unstagedFilesController + NSArrayController + + + webController + PBWebChangesController + + + IBProjectSource PBGitCommitController.h @@ -1500,6 +1625,25 @@ NSTableView + + YES + + YES + rowClicked: + tableClicked: + + + YES + + rowClicked: + NSCell + + + tableClicked: + NSTableView + + + YES @@ -1519,6 +1663,40 @@ NSTableView + + YES + + YES + commitController + stagedFilesController + stagedTable + unstagedFilesController + unstagedTable + + + YES + + commitController + PBGitCommitController + + + stagedFilesController + NSArrayController + + + stagedTable + NSTableView + + + unstagedFilesController + NSArrayController + + + unstagedTable + NSTableView + + + IBProjectSource PBGitIndexController.h @@ -1547,6 +1725,13 @@ refresh: id + + refresh: + + refresh: + id + + IBProjectSource PBViewController.h @@ -1572,6 +1757,35 @@ NSArrayController + + YES + + YES + cachedFilesController + controller + indexController + unstagedFilesController + + + YES + + cachedFilesController + NSArrayController + + + controller + PBGitCommitController + + + indexController + PBGitIndexController + + + unstagedFilesController + NSArrayController + + + IBProjectSource PBWebChangesController.h @@ -1593,6 +1807,25 @@ WebView + + YES + + YES + repository + view + + + YES + + repository + id + + + view + WebView + + + IBProjectSource PBWebController.h @@ -1976,6 +2209,34 @@ Foundation.framework/Headers/NSURLDownload.h + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CIImageProvider.h + + + + NSObject + + IBFrameworkSource + ScriptingBridge.framework/Headers/SBApplication.h + + NSObject @@ -2185,6 +2446,13 @@ view NSView + + view + + view + NSView + + IBFrameworkSource AppKit.framework/Headers/NSViewController.h @@ -2224,6 +2492,70 @@ id + + YES + + YES + goBack: + goForward: + makeTextLarger: + makeTextSmaller: + makeTextStandardSize: + reload: + reloadFromOrigin: + stopLoading: + takeStringURLFrom: + toggleContinuousSpellChecking: + toggleSmartInsertDelete: + + + YES + + goBack: + id + + + goForward: + id + + + makeTextLarger: + id + + + makeTextSmaller: + id + + + makeTextStandardSize: + id + + + reload: + id + + + reloadFromOrigin: + id + + + stopLoading: + id + + + takeStringURLFrom: + id + + + toggleContinuousSpellChecking: + id + + + toggleSmartInsertDelete: + id + + + IBFrameworkSource WebKit.framework/Headers/WebView.h diff --git a/PBGitDefaults.h b/PBGitDefaults.h index 46b28b5..a95b524 100644 --- a/PBGitDefaults.h +++ b/PBGitDefaults.h @@ -24,8 +24,6 @@ + (void) setShouldCheckoutBranch:(BOOL)shouldCheckout; + (NSString *) recentCloneDestination; + (void) setRecentCloneDestination:(NSString *)path; -+ (BOOL) suppressAcceptDropRef; -+ (void) setSuppressAcceptDropRef:(BOOL)suppress; + (BOOL) showStageView; + (void) setShowStageView:(BOOL)suppress; + (BOOL) openPreviousDocumentsOnLaunch; @@ -37,4 +35,10 @@ + (NSInteger)historySearchMode; + (void)setHistorySearchMode:(NSInteger)mode; + +// Suppressed Dialog Warnings ++ (void)suppressDialogWarningForDialog:(NSString *)dialog; ++ (BOOL)isDialogWarningSuppressedForDialog:(NSString *)dialog; ++ (void)resetAllDialogWarnings; + @end diff --git a/PBGitDefaults.m b/PBGitDefaults.m index ccc2162..5656469 100644 --- a/PBGitDefaults.m +++ b/PBGitDefaults.m @@ -21,12 +21,12 @@ #define kShowOpenPanelOnLaunch @"PBShowOpenPanelOnLaunch" #define kShouldCheckoutBranch @"PBShouldCheckoutBranch" #define kRecentCloneDestination @"PBRecentCloneDestination" -#define kSuppressAcceptDropRef @"PBSuppressAcceptDropRef" #define kShowStageView @"PBShowStageView" #define kOpenPreviousDocumentsOnLaunch @"PBOpenPreviousDocumentsOnLaunch" #define kPreviousDocumentPaths @"PBPreviousDocumentPaths" #define kBranchFilterState @"PBBranchFilter" #define kHistorySearchMode @"PBHistorySearchMode" +#define kSuppressedDialogWarnings @"Suppressed Dialog Warnings" @implementation PBGitDefaults @@ -125,16 +125,6 @@ [[NSUserDefaults standardUserDefaults] setObject:path forKey:kRecentCloneDestination]; } -+ (BOOL) suppressAcceptDropRef -{ - return [[NSUserDefaults standardUserDefaults] boolForKey:kSuppressAcceptDropRef]; -} - -+ (void) setSuppressAcceptDropRef:(BOOL)suppress -{ - return [[NSUserDefaults standardUserDefaults] setBool:suppress forKey:kSuppressAcceptDropRef]; -} - + (BOOL) showStageView { return [[NSUserDefaults standardUserDefaults] boolForKey:kShowStageView]; @@ -185,4 +175,38 @@ } + +// Suppressed Dialog Warnings +// +// Represents dialogs where the user has checked the "Do not show this message again" checkbox. +// Keep these together in an array to make it easier to reset all the warnings. + ++ (NSSet *)suppressedDialogWarnings +{ + NSSet *suppressedDialogWarnings = [NSSet setWithArray:[[NSUserDefaults standardUserDefaults] arrayForKey:kSuppressedDialogWarnings]]; + if (suppressedDialogWarnings == nil) + suppressedDialogWarnings = [NSSet set]; + + return suppressedDialogWarnings; +} + ++ (void)suppressDialogWarningForDialog:(NSString *)dialog +{ + NSSet *suppressedDialogWarnings = [[self suppressedDialogWarnings] setByAddingObject:dialog]; + + [[NSUserDefaults standardUserDefaults] setObject:[suppressedDialogWarnings allObjects] forKey:kSuppressedDialogWarnings]; +} + ++ (BOOL)isDialogWarningSuppressedForDialog:(NSString *)dialog +{ + return [[self suppressedDialogWarnings] containsObject:dialog]; +} + ++ (void)resetAllDialogWarnings +{ + [[NSUserDefaults standardUserDefaults] setObject:nil forKey:kSuppressedDialogWarnings]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} + + @end diff --git a/PBGitHistoryController.h b/PBGitHistoryController.h index 9eb81e9..93bfea0 100644 --- a/PBGitHistoryController.h +++ b/PBGitHistoryController.h @@ -18,6 +18,7 @@ @class PBRefController; @class QLPreviewPanel; @class PBCommitList; +@class GLFileView; @class PBGitSHA; @class PBHistorySearchController; @@ -34,6 +35,7 @@ IBOutlet PBWebHistoryController *webHistoryController; QLPreviewPanel* previewPanel; IBOutlet PBHistorySearchController *searchController; + IBOutlet GLFileView *fileView; IBOutlet PBGitGradientBarView *upperToolbarView; IBOutlet NSButton *mergeButton; diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m index dd024d9..6113e6e 100644 --- a/PBGitHistoryController.m +++ b/PBGitHistoryController.m @@ -23,17 +23,22 @@ #import "PBHistorySearchController.h" #define QLPreviewPanel NSClassFromString(@"QLPreviewPanel") #import "PBQLTextView.h" +#import "GLFileView.h" +#import "PBSourceViewCell.h" #define kHistorySelectedDetailIndexKey @"PBHistorySelectedDetailIndex" #define kHistoryDetailViewIndex 0 #define kHistoryTreeViewIndex 1 +#define kHistorySplitViewPositionDefault @"History SplitView Position" + @interface PBGitHistoryController () - (void) updateBranchFilterMatrix; - (void) restoreFileBrowserSelection; - (void) saveFileBrowserSelection; +- (void)saveSplitViewPosition; @end @@ -76,16 +81,19 @@ [[commitList tableColumnWithIdentifier:@"SubjectColumn"] setSortDescriptorPrototype:[[NSSortDescriptor alloc] initWithKey:@"subject" ascending:YES]]; // Add a menu that allows a user to select which columns to view [[commitList headerView] setMenu:[self tableColumnMenu]]; + [historySplitView setTopMin:58.0 andBottomMin:100.0]; - [historySplitView uncollapse]; + [historySplitView setHidden:YES]; + [self performSelector:@selector(restoreSplitViewPositiion) withObject:nil afterDelay:0]; [upperToolbarView setTopShade:237/255.0 bottomShade:216/255.0]; [scopeBarView setTopColor:[NSColor colorWithCalibratedHue:0.579 saturation:0.068 brightness:0.898 alpha:1.000] bottomColor:[NSColor colorWithCalibratedHue:0.579 saturation:0.119 brightness:0.765 alpha:1.000]]; - //[scopeBarView setTopShade:207/255.0 bottomShade:180/255.0]; [self updateBranchFilterMatrix]; + [super awakeFromNib]; + [fileBrowser setDelegate:self]; } - (void)updateKeys @@ -275,6 +283,16 @@ [[NSWorkspace sharedWorkspace] openTempFile:name]; } +- (BOOL)validateMenuItem:(NSMenuItem *)menuItem +{ + if ([menuItem action] == @selector(setDetailedView:)) { + [menuItem setState:(self.selectedCommitDetailsIndex == kHistoryDetailViewIndex) ? NSOnState : NSOffState]; + } else if ([menuItem action] == @selector(setTreeView:)) { + [menuItem setState:(self.selectedCommitDetailsIndex == kHistoryTreeViewIndex) ? NSOnState : NSOffState]; + } + return YES; +} + - (IBAction) setDetailedView:(id)sender { self.selectedCommitDetailsIndex = kHistoryDetailViewIndex; @@ -408,13 +426,6 @@ [self updateKeys]; } -- (void)viewLoaded -{ - float position = [[NSUserDefaults standardUserDefaults] floatForKey:@"PBGitSplitViewPosition"]; - if (position) - [historySplitView setPosition:position ofDividerAtIndex:0]; -} - - (NSResponder *)firstResponder; { return commitList; @@ -477,9 +488,7 @@ - (void)closeView { - float position = [[[historySplitView subviews] objectAtIndex:0] frame].size.height; - [[NSUserDefaults standardUserDefaults] setFloat:position forKey:@"PBGitSplitViewPosition"]; - [[NSUserDefaults standardUserDefaults] synchronize]; + [self saveSplitViewPosition]; if (commitController) { [commitController removeObserver:self forKeyPath:@"selection"]; @@ -493,6 +502,7 @@ } [webHistoryController closeView]; + [fileView closeView]; [super closeView]; } @@ -608,12 +618,17 @@ return menuItems; } -- (BOOL)splitView:(NSSplitView *)sender canCollapseSubview:(NSView *)subview { + +#pragma mark NSSplitView delegate methods + +- (BOOL)splitView:(NSSplitView *)splitView canCollapseSubview:(NSView *)subview +{ return TRUE; } -- (BOOL)splitView:(NSSplitView *)splitView shouldCollapseSubview:(NSView *)subview forDoubleClickOnDividerAtIndex:(NSInteger)dividerIndex { - int index = [[splitView subviews] indexOfObject:subview]; +- (BOOL)splitView:(NSSplitView *)splitView shouldCollapseSubview:(NSView *)subview forDoubleClickOnDividerAtIndex:(NSInteger)dividerIndex +{ + NSUInteger index = [[splitView subviews] indexOfObject:subview]; // this method (and canCollapse) are called by the splitView to decide how to collapse on double-click // we compare our two subviews, so that always the smaller one is collapsed. if([[[splitView subviews] objectAtIndex:index] frame].size.height < [[[splitView subviews] objectAtIndex:((index+1)%2)] frame].size.height) { @@ -622,14 +637,59 @@ return FALSE; } -- (CGFloat)splitView:(NSSplitView *)sender constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)offset { - return proposedMin + historySplitView.topViewMin; +- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)dividerIndex +{ + return historySplitView.topViewMin; } -- (CGFloat)splitView:(NSSplitView *)sender constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)offset { - if(offset == 1) - return proposedMax - historySplitView.bottomViewMin; - return [sender frame].size.height; +- (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)dividerIndex +{ + return [splitView frame].size.height - [splitView dividerThickness] - historySplitView.bottomViewMin; +} + +// while the user resizes the window keep the upper (history) view constant and just resize the lower view +// unless the lower view gets too small +- (void)splitView:(NSSplitView *)splitView resizeSubviewsWithOldSize:(NSSize)oldSize +{ + NSRect newFrame = [splitView frame]; + + float dividerThickness = [splitView dividerThickness]; + + NSView *upperView = [[splitView subviews] objectAtIndex:0]; + NSRect upperFrame = [upperView frame]; + upperFrame.size.width = newFrame.size.width; + + if ((newFrame.size.height - upperFrame.size.height - dividerThickness) < historySplitView.bottomViewMin) { + upperFrame.size.height = newFrame.size.height - historySplitView.bottomViewMin - dividerThickness; + } + + NSView *lowerView = [[splitView subviews] objectAtIndex:1]; + NSRect lowerFrame = [lowerView frame]; + lowerFrame.origin.y = upperFrame.size.height + dividerThickness; + lowerFrame.size.height = newFrame.size.height - lowerFrame.origin.y; + lowerFrame.size.width = newFrame.size.width; + + [upperView setFrame:upperFrame]; + [lowerView setFrame:lowerFrame]; +} + +// NSSplitView does not save and restore the position of the SplitView correctly so do it manually +- (void)saveSplitViewPosition +{ + float position = [[[historySplitView subviews] objectAtIndex:0] frame].size.height; + [[NSUserDefaults standardUserDefaults] setFloat:position forKey:kHistorySplitViewPositionDefault]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} + +// make sure this happens after awakeFromNib +- (void)restoreSplitViewPositiion +{ + float position = [[NSUserDefaults standardUserDefaults] floatForKey:kHistorySplitViewPositionDefault]; + if (position < 1.0) + position = 175; + + [historySplitView setPosition:position ofDividerAtIndex:0]; + [historySplitView setHidden:NO]; } @@ -756,4 +816,15 @@ return iconRect; } +- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(PBSourceViewCell *)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item +{ + NSWorkspace *workspace = [NSWorkspace sharedWorkspace]; + PBGitTree *object = [item representedObject]; + NSString *workingDirectory = [[repository workingDirectory] stringByAppendingString:@"/"]; + NSString *path = [workingDirectory stringByAppendingPathComponent:[object fullPath]]; + NSImage *image = [workspace iconForFile:path]; + [image setSize:NSMakeSize(15, 15)]; + [cell setImage:image]; +} + @end diff --git a/PBGitHistoryView.xib b/PBGitHistoryView.xib index 3c9d8be..3d02796 100644 --- a/PBGitHistoryView.xib +++ b/PBGitHistoryView.xib @@ -2,9 +2,9 @@ 1050 - 10F569 + 10H574 804 - 1038.29 + 1038.35 461.00 YES @@ -21,6 +21,7 @@ YES + YES @@ -502,7 +503,7 @@ - d MMMM yyyy h:mm a + d MMMM yyyy HH:mm NO @@ -1105,7 +1106,7 @@ - 268 + 274 YES @@ -1115,7 +1116,7 @@ YES - 268 + 265 YES @@ -1237,7 +1238,6 @@ 2 - HistoryViewSplitView {955, 434} @@ -2018,6 +2018,30 @@ 487 + + + fileView + + + + 488 + + + + fileListSplitView + + + + 489 + + + + delegate + + + + 490 + @@ -2651,6 +2675,7 @@ 16.IBPluginDependency 17.IBPluginDependency 18.IBPluginDependency + 19.CustomClassName 19.IBPluginDependency 2.CustomClassName 2.IBEditorWindowLastContentRect @@ -2768,6 +2793,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + PBIconAndTextCell com.apple.InterfaceBuilder.CocoaPlugin PBCollapsibleSplitView {{312, 577}, {852, 384}} @@ -2932,7 +2958,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.WebKitIBPlugin - {{67, 422}, {955, 434}} + {{1084, 241}, {955, 434}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -2970,7 +2996,7 @@ - 499 + 490 @@ -2983,12 +3009,14 @@ YES accessoryView + fileListSplitView historyController typeBar YES NSView + NSSplitView PBGitHistoryController MGScopeBar @@ -2998,6 +3026,7 @@ YES accessoryView + fileListSplitView historyController typeBar @@ -3007,6 +3036,10 @@ accessoryView NSView + + fileListSplitView + NSSplitView + historyController PBGitHistoryController @@ -3075,6 +3108,13 @@ NSApplication+GitXScripting.h + + NSCell + + IBProjectSource + View/CellTrackingRect.h + + NSOutlineView @@ -3309,6 +3349,7 @@ commitController commitList fileBrowser + fileView historySplitView localRemoteBranchesFilterItem mergeButton @@ -3330,6 +3371,7 @@ NSArrayController PBCommitList NSOutlineView + GLFileView PBCollapsibleSplitView NSButton NSButton @@ -3354,6 +3396,7 @@ commitController commitList fileBrowser + fileView historySplitView localRemoteBranchesFilterItem mergeButton @@ -3390,6 +3433,10 @@ fileBrowser NSOutlineView + + fileView + GLFileView + historySplitView PBCollapsibleSplitView @@ -3604,6 +3651,14 @@ PBHistorySearchController.h + + PBIconAndTextCell + NSTextFieldCell + + IBProjectSource + PBIconAndTextCell.h + + PBNiceSplitView NSSplitView @@ -4379,6 +4434,13 @@ QuartzCore.framework/Headers/CIImageProvider.h + + NSObject + + IBFrameworkSource + ScriptingBridge.framework/Headers/SBApplication.h + + NSObject diff --git a/PBGitIndexController.m b/PBGitIndexController.m index d72e8bc..02a5fce 100644 --- a/PBGitIndexController.m +++ b/PBGitIndexController.m @@ -113,6 +113,19 @@ [ignoreItem setTarget:self]; [ignoreItem setRepresentedObject:selectedFiles]; [menu addItem:ignoreItem]; + + if ([selectedFiles count] == 1) { + NSString *path = [[selectedFiles objectAtIndex:0] path]; + NSString *extension = [path pathExtension]; + if ([extension length] > 0) { + ignoreText = [NSString stringWithFormat:@"Ignore Files with extension (.%@)", extension]; + ignoreItem = [[NSMenuItem alloc] initWithTitle:ignoreText action:@selector(ignoreFilesWithExtensionAction:) keyEquivalent:@""]; + [ignoreItem setTarget:self]; + [ignoreItem setRepresentedObject:extension]; + [menu addItem:ignoreItem]; + [ignoreItem release]; + } + } } if ([selectedFiles count] == 1) { @@ -171,6 +184,18 @@ [commitController.index refresh]; } +- (void) ignoreFilesWithExtensionAction:(id) sender { + NSString *extension = [sender representedObject]; + if ([extension length] == 0) + return; + PBChangedFile *file = [[PBChangedFile alloc] initWithPath:[NSString stringWithFormat:@"*.%@", extension]]; + + + [self ignoreFiles:[NSArray arrayWithObject:file]]; + [file release]; + [commitController.index refresh]; +} + - (void)discardFilesAction:(id) sender { NSArray *selectedFiles = [sender representedObject]; @@ -226,7 +251,13 @@ - (void)tableView:(NSTableView*)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)rowIndex { id controller = [tableView tag] == 0 ? unstagedFilesController : stagedFilesController; - [[tableColumn dataCell] setImage:[[[controller arrangedObjects] objectAtIndex:rowIndex] icon]]; + PBChangedFile *changedFile = [[controller arrangedObjects] objectAtIndex:rowIndex]; + PBChangedFileStatus status = [changedFile status]; + NSImage *imageToSet = [changedFile icon]; + if (controller == stagedFilesController && status == NEW) { + imageToSet = [PBChangedFile iconForStatus:ADDED]; + } + [[tableColumn dataCell] setImage:imageToSet]; } - (void) tableClicked:(NSTableView *) tableView diff --git a/PBGitMenuItem.h b/PBGitMenuItem.h new file mode 100644 index 0000000..7e81edd --- /dev/null +++ b/PBGitMenuItem.h @@ -0,0 +1,20 @@ +// +// PBGitSVStashItem.h +// GitX +// +// Created by Tomasz Krasnyk on 10-11-05. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import +#import "PBSourceViewItem.h" +#import "PBPresentable.h" + + +@interface PBGitMenuItem : PBSourceViewItem { + id sourceObject; +} +@property (nonatomic, retain, readonly) id sourceObject; + +- initWithSourceObject:(id) anObject; +@end diff --git a/PBGitMenuItem.m b/PBGitMenuItem.m new file mode 100644 index 0000000..38b6895 --- /dev/null +++ b/PBGitMenuItem.m @@ -0,0 +1,62 @@ +// +// PBGitSVStashItem.m +// GitX +// +// Created by Tomasz Krasnyk on 10-11-05. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import "PBGitMenuItem.h" + + +@implementation PBGitMenuItem +@synthesize sourceObject; + +#pragma mark - +#pragma mark Inits/dealloc +//--------------------------------------------------------------------------------------------- + +- initWithSourceObject:(id) anObject { + if (self = [super init]) { + super.title = [anObject displayDescription]; + sourceObject = [anObject retain]; + } + return self; +} + +- (void) dealloc { + [sourceObject release]; + [super dealloc]; +} + +//--------------------------------------------------------------------------------------------- +#pragma mark - + + +- (NSImage *) icon { + return [self.sourceObject icon]; +} + + +- (void) addChild:(PBGitMenuItem *)child { + BOOL added = NO; + for (PBGitMenuItem *item in self.children) { + if ([[(id)child.sourceObject path] hasPrefix:[(id)[item sourceObject] path]]) { + [item addChild:child]; + added = YES; + } + } + if (!added) { + [super addChild:child]; + } +} + +- (void) expand { + NSObject *item = self.parent; + while (item && [item isKindOfClass:[PBGitMenuItem class]]) { + [(id)item expand]; + item = [(id)item parent]; + } +} + +@end diff --git a/PBGitRepository.h b/PBGitRepository.h index f5669e2..a6a4ba7 100644 --- a/PBGitRepository.h +++ b/PBGitRepository.h @@ -12,6 +12,10 @@ #import "PBGitConfig.h" #import "PBGitRefish.h" +#import "PBStashController.h" +#import "PBGitResetController.h" +#import "PBSubmoduleController.h" + extern NSString* PBGitRepositoryErrorDomain; typedef enum branchFilterTypes { kGitXAllBranchesFilter = 0, @@ -53,8 +57,13 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) { PBGitRevSpecifier *_headRef; // Caching PBGitSHA* _headSha; - NSArray *stashes; + PBStashController *stashController; + PBSubmoduleController *submoduleController; + PBGitResetController *resetController; } +@property (nonatomic, retain, readonly) PBStashController *stashController; +@property (nonatomic, retain, readonly) PBSubmoduleController *submoduleController; +@property (nonatomic, retain, readonly) PBGitResetController *resetController; - (void) cloneRepositoryToPath:(NSString *)path bare:(BOOL)isBare; - (void) beginAddRemote:(NSString *)remoteName forURL:(NSString *)remoteURL; @@ -98,7 +107,6 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) { - (NSString *)gitIgnoreFilename; - (BOOL)isBareRepository; -- (void) reloadStashes; - (void) reloadRefs; - (void) addRef:(PBGitRef *)ref fromParameters:(NSArray *)params; - (void) lazyReload; @@ -137,6 +145,7 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) { // for the scripting bridge - (void)findInModeScriptCommand:(NSScriptCommand *)command; +- (NSMenu *) menu; @property (assign) BOOL hasChanged; @property (readonly) PBGitWindowController *windowController; diff --git a/PBGitRepository.m b/PBGitRepository.m index 3c92559..06584e4 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -22,20 +22,39 @@ #import "PBHistorySearchController.h" #import "PBGitStash.h" +#import "PBGitSubmodule.h" NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; @interface PBGitRepository() -@property (nonatomic, retain) NSArray *stashes; @end @implementation PBGitRepository -@synthesize stashes; +@synthesize stashController; +@synthesize submoduleController; +@synthesize resetController; @synthesize revisionList, branches, currentBranch, refs, hasChanged, config; @synthesize currentBranchFilter; +- (NSMenu *) menu { + NSMenu *menu = [[NSMenu alloc] init]; + NSMutableArray *items = [[NSMutableArray alloc] init]; + [items addObjectsFromArray:[self.submoduleController menuItems]]; + [items addObject:[NSMenuItem separatorItem]]; + [items addObjectsFromArray:[self.stashController menu]]; + [items addObject:[NSMenuItem separatorItem]]; + [items addObjectsFromArray:[self.resetController menuItems]]; + + for (NSMenuItem *item in items) { + [menu addItem:item]; + } + + [menu setAutoenablesItems:YES]; + return menu; +} + - (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError { if (outError) { @@ -143,6 +162,10 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; [self reloadRefs]; currentBranchFilter = [PBGitDefaults branchFilter]; revisionList = [[PBGitHistoryList alloc] initWithRepository:self]; + + resetController = [[PBGitResetController alloc] initWithRepository:self]; + stashController = [[PBStashController alloc] initWithRepository:self]; + submoduleController = [[PBSubmoduleController alloc] initWithRepository:self]; } - (void)close @@ -255,23 +278,6 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; [refs setObject:[NSMutableArray arrayWithObject:ref] forKey:sha]; } -- (void) reloadStashes { - NSArray *arguments = [NSArray arrayWithObjects:@"stash", @"list", nil]; - NSString *output = [self outputInWorkdirForArguments:arguments]; - NSArray *lines = [output componentsSeparatedByString:@"\n"]; - - NSMutableArray *loadedStashes = [[NSMutableArray alloc] init]; - - for (NSString *stashLine in lines) { - PBGitStash *stash = [[PBGitStash alloc] initWithRawStashLine:stashLine]; - [loadedStashes addObject:stash]; - [stash release]; - } - - self.stashes = loadedStashes; - [loadedStashes release]; -} - - (void) reloadRefs { _headRef = nil; @@ -306,7 +312,8 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; [self willChangeValueForKey:@"refs"]; [self didChangeValueForKey:@"refs"]; - [self reloadStashes]; + [self.stashController reload]; + [self.submoduleController reload]; [[[self windowController] window] setTitle:[self displayName]]; } @@ -1251,11 +1258,6 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; return nil; } -- (void) dealloc { - [stashes release]; - [super dealloc]; -} - - (void) finalize { NSLog(@"Dealloc of repository"); diff --git a/PBGitSVStashItem.h b/PBGitSVStashItem.h deleted file mode 100644 index e3cd134..0000000 --- a/PBGitSVStashItem.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// PBGitSVStashItem.h -// GitX -// -// Created by Tomasz Krasnyk on 10-11-05. -// Copyright 2010 __MyCompanyName__. All rights reserved. -// - -#import -#import "PBSourceViewItem.h" -#import "PBGitStash.h" - - -@interface PBGitSVStashItem : PBSourceViewItem { - PBGitStash *stash; -} -@property (nonatomic, retain, readonly) PBGitStash *stash; - -- initWithStash:(PBGitStash *) aStash; -@end diff --git a/PBGitSVStashItem.m b/PBGitSVStashItem.m deleted file mode 100644 index d91d069..0000000 --- a/PBGitSVStashItem.m +++ /dev/null @@ -1,45 +0,0 @@ -// -// PBGitSVStashItem.m -// GitX -// -// Created by Tomasz Krasnyk on 10-11-05. -// Copyright 2010 __MyCompanyName__. All rights reserved. -// - -#import "PBGitSVStashItem.h" - - -@implementation PBGitSVStashItem -@synthesize stash; - -#pragma mark - -#pragma mark Inits/dealloc -//--------------------------------------------------------------------------------------------- - -- initWithStash:(PBGitStash *) aStash { - if (self = [super init]) { - NSString *displayTitle = [NSString stringWithFormat:@"%@ (%@)", [aStash message], [aStash stashSourceMessage]]; - super.title = displayTitle; - stash = [aStash retain]; - } - return self; -} - -- (void) dealloc { - [stash release]; - [super dealloc]; -} - -//--------------------------------------------------------------------------------------------- -#pragma mark - - - -- (NSImage *) icon { - static NSImage *tagImage = nil; - if (!tagImage) - tagImage = [NSImage imageNamed:@"stash-icon.png"]; - - return tagImage; -} - -@end diff --git a/PBGitSidebarController.h b/PBGitSidebarController.h index 352302a..ba7ab35 100644 --- a/PBGitSidebarController.h +++ b/PBGitSidebarController.h @@ -29,7 +29,7 @@ /* Specific things */ PBSourceViewItem *stage; - PBSourceViewItem *branches, *remotes, *tags, *others, *stashes; + PBSourceViewItem *branches, *remotes, *tags, *others, *stashes, *submodules; PBGitHistoryController *historyViewController; PBGitCommitController *commitViewController; @@ -49,4 +49,7 @@ @property(readonly) NSMutableArray *items; @property(readonly) NSView *sourceListControlsView; +@property(readonly) PBGitHistoryController *historyViewController; +@property(readonly) PBGitCommitController *commitViewController; + @end diff --git a/PBGitSidebarController.m b/PBGitSidebarController.m index 5e76b26..6fd21fc 100644 --- a/PBGitSidebarController.m +++ b/PBGitSidebarController.m @@ -16,12 +16,16 @@ #import "PBAddRemoteSheet.h" #import "PBGitDefaults.h" #import "PBHistorySearchController.h" -#import "PBGitSVStashItem.h" +#import "PBGitMenuItem.h" #import "PBStashCommandFactory.h" +#import "PBRemoteCommandFactory.h" #import "PBCommandMenuItem.h" +#import "PBGitStash.h" +#import "PBGitSubmodule.h" static NSString * const kObservingContextStashes = @"stashesChanged"; +static NSString * const kObservingContextSubmodules = @"submodulesChanged"; @interface PBGitSidebarController () @@ -36,6 +40,8 @@ static NSString * const kObservingContextStashes = @"stashesChanged"; @implementation PBGitSidebarController @synthesize items; @synthesize sourceListControlsView; +@synthesize historyViewController; +@synthesize commitViewController; - (id)initWithRepository:(PBGitRepository *)theRepository superController:(PBGitWindowController *)controller { @@ -57,7 +63,9 @@ static NSString * const kObservingContextStashes = @"stashesChanged"; [repository addObserver:self forKeyPath:@"currentBranch" options:0 context:@"currentBranchChange"]; [repository addObserver:self forKeyPath:@"branches" options:(NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew) context:@"branchesModified"]; - [repository addObserver:self forKeyPath:@"stashes" options:NSKeyValueObservingOptionNew context:@"stashesChanged"]; + [repository addObserver:self forKeyPath:@"stashController.stashes" options:NSKeyValueObservingOptionNew context:kObservingContextStashes]; + [repository addObserver:self forKeyPath:@"submoduleController.submodules" options:NSKeyValueObservingOptionNew context:kObservingContextSubmodules]; + [self menuNeedsUpdate:[actionButton menu]]; @@ -65,6 +73,9 @@ static NSString * const kObservingContextStashes = @"stashesChanged"; [self selectStage]; else [self selectCurrentBranch]; + + [sourceView setDoubleAction:@selector(outlineDoubleClicked)]; + [sourceView setTarget:self]; } - (void)closeView @@ -74,7 +85,8 @@ static NSString * const kObservingContextStashes = @"stashesChanged"; [repository removeObserver:self forKeyPath:@"currentBranch"]; [repository removeObserver:self forKeyPath:@"branches"]; - [repository removeObserver:self forKeyPath:@"stashes"]; + [repository removeObserver:self forKeyPath:@"stashController.stashes"]; + [repository removeObserver:self forKeyPath:@"submoduleController.submodules"]; [super closeView]; } @@ -100,14 +112,39 @@ static NSString * const kObservingContextStashes = @"stashesChanged"; for (PBGitRevSpecifier *rev in removedRevSpecs) [self removeRevSpec:rev]; } - } else if ([@"stashesChanged" isEqualToString:context]) { // isEqualToString: is not needed here + } else if ([kObservingContextStashes isEqualToString:context]) { // isEqualToString: is not needed here [stashes.children removeAllObjects]; NSArray *newStashes = [change objectForKey:NSKeyValueChangeNewKey]; + PBGitMenuItem *lastItem = nil; for (PBGitStash *stash in newStashes) { - PBGitSVStashItem *item = [[PBGitSVStashItem alloc] initWithStash:stash]; + PBGitMenuItem *item = [[PBGitMenuItem alloc] initWithSourceObject:stash]; [stashes addChild:item]; [item release]; + lastItem = item; + } + if (lastItem) { + [sourceView PBExpandItem:lastItem expandParents:YES]; + } + [sourceView reloadData]; + } else if ([kObservingContextSubmodules isEqualToString:context]) { + [submodules.children removeAllObjects]; + NSArray *newSubmodules = [change objectForKey:NSKeyValueChangeNewKey]; + + for (PBGitSubmodule *submodule in newSubmodules) { + PBGitMenuItem *item = [[PBGitMenuItem alloc] initWithSourceObject:submodule]; + + BOOL added = NO; + for (PBGitMenuItem *addedItems in [submodules children]) { + if ([[submodule path] hasPrefix:[(id)[addedItems sourceObject] path]]) { + [addedItems addChild:item]; + added = YES; + } + } + if (!added) { + [submodules addChild:item]; + } + [sourceView PBExpandItem:item expandParents:YES]; } [sourceView reloadData]; } else { @@ -158,6 +195,17 @@ static NSString * const kObservingContextStashes = @"stashesChanged"; [sourceView selectRowIndexes:index byExtendingSelection:NO]; } +- (void) outlineDoubleClicked { + PBSourceViewItem *item = [self selectedItem]; + if ([item isKindOfClass:[PBGitMenuItem class]]) { + PBGitMenuItem *sidebarItem = (PBGitMenuItem *) item; + NSObject *sourceObject = [sidebarItem sourceObject]; + if ([sourceObject isKindOfClass:[PBGitSubmodule class]]) { + [[repository.submoduleController defaultCommandForSubmodule:(id)sourceObject] invoke]; + } + } +} + - (PBSourceViewItem *) itemForRev:(PBGitRevSpecifier *)rev { PBSourceViewItem *foundItem = nil; @@ -237,7 +285,14 @@ static NSString * const kObservingContextStashes = @"stashesChanged"; - (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(PBSourceViewCell *)cell forTableColumn:(NSTableColumn *)tableColumn item:(PBSourceViewItem *)item { cell.isCheckedOut = [item.revSpecifier isEqual:[repository headRef]]; - + BOOL showsActionButton = NO; + if ([item respondsToSelector:@selector(showsActionButton)]) { + showsActionButton = [item showsActionButton]; + [cell setTarget:self]; + cell.iInfoButtonAction = @selector(infoButtonAction:); + } + cell.showsActionButton = showsActionButton; + [cell setImage:[item icon]]; } @@ -246,6 +301,10 @@ static NSString * const kObservingContextStashes = @"stashesChanged"; return ![item isGroupItem]; } +- (BOOL)outlineView:(NSOutlineView *)outlineView shouldTrackCell:(NSCell *)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item { + return [item isGroupItem]; +} + // // The next method is necessary to hide the triangle for uncollapsible items // That is, items which should always be displayed, such as the Project group. @@ -258,16 +317,19 @@ static NSString * const kObservingContextStashes = @"stashesChanged"; - (void)populateList { PBSourceViewItem *project = [PBSourceViewItem groupItemWithTitle:[repository projectName]]; + project.showsActionButton = YES; project.isUncollapsible = YES; stage = [PBGitSVStageItem stageItem]; [project addChild:stage]; + branches = [PBSourceViewItem groupItemWithTitle:@"Branches"]; remotes = [PBSourceViewItem groupItemWithTitle:@"Remotes"]; tags = [PBSourceViewItem groupItemWithTitle:@"Tags"]; others = [PBSourceViewItem groupItemWithTitle:@"Other"]; stashes = [PBSourceViewItem groupItemWithTitle:@"Stashes"]; + submodules = [PBSourceViewItem groupItemWithTitle:@"Submodules"]; for (PBGitRevSpecifier *rev in repository.branches) [self addRevSpec:rev]; @@ -278,12 +340,14 @@ static NSString * const kObservingContextStashes = @"stashesChanged"; [items addObject:tags]; [items addObject:others]; [items addObject:stashes]; + [items addObject:submodules]; [sourceView reloadData]; [sourceView expandItem:project]; [sourceView expandItem:branches expandChildren:YES]; [sourceView expandItem:remotes]; - + //[sourceView expandItem:submodules expandChildren:YES]; + [sourceView reloadItem:nil reloadChildren:YES]; } @@ -344,17 +408,22 @@ static NSString * const kObservingContextStashes = @"stashesChanged"; - (NSMenu *) menuForRow:(NSInteger)row { + if (row == 0) { + return [historyViewController.repository menu]; + } PBSourceViewItem *viewItem = [sourceView itemAtRow:row]; - if ([viewItem isKindOfClass:[PBGitSVStashItem class]]) { - PBGitSVStashItem *stashItem = (PBGitSVStashItem *) viewItem; - NSArray *commands = [PBStashCommandFactory commandsForObject:[stashItem stash] repository:historyViewController.repository]; + if ([viewItem isKindOfClass:[PBGitMenuItem class]]) { + PBGitMenuItem *stashItem = (PBGitMenuItem *) viewItem; + NSMutableArray *commands = [[NSMutableArray alloc] init]; + [commands addObjectsFromArray:[PBStashCommandFactory commandsForObject:[stashItem sourceObject] repository:historyViewController.repository]]; + [commands addObjectsFromArray:[PBRemoteCommandFactory commandsForObject:[stashItem sourceObject] repository:historyViewController.repository]]; if (!commands) { return nil; } NSMenu *menu = [[NSMenu alloc] init]; + [menu setAutoenablesItems:NO]; for (PBCommand *command in commands) { PBCommandMenuItem *item = [[PBCommandMenuItem alloc] initWithCommand:command]; - [item setEnabled:YES]; [menu addItem:item]; [item release]; } diff --git a/PBGitSidebarView.xib b/PBGitSidebarView.xib index 85c93bb..bf1d2d4 100644 --- a/PBGitSidebarView.xib +++ b/PBGitSidebarView.xib @@ -3,7 +3,7 @@ 1050 10F569 - 804 + 1222 1038.29 461.00 @@ -12,8 +12,19 @@ YES - - + NSSegmentedControl + NSPopUpButton + NSScroller + NSMenuItem + NSMenu + NSTextFieldCell + NSScrollView + NSOutlineView + NSCustomView + NSCustomObject + NSPopUpButtonCell + NSTableColumn + NSSegmentedCell YES @@ -59,6 +70,8 @@ 4352 {153, 354} + + YES @@ -78,7 +91,7 @@ LucidaGrande 11 - 3100 + 3088 3 @@ -161,6 +174,7 @@ {153, 354} + @@ -171,6 +185,8 @@ -2147483392 {{137, 1}, {15, 338}} + + _doScroller: 0.99698790000000004 @@ -180,6 +196,8 @@ -2147483392 {{-100, -100}, {196, 15}} + + 1 _doScroller: @@ -188,7 +206,8 @@ {153, 354} - + + 528 @@ -198,10 +217,12 @@ {153, 354} + + NSView - + 268 YES @@ -419,7 +440,7 @@ - + YES @@ -745,6 +766,7 @@ YES -3.IBPluginDependency 10.IBPluginDependency + 11.CustomClassName 11.IBPluginDependency 13.IBPluginDependency 16.CustomClassName @@ -782,6 +804,7 @@ YES com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + TrackableOutlineView com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin PBSourceViewCell @@ -1003,7 +1026,7 @@ IBProjectSource - PBGitSidebarController.h + ./classes-xjh84/PBGitSidebarController.h @@ -1011,7 +1034,7 @@ NSTextFieldCell IBProjectSource - PBIconAndTextCell.h + ./classes-xjh84/PBIconAndTextCell.h @@ -1019,7 +1042,7 @@ PBIconAndTextCell IBProjectSource - PBSourceViewCell.h + ./classes-xjh84/PBSourceViewCell.h @@ -1652,35 +1675,32 @@ IBFrameworkSource AppKit.framework/Headers/NSDrawer.h - - - NSWindow - NSResponder - IBFrameworkSource - AppKit.framework/Headers/NSWindow.h + IBProjectSource + ./classes-xjh84/PBViewController.h - NSWindow + TrackableOutlineView + NSOutlineView - IBFrameworkSource - AppKit.framework/Headers/NSWindowScripting.h + IBProjectSource + ./classes-xjh84/TrackableOutlineView.h 0 IBCocoaFramework - + com.apple.InterfaceBuilder.CocoaPlugin.macosx - + com.apple.InterfaceBuilder.CocoaPlugin.macosx - + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 diff --git a/PBGitWindowController.m b/PBGitWindowController.m index 9fb9c13..ba926be 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -43,7 +43,11 @@ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { - if ([menuItem action] == @selector(showCommitView:) || [menuItem action] == @selector(showHistoryView:)) { + if ([menuItem action] == @selector(showCommitView:)) { + [menuItem setState:(contentController == sidebarController.commitViewController) ? YES : NO]; + return ![repository isBareRepository]; + } else if ([menuItem action] == @selector(showHistoryView:)) { + [menuItem setState:(contentController != sidebarController.commitViewController) ? YES : NO]; return ![repository isBareRepository]; } return YES; diff --git a/PBIconAndTextCell.m b/PBIconAndTextCell.m index c2c0052..210b23d 100644 --- a/PBIconAndTextCell.m +++ b/PBIconAndTextCell.m @@ -26,12 +26,12 @@ return cell; } -- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(NSInteger)selStart length:(NSInteger)selLength -{ - NSRect textFrame, imageFrame; - NSDivideRect (aRect, &imageFrame, &textFrame, 3 + [image size].width, NSMinXEdge); - [super selectWithFrame: textFrame inView: controlView editor:textObj delegate:anObject start:selStart length:selLength]; -} +//- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(NSInteger)selStart length:(NSInteger)selLength +//{ +// NSRect textFrame, imageFrame; +// NSDivideRect (aRect, &imageFrame, &textFrame, 3 + [image size].width, NSMinXEdge); +// [super selectWithFrame: textFrame inView: controlView editor:textObj delegate:anObject start:selStart length:selLength]; +//} - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { @@ -69,56 +69,56 @@ // = Hit testing = // =============== // Adopted from PhotoSearch Apple sample code +// +//- (NSUInteger)hitTestForEvent:(NSEvent *)event inRect:(NSRect)cellFrame ofView:(NSView *)controlView +//{ +// NSPoint point = [controlView convertPoint:[event locationInWindow] fromView:nil]; +// +// NSRect textFrame, imageFrame; +// NSDivideRect (cellFrame, &imageFrame, &textFrame, 3 + [image size].width, NSMinXEdge); +// if (NSMouseInRect(point, imageFrame, [controlView isFlipped])) +// return NSCellHitContentArea | NSCellHitTrackableArea; +// +// return [super hitTestForEvent:event inRect:cellFrame ofView:controlView]; +//} -- (NSUInteger)hitTestForEvent:(NSEvent *)event inRect:(NSRect)cellFrame ofView:(NSView *)controlView -{ - NSPoint point = [controlView convertPoint:[event locationInWindow] fromView:nil]; - - NSRect textFrame, imageFrame; - NSDivideRect (cellFrame, &imageFrame, &textFrame, 3 + [image size].width, NSMinXEdge); - if (NSMouseInRect(point, imageFrame, [controlView isFlipped])) - return NSCellHitContentArea | NSCellHitTrackableArea; - - return [super hitTestForEvent:event inRect:cellFrame ofView:controlView]; -} - -+ (BOOL)prefersTrackingUntilMouseUp -{ - // NSCell returns NO for this by default. If you want to have trackMouse:inRect:ofView:untilMouseUp: always track until the mouse is up, then you MUST return YES. Otherwise, strange things will happen. - return YES; -} - -- (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView:(NSView *)controlView untilMouseUp:(BOOL)flag -{ - [self setControlView:controlView]; - - NSRect textFrame, imageFrame; - NSDivideRect (cellFrame, &imageFrame, &textFrame, 3 + [image size].width, NSMinXEdge); - while ([theEvent type] != NSLeftMouseUp) { - // This is VERY simple event tracking. We simply check to see if the mouse is in the "i" button or not and dispatch entered/exited mouse events - NSPoint point = [controlView convertPoint:[theEvent locationInWindow] fromView:nil]; - BOOL mouseInButton = NSMouseInRect(point, imageFrame, [controlView isFlipped]); - if (mouseDownInButton != mouseInButton) { - mouseDownInButton = mouseInButton; - [controlView setNeedsDisplayInRect:cellFrame]; - } - if ([theEvent type] == NSMouseEntered || [theEvent type] == NSMouseExited) - [NSApp sendEvent:theEvent]; - // Note that we process mouse entered and exited events and dispatch them to properly handle updates - theEvent = [[controlView window] nextEventMatchingMask:(NSLeftMouseUpMask | NSLeftMouseDraggedMask | NSMouseEnteredMask | NSMouseExitedMask)]; - } - - // Another way of implementing the above code would be to keep an NSButtonCell as an ivar, and simply call trackMouse:inRect:ofView:untilMouseUp: on it, if the tracking area was inside of it. - if (mouseDownInButton) { - // Send the action, and redisplay - mouseDownInButton = NO; - [controlView setNeedsDisplayInRect:cellFrame]; - if (self.action) - [NSApp sendAction:self.action to:self.target from:self]; - } - - // We return YES since the mouse was released while we were tracking. Not returning YES when you processed the mouse up is an easy way to introduce bugs! - return YES; -} +//+ (BOOL)prefersTrackingUntilMouseUp +//{ +// // NSCell returns NO for this by default. If you want to have trackMouse:inRect:ofView:untilMouseUp: always track until the mouse is up, then you MUST return YES. Otherwise, strange things will happen. +// return YES; +//} +// +//- (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView:(NSView *)controlView untilMouseUp:(BOOL)flag +//{ +// [self setControlView:controlView]; +// +// NSRect textFrame, imageFrame; +// NSDivideRect (cellFrame, &imageFrame, &textFrame, 3 + [image size].width, NSMinXEdge); +// while ([theEvent type] != NSLeftMouseUp) { +// // This is VERY simple event tracking. We simply check to see if the mouse is in the "i" button or not and dispatch entered/exited mouse events +// NSPoint point = [controlView convertPoint:[theEvent locationInWindow] fromView:nil]; +// BOOL mouseInButton = NSMouseInRect(point, imageFrame, [controlView isFlipped]); +// if (mouseDownInButton != mouseInButton) { +// mouseDownInButton = mouseInButton; +// [controlView setNeedsDisplayInRect:cellFrame]; +// } +// if ([theEvent type] == NSMouseEntered || [theEvent type] == NSMouseExited) +// [NSApp sendEvent:theEvent]; +// // Note that we process mouse entered and exited events and dispatch them to properly handle updates +// theEvent = [[controlView window] nextEventMatchingMask:(NSLeftMouseUpMask | NSLeftMouseDraggedMask | NSMouseEnteredMask | NSMouseExitedMask)]; +// } +// +// // Another way of implementing the above code would be to keep an NSButtonCell as an ivar, and simply call trackMouse:inRect:ofView:untilMouseUp: on it, if the tracking area was inside of it. +// if (mouseDownInButton) { +// // Send the action, and redisplay +// mouseDownInButton = NO; +// [controlView setNeedsDisplayInRect:cellFrame]; +// if (self.action) +// [NSApp sendAction:self.action to:self.target from:self]; +// } +// +// // We return YES since the mouse was released while we were tracking. Not returning YES when you processed the mouse up is an easy way to introduce bugs! +// return YES; +//} @end diff --git a/PBPrefsWindowController.h b/PBPrefsWindowController.h index ed65d38..5176c3f 100644 --- a/PBPrefsWindowController.h +++ b/PBPrefsWindowController.h @@ -27,5 +27,6 @@ - (void)pathCell:(NSPathCell *)pathCell willDisplayOpenPanel:(NSOpenPanel *)openPanel; - (IBAction) showHideAllFiles: sender; - (IBAction) resetGitPath: sender; +- (IBAction)resetAllDialogWarnings:(id)sender; @end diff --git a/PBPrefsWindowController.m b/PBPrefsWindowController.m index aefec82..7b8eca0 100644 --- a/PBPrefsWindowController.m +++ b/PBPrefsWindowController.m @@ -8,6 +8,7 @@ #import "PBPrefsWindowController.h" #import "PBGitRepository.h" +#import "PBGitDefaults.h" #define kPreferenceViewIdentifier @"PBGitXPreferenceViewIdentifier" @@ -68,6 +69,11 @@ gitPathOpenPanel = openPanel; } +- (IBAction)resetAllDialogWarnings:(id)sender +{ + [PBGitDefaults resetAllDialogWarnings]; +} + #pragma mark - #pragma mark Git Path open panel actions diff --git a/PBRefController.m b/PBRefController.m index c9b8c2e..2ca8941 100644 --- a/PBRefController.m +++ b/PBRefController.m @@ -14,6 +14,14 @@ #import "PBGitDefaults.h" #import "PBDiffWindowController.h" +#import "PBArgumentPickerController.h" + +#define kDialogAcceptDroppedRef @"Accept Dropped Ref" +#define kDialogConfirmPush @"Confirm Push" +#define kDialogDeleteRef @"Delete Ref" + + + @implementation PBRefController - (void)awakeFromNib @@ -45,13 +53,18 @@ #pragma mark Push -- (void) showConfirmPushRefSheet:(PBGitRef *)ref remote:(PBGitRef *)remoteRef +- (void)showConfirmPushRefSheet:(PBGitRef *)ref remote:(PBGitRef *)remoteRef { if ((!ref && !remoteRef) || (ref && ![ref isBranch] && ![ref isRemoteBranch]) || (remoteRef && !([remoteRef refishType] == kGitXRemoteType))) return; + if ([PBGitDefaults isDialogWarningSuppressedForDialog:kDialogConfirmPush]) { + [historyController.repository beginPushRef:ref toRemote:remoteRef]; + return; + } + NSString *description = nil; if (ref && remoteRef) description = [NSString stringWithFormat:@"Push %@ '%@' to remote %@", [ref refishType], [ref shortName], [remoteRef remoteName]]; @@ -66,6 +79,7 @@ alternateButton:@"Cancel" otherButton:nil informativeTextWithFormat:@"Are you sure you want to %@?", sdesc]; + [alert setShowsSuppressionButton:YES]; NSMutableDictionary *info = [NSMutableDictionary dictionary]; if (ref) @@ -79,10 +93,13 @@ contextInfo:info]; } -- (void) confirmPushRefSheetDidEnd:(NSAlert *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo +- (void)confirmPushRefSheetDidEnd:(NSAlert *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { [[sheet window] orderOut:nil]; + if ([[sheet suppressionButton] state] == NSOnState) + [PBGitDefaults suppressDialogWarningForDialog:kDialogConfirmPush]; + if (returnCode == NSAlertDefaultReturn) { PBGitRef *ref = [(NSDictionary *)contextInfo objectForKey:kGitXBranchType]; PBGitRef *remoteRef = [(NSDictionary *)contextInfo objectForKey:kGitXRemoteType]; @@ -212,7 +229,7 @@ } - (void) showTagInfoSheet:(PBRefMenuItem *)sender -{ +{ if ([[sender refish] refishType] != kGitXTagType) return; @@ -230,12 +247,18 @@ #pragma mark Remove a branch, remote or tag -- (void) showDeleteRefSheet:(PBRefMenuItem *)sender +- (void)showDeleteRefSheet:(PBRefMenuItem *)sender { if ([[sender refish] refishType] == kGitXCommitType) return; PBGitRef *ref = (PBGitRef *)[sender refish]; + + if ([PBGitDefaults isDialogWarningSuppressedForDialog:kDialogDeleteRef]) { + [historyController.repository deleteRef:ref]; + return; + } + NSString *ref_desc = [NSString stringWithFormat:@"%@ '%@'", [ref refishType], [ref shortName]]; NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:@"Delete %@?", ref_desc] @@ -243,6 +266,7 @@ alternateButton:@"Cancel" otherButton:nil informativeTextWithFormat:@"Are you sure you want to remove the %@?", ref_desc]; + [alert setShowsSuppressionButton:YES]; [alert beginSheetModalForWindow:[historyController.repository.windowController window] modalDelegate:self @@ -250,10 +274,13 @@ contextInfo:ref]; } -- (void) deleteRefSheetDidEnd:(NSAlert *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo +- (void)deleteRefSheetDidEnd:(NSAlert *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { [[sheet window] orderOut:nil]; + if ([[sheet suppressionButton] state] == NSOnState) + [PBGitDefaults suppressDialogWarningForDialog:kDialogDeleteRef]; + if (returnCode == NSAlertDefaultReturn) { PBGitRef *ref = (PBGitRef *)contextInfo; [historyController.repository deleteRef:ref]; @@ -347,6 +374,7 @@ [dropCommit addRef:ref]; [oldCommit removeRef:ref]; + [historyController.commitList reloadData]; } - (BOOL)tableView:(NSTableView *)aTableView @@ -379,7 +407,7 @@ dropCommit, @"dropCommit", nil]; - if ([PBGitDefaults suppressAcceptDropRef]) { + if ([PBGitDefaults isDialogWarningSuppressedForDialog:kDialogAcceptDroppedRef]) { [self dropRef:dropInfo]; return YES; } @@ -404,7 +432,7 @@ return YES; } -- (void) acceptDropInfoAlertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo +- (void)acceptDropInfoAlertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { [[alert window] orderOut:nil]; @@ -412,7 +440,7 @@ [self dropRef:contextInfo]; if ([[alert suppressionButton] state] == NSOnState) - [PBGitDefaults setSuppressAcceptDropRef:YES]; + [PBGitDefaults suppressDialogWarningForDialog:kDialogAcceptDroppedRef]; } @end diff --git a/PBRefMenuItem.m b/PBRefMenuItem.m index 083de7b..aaaee1f 100644 --- a/PBRefMenuItem.m +++ b/PBRefMenuItem.m @@ -8,6 +8,9 @@ #import "PBRefMenuItem.h" +#import "PBStashCommandFactory.h" +#import "PBCommandMenuItem.h" + @implementation PBRefMenuItem @synthesize refish; @@ -133,7 +136,7 @@ [items addObject:[PBRefMenuItem separatorItem]]; NSString *deleteTitle = [NSString stringWithFormat:@"Delete %@…", targetRefName]; [items addObject:[PBRefMenuItem itemWithTitle:deleteTitle action:@selector(showDeleteRefSheet:) enabled:!isDetachedHead]]; - + for (PBRefMenuItem *item in items) { [item setTarget:target]; [item setRefish:ref]; diff --git a/PBSourceViewCell.h b/PBSourceViewCell.h index 5b88392..f9ef694 100644 --- a/PBSourceViewCell.h +++ b/PBSourceViewCell.h @@ -12,8 +12,14 @@ @interface PBSourceViewCell : PBIconAndTextCell { BOOL isCheckedOut; + BOOL showsActionButton; + + BOOL iMouseDownInInfoButton; + BOOL iMouseHoveredInInfoButton; + SEL iInfoButtonAction; } - +@property (nonatomic) BOOL showsActionButton; +@property (nonatomic) SEL iInfoButtonAction; @property (assign) BOOL isCheckedOut; @end diff --git a/PBSourceViewCell.m b/PBSourceViewCell.m index eb60bca..fa7a88a 100644 --- a/PBSourceViewCell.m +++ b/PBSourceViewCell.m @@ -10,22 +10,32 @@ #import "PBGitSidebarController.h" #import "PBSourceViewBadge.h" - +@interface PBSourceViewCell() +- (NSRect)infoButtonRectForBounds:(NSRect)bounds; +@end @implementation PBSourceViewCell - +@synthesize iInfoButtonAction; @synthesize isCheckedOut; +@synthesize showsActionButton; # pragma mark context menu delegate methods +- init { + if (self = [super init]) { + + } + return self; +} + - (NSMenu *) menuForEvent:(NSEvent *)event inRect:(NSRect)rect ofView:(NSOutlineView *)view { - NSPoint point = [view convertPoint:[event locationInWindow] fromView:nil]; + NSPoint point = [self.controlView convertPoint:[event locationInWindow] fromView:nil]; NSInteger row = [view rowAtPoint:point]; PBGitSidebarController *controller = [view delegate]; - + return [controller menuForRow:row]; } @@ -33,7 +43,7 @@ #pragma mark drawing - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)outlineView -{ +{ if (isCheckedOut) { NSImage *checkedOutImage = [PBSourceViewBadge checkedOutBadgeForCell:self]; NSSize imageSize = [checkedOutImage size]; @@ -52,4 +62,152 @@ [super drawWithFrame:cellFrame inView:outlineView]; } + +#pragma mark - +#pragma mark Button support + +- (NSRect)infoButtonRectForBounds:(NSRect)bounds { + CGFloat infoButtonWidth = 17.0f; + CGFloat infoButtonHeight = 11.0f; + return NSMakeRect(NSMaxX(bounds) - infoButtonWidth, NSMinY(bounds) + (NSHeight(bounds) - infoButtonHeight)/2.0f, infoButtonWidth, infoButtonHeight); +} + +- (NSImage *)infoButtonImage { + // Construct an image name based on our current state + NSString *imageName = [NSString stringWithFormat:@"sourceListAction%@.png", + //[self isHighlighted] ? @"selected" : @"normal", + iMouseDownInInfoButton ? @"Over" : + iMouseHoveredInInfoButton ? @"Over" : @""]; + return [NSImage imageNamed:imageName]; +} + +- (void)drawInteriorWithFrame:(NSRect)bounds inView:(NSView *)controlView { + [super drawInteriorWithFrame:bounds inView:controlView]; + + if (showsActionButton) { + NSRect infoButtonRect = [self infoButtonRectForBounds:bounds]; + NSImage *anImage = [self infoButtonImage]; + [anImage setFlipped:[controlView isFlipped]]; + [anImage drawInRect:infoButtonRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0]; + } +} + + +//- (NSUInteger)hitTestForEvent:(NSEvent *)event inRect:(NSRect)cellFrame ofView:(NSView *)controlView { +// if (showsActionButton) { +// NSPoint point = [controlView convertPoint:[event locationInWindow] fromView:nil]; +// // +// // NSRect titleRect = [self titleRectForBounds:cellFrame]; +// // if (NSMouseInRect(point, titleRect, [controlView isFlipped])) { +// // return NSCellHitContentArea | NSCellHitEditableTextArea; +// // } +// // +// // NSRect imageRect = [self imageRectForBounds:cellFrame]; +// // if (NSMouseInRect(point, imageRect, [controlView isFlipped])) { +// // return NSCellHitContentArea; +// // } +// // +// // // Did we hit the sub title? +// // NSAttributedString *attributedSubTitle = [self attributedSubTitle]; +// // if ([attributedSubTitle length] > 0) { +// // NSRect attributedSubTitleRect = [self rectForSubTitleBasedOnTitleRect:titleRect inBounds:cellFrame]; +// // if (NSMouseInRect(point, attributedSubTitleRect, [controlView isFlipped])) { +// // // Notice that this text isn't an editable area. Clicking on it won't begin an editing session. +// // return NSCellHitContentArea; +// // } +// // } +// +// // How about the info button? +// NSRect infoButtonRect = [self infoButtonRectForBounds:cellFrame]; +// if (NSMouseInRect(point, infoButtonRect, [controlView isFlipped])) { +// return NSCellHitContentArea | NSCellHitTrackableArea; +// } +// } +// +// return [super hitTestForEvent:event inRect:cellFrame ofView:controlView]; +//} + +//+ (BOOL)prefersTrackingUntilMouseUp { +// // NSCell returns NO for this by default. If you want to have trackMouse:inRect:ofView:untilMouseUp: always track until the mouse is up, then you MUST return YES. Otherwise, strange things will happen. +// return YES; +//} + +// Mouse tracking -- the only part we want to track is the "info" button +- (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView:(NSView *)controlView untilMouseUp:(BOOL)flag { +// [self setControlView:controlView]; +// + NSRect infoButtonRect = [self infoButtonRectForBounds:cellFrame]; + if ([theEvent type] != NSLeftMouseUp) { + // This is VERY simple event tracking. We simply check to see if the mouse is in the "i" button or not and dispatch entered/exited mouse events + NSPoint point = [controlView convertPoint:[theEvent locationInWindow] fromView:nil]; + BOOL mouseInButton = NSMouseInRect(point, infoButtonRect, [controlView isFlipped]); + if (iMouseDownInInfoButton != mouseInButton) { + iMouseDownInInfoButton = mouseInButton; + [controlView setNeedsDisplayInRect:cellFrame]; + } + if ([theEvent type] == NSMouseEntered || [theEvent type] == NSMouseExited) { + [NSApp sendEvent:theEvent]; + } + // Note that we process mouse entered and exited events and dispatch them to properly handle updates + theEvent = [[controlView window] nextEventMatchingMask:(NSLeftMouseUpMask | NSLeftMouseDraggedMask | NSMouseEnteredMask | NSMouseExitedMask)]; + } + + // Another way of implementing the above code would be to keep an NSButtonCell as an ivar, and simply call trackMouse:inRect:ofView:untilMouseUp: on it, if the tracking area was inside of it. + + NSPoint locationOfTouch = [controlView convertPoint:[theEvent locationInWindow] fromView:nil]; + + BOOL mouseInButton = NSMouseInRect(locationOfTouch, [self infoButtonRectForBounds:cellFrame], [controlView isFlipped]); + if (mouseInButton) { + // show menu + NSMenu *menu = [self menuForEvent:theEvent inRect:cellFrame ofView:controlView]; + if (menu){ + [NSMenu popUpContextMenu:menu withEvent:theEvent forView:controlView]; + } + } + + if (iMouseDownInInfoButton) { + // Send the action, and redisplay + iMouseDownInInfoButton = NO; + [controlView setNeedsDisplayInRect:cellFrame]; + } + + return [super trackMouse:theEvent inRect:cellFrame ofView:controlView untilMouseUp:flag]; + + +// +// // We return YES since the mouse was released while we were tracking. Not returning YES when you processed the mouse up is an easy way to introduce bugs! +// return YES; +} + + +// Mouse movement tracking -- we have a custom NSOutlineView subclass that automatically lets us add mouseEntered:/mouseExited: support to any cell! +- (void)addTrackingAreasForView:(NSView *)controlView inRect:(NSRect)cellFrame withUserInfo:(NSDictionary *)userInfo mouseLocation:(NSPoint)mouseLocation { + NSRect infoButtonRect = [self infoButtonRectForBounds:cellFrame]; + + NSTrackingAreaOptions options = NSTrackingEnabledDuringMouseDrag | NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways; + + BOOL mouseIsInside = NSMouseInRect(mouseLocation, infoButtonRect, [controlView isFlipped]); + if (mouseIsInside) { + options |= NSTrackingAssumeInside; + [controlView setNeedsDisplayInRect:cellFrame]; + } + + // We make the view the owner, and it delegates the calls back to the cell after it is properly setup for the corresponding row/column in the outlineview + NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:infoButtonRect options:options owner:controlView userInfo:userInfo]; + [controlView addTrackingArea:area]; + [area release]; +} + +- (void)mouseEntered:(NSEvent *)event { + iMouseHoveredInInfoButton = YES; + [(NSControl *)[self controlView] updateCell:self]; +} + +- (void)mouseExited:(NSEvent *)event { + iMouseHoveredInInfoButton = NO; + [(NSControl *)[self controlView] updateCell:self]; +} + + + @end diff --git a/PBSourceViewItem.h b/PBSourceViewItem.h index 399f8e7..cf97d4b 100644 --- a/PBSourceViewItem.h +++ b/PBSourceViewItem.h @@ -20,7 +20,10 @@ BOOL isGroupItem; BOOL isUncollapsible; + + BOOL showsActionButton; } +@property (nonatomic) BOOL showsActionButton; + (id)groupItemWithTitle:(NSString *)title; + (id)itemWithRevSpec:(PBGitRevSpecifier *)revSpecifier; diff --git a/PBSourceViewItem.m b/PBSourceViewItem.m index 5d450fb..aa756e0 100644 --- a/PBSourceViewItem.m +++ b/PBSourceViewItem.m @@ -12,6 +12,7 @@ @implementation PBSourceViewItem @synthesize parent, title, isGroupItem, children, revSpecifier, isUncollapsible; +@synthesize showsActionButton; @dynamic icon; - (id)init diff --git a/PBStashController.h b/PBStashController.h new file mode 100644 index 0000000..f6f6a60 --- /dev/null +++ b/PBStashController.h @@ -0,0 +1,31 @@ +// +// PBStashController.h +// GitX +// +// Created by Tomasz Krasnyk on 10-11-27. +// Copyright (c) 2010 __MyCompanyName__. All rights reserved. +// + +#import +#import "PBGitStash.h" + +@class PBGitRepository; + +@interface PBStashController : NSObject { + NSArray *stashes; +@private + PBGitRepository *repository; +} +@property (nonatomic, retain, readonly) NSArray *stashes; + +- (id) initWithRepository:(PBGitRepository *) repo; + +- (void) reload; + +- (NSArray *) menu; + +// actions +- (void) stashLocalChanges; +- (void) clearAllStashes; + +@end diff --git a/PBStashController.m b/PBStashController.m new file mode 100644 index 0000000..eccde18 --- /dev/null +++ b/PBStashController.m @@ -0,0 +1,110 @@ +// +// PBStashController.m +// GitX +// +// Created by Tomasz Krasnyk on 10-11-27. +// Copyright (c) 2010 __MyCompanyName__. All rights reserved. +// + +#import "PBStashController.h" +#import "PBGitRepository.h" +#import "PBCommand.h" +#import "PBCommandWithParameter.h" + +static NSString * const kCommandName = @"stash"; + +@interface PBStashController() +@property (nonatomic, retain) NSArray *stashes; +@end + + + +@implementation PBStashController +@synthesize stashes; + +- (id) initWithRepository:(PBGitRepository *) repo { + if (self = [super init]){ + repository = [repo retain]; + } + return self; +} + +- (void)dealloc { + [repository release]; + [stashes release]; + [super dealloc]; +} + +- (void) reload { + NSArray *arguments = [NSArray arrayWithObjects:kCommandName, @"list", nil]; + NSString *output = [repository outputInWorkdirForArguments:arguments]; + NSArray *lines = [output componentsSeparatedByString:@"\n"]; + + NSMutableArray *loadedStashes = [[NSMutableArray alloc] initWithCapacity:[lines count]]; + + for (NSString *stashLine in lines) { + if ([stashLine length] == 0) + continue; + PBGitStash *stash = [[PBGitStash alloc] initWithRawStashLine:stashLine]; + [loadedStashes addObject:stash]; + [stash release]; + } + + self.stashes = loadedStashes; + [loadedStashes release]; +} + +#pragma mark Actions + +- (void) stashLocalChanges { + NSArray *args = [NSArray arrayWithObject:kCommandName]; + PBCommand *command = [[PBCommand alloc] initWithDisplayName:@"Stash local changes..." parameters:args repository:repository]; + command.commandTitle = command.displayName; + command.commandDescription = @"Stashing local changes"; + + PBCommandWithParameter *cmd = [[PBCommandWithParameter alloc] initWithCommand:command parameterName:@"save" parameterDisplayName:@"Stash message (optional)"]; + [command release]; + + [cmd invoke]; + [cmd release]; +} + +- (void) clearAllStashes { + PBCommand *command = [[PBCommand alloc] initWithDisplayName:@"Clear stashes" parameters:[NSArray arrayWithObjects:kCommandName, @"clear", nil] repository:repository]; + command.commandTitle = command.displayName; + command.commandDescription = @"Clearing stashes"; + [command invoke]; + [command release]; +} + +#pragma mark Menu + +- (NSArray *) menu { + NSMutableArray *array = [[NSMutableArray alloc] init]; + + NSMenuItem *stashChanges = [[NSMenuItem alloc] initWithTitle:@"Stash local changes..." action:@selector(stashLocalChanges) keyEquivalent:@""]; + [stashChanges setTarget:self]; + NSMenuItem *clearStashes = [[NSMenuItem alloc] initWithTitle:@"Clear stashes" action:@selector(clearAllStashes) keyEquivalent:@""]; + [clearStashes setTarget:self]; + + [array addObject:stashChanges]; + [array addObject:clearStashes]; + + return array; +} + +- (BOOL) validateMenuItem:(NSMenuItem *) item { + SEL action = [item action]; + BOOL shouldBeEnabled = YES; + + if (action == @selector(stashLocalChanges)) { + //TODO: check if we have unstaged changes + } else if (action == @selector(clearAllStashes)) { + shouldBeEnabled = [self.stashes count] > 0; + } + + return shouldBeEnabled; +} + + +@end diff --git a/View/CellTrackingRect.h b/View/CellTrackingRect.h new file mode 100644 index 0000000..83aec4c --- /dev/null +++ b/View/CellTrackingRect.h @@ -0,0 +1,64 @@ +/* + + File: CellTrackingRect.h + + Abstract: This file provides a simple informal protocol for an NSCell. + If the cell implements these methods, it can automatically respond + to tracking area events generated by the TrackableOutlineView. + + Version: 1.0 + + Disclaimer: IMPORTANT: This Apple software is supplied to you by + Apple Inc. ("Apple") in consideration of your agreement to the + following terms, and your use, installation, modification or + redistribution of this Apple software constitutes acceptance of these + terms. If you do not agree with these terms, please do not use, + install, modify or redistribute this Apple software. + + In consideration of your agreement to abide by the following terms, and + subject to these terms, Apple grants you a personal, non-exclusive + license, under Apple's copyrights in this original Apple software (the + "Apple Software"), to use, reproduce, modify and redistribute the Apple + Software, with or without modifications, in source and/or binary forms; + provided that if you redistribute the Apple Software in its entirety and + without modifications, you must retain this notice and the following + text and disclaimers in all such redistributions of the Apple Software. + Neither the name, trademarks, service marks or logos of Apple Inc. + may be used to endorse or promote products derived from the Apple + Software without specific prior written permission from Apple. Except + as expressly stated in this notice, no other rights or licenses, express + or implied, are granted by Apple herein, including but not limited to + any patent rights that may be infringed by your derivative works or by + other works in which the Apple Software may be incorporated. + + The Apple Software is provided by Apple on an "AS IS" basis. APPLE + MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION + THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND + OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, + MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED + AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), + STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + Copyright (C) 2006-2007 Apple Inc. All Rights Reserved. + */ + +#import + +@interface NSCell (CellTrackingRect) + +/* When called by the control, it is the cell's responsibility to add tracking areas that it wishes to respond to. The cell will then get the appropriate mouse messages sent to it from the control. The owner for the NSTrackingArea must be the control. The userInfo can be copied and have additional things added to it by the cell, if required. +*/ +- (void)addTrackingAreasForView:(NSView *)view inRect:(NSRect)cellFrame withUserInfo:(NSDictionary *)userInfo mouseLocation:(NSPoint)currentPoint; + +- (void)mouseEntered:(NSEvent *)event; +- (void)mouseExited:(NSEvent *)event; + +@end + diff --git a/View/PBArgumentPicker.h b/View/PBArgumentPicker.h new file mode 100644 index 0000000..a273efa --- /dev/null +++ b/View/PBArgumentPicker.h @@ -0,0 +1,24 @@ +// +// PBArgumentPicker.h +// GitX +// +// Created by Tomasz Krasnyk on 10-11-06. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import + + +@interface PBArgumentPicker : NSView { + IBOutlet NSTextField *textField; + IBOutlet NSTextField *label; + IBOutlet NSButton *okButton; + IBOutlet NSButton *cancelButton; +} +@property (nonatomic, retain, readonly) NSTextField *textField; +@property (nonatomic, retain, readonly) NSTextField *label; +@property (nonatomic, retain, readonly) NSButton *okButton; +@property (nonatomic, retain, readonly) NSButton *cancelButton; + + +@end diff --git a/View/PBArgumentPicker.m b/View/PBArgumentPicker.m new file mode 100644 index 0000000..2902715 --- /dev/null +++ b/View/PBArgumentPicker.m @@ -0,0 +1,27 @@ +// +// PBArgumentPicker.m +// GitX +// +// Created by Tomasz Krasnyk on 10-11-06. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import "PBArgumentPicker.h" + + +@implementation PBArgumentPicker +@synthesize okButton; +@synthesize cancelButton; +@synthesize textField; +@synthesize label; + +- (id)initWithFrame:(NSRect)frame { + self = [super initWithFrame:frame]; + if (self) { + // Initialization code here. + } + return self; +} + + +@end diff --git a/View/TrackableOutlineView.h b/View/TrackableOutlineView.h new file mode 100644 index 0000000..a384d80 --- /dev/null +++ b/View/TrackableOutlineView.h @@ -0,0 +1,58 @@ +/* + + File: TrackableOutlineView.h + + Abstract: This TrackableOutlineView class declaration. + + Version: 1.0 + + Disclaimer: IMPORTANT: This Apple software is supplied to you by + Apple Inc. ("Apple") in consideration of your agreement to the + following terms, and your use, installation, modification or + redistribution of this Apple software constitutes acceptance of these + terms. If you do not agree with these terms, please do not use, + install, modify or redistribute this Apple software. + + In consideration of your agreement to abide by the following terms, and + subject to these terms, Apple grants you a personal, non-exclusive + license, under Apple's copyrights in this original Apple software (the + "Apple Software"), to use, reproduce, modify and redistribute the Apple + Software, with or without modifications, in source and/or binary forms; + provided that if you redistribute the Apple Software in its entirety and + without modifications, you must retain this notice and the following + text and disclaimers in all such redistributions of the Apple Software. + Neither the name, trademarks, service marks or logos of Apple Inc. + may be used to endorse or promote products derived from the Apple + Software without specific prior written permission from Apple. Except + as expressly stated in this notice, no other rights or licenses, express + or implied, are granted by Apple herein, including but not limited to + any patent rights that may be infringed by your derivative works or by + other works in which the Apple Software may be incorporated. + + The Apple Software is provided by Apple on an "AS IS" basis. APPLE + MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION + THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND + OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, + MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED + AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), + STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + Copyright (C) 2006-2007 Apple Inc. All Rights Reserved. +*/ + +#import + +@interface TrackableOutlineView : NSOutlineView +{ +@private + NSInteger iMouseRow, iMouseCol; + NSCell *iMouseCell; +} +@end diff --git a/View/TrackableOutlineView.m b/View/TrackableOutlineView.m new file mode 100644 index 0000000..6af3925 --- /dev/null +++ b/View/TrackableOutlineView.m @@ -0,0 +1,185 @@ +/* + + File: TrackableOutlineView.m + + Abstract: The TrackableOutlineView provides an implementation of updateTrackingAreas + that automatically delegates to cells which implement the informal + CellTrackingRect protocol. + + Version: 1.0 + + Disclaimer: IMPORTANT: This Apple software is supplied to you by + Apple Inc. ("Apple") in consideration of your agreement to the + following terms, and your use, installation, modification or + redistribution of this Apple software constitutes acceptance of these + terms. If you do not agree with these terms, please do not use, + install, modify or redistribute this Apple software. + + In consideration of your agreement to abide by the following terms, and + subject to these terms, Apple grants you a personal, non-exclusive + license, under Apple's copyrights in this original Apple software (the + "Apple Software"), to use, reproduce, modify and redistribute the Apple + Software, with or without modifications, in source and/or binary forms; + provided that if you redistribute the Apple Software in its entirety and + without modifications, you must retain this notice and the following + text and disclaimers in all such redistributions of the Apple Software. + Neither the name, trademarks, service marks or logos of Apple Inc. + may be used to endorse or promote products derived from the Apple + Software without specific prior written permission from Apple. Except + as expressly stated in this notice, no other rights or licenses, express + or implied, are granted by Apple herein, including but not limited to + any patent rights that may be infringed by your derivative works or by + other works in which the Apple Software may be incorporated. + + The Apple Software is provided by Apple on an "AS IS" basis. APPLE + MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION + THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND + OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, + MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED + AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), + STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + Copyright (C) 2006-2007 Apple Inc. All Rights Reserved. + */ + +#import "TrackableOutlineView.h" + +#import +#import "CellTrackingRect.h" +#import "PBGitSidebarController.h" + +@implementation TrackableOutlineView + +- (id)init { + self = [super init]; + if (self) { + iMouseRow = -1; + iMouseCol = -1; + } + return self; +} + +- (id)initWithCoder:(NSCoder *)coder { + self = [super initWithCoder:coder]; + if (self) { + iMouseRow = -1; + iMouseCol = -1; + } + return self; +} + +- (void)dealloc { + [iMouseCell release]; + [super dealloc]; +} + +// Tracking rect support + +- (void)updateTrackingAreas { + for (NSTrackingArea *area in [self trackingAreas]) { + // We have to uniquely identify our own tracking areas + if (([area owner] == self) && ([[area userInfo] objectForKey:@"Row"] != nil)) { + [self removeTrackingArea:area]; + } + } + + // Find the visible cells that have a non-empty tracking rect and add rects for each of them + NSRange visibleRows = [self rowsInRect:[self visibleRect]]; + NSIndexSet *visibleColIndexes = [self columnIndexesInRect:[self visibleRect]]; + + NSPoint mouseLocation = [self convertPoint:[[self window] convertScreenToBase:[NSEvent mouseLocation]] fromView:nil]; + NSInteger row; + for (row = visibleRows.location; row < visibleRows.location + visibleRows.length; row++ ) { + // If it is a "full width" cell, we don't have to go through the rows + NSCell *fullWidthCell = [self preparedCellAtColumn:-1 row:row]; + if (fullWidthCell) { + if ([fullWidthCell respondsToSelector:@selector(addTrackingAreasForView:inRect:withUserInfo:mouseLocation:)]) { + NSInteger col = -1; + NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInteger:col], @"Col", [NSNumber numberWithInteger:row], @"Row", nil]; + [fullWidthCell addTrackingAreasForView:self inRect:[self frameOfCellAtColumn:col row:row] withUserInfo:userInfo mouseLocation:mouseLocation]; + } + } else { + NSInteger col; + for (col = [visibleColIndexes firstIndex]; col != NSNotFound; col = [visibleColIndexes indexGreaterThanIndex:col]) { + NSCell *cell = [self preparedCellAtColumn:col row:row]; + if ([cell respondsToSelector:@selector(addTrackingAreasForView:inRect:withUserInfo:mouseLocation:)]) { + NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInteger:col], @"Col", [NSNumber numberWithInteger:row], @"Row", nil]; + [cell addTrackingAreasForView:self inRect:[self frameOfCellAtColumn:col row:row] withUserInfo:userInfo mouseLocation:mouseLocation]; + } + } + } + } +} + +- (void)mouseEntered:(NSEvent *)event { + // Delegate this to the appropriate cell. In order to allow the cell to maintain state, we copy it and use the copy until the mouse is moved outside of the cell. + NSDictionary *userInfo = [event userData]; + NSNumber *row = [userInfo valueForKey:@"Row"]; + NSNumber *col = [userInfo valueForKey:@"Col"]; + if (row && col) { + NSInteger rowVal = [row integerValue]; + NSInteger colVal = [col integerValue]; + NSCell *cell = [self preparedCellAtColumn:colVal row:rowVal]; + // Only set the mouseCell properties AFTER calling preparedCellAtColumn:row:. + if (iMouseCell != cell) { + [iMouseCell release]; + // Store off the col/row + iMouseCol = colVal; + iMouseRow = rowVal; + // Store a COPY of the cell for use when tracking in an area + iMouseCell = [cell copy]; + [iMouseCell setControlView:self]; + if ([iMouseCell respondsToSelector:@selector(mouseEntered:)]) { + [iMouseCell mouseEntered:event]; + } + } + } +} + +- (void)mouseExited:(NSEvent *)event { + NSDictionary *userInfo = [event userData]; + NSNumber *row = [userInfo valueForKey:@"Row"]; + NSNumber *col = [userInfo valueForKey:@"Col"]; + if (row && col) { + NSCell *cell = [self preparedCellAtColumn:[col integerValue] row:[row integerValue]]; + [cell setControlView:self]; + if ([cell respondsToSelector:@selector(mouseExited:)]) { + [cell mouseExited:event]; + } + // We are now done with the copied cell + [iMouseCell release]; + iMouseCell = nil; + iMouseCol = -1; + iMouseRow = -1; + } +} + +/* Since NSTableView/NSOutineView uses the same cell to "stamp" out each row, we need to send the mouseEntered/mouseExited events each time it is drawn. The easy hook for this is the preparedCell method. +*/ +- (NSCell *)preparedCellAtColumn:(NSInteger)column row:(NSInteger)row { + // We check if the selectedCell is nil or not -- the selectedCell is a cell that is currently being edited or tracked. We don't want to return our override if we are in that state. + if ([self selectedCell] == nil && (row == iMouseRow) && (column == iMouseCol)) { + return iMouseCell; + } else { + return [super preparedCellAtColumn:column row:row]; + } +} + +/* In order for the cell to properly update itself with an "updateCell:" call, we must handle the "mouseCell" as a special case +*/ +- (void)updateCell:(NSCell *)aCell { + if (aCell == iMouseCell) { + [self setNeedsDisplayInRect:[self frameOfCellAtColumn:iMouseCol row:iMouseRow]]; + } else { + [super updateCell:aCell]; + } +} + +@end diff --git a/gitx.m b/gitx.m index 3230d01..8c1ae4e 100644 --- a/gitx.m +++ b/gitx.m @@ -124,9 +124,9 @@ void handleSTDINDiff() } } -void handleDiffWithArguments(NSURL *repositoryURL, NSMutableArray *arguments) +void handleDiffWithArguments(NSURL *repositoryURL, NSArray *arguments) { - [arguments insertObject:@"diff" atIndex:0]; + arguments = [[NSArray arrayWithObjects:@"diff", @"--no-ext-diff", nil] arrayByAddingObjectsFromArray:arguments]; int retValue = 1; NSString *diffOutput = [PBEasyPipe outputForCommand:[PBGitBinary path] withArgs:arguments inDir:[repositoryURL path] retValue:&retValue]; diff --git a/html/views/history/history.js b/html/views/history/history.js index c0ac4c6..225e590 100644 --- a/html/views/history/history.js +++ b/html/views/history/history.js @@ -107,7 +107,7 @@ var gistie = function() { var t = new XMLHttpRequest(); t.onreadystatechange = function() { if (t.readyState == 4 && t.status >= 200 && t.status < 300) { - if (m = t.responseText.match(/gist: ([a-f0-9]+)/)) + if (m = t.responseText.match(//)) notify("Code uploaded to gistie #" + m[1] + "", 1); else { notify("Pasting to Gistie failed :(.", -1); @@ -116,7 +116,7 @@ var gistie = function() { } } - t.open('POST', "http://gist.github.com/gists"); + t.open('POST', "https://gist.github.com/gists"); t.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); t.setRequestHeader('Accept', 'text/javascript, text/html, application/xml, text/xml, */*'); t.setRequestHeader('Content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); diff --git a/sourceListAction.png b/sourceListAction.png new file mode 100644 index 0000000..9122fc1 Binary files /dev/null and b/sourceListAction.png differ diff --git a/sourceListActionOver.png b/sourceListActionOver.png new file mode 100644 index 0000000..70e0cb0 Binary files /dev/null and b/sourceListActionOver.png differ diff --git a/submodule-empty.png b/submodule-empty.png new file mode 100644 index 0000000..c012e61 Binary files /dev/null and b/submodule-empty.png differ diff --git a/submodule-matching-index.png b/submodule-matching-index.png new file mode 100644 index 0000000..42d25ba Binary files /dev/null and b/submodule-matching-index.png differ diff --git a/submodule-notmatching-index.png b/submodule-notmatching-index.png new file mode 100644 index 0000000..d5abd30 Binary files /dev/null and b/submodule-notmatching-index.png differ