diff --git a/src/lib/y2ntp_client/dialog/main.rb b/src/lib/y2ntp_client/dialog/main.rb index df0c9515..57db4812 100644 --- a/src/lib/y2ntp_client/dialog/main.rb +++ b/src/lib/y2ntp_client/dialog/main.rb @@ -31,10 +31,21 @@ def contents Left(Y2NtpClient::PolicyCombo.new), VSpacing(1), *hardware_clock_widgets, - Y2NtpClient::ServersTable.new + HBox( + Y2NtpClient::ServersTable.new, + HSpacing(0.2), + Y2NtpClient::AddPoolButton.new + ) ) end + def run + loop do + res = super + return res if res != :redraw + end + end + def abort_button Yast::Label.CancelButton end diff --git a/src/lib/y2ntp_client/dialog/pool.rb b/src/lib/y2ntp_client/dialog/pool.rb index 1a23e00d..950d1ee4 100644 --- a/src/lib/y2ntp_client/dialog/pool.rb +++ b/src/lib/y2ntp_client/dialog/pool.rb @@ -9,10 +9,12 @@ module Y2NtpClient module Dialog - class Main < CWM::Dialog + class Pool < CWM::Dialog # @param pool_entry [nil, Hash] - def initialize(pool_entry = nil) + def initialize(address = "", options = {}) textdomain "ntp-client" + @address = address + @options = options end def title @@ -21,19 +23,30 @@ def title end def contents + @address_widget = PoolAddress.new(@address) + VBox( + HBox( + address, + HSpacing(), + TestButton.new(@address_widget) + ) + ) end def next_button Yast::Label.OKButton end + def resulting_pool + [address_widget.address, @options] + end + private # always open new wizard dialog - def def should_open_dialog? + def should_open_dialog? true end - end end end diff --git a/src/lib/y2ntp_client/widgets.rb b/src/lib/y2ntp_client/widgets.rb index 2770a5f4..3d14adba 100644 --- a/src/lib/y2ntp_client/widgets.rb +++ b/src/lib/y2ntp_client/widgets.rb @@ -187,4 +187,29 @@ def handle nil end end + + class AddPoolButton < CWM::PushButton + def initialize(address_widget) + textdomain "ntp-client" + require "y2ntp_client/dialog/pool" + end + + def label + _("&Add") + end + + def handle + dialog = Dialog::Pool.new("", Yast::NtpClient.ntp_conf.default_pool_options) + + res = dialog.run + + if res == :next + Yast::NtpClient.ntp_conf.add_pool(*dialog.resulting_pool) + + return :redraw + end + + nil + end + end end