mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-11 17:38:38 +00:00
interval for apple script
This commit is contained in:
parent
46f35f4737
commit
970fb99e33
@ -56,12 +56,13 @@ class SupportedTypesHolder {
|
||||
|
||||
enum ItemType: Decodable {
|
||||
case staticButton(title: String)
|
||||
case appleScriptTitledButton(source: String)
|
||||
case appleScriptTitledButton(source: String, refreshInterval: Double)
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case type
|
||||
case title
|
||||
case titleAppleScript
|
||||
case refreshInterval
|
||||
}
|
||||
|
||||
private enum ItemTypeRaw: String, Decodable {
|
||||
@ -75,7 +76,8 @@ enum ItemType: Decodable {
|
||||
switch type {
|
||||
case .appleScriptTitledButton:
|
||||
let source = try container.decode(String.self, forKey: .titleAppleScript)
|
||||
self = .appleScriptTitledButton(source: source)
|
||||
let interval = try container.decode(Double.self, forKey: .refreshInterval)
|
||||
self = .appleScriptTitledButton(source: source, refreshInterval: interval)
|
||||
case .staticButton:
|
||||
let title = try container.decode(String.self, forKey: .title)
|
||||
self = .staticButton(title: title)
|
||||
@ -123,9 +125,11 @@ enum ActionType: Decodable {
|
||||
extension ItemType: Equatable {}
|
||||
func ==(lhs: ItemType, rhs: ItemType) -> Bool {
|
||||
switch (lhs, rhs) {
|
||||
case let (.staticButton(a), .staticButton(b)),
|
||||
let (.appleScriptTitledButton(a), .appleScriptTitledButton(b)):
|
||||
case let (.staticButton(a), .staticButton(b)):
|
||||
return a == b
|
||||
case let (.appleScriptTitledButton(a, b), .appleScriptTitledButton(c, d)):
|
||||
return a == c && b == d
|
||||
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
||||
@ -98,8 +98,8 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
return CustomButtonTouchBarItem(identifier: identifier, title: title) { _ in
|
||||
|
||||
}
|
||||
case .appleScriptTitledButton(source: let source):
|
||||
return AppleScriptTouchBarItem(identifier: identifier, appleScript: source, interval: 30) //fixme interval
|
||||
case .appleScriptTitledButton(source: let source, refreshInterval: let interval):
|
||||
return AppleScriptTouchBarItem(identifier: identifier, appleScript: source, interval: interval)
|
||||
}
|
||||
|
||||
switch identifier {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user