diff --git a/English.lproj/Preferences.xib b/English.lproj/Preferences.xib index ff1e4cf..95363b5 100644 --- a/English.lproj/Preferences.xib +++ b/English.lproj/Preferences.xib @@ -14,6 +14,7 @@ YES + @@ -45,21 +46,70 @@ 268 YES + + + 268 + {{18, 173}, {144, 18}} + + YES + + -2080244224 + 0 + Show relative dates + + LucidaGrande + 13 + 1044 + + + 1211912703 + 2 + + NSImage + NSSwitch + + + NSSwitch + + + + 200 + 25 + + + + + 268 + {{18, 198}, {233, 18}} + + YES + + -2080244224 + 0 + Auto refresh on application focus + + + 1211912703 + 2 + + + + + 200 + 25 + + 268 - {{248, 100}, {41, 22}} + {{248, 122}, {41, 22}} YES -1804468671 272630784 - - LucidaGrande - 13 - 1044 - + YES @@ -85,7 +135,7 @@ 268 - {{121, 102}, {122, 17}} + {{121, 124}, {122, 17}} YES @@ -114,7 +164,7 @@ 268 - {{18, 125}, {273, 18}} + {{18, 147}, {273, 18}} YES @@ -125,13 +175,8 @@ 1211912703 2 - - NSImage - NSSwitch - - - NSSwitch - + + 200 @@ -141,7 +186,7 @@ 268 - {{17, 74}, {99, 17}} + {{17, 96}, {99, 17}} YES @@ -165,7 +210,7 @@ NSFilenamesPboardType - {{121, 70}, {179, 22}} + {{121, 92}, {179, 22}} YES @@ -187,7 +232,7 @@ 268 - {{118, 20}, {192, 42}} + {{118, 42}, {192, 42}} YES @@ -203,7 +248,7 @@ 268 - {{306, 74}, {54, 14}} + {{306, 96}, {54, 14}} YES @@ -228,7 +273,7 @@ 268 - {{18, 150}, {203, 18}} + {{18, 223}, {203, 18}} YES @@ -239,7 +284,7 @@ 1211912703 2 - + @@ -250,7 +295,7 @@ 268 - {{18, 175}, {279, 18}} + {{18, 248}, {279, 18}} YES @@ -261,7 +306,7 @@ 1211912703 2 - + @@ -272,7 +317,7 @@ 268 - {{18, 200}, {207, 18}} + {{18, 273}, {207, 18}} YES @@ -283,7 +328,7 @@ 1211912703 2 - + @@ -292,12 +337,12 @@ - {400, 236} + {397, 309} NSView - + 268 YES @@ -331,7 +376,7 @@ 1211912703 2 - + @@ -501,6 +546,7 @@ {400, 139} + NSView @@ -522,7 +568,7 @@ 1211912703 2 - + @@ -539,6 +585,11 @@ SUUpdater + + YES + PBRefreshAutomatically + PBShowRelativeDates + YES @@ -560,7 +611,7 @@ 1211912703 2 - + @@ -582,7 +633,7 @@ 1211912703 2 - + @@ -604,7 +655,7 @@ 1211912703 2 - + @@ -626,7 +677,7 @@ 1211912703 2 - + @@ -1042,6 +1093,38 @@ 136 + + + value: values.PBRefreshAutomatically + + + + + + value: values.PBRefreshAutomatically + value + values.PBRefreshAutomatically + 2 + + + 143 + + + + value: values.PBShowRelativeDates + + + + + + value: values.PBShowRelativeDates + value + values.PBShowRelativeDates + 2 + + + 147 + @@ -1076,15 +1159,17 @@ YES - - - - + + + + + + General @@ -1476,6 +1561,34 @@ + + 137 + + + YES + + + + + + 138 + + + + + 144 + + + YES + + + + + + 145 + + + @@ -1506,7 +1619,11 @@ 13.IBPluginDependency 130.IBPluginDependency 131.IBPluginDependency + 137.IBPluginDependency + 138.IBPluginDependency 14.IBPluginDependency + 144.IBPluginDependency + 145.IBPluginDependency 15.IBEditorWindowLastContentRect 15.IBPluginDependency 16.IBPluginDependency @@ -1549,7 +1666,7 @@ YES com.apple.InterfaceBuilder.CocoaPlugin - {{845, 648}, {400, 236}} + {{610, 665}, {397, 309}} com.apple.InterfaceBuilder.CocoaPlugin YES @@ -1580,6 +1697,10 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin {{443, 712}, {103, 71}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1593,7 +1714,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{324, 683}, {400, 139}} + {{384, 683}, {400, 139}} com.apple.InterfaceBuilder.CocoaPlugin YES @@ -1643,7 +1764,7 @@ - 136 + 147 diff --git a/PBGitCommit.m b/PBGitCommit.m index 480082c..3aeb040 100644 --- a/PBGitCommit.m +++ b/PBGitCommit.m @@ -38,72 +38,68 @@ NSString * const kGitXCommitType = @"commit"; return [NSDate dateWithTimeIntervalSince1970:timestamp]; } -#ifdef NormalDate -- (NSString *) dateString -{ - NSDateFormatter* formatter = [[NSDateFormatter alloc] initWithDateFormat:@"%Y-%m-%d %H:%M:%S" allowNaturalLanguage:NO]; - return [formatter stringFromDate: self.date]; -} -#else - -// Code modified from Gilean ( http://stackoverflow.com/users/6305/gilean ). -// Copied from stackoverflow's accepted answer for Objective C relative dates. -// http://stackoverflow.com/questions/902950/iphone-convert-date-string-to-a-relative-time-stamp -// Modified the seconds constants with compile time math to aid in ease of adjustment of "Majic" numbers. -// -(NSString *)dateString { - NSDate *todayDate = [NSDate date]; - double ti = [self.date timeIntervalSinceDate:todayDate]; - ti = ti * -1; - if(ti < 1) { - return @"In the future!"; - } else if ( ti < 60 ) { - return @"less than a minute ago"; - } else if ( ti < (60 * 60) ) { - int diff = round(ti / 60); - if ( diff < 2 ) { - return @"1 minute ago"; - } else { - return [NSString stringWithFormat:@"%d minutes ago", diff]; - } - } else if ( ti < ( 60 * 60 * 24 ) ) { - int diff = round(ti / 60 / 60); - if ( diff < 2 ) { - return @"1 hour ago"; - } else { - return[NSString stringWithFormat:@"%d hours ago", diff]; - } - } else if ( ti < ( 60 * 60 * 24 * 7 ) ) { - int diff = round(ti / 60 / 60 / 24); - if ( diff < 2 ) { - return @"1 day ago"; - } else { - return[NSString stringWithFormat:@"%d days ago", diff]; - } - } else if ( ti < ( 60 * 60 * 24 * 31.5 ) ) { - int diff = round(ti / 60 / 60 / 24 / 7); - if ( diff < 2 ) { - return @"1 week ago"; - } else { - return[NSString stringWithFormat:@"%d weeks ago", diff]; - } - } else if ( ti < ( 60 * 60 * 24 * 365 ) ) { - int diff = round(ti / 60 / 60 / 24 / 30); - if ( diff < 2 ) { - return @"1 month ago"; - } else { - return[NSString stringWithFormat:@"%d months ago", diff]; - } + if ([PBGitDefaults showRelativeDates]) { + // Code modified from Gilean ( http://stackoverflow.com/users/6305/gilean ). + // Copied from stackoverflow's accepted answer for Objective C relative dates. + // http://stackoverflow.com/questions/902950/iphone-convert-date-string-to-a-relative-time-stamp + // Modified the seconds constants with compile time math to aid in ease of adjustment of "Majic" numbers. + // + NSDate *todayDate = [NSDate date]; + double ti = [self.date timeIntervalSinceDate:todayDate]; + ti = ti * -1; + if(ti < 1) { + return @"In the future!"; + } else if ( ti < 60 ) { + return @"less than a minute ago"; + } else if ( ti < (60 * 60) ) { + int diff = round(ti / 60); + if ( diff < 2 ) { + return @"1 minute ago"; + } else { + return [NSString stringWithFormat:@"%d minutes ago", diff]; + } + } else if ( ti < ( 60 * 60 * 24 ) ) { + int diff = round(ti / 60 / 60); + if ( diff < 2 ) { + return @"1 hour ago"; + } else { + return[NSString stringWithFormat:@"%d hours ago", diff]; + } + } else if ( ti < ( 60 * 60 * 24 * 7 ) ) { + int diff = round(ti / 60 / 60 / 24); + if ( diff < 2 ) { + return @"1 day ago"; + } else { + return[NSString stringWithFormat:@"%d days ago", diff]; + } + } else if ( ti < ( 60 * 60 * 24 * 31.5 ) ) { + int diff = round(ti / 60 / 60 / 24 / 7); + if ( diff < 2 ) { + return @"1 week ago"; + } else { + return[NSString stringWithFormat:@"%d weeks ago", diff]; + } + } else if ( ti < ( 60 * 60 * 24 * 365 ) ) { + int diff = round(ti / 60 / 60 / 24 / 30); + if ( diff < 2 ) { + return @"1 month ago"; + } else { + return[NSString stringWithFormat:@"%d months ago", diff]; + } + } else { + float diff = round(ti / 60 / 60 / 24 / 365 * 4) / 4.0; + if ( diff < 1.25 ) { + return @"1 year ago"; + } else { + return[NSString stringWithFormat:@"%g years ago", diff]; + } + } } else { - float diff = round(ti / 60 / 60 / 24 / 365 * 4) / 4.0; - if ( diff < 1.25 ) { - return @"1 year ago"; - } else { - return[NSString stringWithFormat:@"%g years ago", diff]; - } + NSDateFormatter* formatter = [[NSDateFormatter alloc] initWithDateFormat:@"%Y-%m-%d %H:%M:%S" allowNaturalLanguage:NO]; + return [formatter stringFromDate: self.date]; } } -#endif - (NSArray*) treeContents { diff --git a/PBGitDefaults.h b/PBGitDefaults.h index 2d850ab..7fb627a 100644 --- a/PBGitDefaults.h +++ b/PBGitDefaults.h @@ -18,6 +18,7 @@ + (BOOL) confirmPublicGists; + (BOOL) isGistPublic; + (BOOL) showWhitespaceDifferences; ++ (BOOL) showRelativeDates; + (BOOL) refreshAutomatically; + (BOOL)openCurDirOnLaunch; + (BOOL)showOpenPanelOnLaunch; diff --git a/PBGitDefaults.m b/PBGitDefaults.m index 396f5d0..23e992a 100644 --- a/PBGitDefaults.m +++ b/PBGitDefaults.m @@ -8,53 +8,58 @@ #import "PBGitDefaults.h" -#define kDefaultVerticalLineLength 50 +#define kDefaultVerticalLineLength 50 #define kCommitMessageViewVerticalLineLength @"PBCommitMessageViewVerticalLineLength" -#define kCommitMessageViewHasVerticalLine @"PBCommitMessageViewHasVerticalLine" -#define kEnableGist @"PBEnableGist" -#define kEnableGravatar @"PBEnableGravatar" -#define kConfirmPublicGists @"PBConfirmPublicGists" -#define kPublicGist @"PBGistPublic" -#define kShowWhitespaceDifferences @"PBShowWhitespaceDifferences" -#define kRefreshAutomatically @"PBRefreshAutomatically" -#define kOpenCurDirOnLaunch @"PBOpenCurDirOnLaunch" -#define kShowOpenPanelOnLaunch @"PBShowOpenPanelOnLaunch" -#define kShouldCheckoutBranch @"PBShouldCheckoutBranch" -#define kRecentCloneDestination @"PBRecentCloneDestination" -#define kSuppressAcceptDropRef @"PBSuppressAcceptDropRef" -#define kShowStageView @"PBShowStageView" -#define kOpenPreviousDocumentsOnLaunch @"PBOpenPreviousDocumentsOnLaunch" -#define kPreviousDocumentPaths @"PBPreviousDocumentPaths" -#define kBranchFilterState @"PBBranchFilter" +#define kCommitMessageViewHasVerticalLine @"PBCommitMessageViewHasVerticalLine" +#define kEnableGist @"PBEnableGist" +#define kEnableGravatar @"PBEnableGravatar" +#define kConfirmPublicGists @"PBConfirmPublicGists" +#define kPublicGist @"PBGistPublic" +#define kShowWhitespaceDifferences @"PBShowWhitespaceDifferences" +#define kRefreshAutomatically @"PBRefreshAutomatically" +#define kOpenCurDirOnLaunch @"PBOpenCurDirOnLaunch" +#define kShowOpenPanelOnLaunch @"PBShowOpenPanelOnLaunch" +#define kShouldCheckoutBranch @"PBShouldCheckoutBranch" +#define kRecentCloneDestination @"PBRecentCloneDestination" +#define kSuppressAcceptDropRef @"PBSuppressAcceptDropRef" +#define kShowStageView @"PBShowStageView" +#define kOpenPreviousDocumentsOnLaunch @"PBOpenPreviousDocumentsOnLaunch" +#define kPreviousDocumentPaths @"PBPreviousDocumentPaths" +#define kBranchFilterState @"PBBranchFilter" +#define kShowRelativeDates @"PBShowRelativeDates" @implementation PBGitDefaults -+ (void)initialize -{ - NSMutableDictionary *defaultValues = [NSMutableDictionary dictionary]; - [defaultValues setObject:[NSNumber numberWithInt:kDefaultVerticalLineLength] ++ (void) initialize { + NSMutableDictionary * defaultValues = [NSMutableDictionary dictionary]; + + [defaultValues setObject:[NSNumber numberWithInt:kDefaultVerticalLineLength] forKey:kCommitMessageViewVerticalLineLength]; [defaultValues setObject:[NSNumber numberWithBool:YES] forKey:kCommitMessageViewHasVerticalLine]; - [defaultValues setObject:[NSNumber numberWithBool:YES] - forKey:kEnableGist]; - [defaultValues setObject:[NSNumber numberWithBool:YES] - forKey:kEnableGravatar]; - [defaultValues setObject:[NSNumber numberWithBool:YES] - forKey:kConfirmPublicGists]; - [defaultValues setObject:[NSNumber numberWithBool:NO] - forKey:kPublicGist]; - [defaultValues setObject:[NSNumber numberWithBool:YES] - forKey:kShowWhitespaceDifferences]; - [defaultValues setObject:[NSNumber numberWithBool:YES] - forKey:kOpenCurDirOnLaunch]; - [defaultValues setObject:[NSNumber numberWithBool:YES] - forKey:kShowOpenPanelOnLaunch]; - [defaultValues setObject:[NSNumber numberWithBool:YES] - forKey:kShouldCheckoutBranch]; - [defaultValues setObject:[NSNumber numberWithBool:NO] + [defaultValues setObject:[NSNumber numberWithBool:YES] + forKey:kEnableGist]; + [defaultValues setObject:[NSNumber numberWithBool:YES] + forKey:kEnableGravatar]; + [defaultValues setObject:[NSNumber numberWithBool:YES] + forKey:kConfirmPublicGists]; + [defaultValues setObject:[NSNumber numberWithBool:NO] + forKey:kPublicGist]; + [defaultValues setObject:[NSNumber numberWithBool:YES] + forKey:kShowWhitespaceDifferences]; + [defaultValues setObject:[NSNumber numberWithBool:YES] + forKey:kOpenCurDirOnLaunch]; + [defaultValues setObject:[NSNumber numberWithBool:YES] + forKey:kShowOpenPanelOnLaunch]; + [defaultValues setObject:[NSNumber numberWithBool:YES] + forKey:kRefreshAutomatically]; + [defaultValues setObject:[NSNumber numberWithBool:YES] + forKey:kShouldCheckoutBranch]; + [defaultValues setObject:[NSNumber numberWithBool:NO] forKey:kOpenPreviousDocumentsOnLaunch]; - [[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues]; + [defaultValues setObject:[NSNumber numberWithBool:YES] + forKey:kShowRelativeDates]; + [[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues]; } + (int) commitMessageViewVerticalLineLength @@ -97,6 +102,11 @@ return [[NSUserDefaults standardUserDefaults] boolForKey:kShowWhitespaceDifferences]; } ++ (BOOL)showRelativeDates +{ + return [[NSUserDefaults standardUserDefaults] boolForKey:kShowRelativeDates]; +} + + (BOOL)openCurDirOnLaunch { return [[NSUserDefaults standardUserDefaults] boolForKey:kOpenCurDirOnLaunch]; diff --git a/PBGitWindowController.m b/PBGitWindowController.m index f065b73..a4cf90c 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -17,7 +17,7 @@ @implementation PBGitWindowController -@synthesize repository; +@synthesize repository, viewController, contentController; - (id)initWithRepository:(PBGitRepository*)theRepository displayDefault:(BOOL)displayDefault { @@ -124,8 +124,8 @@ /* Using ...didBecomeMain is better than ...didBecomeKey here because the QuickLook panel will count as key state change and the outline view window will trigger a refresh in the middle of the QuickLook panel's closing animation which causes a half second freeze with left over artifacts. */ - if (self.viewController && [PBGitDefaults refreshAutomatically]) { - [(PBViewController *)self.viewController refresh:nil]; + if (self.contentController && [PBGitDefaults refreshAutomatically]) { + [self.contentController refresh:nil]; } } diff --git a/PBWebController.m b/PBWebController.m index d185593..14c0c6d 100644 --- a/PBWebController.m +++ b/PBWebController.m @@ -131,6 +131,8 @@ return [PBGitDefaults confirmPublicGists]; else if([feature isEqualToString:@"publicGist"]) return [PBGitDefaults isGistPublic]; + else if ([feature isEqualToString:@"showWhitespaceDifferences"]) + return [PBGitDefaults showWhitespaceDifferences]; else return YES; } diff --git a/html/css/diff.css b/html/css/diff.css index 84c627e..b7937a3 100644 --- a/html/css/diff.css +++ b/html/css/diff.css @@ -49,8 +49,7 @@ } .diff .file .diffcontent .lines .whitespace { - /* background-color: rgba(255,0,0,0.5); */ - background-color: transparent; + background-color: rgba(255,0,0,0.5); } #CurrentHunk { diff --git a/html/lib/diffHighlighter.js b/html/lib/diffHighlighter.js index cda95a8..37a008f 100644 --- a/html/lib/diffHighlighter.js +++ b/html/lib/diffHighlighter.js @@ -188,10 +188,11 @@ var highlightDiff = function(diff, element, callbacks) { sindex = "index=" + lindex.toString() + " "; if (firstChar == "+") { - // Highlight trailing whitespace - if (m = l.match(/\s+$/)) - l = l.replace(/\s+$/, "" + m + ""); - + if (Controller.isFeatureEnabled_("showWhitespaceDifferences")) { + // Highlight trailing whitespace + if (m = l.match(/\s+$/)) + l = l.replace(/\s+$/, "" + m + ""); + } line1 += "\n"; line2 += ++hunk_start_line_2 + "\n"; diffContent += "
" + l + "
"; diff --git a/html/views/commit/index.html b/html/views/commit/index.html index f20b2cd..a87c5f9 100644 --- a/html/views/commit/index.html +++ b/html/views/commit/index.html @@ -9,7 +9,7 @@ - +