From 62319b8cd97e445e833d6c1110e256377d5abb9e Mon Sep 17 00:00:00 2001 From: Nathan Kinsinger Date: Sat, 13 Nov 2010 15:49:00 -0700 Subject: [PATCH] Allow suppressing some of the modal warnings This allows the user to suppress the display of some of the warning dialogs (like "Confirm before Push"). They can be reset with Reset Warnings in the General preferences. --- English.lproj/Preferences.xib | 357 ++++++++++++++++++++++++++++------ PBGitDefaults.h | 8 +- PBGitDefaults.m | 46 +++-- PBPrefsWindowController.h | 1 + PBPrefsWindowController.m | 6 + PBRefController.m | 41 +++- 6 files changed, 375 insertions(+), 84 deletions(-) diff --git a/English.lproj/Preferences.xib b/English.lproj/Preferences.xib index e90280b..6aba53d 100644 --- a/English.lproj/Preferences.xib +++ b/English.lproj/Preferences.xib @@ -2,18 +2,16 @@ 1050 - 10C540 - 759 - 1038.25 - 458.00 + 10H574 + 804 + 1038.35 + 461.00 com.apple.InterfaceBuilder.CocoaPlugin - 759 + 804 YES - - @@ -45,21 +43,74 @@ 268 YES + + + 268 + {{17, 22}, {166, 17}} + + YES + + 68288064 + 272630784 + Reset all dialog warnings: + + LucidaGrande + 13 + 1044 + + + + 6 + System + controlColor + + 3 + MC42NjY2NjY2NjY3AA + + + + 6 + System + controlTextColor + + 3 + MAA + + + + + + + 268 + {{182, 12}, {137, 32}} + + YES + + -2080244224 + 134217728 + Reset Warnings + + + -2038021889 + 129 + + + + 400 + 75 + + 268 - {{248, 100}, {41, 22}} + {{248, 118}, {41, 22}} YES -1804468671 272630784 - - LucidaGrande - 13 - 1044 - + YES @@ -75,17 +126,14 @@ 6 System textColor - - 3 - MAA - + 268 - {{121, 102}, {122, 17}} + {{121, 120}, {122, 17}} YES @@ -94,27 +142,14 @@ Display at column: - - 6 - System - controlColor - - 3 - MC42NjY2NjY2NjY3AA - - - - 6 - System - controlTextColor - - + + 268 - {{18, 125}, {273, 18}} + {{18, 143}, {273, 18}} YES @@ -141,7 +176,7 @@ 268 - {{17, 74}, {99, 17}} + {{17, 92}, {99, 17}} YES @@ -165,7 +200,7 @@ NSFilenamesPboardType - {{121, 70}, {179, 22}} + {{121, 88}, {179, 22}} YES @@ -187,7 +222,7 @@ 268 - {{118, 20}, {192, 42}} + {{118, 52}, {192, 28}} YES @@ -203,7 +238,7 @@ 268 - {{306, 74}, {54, 14}} + {{306, 92}, {54, 14}} YES @@ -228,7 +263,7 @@ 268 - {{18, 150}, {203, 18}} + {{18, 168}, {203, 18}} YES @@ -250,7 +285,7 @@ 268 - {{18, 175}, {279, 18}} + {{18, 193}, {279, 18}} YES @@ -272,7 +307,7 @@ 268 - {{18, 200}, {207, 18}} + {{18, 218}, {207, 18}} YES @@ -292,12 +327,12 @@ - {400, 236} + {400, 254} NSView - + 268 YES @@ -306,7 +341,6 @@ 268 {{39, 45}, {82, 14}} - YES 68288064 @@ -323,7 +357,6 @@ 268 {{18, 103}, {260, 18}} - YES -2080244224 @@ -346,7 +379,6 @@ 268 {{130, 78}, {102, 22}} - YES -2076049856 @@ -434,7 +466,6 @@ 268 {{39, 80}, {89, 17}} - YES 68288064 @@ -451,7 +482,6 @@ 268 {{130, 45}, {251, 14}} - YES 68288064 @@ -489,7 +519,6 @@ 268 {{128, 13}, {96, 28}} - YES 67239424 @@ -507,12 +536,10 @@ {400, 139} - - NSView - + 268 YES @@ -540,22 +567,16 @@ {239, 54} - NSView SUUpdater - - YES - PBCommitMessageViewHasVerticalLine - PBCommitMessageViewVerticalLineLength - YES - + 268 YES @@ -649,7 +670,6 @@ {400, 116} - NSView @@ -1051,6 +1071,14 @@ 135 + + + resetAllDialogWarnings: + + + + 140 + @@ -1094,6 +1122,8 @@ + + General @@ -1485,6 +1515,34 @@ + + 136 + + + YES + + + + + + 137 + + + YES + + + + + + 138 + + + + + 139 + + + @@ -1515,6 +1573,13 @@ 13.IBPluginDependency 130.IBPluginDependency 131.IBPluginDependency + 136.IBAttributePlaceholdersKey + 136.IBPluginDependency + 136.IBViewBoundsToFrameTransform + 137.IBPluginDependency + 137.IBViewBoundsToFrameTransform + 138.IBPluginDependency + 139.IBPluginDependency 14.IBPluginDependency 15.IBEditorWindowLastContentRect 15.IBPluginDependency @@ -1558,7 +1623,7 @@ YES com.apple.InterfaceBuilder.CocoaPlugin - {{845, 648}, {400, 236}} + {{845, 630}, {400, 254}} com.apple.InterfaceBuilder.CocoaPlugin YES @@ -1588,6 +1653,24 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + + ToolTip + + ToolTip + + Resets the of the "Don't show this again" preferences. + + + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABDXwAAwggAAA + + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABCaAAAwegAAA + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin {{443, 712}, {103, 71}} com.apple.InterfaceBuilder.CocoaPlugin @@ -1652,7 +1735,7 @@ - 135 + 140 @@ -1665,6 +1748,13 @@ DBPrefsWindowController.h + + NSApplication + + IBProjectSource + NSApplication+GitXScripting.h + + PBPrefsWindowController DBPrefsWindowController @@ -1673,6 +1763,7 @@ YES checkGitValidity: + resetAllDialogWarnings: resetGitPath: showHideAllFiles: @@ -1681,6 +1772,36 @@ id id id + id + + + + YES + + YES + checkGitValidity: + resetAllDialogWarnings: + resetGitPath: + showHideAllFiles: + + + YES + + checkGitValidity: + id + + + resetAllDialogWarnings: + id + + + resetGitPath: + id + + + showHideAllFiles: + id + @@ -1704,6 +1825,45 @@ NSView + + YES + + YES + badGitPathIcon + generalPrefsView + gitPathController + gitPathOpenAccessory + integrationPrefsView + updatesPrefsView + + + YES + + badGitPathIcon + NSImageView + + + generalPrefsView + NSView + + + gitPathController + NSPathControl + + + gitPathOpenAccessory + NSView + + + integrationPrefsView + NSView + + + updatesPrefsView + NSView + + + IBProjectSource PBPrefsWindowController.h @@ -1733,10 +1893,24 @@ checkForUpdates: id + + checkForUpdates: + + checkForUpdates: + id + + delegate id + + delegate + + delegate + id + + @@ -2125,6 +2299,27 @@ 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 @@ -2332,6 +2527,13 @@ showWindow: id + + showWindow: + + showWindow: + id + + IBFrameworkSource AppKit.framework/Headers/NSWindowController.h @@ -2344,10 +2546,24 @@ checkForUpdates: id + + checkForUpdates: + + checkForUpdates: + id + + delegate id + + delegate + + delegate + id + + @@ -2370,8 +2586,21 @@ ../GitX.xcodeproj 3 - NSStopProgressFreestandingTemplate - {83, 83} + YES + + YES + NSMenuCheckmark + NSMenuMixedState + NSStopProgressFreestandingTemplate + NSSwitch + + + YES + {9, 8} + {7, 2} + {83, 83} + {15, 15} + diff --git a/PBGitDefaults.h b/PBGitDefaults.h index 46b28b5..a95b524 100644 --- a/PBGitDefaults.h +++ b/PBGitDefaults.h @@ -24,8 +24,6 @@ + (void) setShouldCheckoutBranch:(BOOL)shouldCheckout; + (NSString *) recentCloneDestination; + (void) setRecentCloneDestination:(NSString *)path; -+ (BOOL) suppressAcceptDropRef; -+ (void) setSuppressAcceptDropRef:(BOOL)suppress; + (BOOL) showStageView; + (void) setShowStageView:(BOOL)suppress; + (BOOL) openPreviousDocumentsOnLaunch; @@ -37,4 +35,10 @@ + (NSInteger)historySearchMode; + (void)setHistorySearchMode:(NSInteger)mode; + +// Suppressed Dialog Warnings ++ (void)suppressDialogWarningForDialog:(NSString *)dialog; ++ (BOOL)isDialogWarningSuppressedForDialog:(NSString *)dialog; ++ (void)resetAllDialogWarnings; + @end diff --git a/PBGitDefaults.m b/PBGitDefaults.m index ccc2162..5656469 100644 --- a/PBGitDefaults.m +++ b/PBGitDefaults.m @@ -21,12 +21,12 @@ #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 kHistorySearchMode @"PBHistorySearchMode" +#define kSuppressedDialogWarnings @"Suppressed Dialog Warnings" @implementation PBGitDefaults @@ -125,16 +125,6 @@ [[NSUserDefaults standardUserDefaults] setObject:path forKey:kRecentCloneDestination]; } -+ (BOOL) suppressAcceptDropRef -{ - return [[NSUserDefaults standardUserDefaults] boolForKey:kSuppressAcceptDropRef]; -} - -+ (void) setSuppressAcceptDropRef:(BOOL)suppress -{ - return [[NSUserDefaults standardUserDefaults] setBool:suppress forKey:kSuppressAcceptDropRef]; -} - + (BOOL) showStageView { return [[NSUserDefaults standardUserDefaults] boolForKey:kShowStageView]; @@ -185,4 +175,38 @@ } + +// Suppressed Dialog Warnings +// +// Represents dialogs where the user has checked the "Do not show this message again" checkbox. +// Keep these together in an array to make it easier to reset all the warnings. + ++ (NSSet *)suppressedDialogWarnings +{ + NSSet *suppressedDialogWarnings = [NSSet setWithArray:[[NSUserDefaults standardUserDefaults] arrayForKey:kSuppressedDialogWarnings]]; + if (suppressedDialogWarnings == nil) + suppressedDialogWarnings = [NSSet set]; + + return suppressedDialogWarnings; +} + ++ (void)suppressDialogWarningForDialog:(NSString *)dialog +{ + NSSet *suppressedDialogWarnings = [[self suppressedDialogWarnings] setByAddingObject:dialog]; + + [[NSUserDefaults standardUserDefaults] setObject:[suppressedDialogWarnings allObjects] forKey:kSuppressedDialogWarnings]; +} + ++ (BOOL)isDialogWarningSuppressedForDialog:(NSString *)dialog +{ + return [[self suppressedDialogWarnings] containsObject:dialog]; +} + ++ (void)resetAllDialogWarnings +{ + [[NSUserDefaults standardUserDefaults] setObject:nil forKey:kSuppressedDialogWarnings]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} + + @end diff --git a/PBPrefsWindowController.h b/PBPrefsWindowController.h index ed65d38..5176c3f 100644 --- a/PBPrefsWindowController.h +++ b/PBPrefsWindowController.h @@ -27,5 +27,6 @@ - (void)pathCell:(NSPathCell *)pathCell willDisplayOpenPanel:(NSOpenPanel *)openPanel; - (IBAction) showHideAllFiles: sender; - (IBAction) resetGitPath: sender; +- (IBAction)resetAllDialogWarnings:(id)sender; @end diff --git a/PBPrefsWindowController.m b/PBPrefsWindowController.m index aefec82..7b8eca0 100644 --- a/PBPrefsWindowController.m +++ b/PBPrefsWindowController.m @@ -8,6 +8,7 @@ #import "PBPrefsWindowController.h" #import "PBGitRepository.h" +#import "PBGitDefaults.h" #define kPreferenceViewIdentifier @"PBGitXPreferenceViewIdentifier" @@ -68,6 +69,11 @@ gitPathOpenPanel = openPanel; } +- (IBAction)resetAllDialogWarnings:(id)sender +{ + [PBGitDefaults resetAllDialogWarnings]; +} + #pragma mark - #pragma mark Git Path open panel actions diff --git a/PBRefController.m b/PBRefController.m index c9b8c2e..47eda03 100644 --- a/PBRefController.m +++ b/PBRefController.m @@ -14,6 +14,13 @@ #import "PBGitDefaults.h" #import "PBDiffWindowController.h" + +#define kDialogAcceptDroppedRef @"Accept Dropped Ref" +#define kDialogConfirmPush @"Confirm Push" +#define kDialogDeleteRef @"Delete Ref" + + + @implementation PBRefController - (void)awakeFromNib @@ -45,13 +52,18 @@ #pragma mark Push -- (void) showConfirmPushRefSheet:(PBGitRef *)ref remote:(PBGitRef *)remoteRef +- (void)showConfirmPushRefSheet:(PBGitRef *)ref remote:(PBGitRef *)remoteRef { if ((!ref && !remoteRef) || (ref && ![ref isBranch] && ![ref isRemoteBranch]) || (remoteRef && !([remoteRef refishType] == kGitXRemoteType))) return; + if ([PBGitDefaults isDialogWarningSuppressedForDialog:kDialogConfirmPush]) { + [historyController.repository beginPushRef:ref toRemote:remoteRef]; + return; + } + NSString *description = nil; if (ref && remoteRef) description = [NSString stringWithFormat:@"Push %@ '%@' to remote %@", [ref refishType], [ref shortName], [remoteRef remoteName]]; @@ -66,6 +78,7 @@ alternateButton:@"Cancel" otherButton:nil informativeTextWithFormat:@"Are you sure you want to %@?", sdesc]; + [alert setShowsSuppressionButton:YES]; NSMutableDictionary *info = [NSMutableDictionary dictionary]; if (ref) @@ -79,10 +92,13 @@ contextInfo:info]; } -- (void) confirmPushRefSheetDidEnd:(NSAlert *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo +- (void)confirmPushRefSheetDidEnd:(NSAlert *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { [[sheet window] orderOut:nil]; + if ([[sheet suppressionButton] state] == NSOnState) + [PBGitDefaults suppressDialogWarningForDialog:kDialogConfirmPush]; + if (returnCode == NSAlertDefaultReturn) { PBGitRef *ref = [(NSDictionary *)contextInfo objectForKey:kGitXBranchType]; PBGitRef *remoteRef = [(NSDictionary *)contextInfo objectForKey:kGitXRemoteType]; @@ -230,12 +246,18 @@ #pragma mark Remove a branch, remote or tag -- (void) showDeleteRefSheet:(PBRefMenuItem *)sender +- (void)showDeleteRefSheet:(PBRefMenuItem *)sender { if ([[sender refish] refishType] == kGitXCommitType) return; PBGitRef *ref = (PBGitRef *)[sender refish]; + + if ([PBGitDefaults isDialogWarningSuppressedForDialog:kDialogDeleteRef]) { + [historyController.repository deleteRef:ref]; + return; + } + NSString *ref_desc = [NSString stringWithFormat:@"%@ '%@'", [ref refishType], [ref shortName]]; NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:@"Delete %@?", ref_desc] @@ -243,6 +265,7 @@ alternateButton:@"Cancel" otherButton:nil informativeTextWithFormat:@"Are you sure you want to remove the %@?", ref_desc]; + [alert setShowsSuppressionButton:YES]; [alert beginSheetModalForWindow:[historyController.repository.windowController window] modalDelegate:self @@ -250,10 +273,13 @@ contextInfo:ref]; } -- (void) deleteRefSheetDidEnd:(NSAlert *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo +- (void)deleteRefSheetDidEnd:(NSAlert *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { [[sheet window] orderOut:nil]; + if ([[sheet suppressionButton] state] == NSOnState) + [PBGitDefaults suppressDialogWarningForDialog:kDialogDeleteRef]; + if (returnCode == NSAlertDefaultReturn) { PBGitRef *ref = (PBGitRef *)contextInfo; [historyController.repository deleteRef:ref]; @@ -347,6 +373,7 @@ [dropCommit addRef:ref]; [oldCommit removeRef:ref]; + [historyController.commitList reloadData]; } - (BOOL)tableView:(NSTableView *)aTableView @@ -379,7 +406,7 @@ dropCommit, @"dropCommit", nil]; - if ([PBGitDefaults suppressAcceptDropRef]) { + if ([PBGitDefaults isDialogWarningSuppressedForDialog:kDialogAcceptDroppedRef]) { [self dropRef:dropInfo]; return YES; } @@ -404,7 +431,7 @@ return YES; } -- (void) acceptDropInfoAlertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo +- (void)acceptDropInfoAlertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { [[alert window] orderOut:nil]; @@ -412,7 +439,7 @@ [self dropRef:contextInfo]; if ([[alert suppressionButton] state] == NSOnState) - [PBGitDefaults setSuppressAcceptDropRef:YES]; + [PBGitDefaults suppressDialogWarningForDialog:kDialogAcceptDroppedRef]; } @end