diff options
author | rowanbeentje <rowan@beent.je> | 2011-09-10 16:55:17 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2011-09-10 16:55:17 +0000 |
commit | a0743aaf9e8e3d9151fb7acf4b1c6da06338be88 (patch) | |
tree | 92919e09c12b4b78c494c7e7c6137209e03c1e88 /Source | |
parent | 752b2b576a307130d5f698beed67ccae5c96b166 (diff) | |
download | sequelpro-a0743aaf9e8e3d9151fb7acf4b1c6da06338be88.tar.gz sequelpro-a0743aaf9e8e3d9151fb7acf4b1c6da06338be88.tar.bz2 sequelpro-a0743aaf9e8e3d9151fb7acf4b1c6da06338be88.zip |
- Add the ability to view hidden files in SSH/SSL key selection dialogs; this addresses Issue #1176
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPConnectionController.h | 2 | ||||
-rw-r--r-- | Source/SPConnectionController.m | 37 | ||||
-rw-r--r-- | Source/SPConstants.h | 1 | ||||
-rw-r--r-- | Source/SPConstants.m | 1 | ||||
-rw-r--r-- | Source/SPFavoritesPreferencePane.h | 3 | ||||
-rw-r--r-- | Source/SPFavoritesPreferencePane.m | 37 |
6 files changed, 57 insertions, 24 deletions
diff --git a/Source/SPConnectionController.h b/Source/SPConnectionController.h index 3f9cf866..33a41d37 100644 --- a/Source/SPConnectionController.h +++ b/Source/SPConnectionController.h @@ -59,6 +59,7 @@ #ifndef SP_REFACTOR /* ivars */ NSView *databaseConnectionSuperview; NSSplitView *databaseConnectionView; + NSOpenPanel *keySelectionPanel; #endif SPKeychain *keychain; NSUserDefaults *prefs; @@ -211,6 +212,7 @@ - (IBAction)editFavorites:(id)sender; - (IBAction)showHelp:(id)sender; - (IBAction)updateSSLInterface:(id)sender; +- (IBAction)updateKeyLocationFileVisibility:(id)sender; - (void)resizeTabViewToConnectionType:(NSUInteger)theType animating:(BOOL)animate; - (IBAction)sortFavorites:(id)sender; - (IBAction)reverseSortFavorites:(id)sender; diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index e7a70caf..61c6281c 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -45,6 +45,10 @@ #import "SPDatabaseViewController.h" #endif +@interface NSSavePanel (NSSavePanel_unpublishedUntilSnowLeopardAPI) +- (void)setShowsHiddenFiles:(BOOL)flag; +@end + @interface SPConnectionController (PrivateAPI) #ifndef SP_REFACTOR /* @interface */ @@ -604,7 +608,8 @@ NSString *directoryPath = nil; NSString *filePath = nil; NSArray *permittedFileTypes = nil; - NSOpenPanel *openPanel = [NSOpenPanel openPanel]; + keySelectionPanel = [NSOpenPanel openPanel]; + [keySelectionPanel setShowsHiddenFiles:[prefs boolForKey:SPHiddenKeyFileVisibilityKey]]; #ifndef SP_REFACTOR /* !!! ssh keys */ // Switch details by sender. @@ -624,7 +629,7 @@ } permittedFileTypes = [NSArray arrayWithObjects:@"pem", @"", nil]; - [openPanel setAccessoryView:sshKeyLocationHelp]; + [keySelectionPanel setAccessoryView:sshKeyLocationHelp]; // SSL key file location: } else if (sender == standardSSLKeyFileButton || sender == socketSSLKeyFileButton) { @@ -633,7 +638,7 @@ return; } permittedFileTypes = [NSArray arrayWithObjects:@"pem", @"key", @"", nil]; - [openPanel setAccessoryView:sslKeyFileLocationHelp]; + [keySelectionPanel setAccessoryView:sslKeyFileLocationHelp]; // SSL certificate file location: } else if (sender == standardSSLCertificateButton || sender == socketSSLCertificateButton) { @@ -642,7 +647,7 @@ return; } permittedFileTypes = [NSArray arrayWithObjects:@"pem", @"cert", @"crt", @"", nil]; - [openPanel setAccessoryView:sslCertificateLocationHelp]; + [keySelectionPanel setAccessoryView:sslCertificateLocationHelp]; // SSL CA certificate file location: } else if (sender == standardSSLCACertButton || sender == socketSSLCACertButton) { @@ -651,17 +656,17 @@ return; } permittedFileTypes = [NSArray arrayWithObjects:@"pem", @"cert", @"crt", @"", nil]; - [openPanel setAccessoryView:sslCACertLocationHelp]; + [keySelectionPanel setAccessoryView:sslCACertLocationHelp]; } #endif - [openPanel beginSheetForDirectory:directoryPath - file:filePath - types:permittedFileTypes - modalForWindow:[tableDocument parentWindow] - modalDelegate:self - didEndSelector:@selector(chooseKeyLocationSheetDidEnd:returnCode:contextInfo:) - contextInfo:sender]; + [keySelectionPanel beginSheetForDirectory:directoryPath + file:filePath + types:permittedFileTypes + modalForWindow:[tableDocument parentWindow] + modalDelegate:self + didEndSelector:@selector(chooseKeyLocationSheetDidEnd:returnCode:contextInfo:) + contextInfo:sender]; } /** @@ -742,6 +747,14 @@ [self resizeTabViewToConnectionType:[self type] animating:YES]; } +/** + * Toggle hidden file visiblity in response to accessory view changes + */ +- (IBAction)updateKeyLocationFileVisibility:(id)sender +{ + [keySelectionPanel setShowsHiddenFiles:[prefs boolForKey:SPHiddenKeyFileVisibilityKey]]; +} + #pragma mark - #pragma mark Connection details interaction and display diff --git a/Source/SPConstants.h b/Source/SPConstants.h index eebe3d63..7c5e1f17 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -396,6 +396,7 @@ extern NSString *SPLastImportIntoNewTableEncoding; extern NSString *SPLastImportIntoNewTableType; extern NSString *SPGlobalValueHistory; extern NSString *SPBundleDeletedDefaultBundlesKey; +extern NSString *SPHiddenKeyFileVisibilityKey; // URLs extern NSString *SPDonationsURL; diff --git a/Source/SPConstants.m b/Source/SPConstants.m index 8b524666..14eefde7 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -207,6 +207,7 @@ NSString *SPLastImportIntoNewTableEncoding = @"LastImportIntoNewTableEncod NSString *SPLastImportIntoNewTableType = @"LastImportIntoNewTableType"; NSString *SPGlobalValueHistory = @"GlobalValueHistory"; NSString *SPBundleDeletedDefaultBundlesKey = @"deletedDefaultBundles"; +NSString *SPHiddenKeyFileVisibilityKey = @"KeySelectionHiddenFilesVisibility"; // URLs NSString *SPDonationsURL = @"http://www.sequelpro.com/donate.html"; diff --git a/Source/SPFavoritesPreferencePane.h b/Source/SPFavoritesPreferencePane.h index 9d77d4c4..4bcd2cd3 100644 --- a/Source/SPFavoritesPreferencePane.h +++ b/Source/SPFavoritesPreferencePane.h @@ -73,6 +73,8 @@ IBOutlet BWAnchoredButtonBar *splitViewButtonBar; SPKeychain *keychain; + + NSOpenPanel *keySelectionPanel; NSInteger favoriteType; NSDictionary *currentFavorite; @@ -92,6 +94,7 @@ - (IBAction)chooseKeyLocation:(id)sender; - (IBAction)favoriteTypeDidChange:(id)sender; - (IBAction)chooseKeyLocation:(id)sender; +- (IBAction)updateKeyLocationFileVisibility:(id)sender; - (void)selectFavorites:(NSArray *)favorites; diff --git a/Source/SPFavoritesPreferencePane.m b/Source/SPFavoritesPreferencePane.m index 7641e5c8..6a5270c0 100644 --- a/Source/SPFavoritesPreferencePane.m +++ b/Source/SPFavoritesPreferencePane.m @@ -37,6 +37,10 @@ @end +@interface NSSavePanel (NSSavePanel_unpublishedUntilSnowLeopardAPI) +- (void)setShowsHiddenFiles:(BOOL)flag; +@end + @implementation SPFavoritesPreferencePane #pragma mark - @@ -274,7 +278,8 @@ NSString *directoryPath = nil; NSString *filePath = nil; NSArray *permittedFileTypes = nil; - NSOpenPanel *openPanel = [NSOpenPanel openPanel]; + keySelectionPanel = [NSOpenPanel openPanel]; + [keySelectionPanel setShowsHiddenFiles:[prefs boolForKey:SPHiddenKeyFileVisibilityKey]]; // Switch details by sender. // First, SSH keys: @@ -295,7 +300,7 @@ permittedFileTypes = [NSArray arrayWithObjects:@"pem", @"", nil]; - [openPanel setAccessoryView:sshKeyLocationHelp]; + [keySelectionPanel setAccessoryView:sshKeyLocationHelp]; // SSL key file location: } @@ -306,7 +311,7 @@ } permittedFileTypes = [NSArray arrayWithObjects:@"pem", @"key", @"", nil]; - [openPanel setAccessoryView:sslKeyFileLocationHelp]; + [keySelectionPanel setAccessoryView:sslKeyFileLocationHelp]; // SSL certificate file location: } @@ -317,7 +322,7 @@ } permittedFileTypes = [NSArray arrayWithObjects:@"pem", @"cert", @"crt", @"", nil]; - [openPanel setAccessoryView:sslCertificateLocationHelp]; + [keySelectionPanel setAccessoryView:sslCertificateLocationHelp]; // SSL CA certificate file location: } @@ -328,16 +333,24 @@ } permittedFileTypes = [NSArray arrayWithObjects:@"pem", @"cert", @"crt", @"", nil]; - [openPanel setAccessoryView:sslCACertLocationHelp]; + [keySelectionPanel setAccessoryView:sslCACertLocationHelp]; } - [openPanel beginSheetForDirectory:directoryPath - file:filePath - types:permittedFileTypes - modalForWindow:[[self view] window] - modalDelegate:self - didEndSelector:@selector(chooseKeyLocationSheetDidEnd:returnCode:contextInfo:) - contextInfo:sender]; + [keySelectionPanel beginSheetForDirectory:directoryPath + file:filePath + types:permittedFileTypes + modalForWindow:[[self view] window] + modalDelegate:self + didEndSelector:@selector(chooseKeyLocationSheetDidEnd:returnCode:contextInfo:) + contextInfo:sender]; +} + +/** + * Toggle hidden file visiblity in response to accessory view changes + */ +- (IBAction)updateKeyLocationFileVisibility:(id)sender +{ + [keySelectionPanel setShowsHiddenFiles:[prefs boolForKey:SPHiddenKeyFileVisibilityKey]]; } #pragma mark - |