populating the autoload switch state

pull/14/head
sezanzeb 4 years ago
parent 881b906b44
commit 64f7c3de3a

@ -56,9 +56,22 @@ class _Config:
del self._config['autoload'][device]
def iterate_autoload_presets(self):
"""get tuples of (device, preset)."""
"""Get tuples of (device, preset)."""
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):
"""Load the config from the file system."""
self.clear_config()

@ -364,6 +364,12 @@ class Window:
)
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.add_empty()

Loading…
Cancel
Save