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_vmlist[
|
||||||
self.default_template_combo.currentIndex()]
|
self.default_template_combo.currentIndex()]
|
||||||
|
|
||||||
|
|
||||||
def __init_kernel_defaults__(self):
|
def __init_kernel_defaults__(self):
|
||||||
kernel_list = []
|
self.kernels_list, self.kernels_idx = utils.prepare_kernel_choice(
|
||||||
# TODO system_path["qubes_kernels_base_dir"]
|
self.default_kernel_combo, self.qvm_collection, 'default_kernel',
|
||||||
# idea: qubes.pools['linux-kernel'].volumes
|
None,
|
||||||
for k in os.listdir('/var/lib/qubes/vm-kernels'):
|
allow_none=True
|
||||||
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)
|
|
||||||
|
|
||||||
def __apply_kernel_defaults__(self):
|
def __apply_kernel_defaults__(self):
|
||||||
if self.default_kernel_combo.currentIndex() != self.kernel_idx:
|
self.qvm_collection.default_kernel = \
|
||||||
kernel = str(self.default_kernel_combo.currentText())
|
self.kernels_list[self.default_kernel_combo.currentIndex()]
|
||||||
kernel = kernel.split(' ')[0]
|
|
||||||
|
|
||||||
self.qvm_collection.default_kernel = kernel
|
|
||||||
|
|
||||||
|
|
||||||
def __init_mem_defaults__(self):
|
def __init_mem_defaults__(self):
|
||||||
#qmemman settings
|
#qmemman settings
|
||||||
|
@ -33,7 +33,7 @@ def _filter_internal(vm):
|
|||||||
def prepare_choice(widget, holder, propname, choice, default,
|
def prepare_choice(widget, holder, propname, choice, default,
|
||||||
filter_function=None, *,
|
filter_function=None, *,
|
||||||
icon_getter=None, allow_internal=None, allow_default=False,
|
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
|
# for newly created vms, set propname to None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user