Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mchf committed Nov 22, 2016
1 parent 26ef1a0 commit 78d808b
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions src/include/network/services/dns.rb
Expand Up @@ -65,7 +65,6 @@ def initialize_network_services_dns(include_target)
@widget_descr_dns = {
"HOSTNAME" => {
"widget" => :textentry,
# textentry label
"label" => Label.HostName,
"opt" => [],
"help" => Ops.get_string(@help, "hostname_global", ""),
Expand All @@ -83,7 +82,6 @@ def initialize_network_services_dns(include_target)
},
"HOSTNAME_GLOBAL" => {
"widget" => :empty,
# #91202
"init" => fun_ref(
method(:initHostnameGlobal),
"void (string)"
Expand All @@ -95,14 +93,12 @@ def initialize_network_services_dns(include_target)
},
"DOMAIN" => {
"widget" => :textentry,
# textentry label
"label" => _("&Domain Name"),
"opt" => [],
# Do nothing (the widget doesnt have notify anyway)
# In particular do not disable the host and domain name widgets,
# setting of FQDN should be possible even if DHCP overrides it.
# N#28427, N#63423.
# "handle": nil,
"valid_chars" => Hostname.ValidCharsDomain(
),
"validate_type" => :function_no_popup,
Expand All @@ -122,7 +118,6 @@ def initialize_network_services_dns(include_target)
CheckBox(Id("DHCP_HOSTNAME"), Opt(:notify), _("Change Hostname via DHCP"), true),
ReplacePoint(Id("dh_host_text"), Empty())
),
# help
"help" => Ops.get_string(@help, "dhcp_hostname", ""),
"init" => fun_ref(method(:InitDhcpHostname), "void (string)"),
"handle" => fun_ref(method(:HandleDhcpHostname), "symbol (string, map)")
Expand Down Expand Up @@ -157,10 +152,8 @@ def initialize_network_services_dns(include_target)
},
"WRITE_HOSTNAME" => {
"widget" => :checkbox,
# checkbox label
"label" => _("&Assign Hostname to Loopback IP"),
"opt" => [],
# help
"help" => Ops.get_string(@help, "write_hostname", "")
},
"MODIFY_RESOLV" => {
Expand Down Expand Up @@ -190,7 +183,6 @@ def initialize_network_services_dns(include_target)
},
"NAMESERVER_1" => {
"widget" => :textentry,
# textentry label
"label" => _("Name Server &1"),
"opt" => [],
"help" => "",
Expand All @@ -214,15 +206,13 @@ def initialize_network_services_dns(include_target)
# NAMESERVER_2 and NAMESERVER_3 are cloned in the dialog function
"SEARCHLIST_S" => {
"widget" => :multi_line_edit,
# textentry label
"label" => _("Do&main Search"),
"opt" => [],
"help" => Ops.get_string(@help, "searchlist_s", ""),
"handle" => fun_ref(
method(:HandleResolverData),
"symbol (string, map)"
),
# "valid_chars": Hostname::ValidCharsFQ, // TODO: whitespace. unused anyway?
"validate_type" => :function,
"validate_function" => fun_ref(
method(:ValidateSearchList),
Expand All @@ -241,9 +231,7 @@ def initialize_network_services_dns(include_target)
"NAMESERVER_3",
Ops.get(@widget_descr_dns, "NAMESERVER_1", {})
)
# text entry label
Ops.set(@widget_descr_dns, ["NAMESERVER_2", "label"], _("Name Server &2"))
# text entry label
Ops.set(@widget_descr_dns, ["NAMESERVER_3", "label"], _("Name Server &3"))

@dns_contents = VBox(
Expand Down Expand Up @@ -271,7 +259,6 @@ def initialize_network_services_dns(include_target)
),
VSpacing(0.49),
Left(HBox("MODIFY_RESOLV", HSpacing(1), "PLAIN_POLICY")),
# Frame label
Frame(
_("Name Servers and Domain Search List"),
VBox(
Expand Down Expand Up @@ -469,13 +456,15 @@ def InitDhcpHostname(_key)
UI.ChangeWidget(Id("DHCP_HOSTNAME"), :Value, dhcp_hostname)
end

# Handler for DHCP_HOSTNAME checkbox
def HandleDhcpHostname(_key, _event)
UI.ChangeWidget(Id("DHCP_IFACES"), :Enabled, use_dhcp_hostname?)
UI.ChangeWidget(Id("DHCP_DEFAULT"), :Enabled, use_dhcp_hostname?)

nil
end

# Checks whether setting hostname via DHCP is allowed
def use_dhcp_hostname?
UI.QueryWidget(Id("DHCP_HOSTNAME"), :Value)
end
Expand Down Expand Up @@ -666,11 +655,7 @@ def handleModifyResolvPolicy(key, _event)
UI.QueryWidget(Id("MODIFY_RESOLV"), :Value)
)

@resolver_modifiable = if UI.QueryWidget(Id("MODIFY_RESOLV"), :Value) == :nomodify
false
else
true
end
@resolver_modifiable = UI.QueryWidget(Id("MODIFY_RESOLV"), :Value) != :nomodify

initPolicy(key)

Expand Down

0 comments on commit 78d808b

Please sign in to comment.