diff options
author | stuconnolly <stuart02@gmail.com> | 2010-03-27 15:34:31 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2010-03-27 15:34:31 +0000 |
commit | 0b4ee446f7052f964f704d8dfabe53103733325b (patch) | |
tree | f09193b597cf3f9771d77a4694d8dd0b5b0a98ed | |
parent | 0559e08ff40bc2496c6af22beb4df99cf112e13b (diff) | |
download | sequelpro-0b4ee446f7052f964f704d8dfabe53103733325b.tar.gz sequelpro-0b4ee446f7052f964f704d8dfabe53103733325b.tar.bz2 sequelpro-0b4ee446f7052f964f704d8dfabe53103733325b.zip |
Add the ability to sort the connection favorites table view in the preferences. Sort options are by name, host or type as well as the option to be sorted in reverse order. This implements issue #490.
-rw-r--r-- | Interfaces/English.lproj/MainMenu.xib | 293 | ||||
-rw-r--r-- | Resources/PreferenceDefaults.plist | 8 | ||||
-rw-r--r-- | Source/SPConstants.h | 10 | ||||
-rw-r--r-- | Source/SPConstants.m | 2 | ||||
-rw-r--r-- | Source/SPPreferenceController.h | 21 | ||||
-rw-r--r-- | Source/SPPreferenceController.m | 95 | ||||
-rw-r--r-- | Source/TableDocument.m | 6 |
7 files changed, 422 insertions, 13 deletions
diff --git a/Interfaces/English.lproj/MainMenu.xib b/Interfaces/English.lproj/MainMenu.xib index 0dcd0af4..a51aa337 100644 --- a/Interfaces/English.lproj/MainMenu.xib +++ b/Interfaces/English.lproj/MainMenu.xib @@ -12,7 +12,7 @@ </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="498"/> + <integer value="1059"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -1209,6 +1209,73 @@ <reference key="NSOnImage" ref="625762401"/> <reference key="NSMixedImage" ref="315854375"/> </object> + <object class="NSMenuItem" id="121425259"> + <reference key="NSMenu" ref="466354362"/> + <string key="NSTitle">Favorites</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="625762401"/> + <reference key="NSMixedImage" ref="315854375"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="65194311"> + <string key="NSTitle">Favorites</string> + <object class="NSMutableArray" key="NSMenuItems"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSMenuItem" id="467685932"> + <reference key="NSMenu" ref="65194311"/> + <string key="NSTitle">Sort By Name</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="625762401"/> + <reference key="NSMixedImage" ref="315854375"/> + </object> + <object class="NSMenuItem" id="326070376"> + <reference key="NSMenu" ref="65194311"/> + <string key="NSTitle">Sort By Host</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="625762401"/> + <reference key="NSMixedImage" ref="315854375"/> + </object> + <object class="NSMenuItem" id="836793492"> + <reference key="NSMenu" ref="65194311"/> + <string key="NSTitle">Sort By Type</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="625762401"/> + <reference key="NSMixedImage" ref="315854375"/> + </object> + <object class="NSMenuItem" id="826127767"> + <reference key="NSMenu" ref="65194311"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="625762401"/> + <reference key="NSMixedImage" ref="315854375"/> + </object> + <object class="NSMenuItem" id="587544115"> + <reference key="NSMenu" ref="65194311"/> + <string key="NSTitle">Reverse Sort Order</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="625762401"/> + <reference key="NSMixedImage" ref="315854375"/> + </object> + </object> + </object> + </object> + <object class="NSMenuItem" id="486174990"> + <reference key="NSMenu" ref="466354362"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="625762401"/> + <reference key="NSMixedImage" ref="315854375"/> + </object> <object class="NSMenuItem" id="358795349"> <reference key="NSMenu" ref="466354362"/> <string key="NSTitle">Hide Toolbar</string> @@ -2950,6 +3017,38 @@ </object> <int key="connectionID">1051</int> </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">sortFavorites:</string> + <reference key="source" ref="63651044"/> + <reference key="destination" ref="467685932"/> + </object> + <int key="connectionID">1066</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">sortFavorites:</string> + <reference key="source" ref="63651044"/> + <reference key="destination" ref="326070376"/> + </object> + <int key="connectionID">1067</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">reverseFavoritesSortOrder:</string> + <reference key="source" ref="63651044"/> + <reference key="destination" ref="587544115"/> + </object> + <int key="connectionID">1068</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">sortFavorites:</string> + <reference key="source" ref="63651044"/> + <reference key="destination" ref="836793492"/> + </object> + <int key="connectionID">1070</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -4274,6 +4373,8 @@ <reference ref="438779812"/> <reference ref="388367969"/> <reference ref="417888240"/> + <reference ref="121425259"/> + <reference ref="486174990"/> </object> <reference key="parent" ref="401969940"/> </object> @@ -4357,6 +4458,58 @@ <reference key="object" ref="417888240"/> <reference key="parent" ref="466354362"/> </object> + <object class="IBObjectRecord"> + <int key="objectID">1058</int> + <reference key="object" ref="121425259"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="65194311"/> + </object> + <reference key="parent" ref="466354362"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1059</int> + <reference key="object" ref="65194311"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="467685932"/> + <reference ref="326070376"/> + <reference ref="826127767"/> + <reference ref="587544115"/> + <reference ref="836793492"/> + </object> + <reference key="parent" ref="121425259"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1061</int> + <reference key="object" ref="486174990"/> + <reference key="parent" ref="466354362"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1062</int> + <reference key="object" ref="467685932"/> + <reference key="parent" ref="65194311"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1063</int> + <reference key="object" ref="326070376"/> + <reference key="parent" ref="65194311"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1064</int> + <reference key="object" ref="826127767"/> + <reference key="parent" ref="65194311"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1065</int> + <reference key="object" ref="587544115"/> + <reference key="parent" ref="65194311"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1069</int> + <reference key="object" ref="836793492"/> + <reference key="parent" ref="65194311"/> + </object> </object> </object> <object class="NSMutableDictionary" key="flattenedProperties"> @@ -4385,10 +4538,19 @@ <string>1047.IBPluginDependency</string> <string>1048.IBPluginDependency</string> <string>1050.IBPluginDependency</string> + <string>1058.IBPluginDependency</string> + <string>1059.IBEditorWindowLastContentRect</string> + <string>1059.IBPluginDependency</string> <string>106.IBEditorWindowLastContentRect</string> <string>106.IBPluginDependency</string> <string>106.ImportedFromIB2</string> <string>106.editorWindowContentRectSynchronizationRect</string> + <string>1061.IBPluginDependency</string> + <string>1062.IBPluginDependency</string> + <string>1063.IBPluginDependency</string> + <string>1064.IBPluginDependency</string> + <string>1065.IBPluginDependency</string> + <string>1069.IBPluginDependency</string> <string>111.IBPluginDependency</string> <string>111.ImportedFromIB2</string> <string>129.IBPluginDependency</string> @@ -4753,11 +4915,20 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>{{765, 481}, {180, 93}}</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>{{824, 199}, {204, 153}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1"/> <string>{{561, 605}, {181, 43}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1"/> @@ -4889,7 +5060,7 @@ <integer value="1"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1"/> - <string>{{514, 531}, {251, 293}}</string> + <string>{{514, 501}, {251, 323}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1"/> <string>{{698, 703}, {184, 133}}</string> @@ -5163,7 +5334,7 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">1057</int> + <int key="maxID">1070</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -5346,7 +5517,7 @@ </object> <object class="IBPartialClassDescription"> <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier" id="472462125"> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="381988713"> <string key="majorKey">IBProjectSource</string> <string key="minorKey">Source/SPQueryFavoriteManager.h</string> </object> @@ -5528,6 +5699,118 @@ <reference key="sourceIdentifier" ref="296977353"/> </object> <object class="IBPartialClassDescription"> + <string key="className">SPPreferenceController</string> + <string key="superclassName">NSWindowController</string> + <object class="NSMutableDictionary" key="actions"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>addFavorite:</string> + <string>changeFont:</string> + <string>displayAutoUpdatePreferences:</string> + <string>displayEditorPreferences:</string> + <string>displayFavoritePreferences:</string> + <string>displayGeneralPreferences:</string> + <string>displayNetworkPreferences:</string> + <string>displayNotificationPreferences:</string> + <string>displayTablePreferences:</string> + <string>duplicateFavorite:</string> + <string>favoriteTypeDidChange:</string> + <string>removeFavorite:</string> + <string>reverseFavoritesSortOrder:</string> + <string>setDefaultColors:</string> + <string>showCustomQueryFontPanel:</string> + <string>showGlobalResultTableFontPanel:</string> + <string>sortFavorites:</string> + <string>updateDefaultFavorite:</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + </object> + </object> + <object class="NSMutableDictionary" key="outlets"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>autoUpdateView</string> + <string>defaultFavoritePopup</string> + <string>editorFontName</string> + <string>editorView</string> + <string>favoriteHostTextField</string> + <string>favoriteHostTextFieldSSH</string> + <string>favoriteNameTextField</string> + <string>favoriteUserTextField</string> + <string>favoriteUserTextFieldSSH</string> + <string>favoriteUserTextFieldSocket</string> + <string>favoritesController</string> + <string>favoritesTabView</string> + <string>favoritesTableView</string> + <string>favoritesView</string> + <string>generalView</string> + <string>globalResultTableFontName</string> + <string>networkView</string> + <string>notificationsView</string> + <string>preferencesWindow</string> + <string>socketPasswordField</string> + <string>sshPasswordField</string> + <string>sshSQLPasswordField</string> + <string>standardPasswordField</string> + <string>tableCell</string> + <string>tablesView</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>NSView</string> + <string>NSPopUpButton</string> + <string>NSTextField</string> + <string>NSView</string> + <string>NSTextField</string> + <string>NSTextField</string> + <string>NSTextField</string> + <string>NSTextField</string> + <string>NSTextField</string> + <string>NSTextField</string> + <string>NSArrayController</string> + <string>NSTabView</string> + <string>NSTableView</string> + <string>NSView</string> + <string>NSView</string> + <string>NSTextField</string> + <string>NSView</string> + <string>NSView</string> + <string>NSWindow</string> + <string>NSSecureTextField</string> + <string>NSSecureTextField</string> + <string>NSSecureTextField</string> + <string>NSSecureTextField</string> + <string>id</string> + <string>NSView</string> + </object> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">Source/SPPreferenceController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> <string key="className">SPProcessListController</string> <string key="superclassName">NSWindowController</string> <object class="NSMutableDictionary" key="actions"> @@ -5696,7 +5979,7 @@ <string>BWAnchoredButtonBar</string> </object> </object> - <reference key="sourceIdentifier" ref="472462125"/> + <reference key="sourceIdentifier" ref="381988713"/> </object> <object class="IBPartialClassDescription"> <string key="className">SPServerVariablesController</string> diff --git a/Resources/PreferenceDefaults.plist b/Resources/PreferenceDefaults.plist index 281afa3a..1e71ad22 100644 --- a/Resources/PreferenceDefaults.plist +++ b/Resources/PreferenceDefaults.plist @@ -153,5 +153,13 @@ <true/> <key>PrintWarningRowLimit</key> <integer>1000</integer> + <key>ProcessListShowProcessID</key> + <true/> + <key>ProcessListShowFullProcessList</key> + <true/> + <key>FavoritesSortedBy</key> + <integer>0</integer> + <key>FavoritesSortedInReverse</key> + <false/> </dict> </plist> diff --git a/Source/SPConstants.h b/Source/SPConstants.h index 54bce4d1..c849c3ba 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -93,6 +93,14 @@ typedef enum SPSSHPasswordNone = 2 } SPSSHTunnelPasswordMode; +// Sort by constants +typedef enum +{ + SPFavoritesSortNameItem = 0, + SPFavoritesSortHostItem = 1, + SPFavoritesSortTypeItem = 2 +} SPFavoritesSortItem; + // Long running notification time for Growl messages extern const CGFloat SPLongRunningNotificationTime; @@ -200,6 +208,8 @@ extern NSString *SPTableInformationPanelCollapsed; extern NSString *SPTableColumnWidths; extern NSString *SPProcessListShowProcessID; extern NSString *SPProcessListShowFullProcessList; +extern NSString *SPFavoritesSortedBy; +extern NSString *SPFavoritesSortedInReverse; // Hidden Prefs extern NSString *SPPrintWarningRowLimit; diff --git a/Source/SPConstants.m b/Source/SPConstants.m index f0df9dac..8a2729e8 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -130,6 +130,8 @@ NSString *SPTableInformationPanelCollapsed = @"TableInformationPanelCollap NSString *SPTableColumnWidths = @"tableColumnWidths"; NSString *SPProcessListShowProcessID = @"ProcessListShowProcessID"; NSString *SPProcessListShowFullProcessList = @"ProcessListShowFullProcessList"; +NSString *SPFavoritesSortedBy = @"FavoritesSortedBy"; +NSString *SPFavoritesSortedInReverse = @"FavoritesSortedInReverse"; // Hidden Prefs NSString *SPPrintWarningRowLimit = @"PrintWarningRowLimit"; diff --git a/Source/SPPreferenceController.h b/Source/SPPreferenceController.h index e8e7a50d..029993d9 100644 --- a/Source/SPPreferenceController.h +++ b/Source/SPPreferenceController.h @@ -25,6 +25,8 @@ #import <Cocoa/Cocoa.h> +#import "SPConstants.h" + @class SPKeychain; @interface SPPreferenceController : NSWindowController @@ -57,15 +59,13 @@ IBOutlet NSTextField *favoriteHostTextFieldSSH; IBOutlet id tableCell; - - SPKeychain *keychain; - NSDictionary *currentFavorite; - + IBOutlet NSTextField *editorFontName; IBOutlet NSTextField *globalResultTableFontName; - NSInteger fontChangeTarget; - + SPKeychain *keychain; + NSDictionary *currentFavorite; + NSToolbar *toolbar; NSToolbarItem *generalItem; @@ -80,7 +80,10 @@ NSUserDefaults *prefs; BOOL favoriteNameFieldWasTouched; - NSInteger favoriteType; + NSInteger favoriteType, fontChangeTarget; + + BOOL reverseFavoritesSort; + SPFavoritesSortItem previousSortItem, currentSortItem; } - (void)applyRevisionChanges; @@ -89,10 +92,12 @@ - (IBAction)addFavorite:(id)sender; - (IBAction)removeFavorite:(id)sender; - (IBAction)duplicateFavorite:(id)sender; - - (IBAction)updateDefaultFavorite:(id)sender; +- (IBAction)updateDefaultFavorite:(id)sender; - (IBAction)showCustomQueryFontPanel:(id)sender; - (IBAction)showGlobalResultTableFontPanel:(id)sender; - (IBAction)setDefaultColors:(id)sender; +- (IBAction)sortFavorites:(id)sender; +- (IBAction)reverseFavoritesSortOrder:(id)sender; // Toolbar item IBAction methods - (IBAction)displayGeneralPreferences:(id)sender; diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m index 33cc9e81..760a48b8 100644 --- a/Source/SPPreferenceController.m +++ b/Source/SPPreferenceController.m @@ -34,6 +34,7 @@ @interface SPPreferenceController (PrivateAPI) - (void)_setupToolbar; +- (void)_sortFavorites; - (void)_resizeWindowForContentView:(NSView *)view; @end @@ -57,6 +58,9 @@ favoriteNameFieldWasTouched = YES; favoriteType = 0; fontChangeTarget = 0; + reverseFavoritesSort = NO; + + previousSortItem = SPFavoritesSortNameItem; } return self; @@ -71,6 +75,10 @@ keychain = [[SPKeychain alloc] init]; + // Set sort items + currentSortItem = [prefs integerForKey:SPFavoritesSortedBy]; + reverseFavoritesSort = [prefs boolForKey:SPFavoritesSortedInReverse]; + [tableCell setImage:[NSImage imageNamed:@"database"]]; // Replace column's NSTextFieldCell with custom SWProfileTextFieldCell @@ -87,6 +95,8 @@ [self updateDefaultFavoritePopup]; [prefs synchronize]; + + [self _sortFavorites]; } #pragma mark - @@ -425,6 +435,38 @@ } } +/** + * Sorts the favorites table view based on the selected sort by item + */ +- (IBAction)sortFavorites:(id)sender +{ + previousSortItem = currentSortItem; + currentSortItem = [[sender menu] indexOfItem:sender]; + + [prefs setInteger:currentSortItem forKey:SPFavoritesSortedBy]; + + // Perform sorting + [self _sortFavorites]; + + [[[sender menu] itemAtIndex:previousSortItem] setState:NSOffState]; + [[[sender menu] itemAtIndex:currentSortItem] setState:NSOnState]; +} + +/** + * Reverses the favorites table view sorting based on the selected criteria + */ +- (IBAction)reverseFavoritesSortOrder:(id)sender +{ + reverseFavoritesSort = (![sender state]); + + [prefs setBool:reverseFavoritesSort forKey:SPFavoritesSortedInReverse]; + + // Perform re-sorting + [self _sortFavorites]; + + [sender setState:reverseFavoritesSort]; +} + #pragma mark - #pragma mark Toolbar item IBAction methods @@ -1113,6 +1155,22 @@ return ([favoritesTableView numberOfSelectedRows] > 0); } + if ((action == @selector(sortFavorites:)) || (action == @selector(reverseFavoritesSortOrder:))) { + + // Loop all the items in the sort by menu only checking the currently selected one + for (NSMenuItem *item in [[menuItem menu] itemArray]) + { + [item setState:([[menuItem menu] indexOfItem:item] == currentSortItem) ? NSOnState : NSOffState]; + } + + // Check or uncheck the reverse sort item + if (action == @selector(reverseFavoritesSortOrder:)) { + [menuItem setState:reverseFavoritesSort]; + } + + return [[toolbar selectedItemIdentifier] isEqualToString:SPPreferenceToolbarFavorites]; + } + return YES; } @@ -1219,6 +1277,43 @@ [self displayGeneralPreferences:nil]; } +/** + * Sorts the connection favorites based on the selected criteria. + */ +- (void)_sortFavorites +{ + NSString *sortKey = @""; + + switch (currentSortItem) + { + case SPFavoritesSortNameItem: + sortKey = @"name"; + break; + case SPFavoritesSortHostItem: + sortKey = @"host"; + break; + case SPFavoritesSortTypeItem: + sortKey = @"type"; + break; + default: + sortKey = @"name"; + break; + } + + NSSortDescriptor *sortDescriptor = nil; + + if (currentSortItem == SPFavoritesSortTypeItem) { + sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:sortKey ascending:reverseFavoritesSort] autorelease]; + } + else { + sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:sortKey ascending:reverseFavoritesSort selector:@selector(caseInsensitiveCompare:)] autorelease]; + } + + [favoritesController setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]]; + + [favoritesTableView reloadData]; +} + // ------------------------------------------------------------------------------- // _resizeWindowForContentView: // diff --git a/Source/TableDocument.m b/Source/TableDocument.m index d73fa943..2a95c158 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -3148,6 +3148,12 @@ return ([[tablesListInstance valueForKeyPath:@"tables"] count] > 1); } + + // If validation for the sort favorites tableview items reaches here then the preferences window isn't + // open return NO. + if (([menuItem action] == @selector(sortFavorites:)) || ([menuItem action] == @selector(reverseFavoritesSortOrder:))) { + return NO; + } return [super validateMenuItem:menuItem]; } |