diff --git a/Commands/PBCommand.h b/Commands/PBCommand.h index ee92b27..4f63935 100644 --- a/Commands/PBCommand.h +++ b/Commands/PBCommand.h @@ -7,22 +7,28 @@ // #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; } +@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..e427372 100644 --- a/Commands/PBCommand.m +++ b/Commands/PBCommand.m @@ -7,29 +7,39 @@ // #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; - (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; } return self; } - (void) dealloc { + [repository release]; [commandDescription release]; [commandTitle release]; [parameters release]; @@ -37,8 +47,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..934c6e3 --- /dev/null +++ b/Commands/PBRemoteCommandFactory.m @@ -0,0 +1,38 @@ +// +// 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" + + +@implementation PBRemoteCommandFactory + ++ (NSArray *) commandsForSubmodule:(PBGitSubmodule *) submodule inRepository:(PBGitRepository *) repository { + NSMutableArray *commands = [[NSMutableArray alloc] init]; + + NSString *repoPath = [repository workingDirectory]; + + NSString *path = [repoPath stringByAppendingPathComponent:[submodule path]]; + + PBOpenDocumentCommand *command = [[PBOpenDocumentCommand alloc] initWithDocumentAbsolutePath:path]; + command.commandTitle = command.displayName; + command.commandDescription = @"Opening document"; + [commands addObject:command]; + + 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/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/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index 28ef783..3cf11aa 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -24,13 +24,22 @@ 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 */; }; + 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 */; }; 3BC07F4C0ED5A5C5009A7768 /* HistoryViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 3BC07F4A0ED5A5C5009A7768 /* HistoryViewTemplate.png */; }; 3BC07F4D0ED5A5C5009A7768 /* CommitViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 3BC07F4B0ED5A5C5009A7768 /* CommitViewTemplate.png */; }; 47DBDB580E94EDE700671A1E /* DBPrefsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 47DBDB570E94EDE700671A1E /* DBPrefsWindowController.m */; }; @@ -252,8 +261,8 @@ 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 = ""; }; + 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 = ""; }; @@ -265,8 +274,22 @@ 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 = ""; }; 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 = ""; }; @@ -549,6 +572,8 @@ 080E96DDFE201D6D7F000001 /* Classes */ = { isa = PBXGroup; children = ( + 21230EDF1285EF880046E5A1 /* Controller */, + 21230ED41285ED760046E5A1 /* View */, 21230D991285524C0046E5A1 /* Commands */, 21230D321284C4F10046E5A1 /* Model */, ); @@ -597,6 +622,8 @@ 21230D331284C5080046E5A1 /* PBGitStash.h */, 21230D341284C5080046E5A1 /* PBGitStash.m */, 21230D4D1284C92E0046E5A1 /* PBPresentable.h */, + 212311DB12872BF20046E5A1 /* PBGitSubmodule.h */, + 212311DC12872BF20046E5A1 /* PBGitSubmodule.m */, ); path = Model; sourceTree = ""; @@ -606,15 +633,37 @@ children = ( 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 */, + ); + path = View; + sourceTree = ""; + }; + 21230EDF1285EF880046E5A1 /* Controller */ = { + isa = PBXGroup; + children = ( + 21230EE01285EFB20046E5A1 /* PBArgumentPickerController.h */, + 21230EE11285EFB20046E5A1 /* PBArgumentPickerController.m */, + ); + path = Controller; + sourceTree = ""; + }; 29B97314FDCFA39411CA2CEA /* GitTest */ = { isa = PBXGroup; children = ( @@ -642,6 +691,9 @@ 29B97315FDCFA39411CA2CEA /* Other Sources */ = { isa = PBXGroup; children = ( + 2123121B128735E90046E5A1 /* submodule-notmatching-index.png */, + 2123121C128735E90046E5A1 /* submodule-matching-index.png */, + 2123121D128735E90046E5A1 /* submodule-empty.png */, D858108011274D28007F254B /* Branch.png */, D858108111274D28007F254B /* RemoteBranch.png */, D858108211274D28007F254B /* Tag.png */, @@ -695,6 +747,7 @@ D8FDD9F511432A12005647F6 /* PBCloneRepositoryPanel.xib */, 47DBDB680E94EF6500671A1E /* Preferences.xib */, F569AE920F2CBD7C00C2FFA7 /* Credits.html */, + 21230ED11285EB5A0046E5A1 /* PBArgumentPicker.xib */, F58DB55F10566E3900CFDF4A /* PBGitSidebarView.xib */, D8022FE711E124A0003C21F6 /* PBGitXMessageSheet.xib */, ); @@ -793,8 +846,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 */, @@ -1242,6 +1295,10 @@ D8F4AB7912298CE200D6D53C /* rewindImage.pdf 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 */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1392,12 +1449,17 @@ D8B4DC571220D1E4004166D6 /* PBHistorySearchController.m in Sources */, D8712A00122B14EC00012334 /* GitXTextFieldCell.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 */, ); 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..3d99fcb --- /dev/null +++ b/Model/PBGitSubmodule.h @@ -0,0 +1,34 @@ +// +// 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; +} +@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; +@end diff --git a/Model/PBGitSubmodule.m b/Model/PBGitSubmodule.m new file mode 100644 index 0000000..0d71bb3 --- /dev/null +++ b/Model/PBGitSubmodule.m @@ -0,0 +1,113 @@ +// +// 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; + +- (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 { + [name release]; + [path release]; + [checkedOutCommit release]; + [super dealloc]; +} + +#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/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/PBGitIndexController.m b/PBGitIndexController.m index d72e8bc..48d727c 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]; 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 986c0aa..85462fd 100644 --- a/PBGitRepository.h +++ b/PBGitRepository.h @@ -54,6 +54,7 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) { PBGitSHA* _headSha; NSArray *stashes; + NSArray *submodules; } - (void) cloneRepositoryToPath:(NSString *)path bare:(BOOL)isBare; @@ -140,4 +141,6 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) { @property (assign) PBGitRevSpecifier *currentBranch; @property (assign) NSInteger currentBranchFilter; @property (retain) NSMutableDictionary* refs; +@property (readonly) NSArray *stashes; +@property (readonly) NSArray *submodules; @end diff --git a/PBGitRepository.m b/PBGitRepository.m index 2d18d5d..23cc380 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -22,17 +22,20 @@ #import "PBHistorySearchController.h" #import "PBGitStash.h" +#import "PBGitSubmodule.h" NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; @interface PBGitRepository() @property (nonatomic, retain) NSArray *stashes; +@property (nonatomic, retain) NSArray *submodules; @end @implementation PBGitRepository @synthesize stashes; +@synthesize submodules; @synthesize revisionList, branches, currentBranch, refs, hasChanged, config; @synthesize currentBranchFilter; @@ -260,9 +263,11 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; NSString *output = [self outputInWorkdirForArguments:arguments]; NSArray *lines = [output componentsSeparatedByString:@"\n"]; - NSMutableArray *loadedStashes = [[NSMutableArray alloc] init]; + 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]; @@ -272,6 +277,23 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; [loadedStashes release]; } +- (void) reloadSubmodules { + + NSArray *arguments = [NSArray arrayWithObjects:@"submodule", @"status", @"--recursive", nil]; + NSString *output = [self 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]; + } + self.submodules = loadedSubmodules; +} + - (void) reloadRefs { _headRef = nil; @@ -307,6 +329,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; [self didChangeValueForKey:@"refs"]; [self reloadStashes]; + [self reloadSubmodules]; [[[self windowController] window] setTitle:[self displayName]]; } @@ -1166,11 +1189,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 68b5405..ad5967a 100644 --- a/PBGitSidebarController.h +++ b/PBGitSidebarController.h @@ -25,7 +25,7 @@ /* Specific things */ PBSourceViewItem *stage; - PBSourceViewItem *branches, *remotes, *tags, *others, *stashes; + PBSourceViewItem *branches, *remotes, *tags, *others, *stashes, *submodules; PBGitHistoryController *historyViewController; PBGitCommitController *commitViewController; diff --git a/PBGitSidebarController.m b/PBGitSidebarController.m index 81b696f..4a9c6ac 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 () @@ -57,7 +61,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:@"stashes" options:NSKeyValueObservingOptionNew context:kObservingContextStashes]; + [repository addObserver:self forKeyPath:@"submodules" options:NSKeyValueObservingOptionNew context:kObservingContextSubmodules]; + [self menuNeedsUpdate:[actionButton menu]]; @@ -75,6 +81,7 @@ static NSString * const kObservingContextStashes = @"stashesChanged"; [repository removeObserver:self forKeyPath:@"currentBranch"]; [repository removeObserver:self forKeyPath:@"branches"]; [repository removeObserver:self forKeyPath:@"stashes"]; + [repository removeObserver:self forKeyPath:@"submodules"]; [super closeView]; } @@ -100,14 +107,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 { @@ -268,6 +300,7 @@ static NSString * const kObservingContextStashes = @"stashesChanged"; 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 +311,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]; } @@ -345,9 +380,11 @@ static NSString * const kObservingContextStashes = @"stashesChanged"; - (NSMenu *) menuForRow:(NSInteger)row { 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; } diff --git a/PBRefController.m b/PBRefController.m index c9b8c2e..2f8c00d 100644 --- a/PBRefController.m +++ b/PBRefController.m @@ -14,6 +14,8 @@ #import "PBGitDefaults.h" #import "PBDiffWindowController.h" +#import "PBArgumentPickerController.h" + @implementation PBRefController - (void)awakeFromNib @@ -212,7 +214,7 @@ } - (void) showTagInfoSheet:(PBRefMenuItem *)sender -{ +{ if ([[sender refish] refishType] != kGitXTagType) return; diff --git a/PBRefMenuItem.m b/PBRefMenuItem.m index 083de7b..a42b5be 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,11 +136,21 @@ [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]; } + + NSArray *cmds = [PBStashCommandFactory commandsForObject:ref repository:repo]; + if ([cmds count] > 0) { + for (PBCommand *cmd in cmds) { + PBCommandMenuItem *item = [[PBCommandMenuItem alloc] initWithCommand:cmd]; + [item setEnabled:YES]; + [items addObject:item]; + [item release]; + } + } return items; } 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/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