fixed duplicate first rows

This commit is contained in:
sezanzeb 2020-10-31 19:12:27 +01:00 committed by sezanzeb
parent ac1ba6dba3
commit 359d8b687e
2 changed files with 4 additions and 6 deletions

View File

@ -96,9 +96,9 @@ class Window:
# find an select the newest preset based on file modification dates # find an select the newest preset based on file modification dates
device, preset = find_newest_preset() device, preset = find_newest_preset()
if device: if device is not None:
self.on_select_device(device) self.on_select_device(device)
if preset: if preset is not None:
self.on_select_preset(preset) self.on_select_preset(preset)
def get(self, name): def get(self, name):
@ -139,7 +139,7 @@ class Window:
"""Create a new preset and select it.""" """Create a new preset and select it."""
new_preset = create_preset(self.selected_device) new_preset = create_preset(self.selected_device)
self.get('preset_selection').append(new_preset, new_preset) self.get('preset_selection').append(new_preset, new_preset)
self.on_select_preset(new_preset) self.get('preset_selection').set_active_id(new_preset)
def on_select_preset(self, preset): def on_select_preset(self, preset):
"""Show the mappings of the preset""" """Show the mappings of the preset"""
@ -155,8 +155,6 @@ class Window:
key_list.remove_row(i + 1) key_list.remove_row(i + 1)
self.rows = 0 self.rows = 0
self.get('preset_selection').set_active_id(preset)
# TODO show all mapped keys from config # TODO show all mapped keys from config
self.on_add_key_clicked() self.on_add_key_clicked()

View File

@ -91,7 +91,7 @@ class Integration(unittest.TestCase):
self.assertTrue(self.window.window.get_visible()) self.assertTrue(self.window.window.get_visible())
def test_select_device_and_preset(self): def test_select_device_and_preset(self):
class FakeDropdown: class FakeDropdown(Gtk.ComboBoxText):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name