diff options
author | stuconnolly <stuart02@gmail.com> | 2010-03-27 01:25:27 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2010-03-27 01:25:27 +0000 |
commit | 0201464cf3c23d82ea5a476d9224e82ec5b2e479 (patch) | |
tree | e6bdbfc862150282094ae51ecc94b4663ca18870 /Source/SPPreferenceController.m | |
parent | 7c2de8d57e2ef4e463ae788ab2b58b019c8c9828 (diff) | |
download | sequelpro-0201464cf3c23d82ea5a476d9224e82ec5b2e479.tar.gz sequelpro-0201464cf3c23d82ea5a476d9224e82ec5b2e479.tar.bz2 sequelpro-0201464cf3c23d82ea5a476d9224e82ec5b2e479.zip |
Add a contextual menu to the favorites table view in the preferences.
Diffstat (limited to 'Source/SPPreferenceController.m')
-rw-r--r-- | Source/SPPreferenceController.m | 64 |
1 files changed, 35 insertions, 29 deletions
diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m index e365f296..af80ba7f 100644 --- a/Source/SPPreferenceController.m +++ b/Source/SPPreferenceController.m @@ -49,6 +49,7 @@ { if (self = [super initWithWindowNibName:@"Preferences"]) { prefs = [NSUserDefaults standardUserDefaults]; + [self applyRevisionChanges]; currentFavorite = nil; @@ -410,14 +411,6 @@ } // ------------------------------------------------------------------------------- -// saveFavorite: -// ------------------------------------------------------------------------------- -- (IBAction)saveFavorite:(id)sender -{ - -} - -// ------------------------------------------------------------------------------- // updateDefaultFavorite: // ------------------------------------------------------------------------------- - (IBAction)updateDefaultFavorite:(id)sender @@ -558,15 +551,15 @@ // ------------------------------------------------------------------------------- - (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rows toPasteboard:(NSPasteboard*)pboard { - if ([rows count] == 1) { [pboard declareTypes:[NSArray arrayWithObject:SPFavoritesPasteboardDragType] owner:nil]; [pboard setString:[[NSNumber numberWithInteger:[rows firstIndex]] stringValue] forType:SPFavoritesPasteboardDragType]; + return YES; - } else { + } + else { return NO; } - } // ------------------------------------------------------------------------------- @@ -627,6 +620,7 @@ if ([prefs integerForKey:SPDefaultFavorite] == originalRow) { [prefs setInteger:destinationRow forKey:SPDefaultFavorite]; } + [self updateDefaultFavoritePopup]; return YES; @@ -777,7 +771,6 @@ // ------------------------------------------------------------------------------- - (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor { - // Request a password refresh to keep keychain references in synch with favorites [self updateFavoritePasswordsFromField:control]; @@ -793,8 +786,8 @@ // ------------------------------------------------------------------------------- - (void)controlTextDidChange:(NSNotification *)aNotification { - id field = [aNotification object]; + BOOL nameFieldIsEmpty = ( [[favoritesController valueForKeyPath:@"selection.name"] isEqualToString:@""] || [[favoriteNameTextField stringValue] isEqualToString:@""]); @@ -831,11 +824,9 @@ break; } - if(field == favoriteNameTextField) { favoriteNameFieldWasTouched = YES; } - } // ------------------------------------------------------------------------------- // favoriteTypeDidChange: @@ -843,7 +834,6 @@ // ------------------------------------------------------------------------------- - (IBAction)favoriteTypeDidChange:(id)sender { - // If not socket and host is localhost, clear. if ([sender indexOfSelectedItem] != 1 && [[favoritesController valueForKeyPath:@"selection.host"] isEqualToString:@"localhost"]) @@ -963,11 +953,9 @@ // ------------------------------------------------------------------------------- - (void)windowWillClose:(NSNotification *)notification { - // Mark the currently selected field in the window as having finished editing, to trigger saves. if ([preferencesWindow firstResponder]) [preferencesWindow endEditingFor:[preferencesWindow firstResponder]]; - } #pragma mark - @@ -1072,10 +1060,10 @@ [[NSFontPanel sharedFontPanel] setPanelFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorFont]] isMultiple:NO]; [[NSFontPanel sharedFontPanel] makeKeyAndOrderFront:self]; } + // reset syntax highlighting colors - (IBAction)setDefaultColors:(id)sender { - [prefs setObject:[NSArchiver archivedDataWithRootObject:[NSColor colorWithDeviceRed:0.000 green:0.455 blue:0.000 alpha:1.000]] forKey:SPCustomQueryEditorCommentColor]; [prefs setObject:[NSArchiver archivedDataWithRootObject:[NSColor colorWithDeviceRed:0.769 green:0.102 blue:0.086 alpha:1.000]] forKey:SPCustomQueryEditorQuoteColor]; [prefs setObject:[NSArchiver archivedDataWithRootObject:[NSColor colorWithDeviceRed:0.200 green:0.250 blue:1.000 alpha:1.000]] forKey:SPCustomQueryEditorSQLKeywordColor]; @@ -1086,7 +1074,6 @@ [prefs setObject:[NSArchiver archivedDataWithRootObject:[NSColor blackColor]] forKey:SPCustomQueryEditorTextColor]; [prefs setObject:[NSArchiver archivedDataWithRootObject:[NSColor blackColor]] forKey:SPCustomQueryEditorCaretColor]; [prefs setObject:[NSArchiver archivedDataWithRootObject:[NSColor whiteColor]] forKey:SPCustomQueryEditorBackgroundColor]; - } // Set font panel's valid modes @@ -1099,20 +1086,39 @@ - (void)changeFont:(id)sender { NSFont *nf; - switch(fontChangeTarget) { + + switch(fontChangeTarget) + { case 1: - nf = [[NSFontPanel sharedFontPanel] panelConvertFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPGlobalResultTableFont]]]; - [prefs setObject:[NSArchiver archivedDataWithRootObject:nf] forKey:SPGlobalResultTableFont]; - [globalResultTableFontName setStringValue:[NSString stringWithFormat:@"%@, %.1f pt", [nf displayName], [nf pointSize]]]; - break; + nf = [[NSFontPanel sharedFontPanel] panelConvertFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPGlobalResultTableFont]]]; + [prefs setObject:[NSArchiver archivedDataWithRootObject:nf] forKey:SPGlobalResultTableFont]; + [globalResultTableFontName setStringValue:[NSString stringWithFormat:@"%@, %.1f pt", [nf displayName], [nf pointSize]]]; + break; case 2: - nf = [[NSFontPanel sharedFontPanel] panelConvertFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorFont]]]; - [prefs setObject:[NSArchiver archivedDataWithRootObject:nf] forKey:SPCustomQueryEditorFont]; - [editorFontName setStringValue:[NSString stringWithFormat:@"%@, %.1f pt", [nf displayName], [nf pointSize]]]; - break; + nf = [[NSFontPanel sharedFontPanel] panelConvertFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorFont]]]; + [prefs setObject:[NSArchiver archivedDataWithRootObject:nf] forKey:SPCustomQueryEditorFont]; + [editorFontName setStringValue:[NSString stringWithFormat:@"%@, %.1f pt", [nf displayName], [nf pointSize]]]; + break; } } +/** + * Menu item validation; + */ +- (BOOL)validateMenuItem:(NSMenuItem *)menuItem +{ + SEL action = [menuItem action]; + + if ((action == @selector(removeFavorite:)) || (action == @selector(duplicateFavorite:))) { + return ([favoritesTableView numberOfSelectedRows] > 0); + } + + return [super validateMenuItem:menuItem]; +} + + +#pragma mark - + // ------------------------------------------------------------------------------- // dealloc // ------------------------------------------------------------------------------- |