populating the autoload switch state

This commit is contained in:
sezanzeb 2020-11-26 21:33:31 +01:00
parent 881b906b44
commit 64f7c3de3a
2 changed files with 20 additions and 1 deletions

View File

@ -56,9 +56,22 @@ class _Config:
del self._config['autoload'][device] del self._config['autoload'][device]
def iterate_autoload_presets(self): def iterate_autoload_presets(self):
"""get tuples of (device, preset).""" """Get tuples of (device, preset)."""
return self._config.get('autoload', {}).items() return self._config.get('autoload', {}).items()
def is_autoloaded(self, device, preset):
"""Should this preset be loaded automatically?"""
# TODO test
autoload_map = self._config.get('autoload')
if autoload_map is None:
return False
autoload_preset = autoload_map.get(device)
if autoload_preset is None:
return False
return True
def load_config(self): def load_config(self):
"""Load the config from the file system.""" """Load the config from the file system."""
self.clear_config() self.clear_config()

View File

@ -364,6 +364,12 @@ class Window:
) )
key_list.insert(single_key_mapping, -1) key_list.insert(single_key_mapping, -1)
autoload_switch = self.get('preset_autoload_switch')
autoload_switch.set_active(config.is_autoloaded(
self.selected_device,
self.selected_preset
))
self.get('preset_name_input').set_text('') self.get('preset_name_input').set_text('')
self.add_empty() self.add_empty()