diff options
-rw-r--r-- | CustomQuery.m | 29 | ||||
-rw-r--r-- | MainController.h | 6 | ||||
-rw-r--r-- | MainController.m | 3 | ||||
-rw-r--r-- | SPGrowlController.h | 34 | ||||
-rw-r--r-- | SPGrowlController.m | 123 | ||||
-rw-r--r-- | TableDocument.m | 46 | ||||
-rw-r--r-- | TableDump.m | 33 | ||||
-rw-r--r-- | TableSource.m | 4 | ||||
-rw-r--r-- | sequel-pro.xcodeproj/project.pbxproj | 6 |
9 files changed, 200 insertions, 84 deletions
diff --git a/CustomQuery.m b/CustomQuery.m index dd85b4b4..2dd43fc4 100644 --- a/CustomQuery.m +++ b/CustomQuery.m @@ -24,8 +24,7 @@ #import "CustomQuery.h" #import "TableDump.h" -#import <Growl/Growl.h> - +#import "SPGrowlController.h" @implementation CustomQuery @@ -140,15 +139,10 @@ sets the tableView columns corresponding to the mysql-result //query finished [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self]; - // Query Finished Growl Notification - [GrowlApplicationBridge notifyWithTitle:@"Query Finished" - description:[NSString stringWithFormat:NSLocalizedString(@"%@",@"description for query finished growl notification"), [errorText stringValue]] - notificationName:@"Query Finished" - iconData:nil - priority:0 - isSticky:NO - clickContext:nil - ]; + // Query finished Growl notification + [[SPGrowlController sharedGrowlController] notifyWithTitle:@"Query Finished" + description:[NSString stringWithFormat:NSLocalizedString(@"%@",@"description for query finished growl notification"), [errorText stringValue]] + notificationName:@"Query Finished"]; return; } @@ -194,15 +188,10 @@ sets the tableView columns corresponding to the mysql-result //query finished [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self]; - // Query Finished Growl Notification - [GrowlApplicationBridge notifyWithTitle:@"Query Finished" - description:[NSString stringWithFormat:NSLocalizedString(@"%@",@"description for query finished growl notification"), [errorText stringValue]] - notificationName:@"Query Finished" - iconData:nil - priority:0 - isSticky:NO - clickContext:nil - ]; + // Query finished Growl notification + [[SPGrowlController sharedGrowlController] notifyWithTitle:@"Query Finished" + description:[NSString stringWithFormat:NSLocalizedString(@"%@",@"description for query finished growl notification"), [errorText stringValue]] + notificationName:@"Query Finished"]; } - (IBAction)chooseQueryFavorite:(id)sender diff --git a/MainController.h b/MainController.h index 504d6340..1c18ba98 100644 --- a/MainController.h +++ b/MainController.h @@ -23,11 +23,9 @@ // Or mail to <lorenz@textor.ch> #import <Cocoa/Cocoa.h> -#import <Growl/Growl.h> - - -@interface MainController : NSObject <GrowlApplicationBridgeDelegate> { +@interface MainController : NSObject +{ IBOutlet id keyChainInstance; IBOutlet id preferencesWindow; diff --git a/MainController.m b/MainController.m index d446b1aa..46996ef6 100644 --- a/MainController.m +++ b/MainController.m @@ -26,7 +26,6 @@ #import "KeyChain.h" #import "TableDocument.h" - @implementation MainController /* @@ -647,8 +646,6 @@ checks for updates and opens download page in default browser //register MainController for AppleScript events [[ NSScriptExecutionContext sharedScriptExecutionContext] setTopLevelObject: self ]; - - [GrowlApplicationBridge setGrowlDelegate:self]; prefs = [[NSUserDefaults standardUserDefaults] retain]; isNewFavorite = NO; diff --git a/SPGrowlController.h b/SPGrowlController.h new file mode 100644 index 00000000..2ad73e8b --- /dev/null +++ b/SPGrowlController.h @@ -0,0 +1,34 @@ +// +// SPGrowlController.h +// sequel-pro +// +// Created by Stuart Connolly (stuconnolly.com) on Nov 28, 2008 +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at <http://code.google.com/p/sequel-pro/> + +#import <Cocoa/Cocoa.h> +#import <Growl/Growl.h> + +@interface SPGrowlController : NSObject <GrowlApplicationBridgeDelegate> + +// Singleton controller ++ (SPGrowlController *)sharedGrowlController; + +// Post notification +- (void)notifyWithTitle:(NSString *)title description:(NSString *)description notificationName:(NSString *)name; + +@end diff --git a/SPGrowlController.m b/SPGrowlController.m new file mode 100644 index 00000000..3f429067 --- /dev/null +++ b/SPGrowlController.m @@ -0,0 +1,123 @@ +// +// SPGrowlController.m +// sequel-pro +// +// Created by Stuart Connolly (stuconnolly.com) on Nov 28, 2008 +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at <http://code.google.com/p/sequel-pro/> + +#import "SPGrowlController.h" + +static SPGrowlController *sharedGrowlController = nil; + +@implementation SPGrowlController + +// ------------------------------------------------------------------------------- +// sharedGrowlController +// +// Returns the shared Growl controller. +// ------------------------------------------------------------------------------- ++ (SPGrowlController *)sharedGrowlController +{ + @synchronized(self) { + if (sharedGrowlController == nil) { + [[self alloc] init]; + } + } + + return sharedGrowlController; +} + +// ------------------------------------------------------------------------------- +// allocWithZone: +// ------------------------------------------------------------------------------- ++ (id)allocWithZone:(NSZone *)zone +{ + @synchronized(self) { + if (sharedGrowlController == nil) { + sharedGrowlController = [super allocWithZone:zone]; + + return sharedGrowlController; + } + } + + return nil; // On subsequent allocation attempts return nil +} + +// ------------------------------------------------------------------------------- +// init +// ------------------------------------------------------------------------------- +- (id)init +{ + if (self = [super init]) { + [GrowlApplicationBridge setGrowlDelegate:self]; + } + + return self; +} + +// ------------------------------------------------------------------------------- +// The following base protocol methods are implemented to ensure the singleton +// status of this class. +// ------------------------------------------------------------------------------- + +- (id)copyWithZone:(NSZone *)zone { return self; } + +- (id)retain { return self; } + +- (unsigned)retainCount { return UINT_MAX; } + +- (id)autorelease { return self; } + +- (void)release { } + +// ------------------------------------------------------------------------------- +// notifyWithTitle:description:notificationName: +// +// Posts a Growl notification using the supplied details and default values. +// ------------------------------------------------------------------------------- +- (void)notifyWithTitle:(NSString *)title description:(NSString *)description notificationName:(NSString *)name +{ + // Post notification + [GrowlApplicationBridge notifyWithTitle:title + description:description + notificationName:name + iconData:nil + priority:0 + isSticky:NO + clickContext:nil]; +} + +// ------------------------------------------------------------------------------- +// notifyWithTitle:description:notificationName: +// +// Posts a Growl notification using the supplied details and effectively ignoring +// the default values. +// ------------------------------------------------------------------------------- +- (void)notifyWithTitle:(NSString *)title description:(NSString *)description notificationName:(NSString *)name iconData:(NSData *)data priority:(int)priority isSticky:(BOOL)sticky clickContext:(id)clickContext +{ + // Post notification + [GrowlApplicationBridge notifyWithTitle:title + description:description + notificationName:name + iconData:data + priority:priority + isSticky:sticky + clickContext:clickContext]; +} + +@end diff --git a/TableDocument.m b/TableDocument.m index 785907f1..f9805288 100644 --- a/TableDocument.m +++ b/TableDocument.m @@ -32,7 +32,7 @@ #import "TableDump.h" #import "TableStatus.h" #import "ImageAndTextCell.h" -#import <Growl/Growl.h> +#import "SPGrowlController.h" NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocumentFavoritesControllerSelectionIndexDidChange"; NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFavoritesControllerFavoritesDidChange"; @@ -207,16 +207,10 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@@%@/%@", mySQLVersion, [userField stringValue], [hostField stringValue], [databaseField stringValue]]]; - // Connected Growl Notification - [GrowlApplicationBridge notifyWithTitle:@"Connected" - description:[NSString stringWithFormat:NSLocalizedString(@"Connected to %@",@"description for connected growl notification"), [tableWindow title]] - notificationName:@"Connected" - iconData:nil - priority:0 - isSticky:NO - clickContext:nil - ]; - + // Connected Growl notification + [[SPGrowlController sharedGrowlController] notifyWithTitle:@"Connected" + description:[NSString stringWithFormat:NSLocalizedString(@"Connected to %@",@"description for connected growl notification"), [tableWindow title]] + notificationName:@"Connected"]; } else if (code == 2) { //can't connect to host @@ -813,16 +807,11 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa NSPasteboard *pb = [NSPasteboard generalPasteboard]; [pb declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:self]; [pb setString:tableSyntax forType:NSStringPboardType]; - - // Table Syntax Copied Growl Notification - [GrowlApplicationBridge notifyWithTitle:@"Table Syntax Copied" - description:[NSString stringWithFormat:NSLocalizedString(@"Syntax for %@ table copied",@"description for table syntax copied growl notification"), [self table]] - notificationName:@"Table Syntax Copied" - iconData:nil - priority:0 - isSticky:NO - clickContext:nil - ]; + + // Table syntax copied Growl notification + [[SPGrowlController sharedGrowlController] notifyWithTitle:@"Table Syntax Copied" + description:[NSString stringWithFormat:NSLocalizedString(@"Syntax for %@ table copied",@"description for table syntax copied growl notification"), [self table]] + notificationName:@"Table Syntax Copied"]; } - (IBAction)checkTable:(id)sender @@ -1015,16 +1004,11 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa - (void)closeConnection { [mySQLConnection disconnect]; - - // Disconnected Growl Notification - [GrowlApplicationBridge notifyWithTitle:@"Disconnected" - description:[NSString stringWithFormat:NSLocalizedString(@"Disconnected from %@",@"description for disconnected growl notification"), [tableWindow title]] - notificationName:@"Disconnected" - iconData:nil - priority:0 - isSticky:NO - clickContext:nil - ]; + + // Disconnected Growl notification + [[SPGrowlController sharedGrowlController] notifyWithTitle:@"Disconnected" + description:[NSString stringWithFormat:NSLocalizedString(@"Disconnected from %@",@"description for disconnected growl notification"), [tableWindow title]] + notificationName:@"Disconnected"]; } diff --git a/TableDump.m b/TableDump.m index 185becec..900632b1 100644 --- a/TableDump.m +++ b/TableDump.m @@ -28,8 +28,7 @@ #import "TableSource.h" #import "TableContent.h" #import "CustomQuery.h" -#import <Growl/Growl.h> - +#import "SPGrowlController.h" @implementation TableDump @@ -255,17 +254,11 @@ saves the export file NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"Couldn't write to file. Be sure that you have the necessary privileges.", @"message of panel when file cannot be written")); } - - // Export Finished Growl Notification - [GrowlApplicationBridge notifyWithTitle:@"Export Finished" - description:[NSString stringWithFormat:NSLocalizedString(@"Finished exporting to %@",@"description for finished exporting growl notification"), [[sheet filename] lastPathComponent]] - notificationName:@"Export Finished" - iconData:nil - priority:0 - isSticky:NO - clickContext:nil - ]; - + + // Export finished Growl notification + [[SPGrowlController sharedGrowlController] notifyWithTitle:@"Export Finished" + description:[NSString stringWithFormat:NSLocalizedString(@"Finished exporting to %@",@"description for finished exporting growl notification"), [[sheet filename] lastPathComponent]] + notificationName:@"Export Finished"]; } #pragma mark import methods @@ -587,16 +580,10 @@ reads mysql-dumpfile importArray = nil; } - // Import Finished Growl Notification - [GrowlApplicationBridge notifyWithTitle:@"Import Finished" - description:[NSString stringWithFormat:NSLocalizedString(@"Finished importing %@",@"description for finished importing growl notification"), [[sheet filename] lastPathComponent]] - notificationName:@"Import Finished" - iconData:nil - priority:0 - isSticky:NO - clickContext:nil - ]; - + // Import finished Growl notification + [[SPGrowlController sharedGrowlController] notifyWithTitle:@"Import Finished" + description:[NSString stringWithFormat:NSLocalizedString(@"Finished importing %@",@"description for finished importing growl notification"), [[sheet filename] lastPathComponent]] + notificationName:@"Import Finished"]; } - (void)setupFieldMappingArray diff --git a/TableSource.m b/TableSource.m index caeb91fc..f8d3a446 100644 --- a/TableSource.m +++ b/TableSource.m @@ -1051,9 +1051,7 @@ traps enter and esc and make/cancel editing without entering next row } - (void)dealloc -{ -// NSLog(@"TableSource dealloc"); - +{ [tableFields release]; [indexes release]; [oldRow release]; diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj index 35ceec42..775de82c 100644 --- a/sequel-pro.xcodeproj/project.pbxproj +++ b/sequel-pro.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 173BFC220EDF7D01003B06C8 /* SPGrowlController.m in Sources */ = {isa = PBXBuildFile; fileRef = 173BFC210EDF7D01003B06C8 /* SPGrowlController.m */; }; 1DDD582D0DA1D0D100B32029 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD582A0DA1D0D100B32029 /* MainMenu.xib */; }; 4D700D280EC2B97C00C9F09E /* appicon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 4D700CF20EC2B97C00C9F09E /* appicon.icns */; }; 4D700D290EC2B97C00C9F09E /* clearconsole.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 4D700CF30EC2B97C00C9F09E /* clearconsole.tiff */; }; @@ -115,6 +116,8 @@ /* Begin PBXFileReference section */ 089C1660FE840EACC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; 1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; }; + 173BFC200EDF7D01003B06C8 /* SPGrowlController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPGrowlController.h; sourceTree = "<group>"; }; + 173BFC210EDF7D01003B06C8 /* SPGrowlController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPGrowlController.m; sourceTree = "<group>"; }; 1DDD582B0DA1D0D100B32029 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MainMenu.xib; sourceTree = "<group>"; }; 2A37F4B0FDCFA73011CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; 2A37F4BAFDCFA73011CA2CEA /* English */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = English; path = English.lproj/Credits.rtf; sourceTree = "<group>"; }; @@ -382,6 +385,8 @@ 4DECC3C30EC2A4AD008D359E /* CustomQuery.m */, 4DECC3C40EC2A4AD008D359E /* TableDump.h */, 4DECC3C50EC2A4AD008D359E /* TableDump.m */, + 173BFC200EDF7D01003B06C8 /* SPGrowlController.h */, + 173BFC210EDF7D01003B06C8 /* SPGrowlController.m */, ); name = Controllers; sourceTree = "<group>"; @@ -604,6 +609,7 @@ 4DECC3F10EC2A54E008D359E /* CMImageView.m in Sources */, B5BE825C0ED18C0B00831294 /* CMTextView.m in Sources */, 4DECC3FA0EC2A573008D359E /* SSHTunnel.m in Sources */, + 173BFC220EDF7D01003B06C8 /* SPGrowlController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; |