diff --git a/hallelujah.xcodeproj/project.pbxproj b/hallelujah.xcodeproj/project.pbxproj index 95e81e7..80f3a0a 100644 --- a/hallelujah.xcodeproj/project.pbxproj +++ b/hallelujah.xcodeproj/project.pbxproj @@ -12,8 +12,6 @@ 0DE74BFE1978EC6A00040F3C /* him.png in Resources */ = {isa = PBXBuildFile; fileRef = 0DE74BFD1978EC6A00040F3C /* him.png */; }; 0DE74C001978F18E00040F3C /* him.icns in Resources */ = {isa = PBXBuildFile; fileRef = 0DE74BFF1978F18E00040F3C /* him.icns */; }; 389468CB1F56A34A00EF1F5E /* web in Resources */ = {isa = PBXBuildFile; fileRef = 389468CA1F56A34A00EF1F5E /* web */; }; - 389468CD1F57BC4D00EF1F5E /* preferences.nib in Resources */ = {isa = PBXBuildFile; fileRef = 389468CC1F57BC4D00EF1F5E /* preferences.nib */; }; - 389468CF1F57BC5B00EF1F5E /* preferences.plist in Resources */ = {isa = PBXBuildFile; fileRef = 389468CE1F57BC5B00EF1F5E /* preferences.plist */; }; 389468D61F57C8CE00EF1F5E /* InputApplicationDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 389468D51F57C8CE00EF1F5E /* InputApplicationDelegate.m */; }; 38DD401A1F5800A400A276CB /* PreferencesMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 38DD40191F5800A400A276CB /* PreferencesMenu.xib */; }; 56DAA2D1B676B02B33021777 /* libPods-hallelujah.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 83B7001F97014A6184CCEDD3 /* libPods-hallelujah.a */; }; @@ -42,8 +40,6 @@ 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; 389468CA1F56A34A00EF1F5E /* web */ = {isa = PBXFileReference; lastKnownFileType = folder; path = web; sourceTree = ""; }; - 389468CC1F57BC4D00EF1F5E /* preferences.nib */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; path = preferences.nib; sourceTree = ""; }; - 389468CE1F57BC5B00EF1F5E /* preferences.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = preferences.plist; sourceTree = ""; }; 389468D41F57C8CE00EF1F5E /* InputApplicationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InputApplicationDelegate.h; path = src/InputApplicationDelegate.h; sourceTree = ""; }; 389468D51F57C8CE00EF1F5E /* InputApplicationDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = InputApplicationDelegate.m; path = src/InputApplicationDelegate.m; sourceTree = ""; }; 38DD40191F5800A400A276CB /* PreferencesMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PreferencesMenu.xib; sourceTree = ""; }; @@ -133,9 +129,7 @@ 29B97317FDCFA39411CA2CEA /* Resources */ = { isa = PBXGroup; children = ( - 389468CC1F57BC4D00EF1F5E /* preferences.nib */, 38DD40191F5800A400A276CB /* PreferencesMenu.xib */, - 389468CE1F57BC5B00EF1F5E /* preferences.plist */, 389468CA1F56A34A00EF1F5E /* web */, F102C5A71F48818A0005B03F /* words_with_frequency_and_translation.json */, F102C5A51F487DE80005B03F /* google_227800_words.bin */, @@ -240,9 +234,7 @@ 0D2BFD8F194588F400DE18D9 /* Images.xcassets in Resources */, 38DD401A1F5800A400A276CB /* PreferencesMenu.xib in Resources */, 0DE74C001978F18E00040F3C /* him.icns in Resources */, - 389468CF1F57BC5B00EF1F5E /* preferences.plist in Resources */, 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */, - 389468CD1F57BC4D00EF1F5E /* preferences.nib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/hallelujah.xcworkspace/xcuserdata/yuwdong.xcuserdatad/UserInterfaceState.xcuserstate b/hallelujah.xcworkspace/xcuserdata/yuwdong.xcuserdatad/UserInterfaceState.xcuserstate index 376dea4..77f56bc 100644 Binary files a/hallelujah.xcworkspace/xcuserdata/yuwdong.xcuserdatad/UserInterfaceState.xcuserstate and b/hallelujah.xcworkspace/xcuserdata/yuwdong.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/hallelujah.xcworkspace/xcuserdata/yuwdong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/hallelujah.xcworkspace/xcuserdata/yuwdong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 33a204c..b5e773c 100644 --- a/hallelujah.xcworkspace/xcuserdata/yuwdong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/hallelujah.xcworkspace/xcuserdata/yuwdong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -10,11 +10,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "src/main.mm" - timestampString = "527608760.655638" + timestampString = "527610592.721219" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "82" - endingLineNumber = "82" + startingLineNumber = "80" + endingLineNumber = "80" landmarkName = "startHttpServer()" landmarkType = "9"> diff --git a/preferences.nib/designable.nib b/preferences.nib/designable.nib deleted file mode 100644 index 9e9cb19..0000000 --- a/preferences.nib/designable.nib +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - disable - baidu - google - - - - - - - - - - - - - - - - - - - - - - - diff --git a/preferences.nib/keyedobjects.nib b/preferences.nib/keyedobjects.nib deleted file mode 100644 index b28dc2e..0000000 Binary files a/preferences.nib/keyedobjects.nib and /dev/null differ diff --git a/preferences.plist b/preferences.plist deleted file mode 100644 index 8b7a9e6..0000000 --- a/preferences.plist +++ /dev/null @@ -1,14 +0,0 @@ - - - - - pinyinApi - - disable - baidu - google - - showTranslations - - - diff --git a/src/InputApplicationDelegate.m b/src/InputApplicationDelegate.m index ae83153..74b6986 100644 --- a/src/InputApplicationDelegate.m +++ b/src/InputApplicationDelegate.m @@ -11,12 +11,11 @@ -(NSMenu*)menu -(void)awakeFromNib { - NSMenuItem* preferences = [_menu itemWithTag:1]; + NSMenuItem* preferenceMenu = [_menu itemWithTag:1]; - if ( preferences ) { - [preferences setAction:@selector(showPreferences:)]; + if ( preferenceMenu ) { + [preferenceMenu setAction:@selector(showPreferences:)]; } - } @end diff --git a/src/InputController.mm b/src/InputController.mm index d1bbbb1..71bdd8b 100644 --- a/src/InputController.mm +++ b/src/InputController.mm @@ -9,7 +9,7 @@ extern NSMutableDictionary* wordsWithFrequencyAndTranslation; extern BOOL defaultEnglishMode; extern NSDictionary* substitutions; -extern NSMutableDictionary* preference; +extern NSUserDefaults* preference; typedef NSInteger KeyCode; static const KeyCode @@ -327,14 +327,11 @@ - (void)candidateSelectionChanged:(NSAttributedString*) candidateString { _insertionIndex = [candidateString length]; - bool showTranslations = [[NSUserDefaults standardUserDefaults] boolForKey: @"showTranslations"]; - - NSArray* pinyinApi = [[NSUserDefaults standardUserDefaults] arrayForKey: @"showTranslations"]; - - NSLog(@"showTranslations: %@, pinyinApi: %@", showTranslations, pinyinApi); - - - [self showAnnotation: candidateString]; + BOOL showTranslation = [preference boolForKey: @"showTranslation"]; + NSLog(@"showTranslation: %hhd", showTranslation); + if (showTranslation) { + [self showAnnotation: candidateString]; + } } - (void)candidateSelected:(NSAttributedString*)candidateString { @@ -363,11 +360,14 @@ - (void)deactivateServer:(id)sender { [self reset]; } --(NSMenu*)menu -{ +-(NSMenu*)menu { return [[NSApp delegate] performSelector:NSSelectorFromString(@"menu")]; } +- (void)showPreferences:(id)sender { + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString: @"http://localhost:62718/index.html"]]; +} + -(void)showAnnotation:(NSAttributedString*)candidateString{ NSArray* subList = [self getTranslations: candidateString];