diff --git a/English.lproj/Preferences.xib b/English.lproj/Preferences.xib index fd43be8..2d8b54b 100644 --- a/English.lproj/Preferences.xib +++ b/English.lproj/Preferences.xib @@ -3,16 +3,18 @@ 1050 10J567 - 851 + 823 1038.35 462.00 com.apple.InterfaceBuilder.CocoaPlugin - 851 + 823 YES + + YES @@ -140,7 +142,7 @@ YES - + 6 System textBackgroundColor @@ -528,7 +530,7 @@ - EEEE, dd MMMM, yyyy HH:mm:ss + EEEE, d. MMMM yyyy HH:mm:ss NO @@ -561,7 +563,7 @@ NSView - + 268 YES @@ -589,6 +591,7 @@ {239, 54} + NSView @@ -597,27 +600,27 @@ YES - PBRefreshAutomatically + PBITerm2Available YES - + 268 YES - + 268 - {{18, 80}, {111, 18}} + {{261, 53}, {121, 18}} YES - - -2080244224 + + 67239424 0 - Enable 'Gist it' + Use iTerm2 - + 1211912703 2 @@ -628,10 +631,111 @@ 25 + + + 36 + + YES + + + 256 + + YES + + + 268 + {{36, 34}, {181, 18}} + + YES + + -2080244224 + 0 + Confirm creation of Gists + + + 1211912703 + 2 + + + + + 200 + 25 + + + + + 268 + {{16, 54}, {111, 18}} + + YES + + -2080244224 + 0 + Enable 'Gist it' + + + 1211912703 + 2 + + + + + 200 + 25 + + + + + 268 + {{36, 12}, {179, 18}} + + YES + + -2080244224 + 0 + Make Gists public + + + 1211912703 + 2 + + + + + 200 + 25 + + + + {{1, 1}, {233, 80}} + + + + {{17, 20}, {235, 96}} + + {0, 0} + + 67239424 + 0 + Gits + + + + 3 + MCAwLjgwMDAwMDAxMTkAA + + + + 1 + 0 + 2 + NO + 268 - {{18, 18}, {121, 18}} + {{261, 80}, {121, 18}} YES @@ -650,52 +754,9 @@ 25 - - - 268 - {{38, 60}, {181, 18}} - - YES - - -2080244224 - 0 - Confirm creation of Gists - - - 1211912703 - 2 - - - - - 200 - 25 - - - - - 268 - {{38, 38}, {179, 18}} - - YES - - -2080244224 - 0 - Make Gists public - - - 1211912703 - 2 - - - - - 200 - 25 - - - {400, 116} + {400, 136} + NSView @@ -1121,6 +1182,38 @@ 144 + + + value: values.PBUseITerm2 + + + + + + value: values.PBUseITerm2 + value + values.PBUseITerm2 + 2 + + + 149 + + + + enabled: values.PBITerm2Available + + + + + + enabled: values.PBITerm2Available + enabled + values.PBITerm2Available + 2 + + + 154 + @@ -1410,10 +1503,9 @@ YES - - + - + Integration @@ -1427,53 +1519,11 @@ - - 89 - - - YES - - - - - - 90 - - - 91 - - 97 - - - YES - - - - - - 98 - - - - - 108 - - - YES - - - - - - 109 - - - 114 @@ -1600,6 +1650,73 @@ + + 145 + + + YES + + + + + + + + 97 + + + YES + + + + + + 98 + + + + + 89 + + + YES + + + + + + 90 + + + + + 108 + + + YES + + + + + + 109 + + + + + 146 + + + YES + + + + + + 147 + + + @@ -1641,6 +1758,9 @@ 141.IBPluginDependency 141.IBViewBoundsToFrameTransform 142.IBPluginDependency + 145.IBViewBoundsToFrameTransform + 146.IBPluginDependency + 147.IBPluginDependency 15.IBEditorWindowLastContentRect 15.IBPluginDependency 16.IBPluginDependency @@ -1673,6 +1793,7 @@ 87.IBEditorWindowLastContentRect 87.IBPluginDependency 88.IBPluginDependency + 88.IBViewBoundsToFrameTransform 89.IBPluginDependency 9.IBPluginDependency 90.IBPluginDependency @@ -1683,7 +1804,7 @@ YES com.apple.InterfaceBuilder.CocoaPlugin - {{511, 548}, {401, 279}} + {{511, 477}, {401, 279}} com.apple.InterfaceBuilder.CocoaPlugin YES @@ -1737,6 +1858,11 @@ P4AAAL+AAADBcAAAw3QAAA com.apple.InterfaceBuilder.CocoaPlugin + + AUKaAABCvgAAA + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin {{443, 712}, {103, 71}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1767,15 +1893,18 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{474, 394}, {239, 54}} + {{505, 405}, {239, 54}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{474, 352}, {400, 116}} + {{329, 400}, {400, 136}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABCYAAAwoIAAA + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1800,7 +1929,7 @@ - 144 + 154 @@ -1820,6 +1949,13 @@ NSApplication+GitXScripting.h + + NSCell + + IBProjectSource + View/CellTrackingRect.h + + PBPrefsWindowController DBPrefsWindowController @@ -2032,6 +2168,14 @@ AppKit.framework/Headers/NSUserInterfaceItemSearching.h + + NSBox + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSBox.h + + NSButton NSControl @@ -2385,6 +2529,13 @@ QuartzCore.framework/Headers/CIImageProvider.h + + NSObject + + IBFrameworkSource + ScriptingBridge.framework/Headers/SBApplication.h + + NSObject diff --git a/GLFileView.m b/GLFileView.m index d51fa6a..f6d68c6 100644 --- a/GLFileView.m +++ b/GLFileView.m @@ -430,8 +430,10 @@ +(NSString *)getFileName:(NSString *)line { - NSRange b = [line rangeOfString:@"b/"]; - NSString *file=[line substringFromIndex:b.location+2]; + NSRange b = [line rangeOfString:@" b/"]; + NSString *file=[line substringFromIndex:b.location+3]; + DLog(@"line=%@",line); + DLog(@"file=%@",file); return file; } diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index d137618..6d32bcb 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -232,6 +232,7 @@ F5FE6C030EB13BC900F30D12 /* PBServicesController.m in Sources */ = {isa = PBXBuildFile; fileRef = F5FE6C020EB13BC900F30D12 /* PBServicesController.m */; }; F5FF4E180E0829C20006317A /* PBGitRevList.mm in Sources */ = {isa = PBXBuildFile; fileRef = F5FF4E170E0829C20006317A /* PBGitRevList.mm */; }; F5FF4E7A0E082E440006317A /* PBGitGrapher.mm in Sources */ = {isa = PBXBuildFile; fileRef = F5FF4E790E082E440006317A /* PBGitGrapher.mm */; }; + FA8DFF3E131AEE2700C0F289 /* Start_iTerm2.applescript in Resources */ = {isa = PBXBuildFile; fileRef = FA8DFF37131AEDD400C0F289 /* Start_iTerm2.applescript */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -575,6 +576,7 @@ F5FF4E170E0829C20006317A /* PBGitRevList.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PBGitRevList.mm; sourceTree = ""; }; F5FF4E780E082E440006317A /* PBGitGrapher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitGrapher.h; sourceTree = ""; }; F5FF4E790E082E440006317A /* PBGitGrapher.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PBGitGrapher.mm; sourceTree = ""; }; + FA8DFF37131AEDD400C0F289 /* Start_iTerm2.applescript */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.applescript; path = Start_iTerm2.applescript; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -815,6 +817,7 @@ 29B97317FDCFA39411CA2CEA /* Resources */ = { isa = PBXGroup; children = ( + FA8DFF37131AEDD400C0F289 /* Start_iTerm2.applescript */, 316E7200131EE9C600AFBB36 /* list_Template.png */, 316E7201131EE9C600AFBB36 /* sidebar_Template.png */, 21025C1012947AB200D87200 /* sourceListAction.png */, @@ -1360,6 +1363,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + FA8DFF3E131AEE2700C0F289 /* Start_iTerm2.applescript in Resources */, F5E92A1B0E88550E00056E75 /* empty_file.png in Resources */, 913D5E500E55645900CECEA2 /* gitx in Resources */, 551BF176112F3F4B00265053 /* gitx_askpasswd in Resources */, diff --git a/PBGitDefaults.h b/PBGitDefaults.h index 6fff110..f4154ff 100644 --- a/PBGitDefaults.h +++ b/PBGitDefaults.h @@ -35,6 +35,9 @@ + (void) setBranchFilter:(NSInteger)state; + (NSInteger)historySearchMode; + (void)setHistorySearchMode:(NSInteger)mode; ++ (BOOL) isUseITerm2; ++ (BOOL) isITerm2Available; ++ (void) setITerm2Available:(BOOL)iTerm2Available; // Suppressed Dialog Warnings diff --git a/PBGitDefaults.m b/PBGitDefaults.m index f6af844..76faa0f 100644 --- a/PBGitDefaults.m +++ b/PBGitDefaults.m @@ -28,6 +28,8 @@ #define kBranchFilterState @"PBBranchFilter" #define kHistorySearchMode @"PBHistorySearchMode" #define kSuppressedDialogWarnings @"Suppressed Dialog Warnings" +#define kUseITerm2 @"PBUseITerm2" +#define kITerm2Available @"PBITerm2Available" @implementation PBGitDefaults @@ -61,6 +63,10 @@ forKey:kOpenPreviousDocumentsOnLaunch]; [defaultValues setObject:[NSNumber numberWithInteger:kGitXBasicSeachMode] forKey:kHistorySearchMode]; + [defaultValues setObject:[NSNumber numberWithBool:NO] + forKey:kUseITerm2]; + [defaultValues setObject:[NSNumber numberWithBool:NO] + forKey:kITerm2Available]; [[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues]; } @@ -183,6 +189,28 @@ [[NSUserDefaults standardUserDefaults] setInteger:mode forKey:kHistorySearchMode]; } ++ (BOOL) isUseITerm2 +{ + [self isITerm2Available]; + return [[NSUserDefaults standardUserDefaults] boolForKey:kUseITerm2]; +} + ++ (BOOL) isITerm2Available +{ + NSString *iTermPath = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:@"com.googlecode.iterm2"]; + [self setITerm2Available:[[NSFileManager defaultManager] fileExistsAtPath:iTermPath]]; + + return [[NSUserDefaults standardUserDefaults] boolForKey:kITerm2Available]; +} + ++ (void) setITerm2Available:(BOOL)iTerm2Available +{ + if (!iTerm2Available) + [[NSUserDefaults standardUserDefaults] setBool:iTerm2Available forKey:kUseITerm2]; + + [[NSUserDefaults standardUserDefaults] setBool:iTerm2Available forKey:kITerm2Available]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} // Suppressed Dialog Warnings diff --git a/PBGitWindowController.m b/PBGitWindowController.m index bca2b1f..e156c85 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -140,6 +140,15 @@ if ([PBGitDefaults refreshAutomatically]) { [contentController refresh:nil]; } + + if ([PBGitDefaults isUseITerm2]) { + [terminalItem setImage:[[NSWorkspace sharedWorkspace] iconForFile:[[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:@"com.googlecode.iterm2"]]]; + [terminalItem setLabel:@"iTerm"]; + } + else { + [terminalItem setImage:[[NSWorkspace sharedWorkspace] iconForFile:@"/Applications/Utilities/Terminal.app/"]]; + [terminalItem setLabel:@"Terminal"]; + } } - (void)showErrorSheetTitle:(NSString *)title message:(NSString *)message arguments:(NSArray *)arguments output:(NSString *)output @@ -161,12 +170,25 @@ - (IBAction) openInTerminal:(id)sender { - TerminalApplication *term = [SBApplication applicationWithBundleIdentifier: @"com.apple.Terminal"]; NSString *workingDirectory = [[repository workingDirectory] stringByAppendingString:@"/"]; - NSString *cmd = [NSString stringWithFormat: @"cd \"%@\"; clear; echo '# Opened by GitX:'; git status", workingDirectory]; - [term doScript: cmd in: nil]; - [NSThread sleepForTimeInterval: 0.1]; - [term activate]; + + if ([PBGitDefaults isUseITerm2]) { + NSStringEncoding encoding; + NSString *resourcePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"Start_iTerm2.applescript"]; + NSString *scriptSource = [NSString stringWithContentsOfFile:resourcePath usedEncoding:&encoding error:nil]; + NSString *iTerm2StartScript = [scriptSource stringByReplacingOccurrencesOfString:@"%%workDir%%" withString:workingDirectory]; + + NSAppleScript *scriptObject = [[NSAppleScript alloc] initWithSource:iTerm2StartScript]; + [scriptObject executeAndReturnError:nil]; + } + else { + TerminalApplication *term = [SBApplication applicationWithBundleIdentifier:@"com.apple.Terminal"]; + NSString *cmd = [NSString stringWithFormat: @"cd \"%@\"; clear; echo '# Opened by GitX:'; git status", workingDirectory]; + [term doScript: cmd in: nil]; + [NSThread sleepForTimeInterval: 0.1]; + [term activate]; + } + } - (IBAction) cloneTo:(id)sender diff --git a/Start_iTerm2.applescript b/Start_iTerm2.applescript new file mode 100644 index 0000000..9a4b875 --- /dev/null +++ b/Start_iTerm2.applescript @@ -0,0 +1,16 @@ +tell application "iTerm" + activate + try + set myterm to the first terminal + on error + set myterm to (make new terminal) + end try + tell myterm + launch session "gitx" + tell the last session + set name to "Opened by GitX" + exec command "/bin/bash" + write text "cd %%workDir%%; clear; echo '# Opened by GitX:'; git status" + end tell + end tell +end tell