Module: Yast::NetworkWidgetsInclude

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

Instance Method Summary collapse

Instance Method Details

#handleIPv6(_key, event) ⇒ Object


177
178
179
180
181
182
# File 'src/include/network/widgets.rb', line 177

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


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

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 "NetworkInterfaces"
  Yast.import "NetworkService"
  Yast.import "Lan"
  Yast.import "LanItems"

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

#initIPv6(_key) ⇒ Object


171
172
173
174
175
# File 'src/include/network/widgets.rb', line 171

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

  nil
end

#ipv6_widgetObject


194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'src/include/network/widgets.rb', line 194

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


149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'src/include/network/widgets.rb', line 149

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


136
137
138
139
140
141
142
143
144
145
146
147
# File 'src/include/network/widgets.rb', line 136

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


61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'src/include/network/widgets.rb', line 61

def ManagedInit(_key)
  items = []

  if NetworkService.is_backend_available(:network_manager)
    items << Item(
      Id("managed"),
      # the user can control the network with the NetworkManager program
      _("NetworkManager Service"),
      NetworkService.is_network_manager
    )
  end
  if NetworkService.is_backend_available(:netconfig)
    items << Item(
      Id("ifup"),
      # ifup is a program name
      _("Traditional ifup"),
      NetworkService.is_netconfig
    )
  end
  if NetworkService.is_backend_available(:wicked)
    items << Item(
      Id("wicked"),
      # wicked is network configuration backend like netconfig
      _("Wicked Service"),
      NetworkService.is_wicked
    )
  end

  items << Item(
    Id("disabled"),
    # used when no network service is active or to disable network service
    _("Network Services Disabled"),
    NetworkService.is_disabled
  )

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

  nil
end

#ManagedStore(_key, _event) ⇒ Object

Store the NetworkManager widget


104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'src/include/network/widgets.rb', line 104

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

  case new_backend
  when "ifup"
    NetworkService.use_netconfig
  when "managed"
    NetworkService.use_network_manager
  when "wicked"
    NetworkService.use_wicked
  else
    NetworkService.disable
  end

  if NetworkService.Modified
    Lan.SetModified

    if Stage.normal && NetworkService.is_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
  end

  nil
end

#storeIPv6(_key, _event) ⇒ Object


184
185
186
187
188
189
190
191
192
# File 'src/include/network/widgets.rb', line 184

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


53
54
55
56
57
# File 'src/include/network/widgets.rb', line 53

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