De-uglify kernel selection in Global Settings
Replaced kernel selection with utils.prepare_kernel; also added option to utils.prepare_choice to treat empty string as None (applicable to kernels).
This commit is contained in:
parent
4882013a32
commit
0700275586
@ -108,31 +108,16 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings,
|
||||
self.default_template_vmlist[
|
||||
self.default_template_combo.currentIndex()]
|
||||
|
||||
|
||||
def __init_kernel_defaults__(self):
|
||||
kernel_list = []
|
||||
# TODO system_path["qubes_kernels_base_dir"]
|
||||
# idea: qubes.pools['linux-kernel'].volumes
|
||||
for k in os.listdir('/var/lib/qubes/vm-kernels'):
|
||||
kernel_list.append(k)
|
||||
|
||||
self.kernel_idx = 0
|
||||
|
||||
for (i, k) in enumerate(kernel_list):
|
||||
text = k
|
||||
if k == self.qvm_collection.default_kernel:
|
||||
text += self.tr(" (current)")
|
||||
self.kernel_idx = i
|
||||
self.default_kernel_combo.insertItem(i, text)
|
||||
self.default_kernel_combo.setCurrentIndex(self.kernel_idx)
|
||||
self.kernels_list, self.kernels_idx = utils.prepare_kernel_choice(
|
||||
self.default_kernel_combo, self.qvm_collection, 'default_kernel',
|
||||
None,
|
||||
allow_none=True
|
||||
)
|
||||
|
||||
def __apply_kernel_defaults__(self):
|
||||
if self.default_kernel_combo.currentIndex() != self.kernel_idx:
|
||||
kernel = str(self.default_kernel_combo.currentText())
|
||||
kernel = kernel.split(' ')[0]
|
||||
|
||||
self.qvm_collection.default_kernel = kernel
|
||||
|
||||
self.qvm_collection.default_kernel = \
|
||||
self.kernels_list[self.default_kernel_combo.currentIndex()]
|
||||
|
||||
def __init_mem_defaults__(self):
|
||||
#qmemman settings
|
||||
|
@ -33,7 +33,7 @@ def _filter_internal(vm):
|
||||
def prepare_choice(widget, holder, propname, choice, default,
|
||||
filter_function=None, *,
|
||||
icon_getter=None, allow_internal=None, allow_default=False,
|
||||
allow_none=False, transform=None):
|
||||
allow_none=False, transform=None, empty_string_is_none=True):
|
||||
|
||||
# for newly created vms, set propname to None
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user