Set opt:imp as the label on option checkboxes.
Do this when selecting an implementation and when enabling an option. TODO: When an option is disabled insert its implementation into the implementation list.
This commit is contained in:
@ -102,6 +102,7 @@ class OptionListBox(ClosedListBox):
|
||||
super(OptionListBox, self).__init__(listwalker)
|
||||
return
|
||||
|
||||
|
||||
# List of RadioButtons
|
||||
class ImpListBox(ClosedListBox):
|
||||
def __init__(self, listwalker):
|
||||
@ -278,7 +279,11 @@ class InstConfigData:
|
||||
self.configuration_dict[cfg_id]['enabled'] = new_state
|
||||
|
||||
def opt_statechange(self, checkbox, new_state, udat=None):
|
||||
opt = checkbox.get_label()
|
||||
if SET_LABEL:
|
||||
opt = checkbox.get_label().split(':')[0]
|
||||
else:
|
||||
opt = checkbox.get_label()
|
||||
|
||||
dbg.msg(3, 'InstConfigData:opt_statechange({0},{1},{2})'.format(opt, new_state, udat))
|
||||
self.opt_dict[opt]['enabled'] = new_state
|
||||
|
||||
@ -309,6 +314,10 @@ class InstConfigManager:
|
||||
firstopt = self.options[0][0]
|
||||
self.imp_lw = self.__gen_imp_listwalker(firstopt)
|
||||
self.option_lw = OptionListWalker(cf_dat.opt_dict, self.opt_statechange)
|
||||
if (SET_LABEL):
|
||||
for label, button in self.option_lw.button_dict.iteritems():
|
||||
button.set_label('{0}:{1}'.format(label, self.cf_dat.opt_dict[label]['selected_imp']))
|
||||
|
||||
self.imp_lb = ImpListBox(self.imp_lw)
|
||||
urwid.connect_signal(self.option_lw, 'focus_change', self.update_imp_lb)
|
||||
item_states = [(i,d['enabled']) for i,d in cf_dat.configuration_dict.iteritems()]
|
||||
@ -346,7 +355,6 @@ class InstConfigManager:
|
||||
|
||||
return RadioButtonListWalker(imp_items, on_state_change=self.imp_statechange, user_data=opt)
|
||||
|
||||
|
||||
def cf_statechange(self, button, new_state, udat=None):
|
||||
self.cf_dat.cf_statechange(button, new_state, udat)
|
||||
b = button.get_label()
|
||||
@ -367,11 +375,21 @@ class InstConfigManager:
|
||||
return
|
||||
|
||||
def opt_statechange(self, button, new_state, udat=None):
|
||||
opt = button.get_label()
|
||||
if (SET_LABEL):
|
||||
opt = button.get_label().split(':')[0]
|
||||
else:
|
||||
opt = button.get_label()
|
||||
|
||||
imp = self.cf_dat.opt_dict[opt]['selected_imp']
|
||||
if new_state == True:
|
||||
if self.__imp_unavailable(imp):
|
||||
self.cf_dat.opt_dict[opt]['selected_imp'] = 'none'
|
||||
imp_button = self.imp_lw.button_dict['none']
|
||||
imp_button.set_state(True)
|
||||
if SET_LABEL:
|
||||
opt_button = self.option_lw.button_dict[opt]
|
||||
opt_button.set_label('{0}:none'.format(opt))
|
||||
# FORCE DEDENT a blank line isn't enough in vim
|
||||
else:
|
||||
self.cf_dat.imp2opt_dict[imp] = opt
|
||||
|
||||
@ -382,6 +400,9 @@ class InstConfigManager:
|
||||
if new_state == True:
|
||||
imp = button.get_label()
|
||||
self.cf_dat.imp2opt_dict[imp] = opt
|
||||
if SET_LABEL:
|
||||
opt_button = self.option_lw.button_dict[opt]
|
||||
opt_button.set_label('{0}:{1}'.format(opt, imp))
|
||||
|
||||
self.cf_dat.imp_statechange(button, new_state, opt)
|
||||
return
|
||||
@ -422,7 +443,8 @@ class DEBUG:
|
||||
|
||||
dbg = DEBUG(enabled=True)
|
||||
def main(config_ini):
|
||||
global cf_dat, cf_man, cf_viewer
|
||||
global cf_dat, cf_man, cf_viewer, SET_LABEL
|
||||
SET_LABEL = True
|
||||
# Make configuration data
|
||||
cf_dat = InstConfigData()
|
||||
cf_dat.read_config_file(config_ini)
|
||||
|
Reference in New Issue
Block a user