aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2014-12-31 03:00:10 +0100
committerMax <post@wickenrode.com>2014-12-31 03:00:10 +0100
commitf12b95bb7b3dda011dea4bb3e0edff1428a38209 (patch)
tree3d180f6e40b6854151c0df9e76301baad0ff0332 /Source
parent2d8fd9c8eff0afca2cab9b8bbb791a0cdf1c583a (diff)
downloadsequelpro-f12b95bb7b3dda011dea4bb3e0edff1428a38209.tar.gz
sequelpro-f12b95bb7b3dda011dea4bb3e0edff1428a38209.tar.bz2
sequelpro-f12b95bb7b3dda011dea4bb3e0edff1428a38209.zip
Remove some duplicate code by adding abstraction
Diffstat (limited to 'Source')
-rw-r--r--Source/SPEditorPreferencePane.m8
-rw-r--r--Source/SPPreferenceController.h2
-rw-r--r--Source/SPPreferenceController.m39
-rw-r--r--Source/SPPreferencePane.h2
-rw-r--r--Source/SPPreferencePane.m5
-rw-r--r--Source/SPPreferencePaneProtocol.h5
-rw-r--r--Source/SPTablesPreferencePane.m5
7 files changed, 28 insertions, 38 deletions
diff --git a/Source/SPEditorPreferencePane.m b/Source/SPEditorPreferencePane.m
index d5127e65..08a833c2 100644
--- a/Source/SPEditorPreferencePane.m
+++ b/Source/SPEditorPreferencePane.m
@@ -732,6 +732,14 @@ static NSString *SPCustomColorSchemeNameLC = @"user-defined";
return NO;
}
+- (void)preferencePaneWillBeShown
+{
+ [self updateColorSchemeSelectionMenu];
+ [self updateDisplayColorThemeName];
+
+ [self updateDisplayedEditorFontName];
+}
+
#pragma mark -
#pragma mark Private API
diff --git a/Source/SPPreferenceController.h b/Source/SPPreferenceController.h
index a001b60c..c34f8542 100644
--- a/Source/SPPreferenceController.h
+++ b/Source/SPPreferenceController.h
@@ -84,8 +84,6 @@
// Toolbar item IBAction methods
- (IBAction)displayPreferencePane:(id)sender;
-- (IBAction)displayTablePreferences:(id)sender;
-- (IBAction)displayEditorPreferences:(id)sender;
- (void)changeFont:(id)sender;
diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m
index 3a67ae80..d28dfcb9 100644
--- a/Source/SPPreferenceController.m
+++ b/Source/SPPreferenceController.m
@@ -105,40 +105,9 @@
[toolbar setSelectedItemIdentifier:[preferencePane preferencePaneIdentifier]];
- [self _resizeWindowForContentView:[preferencePane preferencePaneView]];
-}
-
-/**
- * Displays the table preferences pane.
- */
-- (IBAction)displayTablePreferences:(id)sender
-{
- [[self window] setMinSize:NSMakeSize(0, 0)];
- [[self window] setShowsResizeIndicator:[tablesPreferencePane preferencePaneAllowsResizing]];
-
- [toolbar setSelectedItemIdentifier:[tablesPreferencePane preferencePaneIdentifier]];
-
- [(SPTablesPreferencePane *)tablesPreferencePane updateDisplayedTableFontName];
-
- [self _resizeWindowForContentView:[tablesPreferencePane preferencePaneView]];
-}
-
-/**
- * Displays the editor preferences pane.
- */
-- (IBAction)displayEditorPreferences:(id)sender
-{
- [(SPEditorPreferencePane *)editorPreferencePane updateColorSchemeSelectionMenu];
- [(SPEditorPreferencePane *)editorPreferencePane updateDisplayColorThemeName];
+ [preferencePane preferencePaneWillBeShown];
- [[self window] setMinSize:NSMakeSize(0, 0)];
- [[self window] setShowsResizeIndicator:[editorPreferencePane preferencePaneAllowsResizing]];
-
- [toolbar setSelectedItemIdentifier:[editorPreferencePane preferencePaneIdentifier]];
-
- [(SPEditorPreferencePane *)editorPreferencePane updateDisplayedEditorFontName];
-
- [self _resizeWindowForContentView:[editorPreferencePane preferencePaneView]];
+ [self _resizeWindowForContentView:[preferencePane preferencePaneView]];
}
#pragma mark -
@@ -198,7 +167,7 @@
[tablesItem setLabel:[tablesPreferencePane preferencePaneName]];
[tablesItem setImage:[tablesPreferencePane preferencePaneIcon]];
[tablesItem setTarget:self];
- [tablesItem setAction:@selector(displayTablePreferences:)];
+ [tablesItem setAction:@selector(displayPreferencePane:)];
// Notification preferences
notificationsItem = [[NSToolbarItem alloc] initWithItemIdentifier:[notificationsPreferencePane preferencePaneIdentifier]];
@@ -214,7 +183,7 @@
[editorItem setLabel:[editorPreferencePane preferencePaneName]];
[editorItem setImage:[editorPreferencePane preferencePaneIcon]];
[editorItem setTarget:self];
- [editorItem setAction:@selector(displayEditorPreferences:)];
+ [editorItem setAction:@selector(displayPreferencePane:)];
// AutoUpdate preferences
autoUpdateItem = [[NSToolbarItem alloc] initWithItemIdentifier:[autoUpdatePreferencePane preferencePaneIdentifier]];
diff --git a/Source/SPPreferencePane.h b/Source/SPPreferencePane.h
index 39d239c8..19e0436b 100644
--- a/Source/SPPreferencePane.h
+++ b/Source/SPPreferencePane.h
@@ -42,5 +42,5 @@
{
NSUserDefaults *prefs;
}
-
+- (void)preferencePaneWillBeShown;
@end
diff --git a/Source/SPPreferencePane.m b/Source/SPPreferencePane.m
index a1b85ed7..39a870c7 100644
--- a/Source/SPPreferencePane.m
+++ b/Source/SPPreferencePane.m
@@ -47,4 +47,9 @@
return self;
}
+- (void)preferencePaneWillBeShown
+{
+ // Default: do nothing. Override in subclass.
+}
+
@end
diff --git a/Source/SPPreferencePaneProtocol.h b/Source/SPPreferencePaneProtocol.h
index a9d67598..e00e12ec 100644
--- a/Source/SPPreferencePaneProtocol.h
+++ b/Source/SPPreferencePaneProtocol.h
@@ -79,4 +79,9 @@
*/
- (BOOL)preferencePaneAllowsResizing;
+/**
+ * Called shortly before the preference pane will be made visible
+ */
+- (void)preferencePaneWillBeShown;
+
@end
diff --git a/Source/SPTablesPreferencePane.m b/Source/SPTablesPreferencePane.m
index 5c55af94..f89849ec 100644
--- a/Source/SPTablesPreferencePane.m
+++ b/Source/SPTablesPreferencePane.m
@@ -93,4 +93,9 @@
return NO;
}
+- (void)preferencePaneWillBeShown
+{
+ [self updateDisplayedTableFontName];
+}
+
@end