Class: Y2Network::Widgets::Destination

Inherits:
CWM::CustomWidget
  • Object
show all
Defined in:
src/lib/y2network/widgets/destination.rb

Instance Method Summary collapse

Constructor Details

#initialize(route) ⇒ Destination

Returns a new instance of Destination.

Parameters:



32
33
34
35
36
37
# File 'src/lib/y2network/widgets/destination.rb', line 32

def initialize(route)
  super()
  textdomain "network"

  @route = route
end

Instance Method Details

#contentsObject



39
40
41
42
43
44
# File 'src/lib/y2network/widgets/destination.rb', line 39

def contents
  HBox(
    CheckBox(Id(:default), Opt(:notify, :hstretch), _("Default Route")),
    InputField(Id(:destination), Opt(:hstretch), _("&Destination"))
  )
end

#handleObject



54
55
56
57
58
# File 'src/lib/y2network/widgets/destination.rb', line 54

def handle
  default_value ? disable_destination : enable_destination

  nil
end

#helpObject



46
47
48
49
50
51
52
# File 'src/lib/y2network/widgets/destination.rb', line 46

def help
  _(
    "<p><b>Default Route</b> matches all destination for a given IP " \
    "address family as long as no specific route matches. <b>Destination</b>" \
    " specifies the IP address (in CIDR format) for which the route applies.</p>"
  )
end

#initObject



60
61
62
63
64
65
66
67
68
# File 'src/lib/y2network/widgets/destination.rb', line 60

def init
  Yast::UI.ChangeWidget(Id(:destination), :ValidChars, Yast::IP.ValidChars + "/")
  val = @route.to
  Yast::UI.ChangeWidget(Id(:default), :Value, val == :default)
  if val != :default
    Yast::UI.ChangeWidget(Id(:destination), :Value, (val.to_s + "/" + val.prefix.to_s))
  end
  handle
end

#storeObject



78
79
80
# File 'src/lib/y2network/widgets/destination.rb', line 78

def store
  @route.to = default_value ? :default : IPAddr.new(destination_value)
end

#validateObject



70
71
72
73
74
75
76
# File 'src/lib/y2network/widgets/destination.rb', line 70

def validate
  return true if valid_destination?

  Yast::Popup.Error(_("Destination is invalid."))
  Yast::UI.SetFocus(Id(:destination))
  false
end