aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPGeneralPreferencePane.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2012-05-27 07:43:33 +0000
committerstuconnolly <stuart02@gmail.com>2012-05-27 07:43:33 +0000
commit0ce6000b7a0959b84379564fa9ca685e112cd4c8 (patch)
treecad538e8368601e5469d30ac86ce1058bd80afd3 /Source/SPGeneralPreferencePane.m
parent2767d17a562316ec7ae1eb5af2d2bd7ad2ed918b (diff)
downloadsequelpro-0ce6000b7a0959b84379564fa9ca685e112cd4c8.tar.gz
sequelpro-0ce6000b7a0959b84379564fa9ca685e112cd4c8.tar.bz2
sequelpro-0ce6000b7a0959b84379564fa9ca685e112cd4c8.zip
Improve default favorite popup button handling when there are no favorites.
Diffstat (limited to 'Source/SPGeneralPreferencePane.m')
-rw-r--r--Source/SPGeneralPreferencePane.m22
1 files changed, 16 insertions, 6 deletions
diff --git a/Source/SPGeneralPreferencePane.m b/Source/SPGeneralPreferencePane.m
index b43aefb3..094dff70 100644
--- a/Source/SPGeneralPreferencePane.m
+++ b/Source/SPGeneralPreferencePane.m
@@ -84,16 +84,26 @@ static NSString *SPDatabaseImage = @"database-small";
[defaultFavoritePopup addItemWithTitle:NSLocalizedString(@"Last Used", @"Last Used entry in favorites menu")];
[[defaultFavoritePopup menu] addItem:[NSMenuItem separatorItem]];
- // Add all favorites to the menu
- for (SPTreeNode *node in [[[[[SPFavoritesController sharedFavoritesController] favoritesTree] childNodes] objectAtIndex:0] childNodes])
- {
- NSArray *items = [self _constructMenuItemsForNode:node atLevel:0];
+ NSArray *favorites = [[[[[SPFavoritesController sharedFavoritesController] favoritesTree] childNodes] objectAtIndex:0] childNodes];
+
+ if ([favorites count] > 0) {
- for (NSMenuItem *item in items)
+ // Add all favorites to the menu
+ for (SPTreeNode *node in favorites)
{
- [[defaultFavoritePopup menu] addItem:item];
+ NSArray *items = [self _constructMenuItemsForNode:node atLevel:0];
+
+ for (NSMenuItem *item in items)
+ {
+ [[defaultFavoritePopup menu] addItem:item];
+ }
}
}
+ else {
+ [defaultFavoritePopup addItemWithTitle:NSLocalizedString(@"No Favorties", @"No favorites entry in favorites menu")];
+
+ [[defaultFavoritePopup itemAtIndex:2] setEnabled:NO];
+ }
// Select the default favorite from prefs
[defaultFavoritePopup selectItemWithTag:[prefs boolForKey:SPSelectLastFavoriteUsed] ? 0 : [prefs integerForKey:SPDefaultFavorite]];