firstboot: add option to setup combined sys-net+sys-usb

Fixes QubesOS/qubes-issues#1629
This commit is contained in:
Marek Marczykowski-Górecki 2016-02-08 02:15:39 +01:00
parent 5a3df02a37
commit 098a2752af
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -80,12 +80,14 @@ def started_from_usb():
class QubesChoice(object): class QubesChoice(object):
instances = [] instances = []
def __init__(self, label, states, depend=None, extra_check=None): def __init__(self, label, states, depend=None, extra_check=None,
replace=None):
self.widget = gtk.CheckButton(label) self.widget = gtk.CheckButton(label)
self.states = states self.states = states
self.depend = depend self.depend = depend
self.extra_check = extra_check self.extra_check = extra_check
self.selected = None self.selected = None
self.replace = replace
if self.depend is not None: if self.depend is not None:
self.depend.widget.connect('toggled', self.friend_on_toggled) self.depend.widget.connect('toggled', self.friend_on_toggled)
@ -122,9 +124,16 @@ class QubesChoice(object):
@classmethod @classmethod
def get_states(cls): def get_states(cls):
replaced = reduce(
lambda x, y: x+y if y else x,
(choice.replace for choice in cls.instances if
choice.get_selected()),
()
)
for choice in cls.instances: for choice in cls.instances:
if choice.get_selected(): if choice.get_selected():
for state in choice.states: for state in choice.states:
if state not in replaced:
yield state yield state
@ -382,6 +391,13 @@ class moduleClass(Module):
_('USB qube configuration disabled - you are using USB ' _('USB qube configuration disabled - you are using USB '
'keyboard or USB disk')) 'keyboard or USB disk'))
self.choice_usb_with_net = QubesChoice(
_("Use sys-net qube for both networking and USB devices"),
('qvm.sys-net-with-usb',),
depend=self.choice_usb,
replace=('qvm.sys-usb',),
)
self.check_advanced = gtk.CheckButton( self.check_advanced = gtk.CheckButton(
_('Do not configure anything (for advanced users)')) _('Do not configure anything (for advanced users)'))
self.check_advanced.connect('toggled', self.check_advanced.connect('toggled',