aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPGeneralPreferencePane.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-12-05 15:03:28 +0000
committerstuconnolly <stuart02@gmail.com>2010-12-05 15:03:28 +0000
commit4e87089af2ce50364a3e6fcfdf8a3c31e172d8aa (patch)
tree88ff9ede1a8fb612cd4fbf7a4f90b7cbc8f10f34 /Source/SPGeneralPreferencePane.m
parent93b889667f1b938931b84e8fed07ee58bcba3c8f (diff)
downloadsequelpro-4e87089af2ce50364a3e6fcfdf8a3c31e172d8aa.tar.gz
sequelpro-4e87089af2ce50364a3e6fcfdf8a3c31e172d8aa.tar.bz2
sequelpro-4e87089af2ce50364a3e6fcfdf8a3c31e172d8aa.zip
Apply new favorites outline view patch.
Diffstat (limited to 'Source/SPGeneralPreferencePane.m')
-rw-r--r--Source/SPGeneralPreferencePane.m37
1 files changed, 12 insertions, 25 deletions
diff --git a/Source/SPGeneralPreferencePane.m b/Source/SPGeneralPreferencePane.m
index b87d6ab8..36cbed9f 100644
--- a/Source/SPGeneralPreferencePane.m
+++ b/Source/SPGeneralPreferencePane.m
@@ -36,9 +36,8 @@
- (IBAction)updateDefaultFavorite:(id)sender
{
[prefs setBool:([defaultFavoritePopup indexOfSelectedItem] == 0) forKey:SPSelectLastFavoriteUsed];
-
- // Minus 2 from index to account for the "Last Used" and separator items
- [prefs setInteger:([defaultFavoritePopup indexOfSelectedItem] - 2) forKey:SPDefaultFavorite];
+
+ [prefs setInteger:[[sender selectedItem] tag] forKey:SPDefaultFavorite];
}
#pragma mark -
@@ -56,36 +55,24 @@
[[defaultFavoritePopup menu] addItem:[NSMenuItem separatorItem]];
// Add all favorites to the menu
- for (NSString *favorite in [[favoritesController arrangedObjects] valueForKeyPath:@"name"])
+ for (NSDictionary *favorite in [favoritesController arrangedObjects])
{
- NSMenuItem *favoriteMenuItem = [[NSMenuItem alloc] initWithTitle:favorite action:NULL keyEquivalent:@""];
+ NSMenuItem *favoriteMenuItem = [[NSMenuItem alloc] initWithTitle:[favorite objectForKey:SPFavoriteNameKey] action:NULL keyEquivalent:@""];
+
+ [favoriteMenuItem setTag:[[favorite objectForKey:SPFavoriteIDKey] integerValue]];
[[defaultFavoritePopup menu] addItem:favoriteMenuItem];
[favoriteMenuItem release];
}
- // Add item to switch to edit favorites pane
- [[defaultFavoritePopup menu] addItem:[NSMenuItem separatorItem]];
-
- NSMenuItem *editMenuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Edit Favorites…", @"edit favorites menu item") action:@selector(displayFavoritePreferences:) keyEquivalent:@""];
-
- [editMenuItem setTarget:[[[self view] window] delegate]];
-
- [[defaultFavoritePopup menu] addItem:editMenuItem];
-
- [editMenuItem release];
-
// Select the default favorite from prefs
- [defaultFavoritePopup selectItemAtIndex:(![prefs boolForKey:SPSelectLastFavoriteUsed]) ? ([prefs integerForKey:SPDefaultFavorite] + 2) : 0];
-}
-
-/**
- * Resets the default favorite popup button selection based on the user's preferences.
- */
-- (void)resetDefaultFavoritePopupSelection
-{
- [defaultFavoritePopup selectItemAtIndex:(![prefs boolForKey:SPSelectLastFavoriteUsed]) ? ([prefs integerForKey:SPDefaultFavorite] + 2) : 0];
+ if (![prefs boolForKey:SPSelectLastFavoriteUsed]) {
+ [defaultFavoritePopup selectItemWithTag:[prefs integerForKey:SPDefaultFavorite]];
+ }
+ else {
+ [defaultFavoritePopup selectItemAtIndex:0];
+ }
}
#pragma mark -