diff options
-rw-r--r-- | Interfaces/English.lproj/DBView.xib | 44 | ||||
-rw-r--r-- | Source/SPIdMenu.h | 47 | ||||
-rw-r--r-- | Source/SPIdMenu.m | 73 | ||||
-rw-r--r-- | Source/SPTableStructureDelegate.m | 6 | ||||
-rw-r--r-- | sequel-pro.xcodeproj/project.pbxproj | 6 |
5 files changed, 171 insertions, 5 deletions
diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index d7f22211..4288acde 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -1675,7 +1675,7 @@ <nil key="NSMenuItem"/> <bool key="NSMenuItemRespectAlignment">YES</bool> <object class="NSMenu" key="NSMenu" id="856601787"> - <string key="NSTitle">encodingPopupMenu</string> + <string key="NSTitle">OtherViews</string> <array class="NSMutableArray" key="NSMenuItems"/> </object> <int key="NSSelectedIndex">-1</int> @@ -1717,7 +1717,7 @@ <nil key="NSMenuItem"/> <bool key="NSMenuItemRespectAlignment">YES</bool> <object class="NSMenu" key="NSMenu" id="65801928"> - <string key="NSTitle">collationPopupMenu</string> + <string key="NSTitle">OtherViews</string> <array class="NSMutableArray" key="NSMenuItems"/> </object> <int key="NSSelectedIndex">-1</int> @@ -26385,10 +26385,40 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes> <boolean value="NO" key="749.showNotes"/> <string key="7490.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <boolean value="NO" key="7490.showNotes"/> + <string key="7491.CustomClassName">SPIdMenu</string> + <object class="NSMutableDictionary" key="7491.IBAttributePlaceholdersKey"> + <string key="NS.key.0">IBUserDefinedRuntimeAttributesPlaceholderName</string> + <object class="IBUserDefinedRuntimeAttributesPlaceholder" key="NS.object.0"> + <string key="name">IBUserDefinedRuntimeAttributesPlaceholderName</string> + <reference key="object" ref="856601787"/> + <array key="userDefinedRuntimeAttributes"> + <object class="IBUserDefinedRuntimeAttribute"> + <string key="typeIdentifier">com.apple.InterfaceBuilder.userDefinedRuntimeAttributeType.string</string> + <string key="keyPath">menuId</string> + <string key="value">encodingPopupMenu</string> + </object> + </array> + </object> + </object> <string key="7491.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <boolean value="NO" key="7491.showNotes"/> <string key="7493.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <boolean value="NO" key="7493.showNotes"/> + <string key="7494.CustomClassName">SPIdMenu</string> + <object class="NSMutableDictionary" key="7494.IBAttributePlaceholdersKey"> + <string key="NS.key.0">IBUserDefinedRuntimeAttributesPlaceholderName</string> + <object class="IBUserDefinedRuntimeAttributesPlaceholder" key="NS.object.0"> + <string key="name">IBUserDefinedRuntimeAttributesPlaceholderName</string> + <reference key="object" ref="65801928"/> + <array key="userDefinedRuntimeAttributes"> + <object class="IBUserDefinedRuntimeAttribute"> + <string key="typeIdentifier">com.apple.InterfaceBuilder.userDefinedRuntimeAttributeType.string</string> + <string key="keyPath">menuId</string> + <string key="value">collationPopupMenu</string> + </object> + </array> + </object> + </object> <string key="7494.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <boolean value="NO" key="7494.showNotes"/> <string key="7499.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -29807,6 +29837,14 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes> </object> </object> <object class="IBPartialClassDescription"> + <string key="className">SPIdMenu</string> + <string key="superclassName">NSMenu</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">../Source/SPIdMenu.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> <string key="className">SPIndexesController</string> <string key="superclassName">NSWindowController</string> <dictionary class="NSMutableDictionary" key="actions"> @@ -31025,7 +31063,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes> </object> <object class="IBToOneOutletInfo" key="infoTable"> <string key="name">infoTable</string> - <string key="candidateClassName">id</string> + <string key="candidateClassName">NSTableView</string> </object> <object class="IBToOneOutletInfo" key="tableDataInstance"> <string key="name">tableDataInstance</string> diff --git a/Source/SPIdMenu.h b/Source/SPIdMenu.h new file mode 100644 index 00000000..dbda8952 --- /dev/null +++ b/Source/SPIdMenu.h @@ -0,0 +1,47 @@ +// +// SPIdMenu.h +// sequel-pro +// +// Created by Max Lohrmann on 02.11.15. +// Copyright (c) 2015 Max Lohrmann. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +// More info at <https://github.com/sequelpro/sequelpro> + +#import <Cocoa/Cocoa.h> + +/** + * This class aims to solve the problem, that the only strong connection between + * a menu in IB and code can be made via an outlet. Since comparing breaks once + * the menu is copied (which NSTableView does for its cells) and the menu title + * is localizable, ie. not constant either, we need to add another field. + * + * Note that menuId can be set via IB's "Custom Runtime Attribute" section. + */ +@interface SPIdMenu : NSMenu { + NSString *_menuId; +} + +@property (copy) NSString *menuId; + +@end diff --git a/Source/SPIdMenu.m b/Source/SPIdMenu.m new file mode 100644 index 00000000..7cb7d97e --- /dev/null +++ b/Source/SPIdMenu.m @@ -0,0 +1,73 @@ +// +// SPIdMenu.m +// sequel-pro +// +// Created by Max Lohrmann on 02.11.15. +// Copyright (c) 2015 Max Lohrmann. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +// More info at <https://github.com/sequelpro/sequelpro> + +#import "SPIdMenu.h" + +@implementation SPIdMenu + +@synthesize menuId = _menuId; + +-(id)copyWithZone:(NSZone *)zone +{ + SPIdMenu *copy = [super copyWithZone:zone]; + copy->_menuId = [[self menuId] copyWithZone:zone]; + return copy; +} + +-(void)dealloc +{ + [self setMenuId:nil]; + [super dealloc]; +} + +- (void)encodeWithCoder:(NSCoder *)aCoder +{ + [super encodeWithCoder:aCoder]; + if([aCoder allowsKeyedCoding]) { + [aCoder encodeObject:[self menuId] forKey:@"SPMenuId"]; + } +} + +- (id)initWithCoder:(NSCoder *)aDecoder +{ + if(self = [super initWithCoder:aDecoder]) { + if([aDecoder allowsKeyedCoding]) { + [self setMenuId:[aDecoder decodeObjectForKey:@"SPMenuId"]]; + } + } + return self; +} + +- (NSString *)description +{ + return [[super description] stringByAppendingFormat:@" with menuId=%@",[self menuId]]; +} + +@end diff --git a/Source/SPTableStructureDelegate.m b/Source/SPTableStructureDelegate.m index 3ff4d6e4..6b2249dc 100644 --- a/Source/SPTableStructureDelegate.m +++ b/Source/SPTableStructureDelegate.m @@ -39,6 +39,7 @@ #import "SPServerSupport.h" #import "SPTablesList.h" #import "SPPillAttachmentCell.h" +#import "SPIdMenu.h" #import <SPMySQL/SPMySQL.h> @@ -654,6 +655,7 @@ static void _BuildMenuWithPills(NSMenu *menu,struct _cmpMap *map,size_t mapEntri - (void)menuNeedsUpdate:(NSMenu *)menu { + if(![menu isKindOfClass:[SPIdMenu class]]) return; //NOTE: NSTableView will usually copy the menu and call this method on the copy. Matching with == won't work! //walk through the menu and clear the attributedTitle if set. This will remove the gray color from the default items @@ -665,7 +667,7 @@ static void _BuildMenuWithPills(NSMenu *menu,struct _cmpMap *map,size_t mapEntri NSDictionary *rowData = NSArrayObjectAtIndex(tableFields, [tableSourceView selectedRow]); - if([[menu title] isEqualToString:@"encodingPopupMenu"]) { + if([[menu menuId] isEqualToString:@"encodingPopupMenu"]) { NSString *tableEncoding = [tableDataInstance tableEncoding]; //NSString *databaseEncoding = [databaseDataInstance getDatabaseDefaultCharacterSet]; //NSString *serverEncoding = [databaseDataInstance getServerDefaultCharacterSet]; @@ -691,7 +693,7 @@ static void _BuildMenuWithPills(NSMenu *menu,struct _cmpMap *map,size_t mapEntri _BuildMenuWithPills(menu, defaultCmp, COUNT_OF(defaultCmp)); } - else if([[menu title] isEqualToString:@"collationPopupMenu"]) { + else if([[menu menuId] isEqualToString:@"collationPopupMenu"]) { NSString *encoding = [rowData objectForKey:@"encodingName"]; NSString *encodingDefaultCollation = [databaseDataInstance getDefaultCollationForEncoding:encoding]; NSString *tableCollation = [tableDataInstance statusValueForKey:@"Collation"]; diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj index 44fe6ecc..7abb7567 100644 --- a/sequel-pro.xcodeproj/project.pbxproj +++ b/sequel-pro.xcodeproj/project.pbxproj @@ -198,6 +198,7 @@ 507FF26A1BC8450100104523 /* SPExportSettingsPersistence.m in Sources */ = {isa = PBXBuildFile; fileRef = 507FF2691BC8450100104523 /* SPExportSettingsPersistence.m */; }; 507FF2A11BCD27A700104523 /* SPFunctions.m in Sources */ = {isa = PBXBuildFile; fileRef = 507FF1111BBCC57600104523 /* SPFunctions.m */; }; 507FF2A21BCD27AE00104523 /* SPOSInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 50EAB5B71A8FBB08008F627A /* SPOSInfo.m */; }; + 5089B0271BE714E300E226CD /* SPIdMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = 5089B0261BE714E300E226CD /* SPIdMenu.m */; }; 50A9F8B119EAD4B90053E571 /* SPGotoDatabaseController.m in Sources */ = {isa = PBXBuildFile; fileRef = 50A9F8B019EAD4B90053E571 /* SPGotoDatabaseController.m */; }; 50D3C3491A75B8A800B5429C /* GotoDatabaseDialog.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50D3C34B1A75B8A800B5429C /* GotoDatabaseDialog.xib */; }; 50D3C3521A77135F00B5429C /* SPParserUtils.c in Sources */ = {isa = PBXBuildFile; fileRef = 50D3C3501A77135F00B5429C /* SPParserUtils.c */; }; @@ -916,6 +917,8 @@ 507FF1111BBCC57600104523 /* SPFunctions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPFunctions.m; sourceTree = "<group>"; }; 507FF2681BC8450100104523 /* SPExportSettingsPersistence.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPExportSettingsPersistence.h; sourceTree = "<group>"; }; 507FF2691BC8450100104523 /* SPExportSettingsPersistence.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPExportSettingsPersistence.m; sourceTree = "<group>"; }; + 5089B0251BE714E300E226CD /* SPIdMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPIdMenu.h; sourceTree = "<group>"; }; + 5089B0261BE714E300E226CD /* SPIdMenu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPIdMenu.m; sourceTree = "<group>"; }; 50A9F8AF19EAD4B90053E571 /* SPGotoDatabaseController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPGotoDatabaseController.h; sourceTree = "<group>"; }; 50A9F8B019EAD4B90053E571 /* SPGotoDatabaseController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPGotoDatabaseController.m; sourceTree = "<group>"; }; 50D3C34A1A75B8A800B5429C /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/GotoDatabaseDialog.xib; sourceTree = "<group>"; }; @@ -2394,6 +2397,8 @@ children = ( 507FF1101BBCC4C400104523 /* SPFunctions.h */, 507FF1111BBCC57600104523 /* SPFunctions.m */, + 5089B0251BE714E300E226CD /* SPIdMenu.h */, + 5089B0261BE714E300E226CD /* SPIdMenu.m */, ); name = Utility; sourceTree = "<group>"; @@ -3248,6 +3253,7 @@ 171312CE109D23C700FB465F /* SPTableTextFieldCell.m in Sources */, 174CE14210AB9281008F892B /* SPProcessListController.m in Sources */, 1792C13710AD75C800ABE758 /* SPServerVariablesController.m in Sources */, + 5089B0271BE714E300E226CD /* SPIdMenu.m in Sources */, 1792C26110AE1A2D00ABE758 /* SPConnectionDelegate.m in Sources */, 17CC97F310B4ABE90034CD7A /* SPAboutController.m in Sources */, 5870868410FA3E9C00D58E1C /* SPDataStorage.m in Sources */, |