Skip to content

Commit

Permalink
rename MainMenu.nib to AnnotationWindow.nib; add About menu item li…
Browse files Browse the repository at this point in the history
…nks to github hallelujahIM project
  • Loading branch information
dongyuwei committed Jul 1, 2019
1 parent 25b900c commit a97b59b
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 18 deletions.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<key>LSUIElement</key>
<true/>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<string>AnnotationWindow</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSAppTransportSecurity</key>
Expand Down
14 changes: 10 additions & 4 deletions PreferencesMenu.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12121"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
Expand All @@ -14,9 +14,15 @@
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<menu title="Menu" id="H8n-qw-MXu">
<items>
<menuItem title="Preferences..." tag="1" id="lKW-or-zoD"/>
<menuItem title="Preferences" tag="1" id="lKW-or-zoD"/>
<menuItem title="Upgrade" id="W4U-UV-5uT">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="About" id="qhh-J9-DhA">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
</items>
<point key="canvasLocation" x="139" y="165.5"/>
<point key="canvasLocation" x="139" y="165"/>
</menu>
<customObject id="xeQ-fJ-niv" userLabel="InputApplicationDelegate" customClass="InputApplicationDelegate">
<connections>
Expand Down
14 changes: 7 additions & 7 deletions hallelujah.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
0DE74BFE1978EC6A00040F3C /* him.png in Resources */ = {isa = PBXBuildFile; fileRef = 0DE74BFD1978EC6A00040F3C /* him.png */; };
0DE74C001978F18E00040F3C /* him.icns in Resources */ = {isa = PBXBuildFile; fileRef = 0DE74BFF1978F18E00040F3C /* him.icns */; };
3804D23720F2FC2A00CF1BD9 /* NSScreen+PointConversion.m in Sources */ = {isa = PBXBuildFile; fileRef = 3804D23520F2FC2A00CF1BD9 /* NSScreen+PointConversion.m */; };
38133A1D22C9AF0D004960E3 /* AnnotationWindow.nib in Resources */ = {isa = PBXBuildFile; fileRef = 38133A1B22C9AF0D004960E3 /* AnnotationWindow.nib */; };
381CD8C622C60D610098764F /* WebServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 381CD8C522C60D610098764F /* WebServer.m */; };
3843EC702283BE8E00F52003 /* words_with_frequency_and_translation_and_ipa.json in Resources */ = {isa = PBXBuildFile; fileRef = 3843EC6F2283BE8E00F52003 /* words_with_frequency_and_translation_and_ipa.json */; };
389468CB1F56A34A00EF1F5E /* web in Resources */ = {isa = PBXBuildFile; fileRef = 389468CA1F56A34A00EF1F5E /* web */; };
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 */; };
8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; };
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
E93074B70A5C264700470842 /* InputMethodKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E93074B60A5C264700470842 /* InputMethodKit.framework */; };
Expand All @@ -38,11 +38,11 @@
0DE74BFF1978F18E00040F3C /* him.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = him.icns; sourceTree = "<group>"; };
0F9B2D528219BB1952DEBE74 /* Pods-hallelujah.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-hallelujah.debug.xcconfig"; path = "Pods/Target Support Files/Pods-hallelujah/Pods-hallelujah.debug.xcconfig"; sourceTree = "<group>"; };
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
29B97319FDCFA39411CA2CEA /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/MainMenu.nib; sourceTree = "<group>"; };
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
3804D23520F2FC2A00CF1BD9 /* NSScreen+PointConversion.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSScreen+PointConversion.m"; path = "src/NSScreen+PointConversion.m"; sourceTree = "<group>"; };
3804D23620F2FC2A00CF1BD9 /* NSScreen+PointConversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSScreen+PointConversion.h"; path = "src/NSScreen+PointConversion.h"; sourceTree = "<group>"; };
38133A1C22C9AF0D004960E3 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/AnnotationWindow.nib; sourceTree = "<group>"; };
381CD8C422C60D610098764F /* WebServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebServer.h; path = src/WebServer.h; sourceTree = "<group>"; };
381CD8C522C60D610098764F /* WebServer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WebServer.m; path = src/WebServer.m; sourceTree = "<group>"; };
3843EC6F2283BE8E00F52003 /* words_with_frequency_and_translation_and_ipa.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = words_with_frequency_and_translation_and_ipa.json; path = dictionary/words_with_frequency_and_translation_and_ipa.json; sourceTree = "<group>"; };
Expand Down Expand Up @@ -140,6 +140,7 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
38133A1B22C9AF0D004960E3 /* AnnotationWindow.nib */,
3843EC6F2283BE8E00F52003 /* words_with_frequency_and_translation_and_ipa.json */,
F174745E1FDC2C9400AD2B84 /* cedict.json */,
38DD40191F5800A400A276CB /* PreferencesMenu.xib */,
Expand All @@ -149,7 +150,6 @@
E93396E20A9A0AAD0073E6C4 /* images */,
8D1107310486CEB800E47090 /* Info.plist */,
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
29B97318FDCFA39411CA2CEA /* MainMenu.nib */,
);
name = Resources;
sourceTree = "<group>";
Expand Down Expand Up @@ -242,10 +242,10 @@
0DE74BFE1978EC6A00040F3C /* him.png in Resources */,
F174745F1FDC2C9400AD2B84 /* cedict.json in Resources */,
389468CB1F56A34A00EF1F5E /* web in Resources */,
8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */,
F102C5A61F487DE80005B03F /* google_227800_words.bin in Resources */,
0D2BFD8F194588F400DE18D9 /* Images.xcassets in Resources */,
38DD401A1F5800A400A276CB /* PreferencesMenu.xib in Resources */,
38133A1D22C9AF0D004960E3 /* AnnotationWindow.nib in Resources */,
3843EC702283BE8E00F52003 /* words_with_frequency_and_translation_and_ipa.json in Resources */,
0DE74C001978F18E00040F3C /* him.icns in Resources */,
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */,
Expand Down Expand Up @@ -330,12 +330,12 @@
name = InfoPlist.strings;
sourceTree = "<group>";
};
29B97318FDCFA39411CA2CEA /* MainMenu.nib */ = {
38133A1B22C9AF0D004960E3 /* AnnotationWindow.nib */ = {
isa = PBXVariantGroup;
children = (
29B97319FDCFA39411CA2CEA /* English */,
38133A1C22C9AF0D004960E3 /* English */,
);
name = MainMenu.nib;
name = AnnotationWindow.nib;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
Expand Down
1 change: 1 addition & 0 deletions src/InputApplicationDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

@interface InputApplicationDelegate : NSObject {
IBOutlet NSMenu *_menu;
IBOutlet NSMenuItem *_aboutMenuItem;
}
- (NSMenu *)menu;

Expand Down
11 changes: 8 additions & 3 deletions src/InputApplicationDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ - (NSMenu *)menu {
}

- (void)awakeFromNib {
NSMenuItem *preferenceMenu = [_menu itemWithTag:1];
NSMenuItem *preferenceMenuItem = [_menu itemWithTitle:@"Preferences"];
NSMenuItem *aboutMenuItem = [_menu itemWithTitle:@"About"];

if (preferenceMenu) {
[preferenceMenu setAction:@selector(showPreferences:)];
if (preferenceMenuItem) {
[preferenceMenuItem setAction:@selector(showIMEPreferences:)];
}

if (aboutMenuItem) {
[aboutMenuItem setAction:@selector(clickAbout:)];
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/InputController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,17 @@ - (NSMenu *)menu {
return [[NSApp delegate] performSelector:NSSelectorFromString(@"menu")];
}

- (void)showPreferences:(id)sender {
- (void)showIMEPreferences:(id)sender {
[self openUrl:@"http://localhost:62718/index.html"];
}

- (void)clickAbout:(NSMenuItem *)sender {
[self openUrl:@"https://github.com/dongyuwei/hallelujahIM"];
}

- (void)openUrl:(NSString *)url {
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
[ws openURLs:@[ [NSURL URLWithString:@"http://localhost:62718/index.html"] ]
[ws openURLs:@[ [NSURL URLWithString:url] ]
withAppBundleIdentifier:@"com.apple.Safari"
options:NSWorkspaceLaunchDefault
additionalEventParamDescriptor:NULL
Expand Down
2 changes: 1 addition & 1 deletion src/main.mm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) {
substitutions = getUserDefinedSubstitutions();
pinyinDict = getPinyinData();

[[NSBundle mainBundle] loadNibNamed:@"MainMenu" owner:[NSApplication sharedApplication] topLevelObjects:nil];
[[NSBundle mainBundle] loadNibNamed:@"AnnotationWindow" owner:[NSApplication sharedApplication] topLevelObjects:nil];

[[NSBundle mainBundle] loadNibNamed:@"PreferencesMenu" owner:[NSApplication sharedApplication] topLevelObjects:nil];

Expand Down

0 comments on commit a97b59b

Please sign in to comment.