From 3502af9a810b51116cd93358c608722e3714f4c0 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sun, 14 Jun 2009 20:30:52 +0000 Subject: Add support for titlebar connection status images, and use for SSH tunnels. - Add view and code to support drawing a connection status icon at the left of the titlebar - Use for SSH tunnels; completes Issue #114. - Remove reference to an image resource "j" in the DBView - fixes console log errors. --- Interfaces/English.lproj/DBView.xib | 357 +++++++++++----------------------- Resources/Images/ssh-connected.png | Bin 0 -> 254 bytes Resources/Images/ssh-connecting.png | Bin 0 -> 342 bytes Resources/Images/ssh-disconnected.png | Bin 0 -> 342 bytes Source/CMMCPConnection.h | 1 + Source/CMMCPConnection.m | 24 ++- Source/TableDocument.h | 6 + Source/TableDocument.m | 38 ++++ sequel-pro.xcodeproj/project.pbxproj | 12 ++ 9 files changed, 193 insertions(+), 245 deletions(-) create mode 100644 Resources/Images/ssh-connected.png create mode 100644 Resources/Images/ssh-connecting.png create mode 100644 Resources/Images/ssh-disconnected.png diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index 52a9fe0c..3373c38c 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -2,13 +2,12 @@ 1050 - 9J61 + 9G55 677 - 949.46 + 949.43 353.00 YES - YES @@ -372,7 +371,7 @@ -2042609409 35 - + NSImage button_action @@ -387,7 +386,7 @@ 1048576 2147483647 - + _popUpItemAction: @@ -2274,8 +2273,8 @@ YES YES - , - . + . + , NO YES NO @@ -2939,7 +2938,7 @@ -2042609409 35 - + 400 @@ -2951,7 +2950,7 @@ 1048576 2147483647 - + _popUpItemAction: @@ -6167,7 +6166,7 @@ {3.40282e+38, 3.40282e+38} {560, 200} - + 4370 YES @@ -6292,10 +6291,6 @@ -2031075073 33554467 - - NSImage - j - 400 @@ -6418,7 +6413,6 @@ - 9 YES 1 YES @@ -6621,29 +6615,6 @@ 2322 - - YES - - YES - Apple HTML pasteboard type - Apple PDF pasteboard type - Apple PICT pasteboard type - Apple PNG pasteboard type - Apple URL pasteboard type - CorePasteboardFlavorType 0x6D6F6F76 - CorePasteboardFlavorType 0x75726C20 - NSColor pasteboard type - NSFilenamesPboardType - NSStringPboardType - NeXT Encapsulated PostScript v1.2 pasteboard type - NeXT RTFD pasteboard type - NeXT Rich Text Format v1.0 pasteboard type - NeXT TIFF v4.0 pasteboard type - NeXT font pasteboard type - NeXT ruler pasteboard type - WebURLsWithTitlesPboardType - - {667, 14} @@ -6781,7 +6752,6 @@ {667, 416} - {{0, 0}, {1440, 878}} {560, 222} @@ -12318,6 +12288,46 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {200, 32} NSView + + + 265 + + YES + + + 265 + + YES + + YES + Apple PDF pasteboard type + Apple PICT pasteboard type + Apple PNG pasteboard type + NSFilenamesPboardType + NeXT Encapsulated PostScript v1.2 pasteboard type + NeXT TIFF v4.0 pasteboard type + + + {{14, 0}, {22, 22}} + + + YES + + 130560 + 33554432 + 0 + 0 + 0 + YES + + YES + + + {50, 22} + + + NSView + YES @@ -16083,6 +16093,22 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 5998 + + + titleAccessoryView + + + + 6002 + + + + titleImageView + + + + 6003 + @@ -22744,6 +22770,30 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 + + 5999 + + + YES + + + + Title Icon View + + + 6000 + + + YES + + + + + + 6001 + + + @@ -24102,8 +24152,12 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 5984.IBPluginDependency 5986.IBPluginDependency 5989.IBPluginDependency + 5999.IBEditorWindowLastContentRect + 5999.IBPluginDependency 6.IBPluginDependency 6.ImportedFromIB2 + 6000.IBPluginDependency + 6001.IBPluginDependency 604.IBEditorWindowLastContentRect 604.IBWindowTemplateEditedContentRect 604.ImportedFromIB2 @@ -26011,8 +26065,12 @@ aGUgYWN0aXZlIHNlbGVjdGlvbiAo4oyl4oyYUik com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + {{528, 162}, {50, 22}} + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin {{67, 340}, {667, 416}} {{67, 340}, {667, 416}} @@ -26265,7 +26323,7 @@ Y2hhbmdlIHRoZSBvcmRlcg - 5998 + 6003 @@ -26884,10 +26942,12 @@ Y2hhbmdlIHRoZSBvcmRlcg dropImage: filterTable: openEditSheet: + quickLookFormatButton: reloadTable: reloadTableValues: removeRow: saveEditSheet: + segmentControllerChanged: setCompareTypes: showAll: stepLimitRows: @@ -26909,6 +26969,8 @@ Y2hhbmdlIHRoZSBvcmRlcg id id id + id + id @@ -26923,10 +26985,14 @@ Y2hhbmdlIHRoZSBvcmRlcg editData editImage editSheet - editSheetTabView + editSheetProgressBar + editSheetQuickLookButton + editSheetSegmentControl + editTextScrollView editTextView fieldField filterButton + hexTextScrollView hexTextView limitRowsButton limitRowsField @@ -26961,6 +27027,10 @@ Y2hhbmdlIHRoZSBvcmRlcg id id id + id + id + id + id CMCopyTable id id @@ -27116,6 +27186,8 @@ Y2hhbmdlIHRoZSBvcmRlcg tableTabView tableWindow tablesListInstance + titleAccessoryView + titleImageView userField variablesSheet variablesTableView @@ -27170,6 +27242,8 @@ Y2hhbmdlIHRoZSBvcmRlcg id id id + id + id @@ -27548,207 +27622,6 @@ Y2hhbmdlIHRoZSBvcmRlcg - - YES - - TableContent - NSObject - - YES - - YES - addRow: - closeEditSheet: - copyRow: - dropImage: - filterTable: - openEditSheet: - quickLookFormatButton: - reloadTable: - reloadTableValues: - removeRow: - saveEditSheet: - segmentControllerChanged: - setCompareTypes: - showAll: - stepLimitRows: - toggleFilterField: - - - YES - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - - - - YES - - YES - addButton - argumentField - compareField - copyButton - countText - editData - editImage - editSheet - editSheetProgressBar - editSheetQuickLookButton - editSheetSegmentControl - editTextScrollView - editTextView - fieldField - filterButton - hexTextScrollView - hexTextView - limitRowsButton - limitRowsField - limitRowsStepper - limitRowsText - multipleLineEditingButton - removeButton - tableContentView - tableDataInstance - tableDocumentInstance - tableWindow - tablesListInstance - - - YES - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - CMCopyTable - id - id - id - id - - - - IBDocumentRelativeSource - ../../Source/TableContent.h - - - - TableSource - NSObject - - YES - - YES - addField: - addIndex: - chooseIndexType: - closeIndexSheet: - closeKeySheet: - copyField: - openIndexSheet: - reloadTable: - removeField: - removeIndex: - typeChanged: - - - YES - id - id - id - id - id - id - id - id - id - id - id - - - - YES - - YES - addFieldButton - addIndexButton - chooseKeyButton - copyFieldButton - indexNameField - indexSheet - indexTypeField - indexView - indexedColumnsField - keySheet - removeFieldButton - removeIndexButton - structureGrabber - tableDataInstance - tableSourceView - tableTypeButton - tableWindow - tablesListInstance - - - YES - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - - - - IBDocumentRelativeSource - ../../Source/TableSource.h - - - 0 ../../sequel-pro.xcodeproj diff --git a/Resources/Images/ssh-connected.png b/Resources/Images/ssh-connected.png new file mode 100644 index 00000000..2ba841b5 Binary files /dev/null and b/Resources/Images/ssh-connected.png differ diff --git a/Resources/Images/ssh-connecting.png b/Resources/Images/ssh-connecting.png new file mode 100644 index 00000000..f1e11e59 Binary files /dev/null and b/Resources/Images/ssh-connecting.png differ diff --git a/Resources/Images/ssh-disconnected.png b/Resources/Images/ssh-disconnected.png new file mode 100644 index 00000000..f8e7c83c Binary files /dev/null and b/Resources/Images/ssh-disconnected.png differ diff --git a/Source/CMMCPConnection.h b/Source/CMMCPConnection.h index 7c892ead..814738bf 100644 --- a/Source/CMMCPConnection.h +++ b/Source/CMMCPConnection.h @@ -33,6 +33,7 @@ - (void)willQueryString:(NSString *)query; - (void)queryGaveError:(NSString *)error; +- (void)setStatusIconToImageWithName:(NSString *)imagePath; - (BOOL)connectionEncodingViaLatin1; @end diff --git a/Source/CMMCPConnection.m b/Source/CMMCPConnection.m index db45a3d8..6654948b 100644 --- a/Source/CMMCPConnection.m +++ b/Source/CMMCPConnection.m @@ -239,7 +239,10 @@ static void forcePingTimeout(int signalNumber); theRet = mysql_real_connect(mConnection, theHost, theLogin, thePass, NULL, connectionPort, theSocket, mConnectionFlags); thePass = NULL; if (theRet != mConnection) { - if (connectionTunnel) [connectionTunnel disconnect]; + if (connectionTunnel) { + [connectionTunnel disconnect]; + [delegate setStatusIconToImageWithName:@"ssh-disconnected"]; + } return mConnected = NO; } @@ -260,7 +263,10 @@ static void forcePingTimeout(int signalNumber); { [super disconnect]; - if (connectionTunnel) [connectionTunnel disconnect]; + if (connectionTunnel) { + [connectionTunnel disconnect]; + [delegate setStatusIconToImageWithName:@"ssh-disconnected"]; + } if( serverVersionString != nil ) { [serverVersionString release]; @@ -358,16 +364,19 @@ static void forcePingTimeout(int signalNumber); [connectionTunnel setConnectionStateChangeSelector:nil delegate:nil]; if ([connectionTunnel state] != SPSSH_STATE_IDLE) [connectionTunnel disconnect]; [connectionTunnel connect]; + [delegate setStatusIconToImageWithName:@"ssh-connecting"]; NSDate *tunnelStartDate = [NSDate date], *interfaceInteractionTimer; // Allow the tunnel to attempt to connect in a loop while (1) { if ([connectionTunnel state] == SPSSH_STATE_CONNECTED) { + [delegate setStatusIconToImageWithName:@"ssh-connected"]; connectionPort = [connectionTunnel localPort]; break; } if ([[NSDate date] timeIntervalSinceDate:tunnelStartDate] > (connectionTimeout + 1)) { [connectionTunnel disconnect]; + [delegate setStatusIconToImageWithName:@"ssh-disconnected"]; break; } @@ -449,6 +458,12 @@ static void forcePingTimeout(int signalNumber); { int newState = [theTunnel state]; + if (delegate && [delegate respondsToSelector:@selector(setStatusIconToImageWithName:)]) { + if (newState == SPSSH_STATE_IDLE) [delegate setStatusIconToImageWithName:@"ssh-disconnected"]; + else if (newState == SPSSH_STATE_CONNECTED) [delegate setStatusIconToImageWithName:@"ssh-connected"]; + else [delegate setStatusIconToImageWithName:@"ssh-connecting"]; + } + // Restart the tunnel if it dies if (mConnected && newState == SPSSH_STATE_IDLE && currentSSHTunnelState == SPSSH_STATE_CONNECTED) { currentSSHTunnelState = newState; @@ -614,7 +629,10 @@ static void forcePingTimeout(int signalNumber); [self startKeepAliveTimerResettingState:YES]; return YES; } - if (connectionTunnel) [connectionTunnel disconnect]; + if (connectionTunnel) { + [connectionTunnel disconnect]; + [delegate setStatusIconToImageWithName:@"ssh-disconnected"]; + } return NO; } diff --git a/Source/TableDocument.h b/Source/TableDocument.h index a7ba9d01..946b2492 100644 --- a/Source/TableDocument.h +++ b/Source/TableDocument.h @@ -51,6 +51,8 @@ IBOutlet id spExportControllerInstance; IBOutlet id tableWindow; + IBOutlet id titleAccessoryView; + IBOutlet id titleImageView; IBOutlet id connectSheet; IBOutlet id databaseSheet; IBOutlet id variablesSheet; @@ -215,6 +217,10 @@ - (IBAction)viewRelations:(id)sender; - (IBAction)addConnectionToFavorites:(id)sender; +// titlebar methods +- (void)setStatusIconToImageWithName:(NSString *)imagePath; +- (void)clearStatusIcon; + //toolbar methods - (void)setupToolbar; - (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag; diff --git a/Source/TableDocument.m b/Source/TableDocument.m index c797b530..e9ad5322 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -113,6 +113,17 @@ NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocum // Hide the tabs in the tab view (we only show them to allow switching tabs in interface builder) [tableTabView setTabViewType:NSNoTabsNoBorder]; [tableListSplitter setDividerStyle:NSSplitViewDividerStyleThin]; + + // Add the icon accessory view to the title bar + NSView *windowFrame = [[tableWindow contentView] superview]; + NSRect av = [titleAccessoryView frame]; + NSRect initialAccessoryViewFrame = NSMakeRect( + [windowFrame frame].size.width - av.size.width - 20, + [windowFrame frame].size.height - av.size.height, + av.size.width, + av.size.height); + [titleAccessoryView setFrame:initialAccessoryViewFrame]; + [windowFrame addSubview:titleAccessoryView]; } - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context @@ -383,9 +394,13 @@ NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocum int newState = [theTunnel state]; if (newState == SPSSH_STATE_IDLE) { + [self setStatusIconToImageWithName:@"ssh-disconnected"]; [self failConnectionWithErrorMessage:[theTunnel lastError]]; } else if (newState == SPSSH_STATE_CONNECTED) { + [self setStatusIconToImageWithName:@"ssh-connected"]; [self initiateMySQLConnection]; + } else { + [self setStatusIconToImageWithName:@"ssh-connecting"]; } } @@ -1990,6 +2005,29 @@ NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocum return createTableSyntaxWindow; } +#pragma mark - +#pragma mark Titlebar Methods + +/** + * Set the connection status icon in the titlebar + */ +- (void)setStatusIconToImageWithName:(NSString *)imageName +{ + NSString *imagePath = [[NSBundle mainBundle] pathForResource:imageName ofType:@"png"]; + if (!imagePath) return; + + NSImage *image = [[NSImage alloc] initByReferencingFile:imagePath]; + [titleImageView setImage:image]; +} + +/** + * Clear the connection status icon in the titlebar + */ +- (void)clearStatusIcon +{ + [titleImageView setImage:nil]; +} + #pragma mark - #pragma mark Toolbar Methods diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj index 4a7fdf16..2cbab6a7 100644 --- a/sequel-pro.xcodeproj/project.pbxproj +++ b/sequel-pro.xcodeproj/project.pbxproj @@ -91,6 +91,9 @@ 586F457B0FDB269E00B428D7 /* RegexKitLite.m in Sources */ = {isa = PBXBuildFile; fileRef = 296DC8AB0F909194002A3258 /* RegexKitLite.m */; }; 586F457E0FDB280100B428D7 /* libicucore.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 296DC8BE0F9091DF002A3258 /* libicucore.dylib */; }; 5885940F0F7AEE6000ED0E67 /* sparkle-public-key.pem in Resources */ = {isa = PBXBuildFile; fileRef = 5885940E0F7AEE6000ED0E67 /* sparkle-public-key.pem */; }; + 588B2CC80FE5641E00EC5FC0 /* ssh-connected.png in Resources */ = {isa = PBXBuildFile; fileRef = 588B2CC50FE5641E00EC5FC0 /* ssh-connected.png */; }; + 588B2CC90FE5641E00EC5FC0 /* ssh-connecting.png in Resources */ = {isa = PBXBuildFile; fileRef = 588B2CC60FE5641E00EC5FC0 /* ssh-connecting.png */; }; + 588B2CCA0FE5641E00EC5FC0 /* ssh-disconnected.png in Resources */ = {isa = PBXBuildFile; fileRef = 588B2CC70FE5641E00EC5FC0 /* ssh-disconnected.png */; }; 58C56EF50F438E120035701E /* SPDataCellFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 58C56EF40F438E120035701E /* SPDataCellFormatter.m */; }; 58CB20ED0F79A75D005EA204 /* button_edit_mode_selected.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 58CB20EC0F79A75D005EA204 /* button_edit_mode_selected.tiff */; }; 58CDB3300FCE138D00F8ACA3 /* SPSSHTunnel.m in Sources */ = {isa = PBXBuildFile; fileRef = 58CDB32F0FCE138D00F8ACA3 /* SPSSHTunnel.m */; }; @@ -330,6 +333,9 @@ 586F432A0FD74CFC00B428D7 /* SSHQuestionDialog.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SSHQuestionDialog.xib; sourceTree = ""; }; 588593F30F7AEC9500ED0E67 /* package-application.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "package-application.sh"; sourceTree = ""; }; 5885940E0F7AEE6000ED0E67 /* sparkle-public-key.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "sparkle-public-key.pem"; sourceTree = ""; }; + 588B2CC50FE5641E00EC5FC0 /* ssh-connected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ssh-connected.png"; sourceTree = ""; }; + 588B2CC60FE5641E00EC5FC0 /* ssh-connecting.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ssh-connecting.png"; sourceTree = ""; }; + 588B2CC70FE5641E00EC5FC0 /* ssh-disconnected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ssh-disconnected.png"; sourceTree = ""; }; 58C56EF30F438E120035701E /* SPDataCellFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPDataCellFormatter.h; sourceTree = ""; }; 58C56EF40F438E120035701E /* SPDataCellFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPDataCellFormatter.m; sourceTree = ""; }; 58CB20EC0F79A75D005EA204 /* button_edit_mode_selected.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = button_edit_mode_selected.tiff; sourceTree = ""; }; @@ -722,6 +728,9 @@ 17E641B10EF02036001BC333 /* showconsole.tiff */, 17E641B20EF02036001BC333 /* showvariables.tiff */, 17E641B30EF02036001BC333 /* spyglass.tiff */, + 588B2CC50FE5641E00EC5FC0 /* ssh-connected.png */, + 588B2CC60FE5641E00EC5FC0 /* ssh-connecting.png */, + 588B2CC70FE5641E00EC5FC0 /* ssh-disconnected.png */, B5E2C5F90F2353B5007446E0 /* table-property.png */, 17E641B40EF02036001BC333 /* table-small.tiff */, 584F5F8E0F50ACD800036517 /* table-view-small.tiff */, @@ -1029,6 +1038,9 @@ 29A1B7EB0FD12E55000B88E8 /* printAccessory.xib in Resources */, 586F432B0FD74CFC00B428D7 /* SSHQuestionDialog.xib in Resources */, B54F25E60FD909C400E2CF36 /* toolbar-switch-to-table-relations.png in Resources */, + 588B2CC80FE5641E00EC5FC0 /* ssh-connected.png in Resources */, + 588B2CC90FE5641E00EC5FC0 /* ssh-connecting.png in Resources */, + 588B2CCA0FE5641E00EC5FC0 /* ssh-disconnected.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; -- cgit v1.2.3