Permalink
Browse files

Fix preference pane crash

  • Loading branch information...
youknowone committed Aug 25, 2018
1 parent f64cea9 commit bfd1ca9ee4b8d8118c228893b341f2d1dacf3ccb
Showing with 37 additions and 51 deletions.
  1. +1 −1 Preferences/Base.lproj/Preferences.xib
  2. +36 −50 Preferences/Preferences.swift
@@ -6,7 +6,7 @@
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="GureumPreferencePane" customModule="Preferences" customModuleProvider="target">
<customObject id="-2" userLabel="File's Owner" customClass="GureumPreferencePane">
<connections>
<outlet property="_window" destination="F0z-JX-Cv5" id="KJ8-tk-g3I"/>
<outlet property="defaultInputHangulComboBox" destination="X51-4X-EIq" id="mYa-Fu-R5F"/>
@@ -11,60 +11,11 @@ import PreferencePanes
import Cocoa
@objc class GureumLayoutTable: NSObject {
var gureumPreferencesHangulLayouts = [
"org.youknowone.inputmethod.Gureum.han2",
"org.youknowone.inputmethod.Gureum.han2classic",
"org.youknowone.inputmethod.Gureum.han3final",
"org.youknowone.inputmethod.Gureum.han3finalloose",
"org.youknowone.inputmethod.Gureum.han390",
"org.youknowone.inputmethod.Gureum.han390loose",
"org.youknowone.inputmethod.Gureum.han3noshift",
"org.youknowone.inputmethod.Gureum.han3classic",
"org.youknowone.inputmethod.Gureum.hanroman",
"org.youknowone.inputmethod.Gureum.hanahnmatae",
"org.youknowone.inputmethod.Gureum.han3-2011",
"org.youknowone.inputmethod.Gureum.han3-2011loose",
"org.youknowone.inputmethod.Gureum.han3-2012",
"org.youknowone.inputmethod.Gureum.han3-2012loose",
"org.youknowone.inputmethod.Gureum.han3finalnoshift",
"org.youknowone.inputmethod.Gureum.han3finalnoshiftsymbol",
"org.youknowone.inputmethod.Gureum.han3-2014",
"org.youknowone.inputmethod.Gureum.han3-2015" ]
let layoutNames: [String]
override init() {
let bundle = Bundle(identifier: "org.youknowone.inputmethod.Gureum")!
let info = bundle.localizedInfoDictionary!
var names: [String] = []
for layout in gureumPreferencesHangulLayouts {
names.append(info[layout] as! String)
}
layoutNames = names
super.init()
}
@objc convenience init(bundle: Bundle) {
self.init()
}
}
@objcMembers class GureumPreferencePane: NSPreferencePane, NSComboBoxDataSource {
@IBOutlet weak var defaultInputHangulComboBox: NSComboBox!
var configuration = GureumConfiguration()
let layoutTable = GureumLayoutTable()
func loadFromData() {
}
func saveToData() {
}
@IBAction func openKeyboardPreference(sender: NSControl) {
let myAppleScript = "reveal anchor \"ShortcutsTab\" of pane id \"com.apple.preference.keyboard\""
var error: NSDictionary?
@@ -97,11 +48,46 @@ import Cocoa
}
func comboBox(_ comboBox: NSComboBox, indexOfItemWithStringValue string: String) -> Int {
return layoutTable.layoutNames.index(of: string)!
return layoutTable.layoutNames.index(of: string) ?? NSNotFound
}
func comboBox(_ comboBox: NSComboBox, objectValueForItemAt index: Int) -> Any? {
return layoutTable.layoutNames[index]
}
}
@objc class GureumLayoutTable: NSObject {
let gureumPreferencesHangulLayouts = [
"org.youknowone.inputmethod.Gureum.han2",
"org.youknowone.inputmethod.Gureum.han2classic",
"org.youknowone.inputmethod.Gureum.han3final",
"org.youknowone.inputmethod.Gureum.han3finalloose",
"org.youknowone.inputmethod.Gureum.han390",
"org.youknowone.inputmethod.Gureum.han390loose",
"org.youknowone.inputmethod.Gureum.han3noshift",
"org.youknowone.inputmethod.Gureum.han3classic",
"org.youknowone.inputmethod.Gureum.hanroman",
"org.youknowone.inputmethod.Gureum.hanahnmatae",
"org.youknowone.inputmethod.Gureum.han3-2011",
"org.youknowone.inputmethod.Gureum.han3-2011loose",
"org.youknowone.inputmethod.Gureum.han3-2012",
"org.youknowone.inputmethod.Gureum.han3-2012loose",
"org.youknowone.inputmethod.Gureum.han3finalnoshiftsymbol",
"org.youknowone.inputmethod.Gureum.han3-2014",
"org.youknowone.inputmethod.Gureum.han3-2015" ]
let layoutNames: [String]
override init() {
let bundle = Bundle(identifier: "org.youknowone.inputmethod.Gureum")!
let info = bundle.localizedInfoDictionary!
var names: [String] = []
for layout in gureumPreferencesHangulLayouts {
names.append(info[layout] as! String)
}
layoutNames = names
super.init()
}
}

0 comments on commit bfd1ca9

Please sign in to comment.