Class: Yast::DevicesSelectionBoxClass
- Inherits:
-
Module
- Object
- Module
- Yast::DevicesSelectionBoxClass
- Defined in:
- ../../src/modules/DevicesSelectionBox.rb
Instance Method Summary (collapse)
-
- (Object) Create(unselected_devices, selected_devices, fields, new_selected_size_function, unselected_label, selected_label, change_order)
The maps for the devices must contain the entries “device” and “size_k”.
-
- (Object) GetSelectedDevices
Returns list with the maps of the selected devices.
-
- (Object) GetUnselectedDevices
Returns list with the maps of the unselected devices.
- - (Object) Handle(widget)
- - (Object) main
- - (Object) SelectedSizeTerm(selected_devices)
- - (Object) Sum(devices)
- - (Object) UnselectedSizeTerm(unselected_devices)
- - (Object) UpdateSelectedSize
- - (Object) UpdateUnselectedSize
Instance Method Details
- (Object) Create(unselected_devices, selected_devices, fields, new_selected_size_function, unselected_label, selected_label, change_order)
The maps for the devices must contain the entries “device” and “size_k”.
Ordering of device list is irrelevant. Devices are ordered by StorageFields::IterateTargetMap.
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 |
# File '../../src/modules/DevicesSelectionBox.rb', line 120 def Create(unselected_devices, selected_devices, fields, new_selected_size_function, unselected_label, selected_label, change_order) unselected_devices = deep_copy(unselected_devices) selected_devices = deep_copy(selected_devices) fields = deep_copy(fields) new_selected_size_function = deep_copy(new_selected_size_function) @devices = Builtins.flatten([unselected_devices, selected_devices]) @selected_size_function = new_selected_size_function != nil ? new_selected_size_function : fun_ref(method(:Sum), "integer (list <map>)") device_names = Builtins.maplist(@devices) do |device| Ops.get_string(device, "device", "") end _Predicate = lambda do |disk, partition| disk = deep_copy(disk) partition = deep_copy(partition) StorageFields.PredicateDevice(disk, partition, device_names) end target_map = Storage.GetTargetMap header = StorageFields.TableHeader(fields) content = StorageFields.TableContents( fields, target_map, fun_ref(_Predicate, "symbol (map, map)") ) selected = Builtins.maplist(selected_devices) do |device| Ops.get_string(device, "device", "") end DualMultiSelectionBox.Create( header, content, selected, unselected_label, selected_label, UnselectedSizeTerm(unselected_devices), SelectedSizeTerm(selected_devices), change_order ) end |
- (Object) GetSelectedDevices
Returns list with the maps of the selected devices.
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File '../../src/modules/DevicesSelectionBox.rb', line 62 def GetSelectedDevices selected = Convert.convert( DualMultiSelectionBox.GetSelected, :from => "list", :to => "list <string>" ) ret = Builtins.maplist(selected) do |s| Ops.get(Builtins.filter(@devices) do |d| s == Ops.get_string(d, "device", "") end, 0, {}) end deep_copy(ret) end |
- (Object) GetUnselectedDevices
Returns list with the maps of the unselected devices.
48 49 50 51 52 53 54 55 56 57 58 |
# File '../../src/modules/DevicesSelectionBox.rb', line 48 def GetUnselectedDevices selected = Convert.convert( DualMultiSelectionBox.GetSelected, :from => "list", :to => "list <string>" ) Builtins.filter(@devices) do |device| !Builtins.contains(selected, Ops.get_string(device, "device", "")) end end |
- (Object) Handle(widget)
184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File '../../src/modules/DevicesSelectionBox.rb', line 184 def Handle() DualMultiSelectionBox.Handle() if Builtins.contains( [:unselected, :selected, :add, :add_all, :remove, :remove_all], ) UpdateUnselectedSize() UpdateSelectedSize() end nil end |
- (Object) main
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File '../../src/modules/DevicesSelectionBox.rb', line 30 def main Yast.import "UI" textdomain "storage" Yast.import "Storage" Yast.import "StorageFields" Yast.import "DualMultiSelectionBox" Yast.import "Integer" @devices = [] @selected_size_function = nil end |
- (Object) SelectedSizeTerm(selected_devices)
100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File '../../src/modules/DevicesSelectionBox.rb', line 100 def SelectedSizeTerm(selected_devices) selected_devices = deep_copy(selected_devices) size_k = @selected_size_function.call(selected_devices) # footer text, %1 is replaced by size Left( Label( Builtins.sformat( _("Resulting size: %1"), Storage.KByteToHumanString(size_k) ) ) ) end |
- (Object) Sum(devices)
77 78 79 80 81 82 |
# File '../../src/modules/DevicesSelectionBox.rb', line 77 def Sum(devices) devices = deep_copy(devices) Integer.Sum(Builtins.maplist(devices) do |device| Ops.get_integer(device, "size_k", 0) end) end |
- (Object) UnselectedSizeTerm(unselected_devices)
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File '../../src/modules/DevicesSelectionBox.rb', line 85 def UnselectedSizeTerm(unselected_devices) unselected_devices = deep_copy(unselected_devices) size_k = Sum(unselected_devices) # footer text, %1 is replaced by size Left( Label( Builtins.sformat( _("Total size: %1"), Storage.KByteToHumanString(size_k) ) ) ) end |
- (Object) UpdateSelectedSize
177 178 179 180 181 |
# File '../../src/modules/DevicesSelectionBox.rb', line 177 def UpdateSelectedSize UI.ReplaceWidget(Id(:selected_rp), SelectedSizeTerm(GetSelectedDevices())) nil end |
- (Object) UpdateUnselectedSize
167 168 169 170 171 172 173 174 |
# File '../../src/modules/DevicesSelectionBox.rb', line 167 def UpdateUnselectedSize UI.ReplaceWidget( Id(:unselected_rp), UnselectedSizeTerm(GetUnselectedDevices()) ) nil end |