Permalink
Browse files

• There's now a visible diff button, as a first step toward status wi…

…ndow convergence. Double-clicking continues to invoke diff as well. The UI is subject to change. Feedback welcome.

• Robust subtask launching. Right now, this means that diff failures will be described immediately in an alert rather than failing more-or-less silently. In the future, this will help avoid bogus status updates for failed Add/Remove commands.

• Be less sneaky/more safe about stealing artwork from the TM app.

git-svn-id: http://svn.textmate.org/trunk/Tools/CommitWindowProject@5537 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information...
1 parent 0c783c2 commit 7c0e6fd4d9630c980179e4978b7b197bab0d83bf Chris Thomas committed Oct 21, 2006
View
2 CXTextWithButtonStripCell.h
@@ -14,7 +14,7 @@
// • either @"title" NSString -- localized name of button
// OR @"icon" -- NSImage -- icon
// • @"menu" -- NSMenu -- if present, indicates that this button is a menu button
- // TODO: • @"invocation" -- NSInvocation -- required if this is a push button, useless for menu buttons
+ // • @"invocation" -- NSInvocation -- required if this is a push button, useless for menu buttons
//
NSMutableArray * fButtons;
UInt32 fButtonPressedIndex;
View
21 CXTextWithButtonStripCell.m
@@ -179,6 +179,21 @@ - (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView:(NSView *
inRect:cellFrame
ofView:controlView];
+ // Mouse up --> invoke the appropriate invocation, if any
+ if ([theEvent type] == NSLeftMouseUp)
+ {
+ if( hitButton != NSNotFound )
+ {
+ NSInvocation * invocation = [[fButtons objectAtIndex:fButtonPressedIndex] objectForKey:@"invocation"];
+
+ [invocation invoke];
+ }
+
+ fButtonPressedIndex = NSNotFound;
+ break;
+ }
+
+
// Exit early if the first hit wasn't a button
if( firstIteration && hitButton == NSNotFound )
{
@@ -219,12 +234,6 @@ - (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView:(NSView *
theEvent = [[controlView window] nextEventMatchingMask:(NSLeftMouseDraggedMask | NSLeftMouseUpMask)];
curPoint = [controlView convertPoint:[theEvent locationInWindow] fromView:nil];
- if ([theEvent type] == NSLeftMouseUp)
- {
- fButtonPressedIndex = NSNotFound;
- break;
- }
-
firstIteration = NO;
}
View
38 CommitWindow.xcodeproj/project.pbxproj
@@ -10,11 +10,13 @@
8316703B0A4DB58500199564 /* NSString+StatusString.m in Sources */ = {isa = PBXBuildFile; fileRef = 8316703A0A4DB58500199564 /* NSString+StatusString.m */; };
831670450A4DB70A00199564 /* CommitWindowCommandLine.m in Sources */ = {isa = PBXBuildFile; fileRef = 831670440A4DB70A00199564 /* CommitWindowCommandLine.m */; };
831C222407B6F2EC00397A7E /* CommitWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 831C222307B6F2EC00397A7E /* CommitWindowController.m */; };
+ 831FF4B50ADDC1BA00BD90C2 /* CXTextWithButtonStripCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 831FF4B40ADDC1BA00BD90C2 /* CXTextWithButtonStripCell.m */; };
83BDF3B207DD4165005AC50F /* CWTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 83BDF3B107DD4165005AC50F /* CWTextView.m */; };
- 83C8C89B0ADA89330070245F /* Action.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 83C8C8990ADA89320070245F /* Action.tiff */; };
- 83C8C89C0ADA89330070245F /* ActionPressed.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 83C8C89A0ADA89320070245F /* ActionPressed.tiff */; };
83C8C8A20ADA90140070245F /* CXMenuButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 83C8C8A10ADA90140070245F /* CXMenuButton.m */; };
83F6091D07B8A60400C21FE8 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83F6091C07B8A60400C21FE8 /* ApplicationServices.framework */; };
+ 83FF98860AE7CD7E00D83081 /* Action.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 83FF98830AE7CD7E00D83081 /* Action.tiff */; };
+ 83FF98870AE7CD7E00D83081 /* ActionPressed.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 83FF98840AE7CD7E00D83081 /* ActionPressed.tiff */; };
+ 83FF98CF0AE9AD5400D83081 /* NSTask+CXAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 83FF98CE0AE9AD5400D83081 /* NSTask+CXAdditions.m */; };
8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; };
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
@@ -35,13 +37,17 @@
831670440A4DB70A00199564 /* CommitWindowCommandLine.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommitWindowCommandLine.m; sourceTree = "<group>"; };
831C222207B6F2EC00397A7E /* CommitWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommitWindowController.h; sourceTree = "<group>"; };
831C222307B6F2EC00397A7E /* CommitWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommitWindowController.m; sourceTree = "<group>"; };
+ 831FF4B30ADDC1BA00BD90C2 /* CXTextWithButtonStripCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CXTextWithButtonStripCell.h; sourceTree = "<group>"; };
+ 831FF4B40ADDC1BA00BD90C2 /* CXTextWithButtonStripCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CXTextWithButtonStripCell.m; sourceTree = "<group>"; };
83BDF3B007DD4165005AC50F /* CWTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CWTextView.h; sourceTree = "<group>"; };
83BDF3B107DD4165005AC50F /* CWTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CWTextView.m; sourceTree = "<group>"; };
- 83C8C8990ADA89320070245F /* Action.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = Action.tiff; path = ../../../../../Applications/TextMate.app/Contents/Resources/Action.tiff; sourceTree = SOURCE_ROOT; };
- 83C8C89A0ADA89320070245F /* ActionPressed.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = ActionPressed.tiff; path = ../../../../../Applications/TextMate.app/Contents/Resources/ActionPressed.tiff; sourceTree = SOURCE_ROOT; };
83C8C8A00ADA900B0070245F /* CXMenuButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CXMenuButton.h; sourceTree = SOURCE_ROOT; };
83C8C8A10ADA90140070245F /* CXMenuButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CXMenuButton.m; sourceTree = SOURCE_ROOT; };
83F6091C07B8A60400C21FE8 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; };
+ 83FF98830AE7CD7E00D83081 /* Action.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Action.tiff; sourceTree = "<group>"; };
+ 83FF98840AE7CD7E00D83081 /* ActionPressed.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = ActionPressed.tiff; sourceTree = "<group>"; };
+ 83FF98CE0AE9AD5400D83081 /* NSTask+CXAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSTask+CXAdditions.m"; sourceTree = "<group>"; };
+ 83FF98D00AE9AD5B00D83081 /* NSTask+CXAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSTask+CXAdditions.h"; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
8D1107320486CEB800E47090 /* CommitWindow.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CommitWindow.app; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
@@ -70,6 +76,10 @@
8316703A0A4DB58500199564 /* NSString+StatusString.m */,
83BDF3B007DD4165005AC50F /* CWTextView.h */,
83BDF3B107DD4165005AC50F /* CWTextView.m */,
+ 83FF98D00AE9AD5B00D83081 /* NSTask+CXAdditions.h */,
+ 83FF98CE0AE9AD5400D83081 /* NSTask+CXAdditions.m */,
+ 831FF4B30ADDC1BA00BD90C2 /* CXTextWithButtonStripCell.h */,
+ 831FF4B40ADDC1BA00BD90C2 /* CXTextWithButtonStripCell.m */,
83C8C8A00ADA900B0070245F /* CXMenuButton.h */,
83C8C8A10ADA90140070245F /* CXMenuButton.m */,
);
@@ -126,8 +136,7 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
- 83C8C8990ADA89320070245F /* Action.tiff */,
- 83C8C89A0ADA89320070245F /* ActionPressed.tiff */,
+ 83FF98820AE7CD7E00D83081 /* Icons */,
8D1107310486CEB800E47090 /* Info.plist */,
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
29B97318FDCFA39411CA2CEA /* MainMenu.nib */,
@@ -144,6 +153,15 @@
name = Frameworks;
sourceTree = "<group>";
};
+ 83FF98820AE7CD7E00D83081 /* Icons */ = {
+ isa = PBXGroup;
+ children = (
+ 83FF98830AE7CD7E00D83081 /* Action.tiff */,
+ 83FF98840AE7CD7E00D83081 /* ActionPressed.tiff */,
+ );
+ path = Icons;
+ sourceTree = "<group>";
+ };
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -191,8 +209,8 @@
files = (
8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */,
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */,
- 83C8C89B0ADA89330070245F /* Action.tiff in Resources */,
- 83C8C89C0ADA89330070245F /* ActionPressed.tiff in Resources */,
+ 83FF98860AE7CD7E00D83081 /* Action.tiff in Resources */,
+ 83FF98870AE7CD7E00D83081 /* ActionPressed.tiff in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -227,6 +245,8 @@
8316703B0A4DB58500199564 /* NSString+StatusString.m in Sources */,
831670450A4DB70A00199564 /* CommitWindowCommandLine.m in Sources */,
83C8C8A20ADA90140070245F /* CXMenuButton.m in Sources */,
+ 831FF4B50ADDC1BA00BD90C2 /* CXTextWithButtonStripCell.m in Sources */,
+ 83FF98CF0AE9AD5400D83081 /* NSTask+CXAdditions.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -306,6 +326,7 @@
ppc,
i386,
);
+ GCC_C_LANGUAGE_STANDARD = c99;
MACOSX_DEPLOYMENT_TARGET = 10.3;
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
};
@@ -318,6 +339,7 @@
ppc,
i386,
);
+ GCC_C_LANGUAGE_STANDARD = c99;
MACOSX_DEPLOYMENT_TARGET = 10.3;
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
};
View
48 CommitWindowCommandLine.m
@@ -8,6 +8,8 @@
#import "CommitWindowCommandLine.h"
+#import "NSTask+CXAdditions.h"
+
@implementation CommitWindowController(CommandLine)
- (void) awakeFromNib
@@ -173,31 +175,39 @@ - (IBAction) cancel:(id) sender
- (IBAction) doubleClickRowInTable:(id)sender
{
- if(fDiffCommand != nil)
+ if( fDiffCommand != nil )
{
- NSArray * unquotedArguments = [fDiffCommand componentsSeparatedByString:@","];
- NSString * quoteArgument = @"\"%@\"";
- NSString * diffCommand = @"";
- NSString * mateCommand = [NSString stringWithFormat:@"\"%s/bin/mate\" &> /dev/null &", getenv("TM_SUPPORT_PATH")];
- NSString * filePath = [[[fFilesController arrangedObjects] objectAtIndex:[sender selectedRow]] objectForKey:@"path"];
- unsigned int argumentCount = [unquotedArguments count];
- unsigned int index;
+ NSMutableArray * arguments = [[fDiffCommand componentsSeparatedByString:@","] mutableCopy];
+ NSString * filePath = [[[fFilesController arrangedObjects] objectAtIndex:[sender selectedRow]] objectForKey:@"path"];
+ NSData * diffData;
+ NSString * errorText;
+ int exitStatus;
+
+ [arguments addObject:filePath];
+ exitStatus = [NSTask executeTaskWithArguments:arguments
+ input:nil
+ outputData:&diffData
+ errorString:&errorText];
- for(index = 0; index < argumentCount; index += 1)
+ if( exitStatus != 0 )
{
- NSString * argument = [unquotedArguments objectAtIndex:index];
- NSString * quotedArgument = [NSString stringWithFormat:quoteArgument, argument];
+ NSRunAlertPanel(errorText, @"Exit status (%d) -- Might be a bug!", @"OK", nil, nil, exitStatus);
+ }
+ else
+ {
+ arguments = [NSArray arrayWithObjects:[NSString stringWithFormat:@"%s/bin/mate", getenv("TM_SUPPORT_PATH")], @"-a", nil];
- diffCommand = [diffCommand stringByAppendingString:quotedArgument];
- diffCommand = [diffCommand stringByAppendingString:@" "];
+ // Success, send the diff to TextMate
+ exitStatus = [NSTask executeTaskWithArguments:arguments
+ input:diffData
+ outputData:nil
+ errorString:&errorText];
+ if( exitStatus != 0 )
+ {
+ NSRunAlertPanel(errorText, @"Exit status (%d) -- Might be a bug!", @"OK", nil, nil, exitStatus);
+ }
}
-
- diffCommand = [diffCommand stringByAppendingString:[NSString stringWithFormat:quoteArgument, filePath]];
- diffCommand = [diffCommand stringByAppendingString:[NSString stringWithFormat:@" | %@", mateCommand]];
-
- system([diffCommand UTF8String]);
}
-
}
View
40 CommitWindowController.m
@@ -10,6 +10,7 @@
#import "CXMenuButton.h"
#import "CWTextView.h"
+#import "CXTextWithButtonStripCell.h"
#import "NSString+StatusString.h"
#define kStatusColumnWidthForSingleChar 18
@@ -39,9 +40,44 @@ @implementation CommitWindowController
// fFilesController and fFilesStatusStrings should be set up before calling setupUserInterface.
- (void) setupUserInterface
{
- NSCell * cell = [fPathColumn dataCell];
+ CXTextWithButtonStripCell * cell = (CXTextWithButtonStripCell *)[fPathColumn dataCell];
+
if([cell respondsToSelector:@selector(setLineBreakMode:)])
- [cell setLineBreakMode:NSLineBreakByTruncatingHead];
+ {
+ [cell setLineBreakMode:NSLineBreakByTruncatingHead];
+ }
+
+ // Set up button strip
+ if( fDiffCommand != nil )
+ {
+ NSMutableDictionary * diffButtonDefinition;
+ NSMethodSignature * diffMethodSignature = [self methodSignatureForSelector:@selector(doubleClickRowInTable:)];
+ NSInvocation * diffInvocation = [NSInvocation invocationWithMethodSignature:diffMethodSignature];
+
+ // Arguments 0 and 1
+ [diffInvocation setTarget:self];
+ [diffInvocation setSelector:@selector(doubleClickRowInTable:)];
+
+ // Pretend the table view is the sender
+ [diffInvocation setArgument:&fTableView atIndex:2];
+
+ diffButtonDefinition = [NSMutableDictionary dictionary];
+ [diffButtonDefinition setObject:@"Diff" forKey:@"title"];
+ [diffButtonDefinition setObject:diffInvocation forKey:@"invocation"];
+
+ [cell setButtonDefinitions:[NSArray arrayWithObjects:diffButtonDefinition, nil]];
+
+// NSMenu * itemActionMenu;
+// NSMutableDictionary * actionMenuButtonDefinition;
+// itemActionMenu = [[NSMenu alloc] initWithTitle:@"Test"];
+// [itemActionMenu insertItemWithTitle:@"Add" action:@selector(test:) keyEquivalent:@"" atIndex:0];
+// [itemActionMenu insertItemWithTitle:@"Remove" action:@selector(test:) keyEquivalent:@"" atIndex:0];
+// actionMenuButtonDefinition = [NSMutableDictionary dictionaryWithObject:itemActionMenu forKey:@"menu"];
+//
+// [actionMenuButtonDefinition setObject:@"Action" forKey:@"title"];
+//
+// [itemActionMenu release];
+ }
//
// Set up summary text view resizing
View
5 English.lproj/MainMenu.nib/classes.nib
@@ -8,6 +8,11 @@
SUPERCLASS = NSButton;
},
{
+ CLASS = CXTextWithButtonStripCell;
+ LANGUAGE = ObjC;
+ SUPERCLASS = NSTextFieldCell;
+ },
+ {
ACTIONS = {
cancel = id;
chooseAllFiles = id;
View
2 English.lproj/MainMenu.nib/info.nib
@@ -9,7 +9,7 @@
<key>263</key>
<string>66 389 125 44 0 0 1280 1002 </string>
<key>399</key>
- <string>623 889 75 76 0 0 1280 1002 </string>
+ <string>623 889 208 99 0 0 1280 1002 </string>
</dict>
<key>IBFramework Version</key>
<string>451.0</string>
View
2,359 English.lproj/MainMenu.nib/keyedobjects.nib
1,215 additions, 1,144 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
BIN Icons/Action.tiff
Binary file not shown.
View
BIN Icons/ActionPressed.tiff
Binary file not shown.

0 comments on commit 7c0e6fd

Please sign in to comment.