From 00545fbe73b453ab8866ae8b243cdd90816da87e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Berg?= Date: Wed, 24 Mar 2010 18:43:51 +0100 Subject: [PATCH] Add a preference option for truncating very large info sheet content texts when they exceed a user-configurable limit. --- English.lproj/Preferences.xib | 438 ++++++++++++++++++++++++---------- PBGitDefaults.h | 2 + PBGitDefaults.m | 16 ++ PBGitWindowController.m | 4 +- 4 files changed, 326 insertions(+), 134 deletions(-) diff --git a/English.lproj/Preferences.xib b/English.lproj/Preferences.xib index 95363b5..367ef75 100644 --- a/English.lproj/Preferences.xib +++ b/English.lproj/Preferences.xib @@ -46,104 +46,22 @@ 268 YES - + 268 - {{18, 173}, {144, 18}} + {{294, 160}, {38, 17}} YES - - -2080244224 - 0 - Show relative dates + + 68288064 + 272630784 + chars 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, 122}, {41, 22}} - - YES - - -1804468671 - 272630784 - - - - YES - - 6 - System - textBackgroundColor - - 3 - MQA - - - - 6 - System - textColor - - 3 - MAA - - - - - - - 268 - {{121, 124}, {122, 17}} - - YES - - 68288064 - 272630784 - Display at column: - - + 6 System @@ -157,14 +75,167 @@ 6 System controlTextColor + + 3 + MAA + + + + + + + 268 + {{248, 158}, {41, 22}} + + YES + + -1804468671 + 272630784 + + + + YES + + 6 + System + textBackgroundColor + + 3 + MQA + + + + 6 + System + textColor + + + 268 + {{121, 160}, {122, 17}} + + YES + + 68288064 + 71304192 + Truncate to: + + + + + + + + + 268 + {{18, 185}, {273, 18}} + + YES + + -2080244224 + 0 + Truncate large info sheet messages + + + 1211912703 + 2 + + NSImage + NSSwitch + + + NSSwitch + + + + 200 + 25 + + + + + 268 + {{18, 210}, {144, 18}} + + YES + + -2080244224 + 0 + Show relative dates + + + 1211912703 + 2 + + + + + 200 + 25 + + + + + 268 + {{18, 235}, {233, 18}} + + YES + + -2080244224 + 0 + Auto refresh on application focus + + + 1211912703 + 2 + + + + + 200 + 25 + + + + + 268 + {{248, 101}, {41, 22}} + + YES + + -1804468671 + 272630784 + + + + YES + + + + + + + 268 + {{121, 103}, {122, 17}} + + YES + + 68288064 + 272630784 + Display at column: + + + + + + 268 - {{18, 147}, {273, 18}} + {{18, 130}, {273, 18}} YES @@ -175,7 +246,7 @@ 1211912703 2 - + @@ -186,7 +257,7 @@ 268 - {{17, 96}, {99, 17}} + {{17, 74}, {99, 17}} YES @@ -210,7 +281,7 @@ NSFilenamesPboardType - {{121, 92}, {179, 22}} + {{121, 70}, {179, 22}} YES @@ -232,7 +303,7 @@ 268 - {{118, 42}, {192, 42}} + {{118, 20}, {192, 42}} YES @@ -248,7 +319,7 @@ 268 - {{306, 96}, {54, 14}} + {{306, 74}, {54, 14}} YES @@ -273,7 +344,7 @@ 268 - {{18, 223}, {203, 18}} + {{18, 261}, {203, 18}} YES @@ -284,7 +355,7 @@ 1211912703 2 - + @@ -295,7 +366,7 @@ 268 - {{18, 248}, {279, 18}} + {{18, 286}, {279, 18}} YES @@ -306,7 +377,7 @@ 1211912703 2 - + @@ -317,7 +388,7 @@ 268 - {{18, 273}, {207, 18}} + {{18, 311}, {207, 18}} YES @@ -328,7 +399,7 @@ 1211912703 2 - + @@ -337,7 +408,7 @@ - {397, 309} + {378, 347} NSView @@ -376,7 +447,7 @@ 1211912703 2 - + @@ -568,7 +639,7 @@ 1211912703 2 - + @@ -585,11 +656,6 @@ SUUpdater - - YES - PBRefreshAutomatically - PBShowRelativeDates - YES @@ -611,7 +677,7 @@ 1211912703 2 - + @@ -633,7 +699,7 @@ 1211912703 2 - + @@ -655,7 +721,7 @@ 1211912703 2 - + @@ -677,7 +743,7 @@ 1211912703 2 - + @@ -1125,6 +1191,42 @@ 147 + + + value: values.PBTruncateInfoText + + + + + + value: values.PBTruncateInfoText + value + values.PBTruncateInfoText + 2 + + + 156 + + + + value: values.PBTruncateInfoTextSize + + + + + + value: values.PBTruncateInfoTextSize + value + values.PBTruncateInfoTextSize + + NSValidatesImmediately + + + 2 + + + 158 + @@ -1162,6 +1264,7 @@ + @@ -1169,7 +1272,10 @@ - + + + + General @@ -1589,6 +1695,62 @@ + + 148 + + + YES + + + + + + 149 + + + YES + + + + + + 150 + + + YES + + + + + + 151 + + + + + 152 + + + + + 153 + + + + + 159 + + + YES + + + + + + 160 + + + @@ -1624,9 +1786,17 @@ 14.IBPluginDependency 144.IBPluginDependency 145.IBPluginDependency + 148.IBPluginDependency + 149.IBPluginDependency 15.IBEditorWindowLastContentRect 15.IBPluginDependency + 150.IBPluginDependency + 151.IBPluginDependency + 152.IBPluginDependency + 153.IBPluginDependency + 159.IBPluginDependency 16.IBPluginDependency + 160.IBPluginDependency 17.IBPluginDependency 18.IBPluginDependency 19.IBPluginDependency @@ -1666,15 +1836,25 @@ YES com.apple.InterfaceBuilder.CocoaPlugin - {{610, 665}, {397, 309}} + {{610, 627}, {378, 347}} com.apple.InterfaceBuilder.CocoaPlugin YES - 121 + 20 0 + + + 358 + 0 + + + + 26 + 1 + {628, 654} {{217, 442}, {480, 272}} @@ -1701,6 +1881,8 @@ 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 @@ -1714,6 +1896,12 @@ 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 + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin {{384, 683}, {400, 139}} com.apple.InterfaceBuilder.CocoaPlugin @@ -1764,7 +1952,7 @@ - 147 + 160 @@ -2244,13 +2432,6 @@ ImageKit.framework/Headers/IKImageBrowserView.h - - NSObject - - IBFrameworkSource - ImageKit.framework/Headers/IKSaveOptions.h - - NSObject @@ -2293,13 +2474,6 @@ QuartzFilters.framework/Headers/QuartzFilterManager.h - - NSObject - - IBFrameworkSource - QuickLookUI.framework/Headers/QLPreviewPanel.h - - NSObject @@ -2534,7 +2708,7 @@ com.apple.InterfaceBuilder.CocoaPlugin.macosx - + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 diff --git a/PBGitDefaults.h b/PBGitDefaults.h index 7fb627a..013eb15 100644 --- a/PBGitDefaults.h +++ b/PBGitDefaults.h @@ -12,6 +12,8 @@ } + (int) commitMessageViewVerticalLineLength; ++ (NSInteger) truncateInfoTextSize; ++ (BOOL) truncateInfoText; + (BOOL) commitMessageViewHasVerticalLine; + (BOOL) isGistEnabled; + (BOOL) isGravatarEnabled; diff --git a/PBGitDefaults.m b/PBGitDefaults.m index 23e992a..34e4206 100644 --- a/PBGitDefaults.m +++ b/PBGitDefaults.m @@ -27,6 +27,8 @@ #define kPreviousDocumentPaths @"PBPreviousDocumentPaths" #define kBranchFilterState @"PBBranchFilter" #define kShowRelativeDates @"PBShowRelativeDates" +#define kTruncateInfoText @"PBTruncateInfoText" +#define kTruncateInfoTextSize @"PBTruncateInfoTextSize" @implementation PBGitDefaults @@ -59,6 +61,10 @@ forKey:kOpenPreviousDocumentsOnLaunch]; [defaultValues setObject:[NSNumber numberWithBool:YES] forKey:kShowRelativeDates]; + [defaultValues setObject:[NSNumber numberWithBool:YES] + forKey:kTruncateInfoText]; + [defaultValues setObject:[NSNumber numberWithInteger:1000] + forKey:kTruncateInfoTextSize]; [[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues]; } @@ -67,6 +73,16 @@ return [[NSUserDefaults standardUserDefaults] integerForKey:kCommitMessageViewVerticalLineLength]; } ++ (BOOL) truncateInfoText +{ + return [[NSUserDefaults standardUserDefaults] boolForKey:kTruncateInfoText]; +} + ++ (NSInteger) truncateInfoTextSize +{ + return [[NSUserDefaults standardUserDefaults] integerForKey:kTruncateInfoTextSize]; +} + + (BOOL) commitMessageViewHasVerticalLine { return [[NSUserDefaults standardUserDefaults] boolForKey:kCommitMessageViewHasVerticalLine]; diff --git a/PBGitWindowController.m b/PBGitWindowController.m index b1ade92..16bf1e7 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -111,8 +111,8 @@ - (void)showMessageSheet:(NSString *)messageText infoText:(NSString *)infoText { - if ([infoText length] > SHEET_INFOTEXT_CHAR_LIMIT) { - infoText = [infoText truncateToLength:SHEET_INFOTEXT_CHAR_LIMIT mode:PBNSStringTruncateModeCenter indicator:@" ... "]; + if ([PBGitDefaults truncateInfoText] && ([infoText length] > [PBGitDefaults truncateInfoTextSize])) { + infoText = [infoText truncateToLength:[PBGitDefaults truncateInfoTextSize] mode:PBNSStringTruncateModeCenter indicator:@" ... "]; } [[NSAlert alertWithMessageText:messageText defaultButton:nil