Skip to content

Commit

Permalink
add add button
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Nov 21, 2017
1 parent 67879f6 commit 2987754
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 5 deletions.
13 changes: 12 additions & 1 deletion src/lib/y2ntp_client/dialog/main.rb
Expand Up @@ -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
Expand Down
21 changes: 17 additions & 4 deletions src/lib/y2ntp_client/dialog/pool.rb
Expand Up @@ -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
Expand All @@ -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
25 changes: 25 additions & 0 deletions src/lib/y2ntp_client/widgets.rb
Expand Up @@ -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

0 comments on commit 2987754

Please sign in to comment.