diff options
author | stuconnolly <stuart02@gmail.com> | 2009-11-11 22:51:40 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2009-11-11 22:51:40 +0000 |
commit | 876432a34ce9e99c45b16a2d42df5a0af8baec2c (patch) | |
tree | 7975276f6e55e829c54a72d1cb087ca824ec30ac /Source | |
parent | f3ebf339d5649b25a75b65295e52c760751b690c (diff) | |
download | sequelpro-876432a34ce9e99c45b16a2d42df5a0af8baec2c.tar.gz sequelpro-876432a34ce9e99c45b16a2d42df5a0af8baec2c.tar.bz2 sequelpro-876432a34ce9e99c45b16a2d42df5a0af8baec2c.zip |
Change the main window's non-connected/connecting state title to 'Sequel Pro' and only change it to 'Connecting...' when we are actually trying to establish a connection. Fixes issue #456.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPConnectionController.h | 11 | ||||
-rw-r--r-- | Source/SPConnectionController.m | 15 | ||||
-rw-r--r-- | Source/TableDocument.m | 32 |
3 files changed, 53 insertions, 5 deletions
diff --git a/Source/SPConnectionController.h b/Source/SPConnectionController.h index 3fe45e9a..e4a26a06 100644 --- a/Source/SPConnectionController.h +++ b/Source/SPConnectionController.h @@ -45,8 +45,18 @@ enum spconnection_types @end +@interface NSObject (SPConnectionControllerDelegate) + +- (void)connectionControllerInitiatingConnection:(id)controller; +- (void)connectionControllerConnectAttemptFailed:(id)controller; + +@end + + @interface SPConnectionController : NSObject { + id delegate; + TableDocument *tableDocument; NSWindow *documentWindow; NSSplitView *contentView; @@ -103,6 +113,7 @@ enum spconnection_types IBOutlet NSTextField *progressIndicatorText; } +@property (readwrite, assign) id delegate; @property (readwrite, assign) int type; @property (readwrite, retain) NSString *name; @property (readwrite, retain) NSString *host; diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index fb357f17..8299e024 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -32,6 +32,7 @@ @implementation SPConnectionController +@synthesize delegate; @synthesize type; @synthesize name; @synthesize host; @@ -146,7 +147,7 @@ * connection proxies in use. */ - (IBAction)initiateConnection:(id)sender -{ +{ // Ensure that host is not empty if this is a TCP/IP or SSH connection if (([self type] == SP_CONNECTION_TCPIP || [self type] == SP_CONNECTION_SSHTUNNEL) && ![[self host] length]) { NSRunAlertPanel(NSLocalizedString(@"Insufficient connection details", @"insufficient details message"), NSLocalizedString(@"Insufficient details provided to establish a connection. Please provide at least a host.", @"insufficient details informative message"), NSLocalizedString(@"OK", @"OK button"), nil, nil); @@ -161,7 +162,7 @@ // Ensure that a socket connection is not inadvertently used if (![self checkHost]) return; - + // Basic details have validated - start the connection process animating [addToFavoritesButton setHidden:YES]; [helpButton setHidden:YES]; @@ -193,6 +194,11 @@ [connectionSSHKeychainItemAccount release], connectionSSHKeychainItemAccount = nil; } } + + // Inform the delegate that we are starting the connection process + if (delegate && [delegate respondsToSelector:@selector(connectionControllerInitiatingConnection:)]) { + [delegate connectionControllerInitiatingConnection:self]; + } // Initiate the SSH connection process for tunnels if ([self type] == SP_CONNECTION_SSHTUNNEL) { @@ -395,6 +401,11 @@ } if (errorDetail) [errorDetailText setString:errorDetail]; + + // Inform the delegate that the connection attempt failed + if (delegate && [delegate respondsToSelector:@selector(connectionControllerConnectAttemptFailed:)]) { + [delegate connectionControllerConnectAttemptFailed:self]; + } // Display the connection error message NSBeginAlertSheet(theTitle, NSLocalizedString(@"OK", @"OK button"), (errorDetail) ? NSLocalizedString(@"Show Detail", @"Show detail button") : nil, (isSSHTunnelBindError) ? NSLocalizedString(@"Use Standard Connection", @"use standard connection button") : nil, documentWindow, self, nil, @selector(errorSheetDidEnd:returnCode:contextInfo:), @"connect", theErrorMessage); diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 71ac951f..b8071060 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -163,6 +163,9 @@ // Set up the connection controller connectionController = [[SPConnectionController alloc] initWithDocument:self]; + + // Set the connection controller's delegate + [connectionController setDelegate:self]; // Register observers for when the DisplayTableViewVerticalGridlines preference changes [prefs addObserver:tableSourceInstance forKeyPath:SPDisplayTableViewVerticalGridlines options:NSKeyValueObservingOptionNew context:NULL]; @@ -3480,10 +3483,12 @@ */ - (NSString *)displaySPName { - if (!_isConnected) return [NSString stringWithFormat:@"%@%@", - ([[[self fileURL] absoluteString] length]) ? [NSString stringWithFormat:@"%@ — ",[[[[self fileURL] absoluteString] lastPathComponent] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] : @"", - NSLocalizedString(@"Connecting…", @"window title string indicating that sp is connecting")]; + if (!_isConnected) { + return [NSString stringWithFormat:@"%@%@", + ([[[self fileURL] absoluteString] length]) ? [NSString stringWithFormat:@"%@ — ",[[[[self fileURL] absoluteString] lastPathComponent] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] : @"", @"Sequel Pro"]; + } + return [NSString stringWithFormat:@"%@(MySQL %@) %@%@%@", ([[[self fileURL] absoluteString] length]) ? [NSString stringWithFormat:@"%@ — ",[self displayName]] : @"", mySQLVersion, @@ -3594,6 +3599,27 @@ } #pragma mark - +#pragma mark + +/** + * Invoked by the connection controller when it starts the process of initiating a connection. + */ +- (void)connectionControllerInitiatingConnection:(id)controller +{ + // Update the window title to indicate that we are try to establish a connection + [tableWindow setTitle:NSLocalizedString(@"Connecting…", @"window title string indicating that sp is connecting")]; +} + +/** + * Invoked by the connection controller when the attempt to initiate a connection failed. + */ +- (void)connectionControllerConnectAttemptFailed:(id)controller +{ + // Reset the window title + [tableWindow setTitle:[self displaySPName]]; +} + +#pragma mark - #pragma mark Database name field delegate methods /** |