From 18167b0fa0d58aaf12490c34a663fa661be8ec3e Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Thu, 11 Nov 2010 21:55:18 +0000 Subject: Make sure the root favorite has a name key and value. Also, update string files. --- Source/SPAppController.m | 3 +++ Source/SPConstants.h | 1 + Source/SPConstants.m | 1 + Source/SPFavoritesController.m | 2 +- Source/SPFavoritesPreferencePane.m | 2 +- Source/SPPreferencesUpgrade.m | 10 ++++++---- 6 files changed, 13 insertions(+), 6 deletions(-) (limited to 'Source') diff --git a/Source/SPAppController.m b/Source/SPAppController.m index a1f8b292..b1c1f026 100644 --- a/Source/SPAppController.m +++ b/Source/SPAppController.m @@ -32,6 +32,7 @@ #import "SPEncodingPopupAccessory.h" #import "SPWindowController.h" #import "SPPreferencesUpgrade.h" +#import "SPFavoritesController.h" #import #import @@ -64,6 +65,8 @@ // Migrate old connection favorites to the app's support directory (only uncomment when ready) //SPMigrateConnectionFavoritesData(); + + [SPFavoritesController sharedFavoritesController]; } /** diff --git a/Source/SPConstants.h b/Source/SPConstants.h index 0b51fb17..c90cfe2d 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -400,6 +400,7 @@ extern NSString *SPPreferenceToolbarShortcuts; // Connection favorite keys extern NSString *SPFavoritesRootKey; extern NSString *SPFavoriteChildrenKey; +extern NSString *SPFavoritesGroupNameKey; extern NSString *SPFavoriteIDKey; extern NSString *SPFavoriteNameKey; extern NSString *SPFavoriteDatabaseKey; diff --git a/Source/SPConstants.m b/Source/SPConstants.m index 637e046e..874200d2 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -220,6 +220,7 @@ NSString *SPPreferenceToolbarShortcuts = @"SPPreferenceToolbarShortcut // Connection favorite keys NSString *SPFavoritesRootKey = @"Favorites Root"; NSString *SPFavoriteChildrenKey = @"Children"; +NSString *SPFavoritesGroupNameKey = @"Name"; NSString *SPFavoriteIDKey = @"id"; NSString *SPFavoriteNameKey = @"name"; NSString *SPFavoriteDatabaseKey = @"database"; diff --git a/Source/SPFavoritesController.m b/Source/SPFavoritesController.m index 08df59c8..d66f9b72 100644 --- a/Source/SPFavoritesController.m +++ b/Source/SPFavoritesController.m @@ -182,7 +182,7 @@ static SPFavoritesController *sharedFavoritesController = nil; favorites = [[NSDictionary alloc] initWithContentsOfFile:favoritesFile]; } else { - NSDictionary *newFavorites = [NSDictionary dictionaryWithObject:[NSDictionary dictionaryWithObject:[NSArray array] forKey:SPFavoriteChildrenKey] forKey:SPFavoritesRootKey]; + NSDictionary *newFavorites = [NSDictionary dictionaryWithObject:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Favorites", @"favorites label"), SPFavoritesGroupNameKey, [NSArray array], SPFavoriteChildrenKey, nil] forKey:SPFavoritesRootKey]; NSError *error = nil; NSString *errorString = nil; diff --git a/Source/SPFavoritesPreferencePane.m b/Source/SPFavoritesPreferencePane.m index 7833d923..6b328d47 100644 --- a/Source/SPFavoritesPreferencePane.m +++ b/Source/SPFavoritesPreferencePane.m @@ -743,7 +743,7 @@ - (NSString *)preferencePaneName { - return NSLocalizedString(@"Favorites", @"favorites preference pane name"); + return NSLocalizedString(@"Favorites", @"favorites label"); } - (NSString *)preferencePaneIdentifier diff --git a/Source/SPPreferencesUpgrade.m b/Source/SPPreferencesUpgrade.m index 081be36a..7b1c31cf 100644 --- a/Source/SPPreferencesUpgrade.m +++ b/Source/SPPreferencesUpgrade.m @@ -305,6 +305,7 @@ void SPMigrateConnectionFavoritesData(void) { NSError *error = nil; NSFileManager *fileManager = [NSFileManager defaultManager]; + NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; NSString *dataPath = [fileManager applicationSupportDirectoryForSubDirectory:SPDataSupportFolder error:&error]; @@ -316,10 +317,11 @@ void SPMigrateConnectionFavoritesData(void) NSString *favoritesFile = [dataPath stringByAppendingPathComponent:SPFavoritesDataFile]; // Only proceed if the new favorites plist doesn't already exist - if (![fileManager fileExistsAtPath:favoritesFile]) { - NSDictionary *newFavorites = [NSDictionary dictionaryWithObject:[NSDictionary dictionaryWithObject:[[NSUserDefaults standardUserDefaults] objectForKey:SPFavorites] forKey:SPFavoriteChildrenKey] forKey:SPFavoritesRootKey]; + if (![fileManager fileExistsAtPath:favoritesFile]) { + + NSDictionary *newFavorites = [NSDictionary dictionaryWithObject:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Favorites", @"favorites label"), SPFavoritesGroupNameKey, [prefs objectForKey:SPFavorites], SPFavoriteChildrenKey, nil] forKey:SPFavoritesRootKey]; - NSError *error = nil; + error = nil; NSString *errorString = nil; NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:newFavorites @@ -333,7 +335,7 @@ void SPMigrateConnectionFavoritesData(void) } else { // Only uncomment when migration is complete - //[[NSUserDefaults standardUserDefaults] removeObjectForKey:SPFavorites]; + //[prefs removeObjectForKey:SPFavorites]; } } else if (errorString) { -- cgit v1.2.3