Skip to content

Commit

Permalink
Refactoring / cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kobliha committed Aug 15, 2014
1 parent 387c3c3 commit 3c6587d
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/include/inetd/dialogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@
# Martin Lazar <mlazar@suse.cz>
#
# $Id$
require "yast"

module Yast
module InetdDialogsInclude
include Yast::Logger

def initialize_inetd_dialogs(include_target)
Yast.import "UI"

Expand Down Expand Up @@ -329,12 +333,11 @@ def InetdDialog
VSpacing(0.5),
Left(
RadioButtonGroup(
Id(:enable_disable_inetd),
VBox(
# Translators: Initial and target state of xinetd (or inetd)
Left(RadioButton(Id(:stop), Opt(:notify), _("D&isable"), true)),
Left(
RadioButton(Id(:editable), Opt(:notify), _("Enab&le"), false)
)
Left(RadioButton(Id(:disable), Opt(:notify), _("D&isable"))),
Left(RadioButton(Id(:enable), Opt(:notify), _("Enab&le")))
)
)
),
Expand Down Expand Up @@ -427,7 +430,8 @@ def InetdDialog

# if service active, enable editting
new_state = Inetd.netd_status
UI.ChangeWidget(Id(:editable), :Value, new_state)

UI.ChangeWidget(Id(:enable_disable_inetd), :CurrentButton, new_state ? :enable : :disable)
UI.ChangeWidget(Id(:table), :Enabled, new_state)
UI.ChangeWidget(Id(:create), :Enabled, new_state)
UI.ChangeWidget(Id(:delete), :Enabled, new_state)
Expand All @@ -449,18 +453,20 @@ def InetdDialog
# AARGH unused.
need_rebuild = true

if Convert.to_boolean(UI.QueryWidget(Id(:editable), :Value))
if Inetd.netd_status
UI.SetFocus(Id(:table))
else
UI.SetFocus(Id(:stop))
UI.SetFocus(Id(:enable))
end

ret = UI.UserInput
Builtins.y2milestone("ret %1", ret)
log.info "User ret: #{ret}"

ret = :abort if ret == :cancel # window-close button

if ret == :editable || ret == :stop
new_state2 = Convert.to_boolean(UI.QueryWidget(Id(:editable), :Value))
if [:enable, :disable].include?(ret)
new_state2 = UI.QueryWidget(Id(:enable_disable_inetd), :CurrentButton) == :enable

UI.ChangeWidget(Id(:table), :Enabled, new_state2)
UI.ChangeWidget(Id(:create), :Enabled, new_state2)
UI.ChangeWidget(Id(:delete), :Enabled, new_state2)
Expand Down Expand Up @@ -774,7 +780,7 @@ def InetdDialog
UI.ChangeWidget(Id(:table), :CurrentItem, to_select) if to_select != ""
end

if ret == :next
if ret == :next && Inetd.netd_status
if Inetd.netd_status && IsAnyServiceEnabled(Inetd.netd_conf) == :no
Inetd.netd_status = false
# Translators: Popup::Warning
Expand Down

0 comments on commit 3c6587d

Please sign in to comment.