Module: Yast::NetworkWidgetsInclude
- Defined in:
- ../../src/include/network/widgets.rb
Instance Method Summary (collapse)
-
- (Object) CreateSlaveItems(itemIds, enslavedIfaces)
Builds content for slave configuration dialog (used e.g. when configuring bond slaves) according the given list of itemIds (see LanItems::Items).
- - (Object) enableDevices(enable)
- - (Object) getDeviceContens(selected)
- - (Object) GetDeviceDescription(device_id)
- - (Object) getInternetItems
- - (Object) getNetDeviceItems
- - (Object) handleDevice(items, selected)
- - (Object) initDevice(items)
- - (Object) initialize_network_widgets(include_target)
- - (Object) MakeStartmode(ids)
- - (Object) refreshDevice(via_device)
-
- (Object) ValidateIP(key, event)
Validator for IP adresses, no_popup.
Instance Method Details
- (Object) CreateSlaveItems(itemIds, enslavedIfaces)
Builds content for slave configuration dialog (used e.g. when configuring bond slaves) according the given list of itemIds (see LanItems::Items)
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
# File '../../src/include/network/widgets.rb', line 346 def CreateSlaveItems(itemIds, enslavedIfaces) itemIds = deep_copy(itemIds) enslavedIfaces = deep_copy(enslavedIfaces) items = [] Builtins.foreach(itemIds) do |itemId| description = "" dev_name = LanItems.GetDeviceName(itemId) ifcfg = LanItems.GetDeviceMap(itemId) next if IsEmpty(dev_name) ifcfg = { "dev_name" => dev_name } if ifcfg == nil dev_type = LanItems.GetDeviceType(itemId) if Builtins.contains(["tun", "tap"], dev_type) description = NetworkInterfaces.GetDevTypeDescription(dev_type, true) else description = BuildDescription( "", "", ifcfg, [Ops.get_map(LanItems.GetLanItem(itemId), "hwinfo", {})] ) # this conditions origin from bridge configuration # if enslaving a configured device then its configuration is rewritten # to "0.0.0.0/32" if Ops.get_string(ifcfg, "IPADDR", "") != "0.0.0.0" description = Builtins.sformat("%1 (%2)", description, "configured") end end selected = Builtins.contains(enslavedIfaces, dev_name) items = Builtins.add( items, Item( Id(dev_name), Builtins.sformat("%1 - %2", dev_name, description), selected ) ) end deep_copy(items) end |
- (Object) enableDevices(enable)
312 313 314 315 316 317 |
# File '../../src/include/network/widgets.rb', line 312 def enableDevices(enable) UI.ChangeWidget(:net_device, :Enabled, enable) UI.ChangeWidget(:net_expert, :Enabled, enable) nil end |
- (Object) getDeviceContens(selected)
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File '../../src/include/network/widgets.rb', line 281 def getDeviceContens(selected) VBox( VSpacing(0.5), HBox( HSpacing(3), MinWidth( 30, Label( Id(:net_device), Opt(:hstretch), GetDeviceDescription(selected) ) ), HSpacing(1), PushButton(Id(:net_expert), _("&Change Device")) ), VSpacing(0.5) ) end |
- (Object) GetDeviceDescription(device_id)
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File '../../src/include/network/widgets.rb', line 216 def GetDeviceDescription(device_id) device_name = NetworkInterfaces.GetValue(device_id, "NAME") if device_name == nil || device_name == "" #TRANSLATORS: Informs that device name is not known device_name = _("Unknown device") end Builtins.y2milestone("device_name %1", device_name) #avoid too long device names #if (size(device_name) > 30) { # device_name = substring (device_name, 0, 27) + "..."; #} ip_addr = Builtins.issubstring( NetworkInterfaces.GetValue(device_id, "BOOTPROTO"), "dhcp" ) ? # TRANSLATORS: Part of label, device with IP address assigned by DHCP _("DHCP address") : # TRANSLATORS: Part of label, device with static IP address NetworkInterfaces.GetValue(device_id, "IPADDR") if ip_addr == nil || ip_addr == "" #TRANSLATORS: Informs that no IP has been assigned to the device ip_addr = _("No IP address assigned") end output = Builtins.sformat( _("%1 \n%2 - %3"), device_name, NetworkInterfaces.GetDeviceTypeName(device_id), ip_addr ) output end |
- (Object) getInternetItems
250 251 252 253 254 255 |
# File '../../src/include/network/widgets.rb', line 250 def getInternetItems NetworkInterfaces.Read items = NetworkInterfaces.List("") items = Builtins.filter(items) { |i| i != "lo" } deep_copy(items) end |
- (Object) getNetDeviceItems
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File '../../src/include/network/widgets.rb', line 257 def getNetDeviceItems NetworkInterfaces.Read ifaces = NetworkInterfaces.List("eth") Builtins.y2debug("ifaces=%1", ifaces) ifaces = Convert.convert( Builtins.union(ifaces, NetworkInterfaces.List("eth-pcmcia")), :from => "list", :to => "list <string>" ) Builtins.y2debug("ifaces=%1", ifaces) ifaces = Convert.convert( Builtins.union(ifaces, NetworkInterfaces.List("eth-usb")), :from => "list", :to => "list <string>" ) ifaces = Convert.convert( Builtins.union(ifaces, NetworkInterfaces.List("wlan")), :from => "list", :to => "list <string>" ) # #186102 Builtins.y2debug("ifaces=%1", ifaces) deep_copy(ifaces) end |
- (Object) handleDevice(items, selected)
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# File '../../src/include/network/widgets.rb', line 325 def handleDevice(items, selected) items = deep_copy(items) # popup dialog title via_device = NetworkPopup.ChooseItem( _("Network Device Select"), items, selected ) if via_device != nil UI.ChangeWidget(:net_device, :Value, GetDeviceDescription(via_device)) Builtins.y2milestone("selected network device :%1", via_device) selected = via_device end selected end |
- (Object) initDevice(items)
302 303 304 305 306 307 308 309 310 |
# File '../../src/include/network/widgets.rb', line 302 def initDevice(items) items = deep_copy(items) #If only one device is present, disable "Change device" button if Ops.less_or_equal(Builtins.size(items), 1) UI.ChangeWidget(Id(:net_expert), :Enabled, false) end nil end |
- (Object) initialize_network_widgets(include_target)
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 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 100 101 102 103 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 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File '../../src/include/network/widgets.rb', line 31 def (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 "NetworkPopup" Yast.import "NetworkInterfaces" Yast.import "LanItems" Yast.include include_target, "network/complex.rb" @widget_descr = { # #23315 "DIALPREFIXREGEX" => { "widget" => :textentry, # TextEntry label "label" => _("&Dial Prefix Regular Expression"), "help" => # dial prefix regex help _( "<p>When <b>Dial Prefix Regular Expression</b> is set, users can\n" + "change the dial prefix in KInternet provided that it matches the expression.\n" + "A recommended value is <tt>[09]?</tt>, allowing <tt>0</tt>, <tt>9</tt>,\n" + "and the empty prefix. If the expression is empty, users are not allowed\n" + "to change the prefix.</p>\n" ) }, # obsoleted by BOOTPROTO_* "BOOTPROTO" => { "widget" => :radio_buttons, # radio button group label,method of setup "label" => _( "Setup Method" ), # is this necessary? "items" => [ # radio button label ["dhcp", _("A&utomatic Address Setup (via DHCP)")], # radio button label ["static", _("S&tatic Address Setup")] ], "opt" => [], "help" => _("<p>H</p>") } } # This is the data for widget_descr["STARTMODE"]. # It is separated because the list of items depends on the device type # and will be substituted dynamically. # Helps are rich text, but not paragraphs. @startmode_items = { # onboot, on and boot are aliases for auto # See NetworkInterfaces::CanonicalizeStartmode "auto" => # is a part of the static help text { # Combo box option for Device Activation "label" => _( "At Boot Time" ), "help" => "" }, "off" => # is a part of the static help text { "label" => _("Never"), "help" => "" }, "managed" => { # Combo box option for Device Activation # DO NOT TRANSLATE NetworkManager, it is a program name "label" => _( "By NetworkManager" ), # help text for Device Activation # DO NOT TRANSLATE NetworkManager, it is a program name "help" => _( "<b>By NetworkManager</b>: a desktop applet\ncontrols the interface. There is no need to set it up in YaST." ) }, "manual" => { # Combo box option for Device Activation "label" => _("Manually"), # help text for Device Activation "help" => _( "<p><b>Manually</b>: You control the interface manually\nvia 'ifup' or 'qinternet' (see 'User Controlled' below).</p>\n" ) }, "ifplugd" => { # Combo box option for Device Activation "label" => _( "On Cable Connection" ), # help text for Device Activation "help" => _( "<b>On Cable Connection</b>:\n" + "The interface is watched for whether there is a physical\n" + "network connection. That means either the cable is connected or the\n" + "wireless interface can connect to an access point.\n" ) }, "hotplug" => { # Combo box option for Device Activation "label" => _("On Hotplug"), # help text for Device Activation "help" => _( "With <b>On Hotplug</b>,\n" + "the interface is set up as soon as it is available. This is\n" + "nearly the same as 'At Boot Time', but does not result in an error at\n" + "boot time if the interface is not present.\n" ) }, "nfsroot" => { # Combo box option for Device Activation "label" => _("On NFSroot"), # help text for Device Activation "help" => _( "Using <b>On NFSroot</b> is similar to <tt>auto</tt>. Interfaces with this startmode will never\n" + "be shut down via <tt>rcnetwork stop</tt>. <tt>ifdown <iface></tt> is still available.\n" + "Use this if you have an NFS or iSCSI root filesystem.\n" ) }, "nfsroot" => { # Combo box option for Device Activation "label" => _("On NFSroot"), # help text for Device Activation "help" => _( "Using <b>On NFSroot</b> is nearly like 'auto'. But interfaces with this startmode will never\n" + "be shut down via 'rcnetwork stop'. 'ifdown <iface>' still works.\n" + "Use this when you have a nfs or iscsi root filesystem.\n" ) } } end |
- (Object) MakeStartmode(ids)
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File '../../src/include/network/widgets.rb', line 179 def MakeStartmode(ids) ids = deep_copy(ids) ret = { "widget" => :combobox, # Combo box label - when to activate device (e.g. on boot, manually, never,..) "label" => _( "Activate &device" ), "help" => # Device activation main help. The individual parts will be # substituted as %1 _( "<p><b><big>Device Activation</big></b></p> \n" + "<p>Choose when to bring up the network interface. <b>At Boot Time</b> activates it during system boot, \n" + "<b>Never</b> does not start the device.\n" + "%1</p>\n" ) } helps = "" items = Builtins.maplist(ids) do |id| helps = Ops.add( Ops.add(helps, " "), Ops.get(@startmode_items, [id, "help"], "") ) [id, Ops.get(@startmode_items, [id, "label"], "")] end Ops.set( ret, "help", Builtins.sformat(Ops.get_string(ret, "help", "%1"), helps) ) Ops.set(ret, "items", items) deep_copy(ret) end |
- (Object) refreshDevice(via_device)
319 320 321 322 323 |
# File '../../src/include/network/widgets.rb', line 319 def refreshDevice(via_device) UI.ChangeWidget(:net_device, :Value, GetDeviceDescription(via_device)) nil end |
- (Object) ValidateIP(key, event)
Validator for IP adresses, no_popup
172 173 174 175 176 177 |
# File '../../src/include/network/widgets.rb', line 172 def ValidateIP(key, event) event = deep_copy(event) value = Convert.to_string(UI.QueryWidget(Id(key), :Value)) return IP.Check(value) if value != "" true end |