Skip to content

Commit

Permalink
add delete button
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Nov 21, 2017
1 parent 2a2826e commit 71ec806
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/lib/cfa/chrony_conf.rb
Expand Up @@ -64,6 +64,17 @@ def modify_pool(original_address, new_address, options)
data.add(key, value, placer)
end

def delete_pool(address)
key = "pool[]"
matcher = Matcher.new do |k, v|
k == key &&
v == address ||
( v.respond_to?(:value) && v.value = address )
end

data.delete(matcher)
end

def default_pool_options
{ "iburst" => nil }
end
Expand Down
4 changes: 4 additions & 0 deletions src/lib/y2ntp_client/dialog/main.rb
Expand Up @@ -36,8 +36,12 @@ def contents
table,
HSpacing(0.2),
VBox(
VSpacing(),
Y2NtpClient::AddPoolButton.new,
VSpacing(),
Y2NtpClient::EditPoolButton.new(table),
VSpacing(),
Y2NtpClient::DeletePoolButton.new(table),
VStretch()
)
)
Expand Down
22 changes: 22 additions & 0 deletions src/lib/y2ntp_client/widgets.rb
Expand Up @@ -262,4 +262,26 @@ def handle
@table.handle
end
end

class DeletePoolButton < CWM::PushButton
def initialize(table)
textdomain "ntp-client"

@table = table
end

def label
_("&Delete")
end

def handle
address = @table.value
if address
Yast::Popup.Error(_("No table item is selected"))
return nil
end

Yast::NtpClient.ntp_conf.delete_pool(address)
end
end
end

0 comments on commit 71ec806

Please sign in to comment.