@@ -64,6 +64,7 @@ internal class Settings: NSStackView, Settings_v, NSTextFieldDelegate {
6464 private var widgetActivationThreshold : Int = 0
6565 private var widgetActivationThresholdSize : SizeUnit = . MB
6666 private var ICMPHost : String = " 1.1.1.1 "
67+ private var updateICMPIntervalValue : Int = 1
6768 private var publicIPState : Bool = true
6869 private var publicIPRefreshInterval : String = " never "
6970 private var baseValue : String = " byte "
@@ -73,6 +74,7 @@ internal class Settings: NSStackView, Settings_v, NSTextFieldDelegate {
7374 public var callbackWhenUpdateNumberOfProcesses : ( ( ) -> Void ) = { }
7475 public var usageResetCallback : ( ( ) -> Void ) = { }
7576 public var ICMPHostCallback : ( ( _ newState: Bool ) -> Void ) = { _ in }
77+ public var setInterval : ( ( _ value: Int ) -> Void ) = { _ in }
7678 public var publicIPRefreshIntervalCallback : ( ( ) -> Void ) = { }
7779
7880 private let title : String
@@ -100,6 +102,7 @@ internal class Settings: NSStackView, Settings_v, NSTextFieldDelegate {
100102 self . widgetActivationThreshold = Store . shared. int ( key: " \( self . title) _widgetActivationThreshold " , defaultValue: self . widgetActivationThreshold)
101103 self . widgetActivationThresholdSize = SizeUnit . fromString ( Store . shared. string ( key: " \( self . title) _widgetActivationThresholdSize " , defaultValue: self . widgetActivationThresholdSize. key) )
102104 self . ICMPHost = Store . shared. string ( key: " \( self . title) _ICMPHost " , defaultValue: self . ICMPHost)
105+ self . updateICMPIntervalValue = Store . shared. int ( key: " \( self . title) _updateICMPInterval " , defaultValue: self . updateICMPIntervalValue)
103106 self . publicIPState = Store . shared. bool ( key: " \( self . title) _publicIP " , defaultValue: self . publicIPState)
104107 self . publicIPRefreshInterval = Store . shared. string ( key: " \( self . title) _publicIPRefreshInterval " , defaultValue: self . publicIPRefreshInterval)
105108 self . baseValue = Store . shared. string ( key: " \( self . title) _base " , defaultValue: self . baseValue)
@@ -226,7 +229,12 @@ internal class Settings: NSStackView, Settings_v, NSTextFieldDelegate {
226229 self . addArrangedSubview ( PreferencesSection ( [
227230 PreferencesRow ( localizedString ( " Connectivity host (ICMP) " ) , component: ICMPField) {
228231 NSWorkspace . shared. open ( URL ( string: " https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol " ) !)
229- }
232+ } ,
233+ PreferencesRow ( localizedString ( " Update interval " ) , component: selectView (
234+ action: #selector( self . changeICMPUpdateInterval) ,
235+ items: ReaderUpdateIntervals,
236+ selected: " \( self . updateICMPIntervalValue) "
237+ ) )
230238 ] ) )
231239
232240 if widgets. contains ( where: { $0 == . text } ) {
@@ -321,6 +329,12 @@ internal class Settings: NSStackView, Settings_v, NSTextFieldDelegate {
321329 }
322330 }
323331 }
332+ @objc private func changeICMPUpdateInterval( _ sender: NSMenuItem ) {
333+ guard let key = sender. representedObject as? String , let value = Int ( key) else { return }
334+ self . updateICMPIntervalValue = value
335+ Store . shared. set ( key: " \( self . title) _updateICMPInterval " , value: value)
336+ self . setInterval ( value)
337+ }
324338
325339 @objc func togglePublicIPState( _ sender: NSControl ) {
326340 self . publicIPState = controlState ( sender)
0 commit comments