Provide navigation context for __imp_unavailable method.

This commit is contained in:
Ferdi Franceschini
2014-07-06 20:09:15 +10:00
parent f1b13aa7c6
commit 46b0e1a9a3

View File

@ -445,7 +445,7 @@ class InstConfigManager(object):
self.opt_lb.set_focus(0)
return
def __imp_unavailable(self, opt, imp):
def __imp_unavailable(self, opt, imp, action):
"""Return True if an implementation is unavailable because it is used
by an enabled option.
"""
@ -457,10 +457,18 @@ class InstConfigManager(object):
return False
opt_imp = self.cf_dat.opt_dict[opt]['selected_imp']
if opt_imp == imp:
return False
elif self.cf_dat.opt_dict[ckopt]['enabled']:
return True
if (action == 'focus'):
if opt_imp == imp:
return False
elif self.cf_dat.opt_dict[ckopt]['enabled']:
return True
else:
return False
elif (action == 'state_change'):
if self.cf_dat.opt_dict[ckopt]['enabled']:
return True
else:
return False
else:
return False
@ -468,7 +476,7 @@ class InstConfigManager(object):
"""Generate the appropriate listwalker for the given option."""
imp_items = []
for imp in self.cf_dat.iter_implementations(opt):
if self.__imp_unavailable(opt, imp):
if self.__imp_unavailable(opt, imp, 'focus'):
continue
if imp == self.cf_dat.opt_dict[opt]['selected_imp']:
imp_items.append((imp, True))
@ -514,12 +522,14 @@ class InstConfigManager(object):
opt = button.get_label().split(':')[0]
imp = self.cf_dat.opt_dict[opt]['selected_imp']
if new_state == True:
if self.__imp_unavailable(opt, imp):
if self.__imp_unavailable(opt, imp, 'state_change'):
self.cf_dat.opt_dict[opt]['selected_imp'] = 'none'
imp_none_button = self.imp_lw.button_dict['none']
imp_none_button.set_state(True)
opt_button = self.opt_lw.button_dict[opt]
opt_button.set_label('{0}:none'.format(opt))
self.imp_lw = self.__gen_imp_listwalker(opt)
self.imp_lb.use_listwalker(self.imp_lw)
else:
opt_button = self.opt_lw.button_dict[opt]
opt_button.set_label('{0}:{1}'.format(opt, imp))
@ -605,6 +615,7 @@ class DEBUG:
DBG = DEBUG(enabled=True)
def main(config_ini):
global cf_dat, cf_man, cf_viewer
"""Create configuration editor."""
# Make configuration data