Class: Yast::NetworkPopupClass
- Inherits:
-
Module
- Object
- Module
- Yast::NetworkPopupClass
- Defined in:
- ../../src/modules/NetworkPopup.rb
Instance Method Summary (collapse)
-
- (Object) ChooseItem(_title, items, selected)
Let the user choose one of a list of items.
-
- (Object) ChooseItemSimple(title, items, selected)
Let the user choose one of a list of items.
-
- (Object) HostName(selected)
Give me one host name on the local network.
- - (Object) main
-
- (Object) NFSExport(server, selected)
Give me export path of selected server.
-
- (Object) NFSServer(selected)
Give me NFS server name on the local network.
Instance Method Details
- (Object) ChooseItem(_title, items, selected)
Let the user choose one of a list of items
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 |
# File '../../src/modules/NetworkPopup.rb', line 62 def ChooseItem(_title, items, selected) items = deep_copy(items) item = nil items = Builtins.maplist(items) do |i| device_name = NetworkInterfaces.GetValue(i, "NAME") if device_name.nil? || device_name == "" # TRANSLATORS: Informs that device name is not known device_name = _("Unknown device") end if Ops.greater_than(Builtins.size(device_name), 30) device_name = Ops.add(Builtins.substring(device_name, 0, 27), "...") end ip_addr = if NetworkInterfaces.GetValue(i, "BOOTPROTO") == "dhcp" # TRANSLATORS: Informs that the IP address is assigned via DHCP _("DHCP address") else NetworkInterfaces.GetValue(i, "IPADDR") end if ip_addr.nil? || ip_addr == "" # TRANSLATORS: table item, informing that device has no IP address ip_addr = _("No IP address assigned") end conn = _("No") conn = _("Yes") if NetworkInterfaces.IsConnected(i) Item( Id(i), NetworkInterfaces.GetDeviceTypeName(i), device_name, ip_addr, i, conn ) end UI.OpenDialog( VBox( HSpacing(60), HBox( # translators: table header - details about the network device Table( Id(:items), Header( _("Device Type"), _("Device Name"), _("IP Address"), _("Device ID"), _("Connected") ), items ), VSpacing(10) ), ButtonBox( PushButton( Id(:ok), Opt(:default, :key_F10, :okButton), Label.OKButton ), PushButton( Id(:cancel), Opt(:key_F9, :cancelButton), Label.CancelButton ) ) ) ) UI.ChangeWidget(Id(:items), :CurrentItem, selected) UI.SetFocus(Id(:items)) ret = nil ret = UI.UserInput while ret != :cancel && ret != :ok if ret == :ok item = Convert.to_string(UI.QueryWidget(Id(:items), :CurrentItem)) end UI.CloseDialog item end |
- (Object) ChooseItemSimple(title, items, selected)
Let the user choose one of a list of items
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File '../../src/modules/NetworkPopup.rb', line 147 def ChooseItemSimple(title, items, selected) items = deep_copy(items) item = nil items = Builtins.maplist(items) { |i| Item(Id(i), i, i == selected) } UI.OpenDialog( VBox( HSpacing(40), HBox(SelectionBox(Id(:items), title, items), VSpacing(10)), ButtonBox( PushButton( Id(:ok), Opt(:default, :key_F10, :okButton), Label.OKButton ), PushButton( Id(:cancel), Opt(:key_F9, :cancelButton), Label.CancelButton ) ) ) ) UI.SetFocus(Id(:items)) ret = nil ret = UI.UserInput while ret != :cancel && ret != :ok if ret == :ok item = Convert.to_string(UI.QueryWidget(Id(:items), :CurrentItem)) end UI.CloseDialog item end |
- (Object) HostName(selected)
Give me one host name on the local network
display dialog with all hosts on the local network
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File '../../src/modules/NetworkPopup.rb', line 219 def HostName(selected) if @found_hosts.nil? # label message UI.OpenDialog(Label(_("Scanning for hosts on this LAN..."))) @found_hosts = Convert.convert( Builtins.sort(Convert.to_list(SCR.Read(path(".net.hostnames")))), from: "list", to: "list <string>" ) UI.CloseDialog @found_hosts = [] if @found_hosts.nil? end # selection box label ret = ChooseItemSimple(_("Re&mote Hosts"), @found_hosts, selected) ret end |
- (Object) main
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File '../../src/modules/NetworkPopup.rb', line 42 def main Yast.import "UI" textdomain "base" Yast.import "Label" Yast.import "NetworkInterfaces" # cache all found hosts on the local network @found_hosts = nil # cache all found NFS servers on the local network @found_nfs_servers = nil end |
- (Object) NFSExport(server, selected)
Give me export path of selected server
display dialog with all exported directories from the selected server
244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File '../../src/modules/NetworkPopup.rb', line 244 def NFSExport(server, selected) dirs = Convert.convert( SCR.Read(path(".net.showexports"), server), from: "any", to: "list <string>" ) dirs = [] if dirs.nil? # selection box label ret = ChooseItemSimple(_("&Exported Directories"), dirs, selected) ret end |
- (Object) NFSServer(selected)
Give me NFS server name on the local network
display dialog with all local NFS servers
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 |
# File '../../src/modules/NetworkPopup.rb', line 188 def NFSServer(selected) if @found_nfs_servers.nil? # label message UI.OpenDialog(Label(_("Scanning for hosts on this LAN..."))) # #71064 # this works also if ICMP broadcasts are ignored cmd = "/usr/sbin/rpcinfo -b mountd 1 | cut -d ' ' -f 2 | sort -u" out = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd)) @found_nfs_servers = Builtins.filter( Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n") ) { |s| s != "" } UI.CloseDialog if @found_nfs_servers.nil? @found_nfs_servers = [] else # sort list of servers @found_nfs_servers = Builtins.sort(@found_nfs_servers) end end # selection box label ret = ChooseItemSimple(_("&NFS Servers"), @found_nfs_servers, selected) ret end |