aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-01-04 21:10:26 +0100
committerMax <post@wickenrode.com>2015-01-04 21:10:26 +0100
commit5b55d8c4d24b0c24a5dc74a49cfd70448146d582 (patch)
treeda23678da48ba88a6022f1fee0fc3d61d3f23c9f /Source
parent2735e15bf5d4b3a976435ebb29ca9073de0e5071 (diff)
downloadsequelpro-5b55d8c4d24b0c24a5dc74a49cfd70448146d582.tar.gz
sequelpro-5b55d8c4d24b0c24a5dc74a49cfd70448146d582.tar.bz2
sequelpro-5b55d8c4d24b0c24a5dc74a49cfd70448146d582.zip
Replace some "magic numbers" with constants
Diffstat (limited to 'Source')
-rw-r--r--Source/SPConstants.h8
-rw-r--r--Source/SPDatabaseDocument.m12
-rw-r--r--Source/SPWindowController.m4
3 files changed, 16 insertions, 8 deletions
diff --git a/Source/SPConstants.h b/Source/SPConstants.h
index f0350f07..a2df5bde 100644
--- a/Source/SPConstants.h
+++ b/Source/SPConstants.h
@@ -148,6 +148,14 @@ typedef enum
{
SPMainMenuSequelPro = 0,
SPMainMenuFile = 1,
+ SPMainMenuFileSaveConnection = 1004,
+ SPMainMenuFileSaveConnectionAs = 1005,
+ SPMainMenuFileSaveQuery = 1006,
+ SPMainMenuFileSaveQueryAs = 1008,
+ SPMainMenuFileSaveSession = 1020,
+ SPMainMenuFileSaveSessionAs = 1021,
+ SPMainMenuFileClose = 1003,
+ SPMainMenuFileCloseTab = 1103,
SPMainMenuEdit = 2,
SPMainMenuView = 3,
SPMainMenuDatabase = 4,
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index 6940abfb..ab8eafc6 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -2831,10 +2831,10 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase";
[panel setCanSelectHiddenExtension:YES];
// Save Query...
- if (sender != nil && ([sender tag] == 1006 || [sender tag] == 1008)) {
+ if (sender != nil && ([sender tag] == SPMainMenuFileSaveQuery || [sender tag] == SPMainMenuFileSaveQueryAs)) {
// If Save was invoked, check whether the file was previously opened, and if so save without the panel
- if ([sender tag] == 1006 && [[[self sqlFileURL] path] length]) {
+ if ([sender tag] == SPMainMenuFileSaveQuery && [[[self sqlFileURL] path] length]) {
NSError *error = nil;
NSString *content = [NSString stringWithString:[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string]];
[content writeToURL:sqlFileURL atomically:YES encoding:sqlFileEncoding error:&error];
@@ -2865,11 +2865,11 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase";
// Save As… or Save
}
- else if (sender == nil || [sender tag] == 1005 || [sender tag] == 1004) {
+ else if (sender == nil || [sender tag] == SPMainMenuFileSaveConnection || [sender tag] == SPMainMenuFileSaveConnectionAs) {
// If Save was invoked check for fileURL and Untitled docs and save the spf file without save panel
// otherwise ask for file name
- if (sender != nil && [sender tag] == 1004 && [[[self fileURL] path] length] && ![self isUntitled]) {
+ if (sender != nil && [sender tag] == SPMainMenuFileSaveConnection && [[[self fileURL] path] length] && ![self isUntitled]) {
[self saveDocumentWithFilePath:nil inBackground:YES onlyPreferences:NO contextInfo:nil];
return;
}
@@ -2920,10 +2920,10 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase";
contextInfo = sender == nil ? @"saveSPFfileAndClose" : @"saveSPFfile";
}
// Save Session or Save Session As...
- else if (sender == nil || [sender tag] == 1020 || [sender tag] == 1021)
+ else if (sender == nil || [sender tag] == SPMainMenuFileSaveSession || [sender tag] == SPMainMenuFileSaveSessionAs)
{
// Save As Session
- if ([sender tag] == 1020 && [SPAppDelegate sessionURL]) {
+ if ([sender tag] == SPMainMenuFileSaveSession && [SPAppDelegate sessionURL]) {
[self saveConnectionPanelDidEnd:panel returnCode:1 contextInfo:@"saveAsSession"];
return;
}
diff --git a/Source/SPWindowController.m b/Source/SPWindowController.m
index f90b423d..6edbb684 100644
--- a/Source/SPWindowController.m
+++ b/Source/SPWindowController.m
@@ -83,8 +83,8 @@ enum {
[self _setUpTabBar];
// Retrieve references to the 'Close Window' and 'Close Tab' menus. These are updated as window focus changes.
- closeWindowMenuItem = [[[[NSApp mainMenu] itemWithTag:SPMainMenuFile] submenu] itemWithTag:1003];
- closeTabMenuItem = [[[[NSApp mainMenu] itemWithTag:SPMainMenuFile] submenu] itemWithTag:1103];
+ closeWindowMenuItem = [[[[NSApp mainMenu] itemWithTag:SPMainMenuFile] submenu] itemWithTag:SPMainMenuFileClose];
+ closeTabMenuItem = [[[[NSApp mainMenu] itemWithTag:SPMainMenuFile] submenu] itemWithTag:SPMainMenuFileCloseTab];
// Register for drag start and stop notifications - used to show/hide tab bars
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tabDragStarted:) name:PSMTabDragDidBeginNotification object:nil];