Class: Yast::NetworkPopupClass
- Inherits:
-
Module
- Object
- Module
- Yast::NetworkPopupClass
- Defined in:
- library/network/src/modules/NetworkPopup.rb
Instance Method Summary collapse
-
#ChooseItem(_title, items, selected) ⇒ Object
Let the user choose one of a list of items.
-
#ChooseItemSimple(title, items, selected) ⇒ Object
Let the user choose one of a list of items.
-
#HostName(selected) ⇒ Object
Give me one host name on the local network.
- #main ⇒ Object
-
#NFSExport(server, selected) ⇒ Object
Give me export path of selected server.
-
#NFSServer(selected) ⇒ Object
Give me NFS server name on the local network.
Instance Method Details
#ChooseItem(_title, items, selected) ⇒ Object
Let the user choose one of a list of items
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 |
# File 'library/network/src/modules/NetworkPopup.rb', line 60 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 device_name = Ops.add(Builtins.substring(device_name, 0, 27), "...") if Ops.greater_than(Builtins.size(device_name), 30) 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 item = Convert.to_string(UI.QueryWidget(Id(:items), :CurrentItem)) if ret == :ok UI.CloseDialog item end |
#ChooseItemSimple(title, items, selected) ⇒ Object
Let the user choose one of a list of items
145 146 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 |
# File 'library/network/src/modules/NetworkPopup.rb', line 145 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 item = Convert.to_string(UI.QueryWidget(Id(:items), :CurrentItem)) if ret == :ok UI.CloseDialog item end |
#HostName(selected) ⇒ Object
Give me one host name on the local network
display dialog with all hosts on the local network
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'library/network/src/modules/NetworkPopup.rb', line 214 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 ChooseItemSimple(_("Re&mote Hosts"), @found_hosts, selected) end |
#main ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'library/network/src/modules/NetworkPopup.rb', line 40 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 |
#NFSExport(server, selected) ⇒ Object
Give me export path of selected server
display dialog with all exported directories from the selected server
238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'library/network/src/modules/NetworkPopup.rb', line 238 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 ChooseItemSimple(_("&Exported Directories"), dirs, selected) end |
#NFSServer(selected) ⇒ Object
Give me NFS server name on the local network
display dialog with all local NFS servers
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'library/network/src/modules/NetworkPopup.rb', line 184 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 = "/sbin/rpcinfo -b mountd 1 | /usr/bin/cut -f 2 | /usr/bin/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 @found_nfs_servers = if @found_nfs_servers.nil? [] else # sort list of servers Builtins.sort(@found_nfs_servers) end end # selection box label ChooseItemSimple(_("&NFS Servers"), @found_nfs_servers, selected) end |