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
# File 'src/lib/y2network/widgets/destination.rb', line 32

def initialize(route)
  textdomain "network"

  @route = route
end

Instance Method Details

#contentsObject


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

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

#handleObject


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

def handle
  default_value ? disable_destination : enable_destination

  nil
end

#helpObject


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

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


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

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


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

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

#validateObject


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

def validate
  return true if valid_destination?

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