Wraps InputSourceHelper to a SPM package.

This commit is contained in:
zonble 2022-01-14 00:43:21 +08:00
parent d4772ffa99
commit e01eb46c9f
14 changed files with 337 additions and 27 deletions

View File

@ -39,17 +39,17 @@
D41355D8278D74B5005E5CBD /* LanguageModelManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = D41355D7278D7409005E5CBD /* LanguageModelManager.mm */; };
D41355DB278E6D17005E5CBD /* McBopomofoLM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D41355D9278E6D17005E5CBD /* McBopomofoLM.cpp */; };
D41355DE278EA3ED005E5CBD /* UserPhrasesLM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D41355DC278EA3ED005E5CBD /* UserPhrasesLM.cpp */; };
D427A9C125ED28CC005D43E0 /* OpenCCBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = D427A9C025ED28CC005D43E0 /* OpenCCBridge.swift */; };
D427F76A278C9E29004A2160 /* CandidateUI in Frameworks */ = {isa = PBXBuildFile; productRef = D427F769278C9E29004A2160 /* CandidateUI */; };
D427F76C278CA2B0004A2160 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D427F76B278CA1BA004A2160 /* AppDelegate.swift */; };
D427F7A927905E90004A2160 /* TooltipUI in Frameworks */ = {isa = PBXBuildFile; productRef = D427F7A827905E90004A2160 /* TooltipUI */; };
D427F7AE27907B8A004A2160 /* NotifierUI in Frameworks */ = {isa = PBXBuildFile; productRef = D427F7AD27907B8A004A2160 /* NotifierUI */; };
D427F7B4279086DC004A2160 /* InputSourceHelper in Frameworks */ = {isa = PBXBuildFile; productRef = D427F7B3279086DC004A2160 /* InputSourceHelper */; };
D427F7B6279086F6004A2160 /* InputSourceHelper in Frameworks */ = {isa = PBXBuildFile; productRef = D427F7B5279086F6004A2160 /* InputSourceHelper */; };
D427F7BB27908D78004A2160 /* OpenCCBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = D427F7BA27908D78004A2160 /* OpenCCBridge.swift */; };
D427F7BE27908DD7004A2160 /* OpenCC in Frameworks */ = {isa = PBXBuildFile; productRef = D427F7BD27908DD7004A2160 /* OpenCC */; };
D47F7DCE278BFB57002F9DD7 /* PreferencesWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D47F7DCD278BFB57002F9DD7 /* PreferencesWindowController.swift */; };
D47F7DD0278C0897002F9DD7 /* NonModalAlertWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D47F7DCF278C0897002F9DD7 /* NonModalAlertWindowController.swift */; };
D47F7DD3278C1263002F9DD7 /* UserOverrideModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D47F7DD2278C1263002F9DD7 /* UserOverrideModel.cpp */; };
D47F7DD5278C25A0002F9DD7 /* InputSourceHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D47F7DD4278C25A0002F9DD7 /* InputSourceHelper.swift */; };
D47F7DD6278C3075002F9DD7 /* InputSourceHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D47F7DD4278C25A0002F9DD7 /* InputSourceHelper.swift */; };
D48550A325EBE689006A204C /* OpenCC in Frameworks */ = {isa = PBXBuildFile; productRef = D48550A225EBE689006A204C /* OpenCC */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -167,16 +167,16 @@
D41355DC278EA3ED005E5CBD /* UserPhrasesLM.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = UserPhrasesLM.cpp; sourceTree = "<group>"; };
D41355DD278EA3ED005E5CBD /* UserPhrasesLM.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UserPhrasesLM.h; sourceTree = "<group>"; };
D427A9BF25ED28CC005D43E0 /* McBopomofo-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "McBopomofo-Bridging-Header.h"; sourceTree = "<group>"; };
D427A9C025ED28CC005D43E0 /* OpenCCBridge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenCCBridge.swift; sourceTree = "<group>"; };
D427F768278C9D0D004A2160 /* CandidateUI */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = CandidateUI; path = Packages/CandidateUI; sourceTree = "<group>"; };
D427F76B278CA1BA004A2160 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
D427F7A727905E43004A2160 /* TooltipUI */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = TooltipUI; path = Packages/TooltipUI; sourceTree = "<group>"; };
D427F7AC27907B7E004A2160 /* NotifierUI */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = NotifierUI; path = Packages/NotifierUI; sourceTree = "<group>"; };
D427F7B2279086B5004A2160 /* InputSourceHelper */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = InputSourceHelper; path = Packages/InputSourceHelper; sourceTree = "<group>"; };
D427F7BA27908D78004A2160 /* OpenCCBridge.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OpenCCBridge.swift; sourceTree = "<group>"; };
D47F7DCD278BFB57002F9DD7 /* PreferencesWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesWindowController.swift; sourceTree = "<group>"; };
D47F7DCF278C0897002F9DD7 /* NonModalAlertWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NonModalAlertWindowController.swift; sourceTree = "<group>"; };
D47F7DD1278C1263002F9DD7 /* UserOverrideModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserOverrideModel.h; sourceTree = "<group>"; };
D47F7DD2278C1263002F9DD7 /* UserOverrideModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserOverrideModel.cpp; sourceTree = "<group>"; };
D47F7DD4278C25A0002F9DD7 /* InputSourceHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputSourceHelper.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -184,11 +184,12 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D427F7B4279086DC004A2160 /* InputSourceHelper in Frameworks */,
6A38BC2815FC158A00A8A51F /* InputMethodKit.framework in Frameworks */,
D48550A325EBE689006A204C /* OpenCC in Frameworks */,
D427F7A927905E90004A2160 /* TooltipUI in Frameworks */,
D427F76A278C9E29004A2160 /* CandidateUI in Frameworks */,
D427F7AE27907B8A004A2160 /* NotifierUI in Frameworks */,
D427F7BE27908DD7004A2160 /* OpenCC in Frameworks */,
6A0D4EA715FC0D2D00ABF4B3 /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -197,6 +198,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D427F7B6279086F6004A2160 /* InputSourceHelper in Frameworks */,
6ACA41CD15FC1D7500935EF6 /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -247,10 +249,9 @@
D41355D7278D7409005E5CBD /* LanguageModelManager.mm */,
6A0D4EC815FC0D6400ABF4B3 /* main.m */,
D427F76B278CA1BA004A2160 /* AppDelegate.swift */,
D47F7DD4278C25A0002F9DD7 /* InputSourceHelper.swift */,
D47F7DCF278C0897002F9DD7 /* NonModalAlertWindowController.swift */,
D47F7DCD278BFB57002F9DD7 /* PreferencesWindowController.swift */,
D427A9C025ED28CC005D43E0 /* OpenCCBridge.swift */,
D427F7BA27908D78004A2160 /* OpenCCBridge.swift */,
6A0D4EF615FC0DA600ABF4B3 /* McBopomofo-Prefix.pch */,
D427A9BF25ED28CC005D43E0 /* McBopomofo-Bridging-Header.h */,
);
@ -401,6 +402,7 @@
D427F768278C9D0D004A2160 /* CandidateUI */,
D427F7A727905E43004A2160 /* TooltipUI */,
D427F7AC27907B7E004A2160 /* NotifierUI */,
D427F7B2279086B5004A2160 /* InputSourceHelper */,
);
name = Packages;
sourceTree = "<group>";
@ -440,10 +442,11 @@
);
name = McBopomofo;
packageProductDependencies = (
D48550A225EBE689006A204C /* OpenCC */,
D427F769278C9E29004A2160 /* CandidateUI */,
D427F7A827905E90004A2160 /* TooltipUI */,
D427F7AD27907B8A004A2160 /* NotifierUI */,
D427F7B3279086DC004A2160 /* InputSourceHelper */,
D427F7BD27908DD7004A2160 /* OpenCC */,
);
productName = McBopomofo;
productReference = 6A0D4EA215FC0D2D00ABF4B3 /* McBopomofo.app */;
@ -464,6 +467,9 @@
6ACA420115FC1DCC00935EF6 /* PBXTargetDependency */,
);
name = McBopomofoInstaller;
packageProductDependencies = (
D427F7B5279086F6004A2160 /* InputSourceHelper */,
);
productName = McBopomofoInstaller;
productReference = 6ACA41CB15FC1D7500935EF6 /* McBopomofoInstaller.app */;
productType = "com.apple.product-type.application";
@ -492,7 +498,7 @@
);
mainGroup = 6A0D4E9215FC0CFA00ABF4B3;
packageReferences = (
D48550A125EBE689006A204C /* XCRemoteSwiftPackageReference "SwiftyOpenCC" */,
D427F7BC27908DD7004A2160 /* XCRemoteSwiftPackageReference "SwiftyOpenCC" */,
);
productRefGroup = 6A0D4EA315FC0D2D00ABF4B3 /* Products */;
projectDirPath = "";
@ -568,12 +574,11 @@
files = (
D427F76C278CA2B0004A2160 /* AppDelegate.swift in Sources */,
6A0D4ED315FC0D6400ABF4B3 /* main.m in Sources */,
D47F7DD5278C25A0002F9DD7 /* InputSourceHelper.swift in Sources */,
D47F7DD0278C0897002F9DD7 /* NonModalAlertWindowController.swift in Sources */,
D427A9C125ED28CC005D43E0 /* OpenCCBridge.swift in Sources */,
D47F7DCE278BFB57002F9DD7 /* PreferencesWindowController.swift in Sources */,
6A0D4ED215FC0D6400ABF4B3 /* InputMethodController.mm in Sources */,
D41355DB278E6D17005E5CBD /* McBopomofoLM.cpp in Sources */,
D427F7BB27908D78004A2160 /* OpenCCBridge.swift in Sources */,
D47F7DD3278C1263002F9DD7 /* UserOverrideModel.cpp in Sources */,
6A0D4F4515FC0EB100ABF4B3 /* Mandarin.cpp in Sources */,
D41355DE278EA3ED005E5CBD /* UserPhrasesLM.cpp in Sources */,
@ -589,7 +594,6 @@
6ACA41F915FC1D9000935EF6 /* AppDelegate.m in Sources */,
6A225A232367A1D700F685C6 /* ArchiveUtil.m in Sources */,
6ACA41FF15FC1D9000935EF6 /* main.m in Sources */,
D47F7DD6278C3075002F9DD7 /* InputSourceHelper.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1054,12 +1058,12 @@
/* End XCConfigurationList section */
/* Begin XCRemoteSwiftPackageReference section */
D48550A125EBE689006A204C /* XCRemoteSwiftPackageReference "SwiftyOpenCC" */ = {
D427F7BC27908DD7004A2160 /* XCRemoteSwiftPackageReference "SwiftyOpenCC" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/ddddxxx/SwiftyOpenCC.git";
requirement = {
kind = revision;
revision = 1d8105a0f7199c90af722bff62728050c858e777;
revision = a802c02cbf1c6fcd529575f11a9876d94fc813f4;
};
};
/* End XCRemoteSwiftPackageReference section */
@ -1077,9 +1081,17 @@
isa = XCSwiftPackageProductDependency;
productName = NotifierUI;
};
D48550A225EBE689006A204C /* OpenCC */ = {
D427F7B3279086DC004A2160 /* InputSourceHelper */ = {
isa = XCSwiftPackageProductDependency;
package = D48550A125EBE689006A204C /* XCRemoteSwiftPackageReference "SwiftyOpenCC" */;
productName = InputSourceHelper;
};
D427F7B5279086F6004A2160 /* InputSourceHelper */ = {
isa = XCSwiftPackageProductDependency;
productName = InputSourceHelper;
};
D427F7BD27908DD7004A2160 /* OpenCC */ = {
isa = XCSwiftPackageProductDependency;
package = D427F7BC27908DD7004A2160 /* XCRemoteSwiftPackageReference "SwiftyOpenCC" */;
productName = OpenCC;
};
/* End XCSwiftPackageProductDependency section */

7
Packages/InputSourceHelper/.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

View File

@ -0,0 +1,25 @@
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "InputSourceHelper",
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "InputSourceHelper",
targets: ["InputSourceHelper"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "InputSourceHelper",
dependencies: []),
]
)

View File

@ -0,0 +1,3 @@
# InputSourceHelper
A description of this package.

View File

@ -0,0 +1,7 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

View File

@ -0,0 +1,25 @@
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "NonModalAlertWindow",
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "NonModalAlertWindow",
targets: ["NonModalAlertWindow"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "NonModalAlertWindow",
dependencies: []),
]
)

View File

@ -0,0 +1,3 @@
# NonModalAlertWindow
A description of this package.

View File

@ -0,0 +1,147 @@
//
// NonModalAlertWindowController.swift
//
// Copyright (c) 2011 The McBopomofo Project.
//
// Contributors:
// Mengjuei Hsieh (@mjhsieh)
// Weizhong Yang (@zonble)
//
// Based on the Syrup Project and the Formosana Library
// by Lukhnos Liu (@lukhnos).
//
// 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.
//
import Cocoa
@objc public protocol NonModalAlertWindowControllerDelegate: AnyObject {
func nonModalAlertWindowControllerDidConfirm(_ controller: NonModalAlertWindowController)
func nonModalAlertWindowControllerDidCancel(_ controller: NonModalAlertWindowController)
}
@objc public class NonModalAlertWindowController: NSWindowController {
@objc (sharedInstance)
public static let shared: NonModalAlertWindowController = {
NSLog("shaerd???")
guard let path = Bundle.main.path(forResource: "NonModalAlertWindow_NonModalAlertWindow", ofType: "bundle"),
let modelBudle = Bundle(path: path),
let xibPath = modelBudle.path(forResource: "NonModalAlertWindowController", ofType: "nib")
else {
let controller = NonModalAlertWindowController(windowNibName: "NonModalAlertWindowController")
return controller
}
NSLog("shared path \(path)")
NSLog("shared modelBudle \(modelBudle)")
NSLog("shared xibPath \(xibPath)")
let controller = NonModalAlertWindowController(windowNibPath: xibPath, owner: self)
return controller
}()
@IBOutlet weak var titleTextField: NSTextField!
@IBOutlet weak var contentTextField: NSTextField!
@IBOutlet weak var confirmButton: NSButton!
@IBOutlet weak var cancelButton: NSButton!
weak var delegate: NonModalAlertWindowControllerDelegate?
@objc public func show(title: String, content: String, confirmButtonTitle: String, cancelButtonTitle: String?, cancelAsDefault: Bool, delegate: NonModalAlertWindowControllerDelegate?) {
if window?.isVisible == true {
self.delegate?.nonModalAlertWindowControllerDidCancel(self)
}
self.delegate = delegate
var oldFrame = confirmButton.frame
confirmButton.title = confirmButtonTitle
confirmButton.sizeToFit()
var newFrame = confirmButton.frame
newFrame.size.width = max(90, newFrame.size.width + 10)
newFrame.origin.x += oldFrame.size.width - newFrame.size.width
confirmButton.frame = newFrame
if let cancelButtonTitle = cancelButtonTitle {
cancelButton.title = cancelButtonTitle
cancelButton.sizeToFit()
var adjustFrame = cancelButton.frame
adjustFrame.size.width = max(90, adjustFrame.size.width + 10)
adjustFrame.origin.x = newFrame.origin.x - adjustFrame.size.width
confirmButton.frame = adjustFrame
cancelButton.isHidden = false
} else {
cancelButton.isHidden = true
}
cancelButton.nextKeyView = confirmButton
confirmButton.nextKeyView = cancelButton
if cancelButtonTitle != nil {
if cancelAsDefault {
window?.defaultButtonCell = cancelButton.cell as? NSButtonCell
} else {
cancelButton.keyEquivalent = " "
window?.defaultButtonCell = confirmButton.cell as? NSButtonCell
}
} else {
window?.defaultButtonCell = confirmButton.cell as? NSButtonCell
}
titleTextField.stringValue = title
oldFrame = contentTextField.frame
contentTextField.stringValue = content
var infiniteHeightFrame = oldFrame
infiniteHeightFrame.size.width -= 4.0
infiniteHeightFrame.size.height = 10240
newFrame = (content as NSString).boundingRect(with: infiniteHeightFrame.size, options: [.usesLineFragmentOrigin], attributes: [.font: contentTextField.font!])
newFrame.size.width = max(newFrame.size.width, oldFrame.size.width)
newFrame.size.height += 4.0
newFrame.origin = oldFrame.origin
newFrame.origin.y -= (newFrame.size.height - oldFrame.size.height)
contentTextField.frame = newFrame
var windowFrame = window?.frame ?? NSRect.zero
windowFrame.size.height += (newFrame.size.height - oldFrame.size.height)
window?.level = NSWindow.Level(Int(CGShieldingWindowLevel()) + 1)
window?.setFrame(windowFrame, display: true)
window?.center()
window?.makeKeyAndOrderFront(self)
NSApp.activate(ignoringOtherApps: true)
}
@IBAction func confirmButtonAction(_ sender: Any) {
delegate?.nonModalAlertWindowControllerDidConfirm(self)
window?.orderOut(self)
}
@IBAction func cancelButtonAction(_ sender: Any) {
cancel(sender)
}
@objc public func cancel(_ sender: Any) {
delegate?.nonModalAlertWindowControllerDidCancel(self)
delegate = nil
window?.orderOut(self)
}
}

View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="19529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19529"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NonModalAlertWindowController" customModule="McBopomofo">
<connections>
<outlet property="cancelButton" destination="71" id="83"/>
<outlet property="confirmButton" destination="5" id="82"/>
<outlet property="contentTextField" destination="59" id="79"/>
<outlet property="titleTextField" destination="39" id="78"/>
<outlet property="window" destination="1" id="3"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" visibleAtLaunch="NO" animationBehavior="default" id="1">
<windowStyleMask key="styleMask" titled="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="420" height="130"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>
<view key="contentView" id="2">
<rect key="frame" x="0.0" y="0.0" width="420" height="130"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5">
<rect key="frame" x="314" y="13" width="92" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<buttonCell key="cell" type="push" title="Button" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="6">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="confirmButtonAction:" target="-2" id="85"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="71">
<rect key="frame" x="222" y="13" width="92" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<buttonCell key="cell" type="push" title="Button" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="73">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="cancelButtonAction:" target="-2" id="86"/>
</connections>
</button>
<imageView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="12">
<rect key="frame" x="24" y="50" width="64" height="64"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="AlertIcon" id="13"/>
</imageView>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="39">
<rect key="frame" x="103" y="97" width="300" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Lorem ipsum" id="40">
<font key="font" metaFont="systemBold"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" preferredMaxLayoutWidth="296" translatesAutoresizingMaskIntoConstraints="NO" id="59">
<rect key="frame" x="103" y="72" width="300" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Lorem ipsum" id="60">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</view>
<connections>
<outlet property="delegate" destination="-2" id="4"/>
</connections>
<point key="canvasLocation" x="140" y="146"/>
</window>
</objects>
<resources>
<image name="AlertIcon" width="64" height="64"/>
</resources>
</document>

View File

@ -44,7 +44,6 @@
@import CandidateUI;
@import NotifierUI;
@import TooltipUI;
@import OpenCC;
// C++ namespace usages
using namespace std;

View File

@ -27,7 +27,8 @@
#import "AppDelegate.h"
#import <sys/mount.h>
#import "McBopomofoInstaller-Swift.h"
//#import "McBopomofoInstaller-Swift.h"
@import InputSourceHelper;
static NSString *const kTargetBin = @"McBopomofo";
static NSString *const kTargetType = @"app";

View File

@ -3,7 +3,7 @@ import OpenCC
// Since SwiftyOpenCC only provide Swift classes, we create an NSObject subclass
// in Swift in order to bridge the Swift classes into our Objective-C++ project.
class OpenCCBridge: NSObject {
public class OpenCCBridge: NSObject {
private static let shared = OpenCCBridge()
private var converter: ChineseConverter?
@ -12,11 +12,7 @@ class OpenCCBridge: NSObject {
super.init()
}
@objc static func convert(_ string: String) -> String? {
@objc public static func convert(_ string: String) -> String? {
shared.converter?.convert(string)
}
private func convert(_ string: String) -> String? {
converter?.convert(string)
}
}

View File

@ -34,7 +34,7 @@
#import <Cocoa/Cocoa.h>
#import <InputMethodKit/InputMethodKit.h>
#import "McBopomofo-Swift.h"
@import InputSourceHelper;
static NSString *const kConnectionName = @"McBopomofo_1_Connection";