Module: Yast::NetworkWidgetsInclude

Defined in:
src/include/network/widgets.rb

Instance Method Summary collapse

Instance Method Details

#handleIPv6(_key, event) ⇒ Object



139
140
141
142
143
144
# File 'src/include/network/widgets.rb', line 139

def handleIPv6(_key, event)
  if Ops.get_string(event, "EventReason", "") == "ValueChanged"
    Lan.SetIPv6(Convert.to_boolean(UI.QueryWidget(Id(:ipv6), :Value)))
  end
  nil
end

#initialize_network_widgets(include_target) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'src/include/network/widgets.rb', line 29

def initialize_network_widgets(include_target)
  Yast.import "UI"

  textdomain "network"

  # Gradually all yast2-network UI will be converted to CWM
  # for easier maintenance.
  # This is just a start.

  Yast.import "IP"
  Yast.import "NetworkService"
  Yast.import "Lan"

  Yast.include include_target, "network/complex.rb"
end

#initIPv6(_key) ⇒ Object



133
134
135
136
137
# File 'src/include/network/widgets.rb', line 133

def initIPv6(_key)
  UI.ChangeWidget(Id(:ipv6), :Value, Lan.ipv6 ? true : false)

  nil
end

#ipv6_widgetObject



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'src/include/network/widgets.rb', line 156

def ipv6_widget
  {
    "widget"        => :custom,
    "custom_widget" => Frame(
      _("IPv6 Protocol Settings"),
      Left(CheckBox(Id(:ipv6), Opt(:notify), _("Enable IPv6")))
    ),
    "opt"           => [],
    "help"          => Ops.get_string(@help, "ipv6", ""),
    "init"          => fun_ref(method(:initIPv6), "void (string)"),
    "handle"        => fun_ref(
      method(:handleIPv6),
      "symbol (string, map)"
    ),
    "store"         => fun_ref(method(:storeIPv6), "void (string, map)")
  }
end

#managed_widgetObject



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'src/include/network/widgets.rb', line 111

def managed_widget
  {
    "widget"        => :custom,
    "custom_widget" => Frame(
      _("General Network Settings"),
      Left(
        ComboBox(
          Id(:managed),
          Opt(:hstretch, :notify),
          _("Network Setup Method"),
          []
        )
      )
    ),
    "opt"           => [],
    "help"          => @help["managed"] || "",
    "init"          => fun_ref(method(:ManagedInit), "void (string)"),
    "handle"        => fun_ref(method(:ManagedHandle), "symbol (string, map)"),
    "store"         => fun_ref(method(:ManagedStore), "void (string, map)")
  }
end

#ManagedHandle(_key, _event) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
# File 'src/include/network/widgets.rb', line 98

def ManagedHandle(_key, _event)
  selected_service = UI.QueryWidget(Id(:managed), :Value)

  # Disable / enable all widgets which depends on network service
  # in the Managed dialog
  # See include/network/lan/dhcp.rb for referenced widgets
  [:clientid, :hostname, :no_defaultroute].each do |i|
    UI.ChangeWidget(Id(i), :Enabled, selected_service == "wicked")
  end

  nil
end

#ManagedInit(_key) ⇒ Object

Initialize the NetworkManager widget

Parameters:

  • _key (String)

    id of the widget



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'src/include/network/widgets.rb', line 58

def ManagedInit(_key)
  items = []

  Y2Network::Backend.available.each do |backend|
    items << Item(
      Id(backend.name),
      # the user can control the network with the NetworkManager program
      backend.label,
      !!Lan.yast_config&.backend?(backend.id)
    )
  end

  UI.ChangeWidget(Id(:managed), :Items, items)

  nil
end

#ManagedStore(_key, _event) ⇒ Object

Store the NetworkManager widget

Parameters:

  • _key (String)

    id of the widget

  • _event (Hash)

    the event being handled



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'src/include/network/widgets.rb', line 78

def ManagedStore(_key, _event)
  new_backend = UI.QueryWidget(Id(:managed), :Value)

  Lan.yast_config.backend = new_backend.to_sym

  if Lan.system_config.backend != Lan.yast_config.backend &&
      (Stage.normal && Lan.yast_config&.backend?(:network_manager))
    Popup.AnyMessage(
      _("Applet needed"),
      _(
        "NetworkManager is controlled by desktop applet\n" \
        "(KDE plasma widget and nm-applet for GNOME).\n" \
        "Be sure it's running and if not, start it manually."
      )
    )
  end

  nil
end

#storeIPv6(_key, _event) ⇒ Object



146
147
148
149
150
151
152
153
154
# File 'src/include/network/widgets.rb', line 146

def storeIPv6(_key, _event)
  if Convert.to_boolean(UI.QueryWidget(Id(:ipv6), :Value))
    Lan.SetIPv6(true)
  else
    Lan.SetIPv6(false)
  end

  nil
end

#ValidateIP(key, _event) ⇒ Object

Validator for IP adresses, no_popup

Parameters:

  • key (String)

    the widget being validated

  • _event (Hash)

    the event being handled

Returns:

  • whether valid



49
50
51
52
53
54
# File 'src/include/network/widgets.rb', line 49

def ValidateIP(key, _event)
  value = Convert.to_string(UI.QueryWidget(Id(key), :Value))
  return IP.Check(value) if value != ""

  true
end