From b72f9507c2be480c680b7f58753789432882f1c4 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Wed, 10 Nov 2010 14:26:44 +0000 Subject: Add a new class template for the favorites controller. --- Source/SPConstants.h | 2 ++ Source/SPConstants.m | 2 ++ Source/SPFavoritesController.h | 35 ++++++++++++++++++++++++ Source/SPFavoritesController.m | 62 ++++++++++++++++++++++++++++++++++++++++++ Source/SPGrowlController.h | 4 ++- Source/SPGrowlController.m | 14 ---------- Source/SPLogger.h | 4 ++- Source/SPLogger.m | 10 ------- Source/SPSingleton.h | 28 +++++++++++++++++++ Source/SPSingleton.m | 56 ++++++++++++++++++++++++++++++++++++++ 10 files changed, 191 insertions(+), 26 deletions(-) create mode 100644 Source/SPFavoritesController.h create mode 100644 Source/SPFavoritesController.m create mode 100644 Source/SPSingleton.h create mode 100644 Source/SPSingleton.m (limited to 'Source') diff --git a/Source/SPConstants.h b/Source/SPConstants.h index 931722ba..651a68c5 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -230,6 +230,7 @@ extern NSString *SPColorThemeFileExtension; extern NSString *SPUserBundleFileExtension; // File names +extern NSString *SPFavoritesDataFile; extern NSString *SPHTMLPrintTemplate; extern NSString *SPHTMLTableInfoPrintTemplate; extern NSString *SPHTMLHelpTemplate; @@ -237,6 +238,7 @@ extern NSString *SPHTMLHelpTemplate; // Folder names extern NSString *SPThemesSupportFolder; extern NSString *SPBundleSupportFolder; +extern NSString *SPDataSupportFolder; // Preference key constants // General Prefpane diff --git a/Source/SPConstants.m b/Source/SPConstants.m index c146e525..bfacad2d 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -51,6 +51,7 @@ NSString *SPColorThemeFileExtension = @"spTheme"; NSString *SPUserBundleFileExtension = @"spBundle"; // File names +NSString *SPFavoritesDataFile = @"Favorites.plist"; NSString *SPHTMLPrintTemplate = @"SPPrintTemplate"; NSString *SPHTMLTableInfoPrintTemplate = @"SPTableInfoPrintTemplate"; NSString *SPHTMLHelpTemplate = @"SPMySQLHelpTemplate"; @@ -58,6 +59,7 @@ NSString *SPHTMLHelpTemplate = @"SPMySQLHelpTemplate"; // Folder names NSString *SPThemesSupportFolder = @"Themes"; NSString *SPBundleSupportFolder = @"Bundles"; +NSString *SPDataSupportFolder = @"Data"; // Preference key constants // General Prefpane diff --git a/Source/SPFavoritesController.h b/Source/SPFavoritesController.h new file mode 100644 index 00000000..5e9d714c --- /dev/null +++ b/Source/SPFavoritesController.h @@ -0,0 +1,35 @@ +// +// $Id$ +// +// SPFavoritesController.h +// sequel-pro +// +// Created by Stuart Connolly (stuconnolly.com) on November 10, 2010 +// Copyright (c) 2010 Stuart Connolly. All rights reserved. +// +// 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 + +#import "SPSingleton.h" + +@interface SPFavoritesController : SPSingleton +{ + NSDictionary *favorties; +} + +- (SPFavoritesController *)sharedFavoritesController; + +@end diff --git a/Source/SPFavoritesController.m b/Source/SPFavoritesController.m new file mode 100644 index 00000000..dacd35dc --- /dev/null +++ b/Source/SPFavoritesController.m @@ -0,0 +1,62 @@ +// +// $Id$ +// +// SPFavoritesController.m +// sequel-pro +// +// Created by Stuart Connolly (stuconnolly.com) on November 10, 2010 +// Copyright (c) 2010 Stuart Connolly. All rights reserved. +// +// 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 + +#import "SPFavoritesController.h" + +static SPFavoritesController *sharedFavoritesController = nil; + +@implementation SPFavoritesController + +/** + * Returns the shared favorites controller. + */ ++ (SPFavoritesController *)sharedFavoritesController +{ + @synchronized(self) { + if (sharedFavoritesController == nil) { + sharedFavoritesController = [[super allocWithZone:NULL] init]; + } + } + + return sharedFavoritesController; +} + ++ (id)allocWithZone:(NSZone *)zone +{ + @synchronized(self) { + return [[self sharedFavoritesController] retain]; + } +} + +- (id)init +{ + if ((self = [super init])) { + + } + + return self; +} + +@end diff --git a/Source/SPGrowlController.h b/Source/SPGrowlController.h index d0a95d6d..d1cb7dc2 100644 --- a/Source/SPGrowlController.h +++ b/Source/SPGrowlController.h @@ -25,9 +25,11 @@ #import +#import "SPSingleton.h" + @class SPDatabaseDocument; -@interface SPGrowlController : NSObject +@interface SPGrowlController : SPSingleton { NSString *timingNotificationName; double timingNotificationStart; diff --git a/Source/SPGrowlController.m b/Source/SPGrowlController.m index 24eccb50..71f93053 100644 --- a/Source/SPGrowlController.m +++ b/Source/SPGrowlController.m @@ -65,20 +65,6 @@ static SPGrowlController *sharedGrowlController = nil; 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; } - -- (NSUInteger)retainCount { return NSUIntegerMax; } - -- (id)autorelease { return self; } - -- (void)release { } - /** * Posts a Growl notification using the supplied details and default values. * Calls the notification after a tiny delay to allow isKeyWindow to have updated diff --git a/Source/SPLogger.h b/Source/SPLogger.h index 3fd2cae9..640e5cb3 100644 --- a/Source/SPLogger.h +++ b/Source/SPLogger.h @@ -23,7 +23,9 @@ // // More info at -@interface SPLogger : NSObject +#import "SPSingleton.h" + +@interface SPLogger : SPSingleton { /** * Dump leaks on termination flag. diff --git a/Source/SPLogger.m b/Source/SPLogger.m index 112edb64..743b0fce 100644 --- a/Source/SPLogger.m +++ b/Source/SPLogger.m @@ -80,16 +80,6 @@ static SPLogger *logger = nil; } } -- (id)copyWithZone:(NSZone *)zone { return self; } - -- (id)retain { return self; } - -- (NSUInteger)retainCount { return NSUIntegerMax; } - -- (void)release {} - -- (id)autorelease { return self; } - - (id)init { if ((self = [super init])) { diff --git a/Source/SPSingleton.h b/Source/SPSingleton.h new file mode 100644 index 00000000..57b5f67b --- /dev/null +++ b/Source/SPSingleton.h @@ -0,0 +1,28 @@ +// +// $Id$ +// +// SPSingleton.h +// sequel-pro +// +// Created by Stuart Connolly (stuconnolly.com) on November 10, 2010 +// Copyright (c) 2010 Stuart Connolly. All rights reserved. +// +// 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 + +@interface SPSingleton : NSObject + +@end diff --git a/Source/SPSingleton.m b/Source/SPSingleton.m new file mode 100644 index 00000000..a1321333 --- /dev/null +++ b/Source/SPSingleton.m @@ -0,0 +1,56 @@ +// +// $Id$ +// +// SPSingleton.m +// sequel-pro +// +// Created by Stuart Connolly (stuconnolly.com) on November 10, 2010 +// Copyright (c) 2010 Stuart Connolly. All rights reserved. +// +// 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 + +#import "SPSingleton.h" + +@implementation SPSingleton + +/** + * 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; +} + +- (NSUInteger)retainCount +{ + return NSUIntegerMax; +} + +- (id)autorelease +{ + return self; +} + +- (void)release { } + +@end -- cgit v1.2.3