g13gui: Fix a fairly major duplication problem

We weren't cloning the defaults from the bindings module, so when we went to go
modify those bindings, we'd change the defaults instead of just that instance.
yay for lack of immutability. :|
This commit is contained in:
June Tate-Gans 2021-04-28 20:53:48 -05:00
parent 476b43ed5f
commit da10da2830
2 changed files with 9 additions and 12 deletions

View File

@ -14,9 +14,9 @@ class BindingProfile(Subject):
def initDefaults(self): def initDefaults(self):
self._stickMode = bindings.StickMode.KEYS self._stickMode = bindings.StickMode.KEYS
self._stickRegions = bindings.DEFAULT_STICK_REGIONS self._stickRegions = bindings.DEFAULT_STICK_REGIONS.copy()
self._stickRegionBindings = bindings.DEFAULT_STICK_REGION_BINDINGS self._stickRegionBindings = bindings.DEFAULT_STICK_REGION_BINDINGS.copy()
self._keyBindings = bindings.DEFAULT_KEY_BINDINGS self._keyBindings = bindings.DEFAULT_KEY_BINDINGS.copy()
self._lcdColor = bindings.DEFAULT_LCD_COLOR self._lcdColor = bindings.DEFAULT_LCD_COLOR
def lcdColor(self): def lcdColor(self):
@ -103,15 +103,15 @@ class BindingProfile(Subject):
def loadFromDict(self, dict): def loadFromDict(self, dict):
self._lcdColor = dict['lcdcolor'] self._lcdColor = dict['lcdcolor']
self._stickMode = dict['stickMode'] self._stickMode = dict['stickMode']
self._stickRegions = dict['stickRegions'] self._stickRegions = dict['stickRegions'].copy()
self._stickRegionBindings = dict['stickRegionBindings'] self._stickRegionBindings = dict['stickRegionBindings'].copy()
self._keyBindings = dict['keyBindings'] self._keyBindings = dict['keyBindings'].copy()
def saveToDict(self): def saveToDict(self):
return { return {
'lcdcolor': self._lcdColor, 'lcdcolor': self._lcdColor,
'stickMode': self._stickMode, 'stickMode': self._stickMode,
'stickRegions': self._stickRegions, 'stickRegions': self._stickRegions.copy(),
'stickRegionBindings': self._stickRegionBindings, 'stickRegionBindings': self._stickRegionBindings.copy(),
'keyBindings': self._keyBindings 'keyBindings': self._keyBindings.copy()
} }

View File

@ -45,9 +45,6 @@ class G13Button(Gtk.MenuButton, GtkObserver):
def updateBindingDisplay(self): def updateBindingDisplay(self):
self._removeChild() self._removeChild()
bindings = self._prefs.selectedProfile().keyBinding(self._keyName) bindings = self._prefs.selectedProfile().keyBinding(self._keyName)
print('[%s %s] %s: %s' % (self._prefs.selectedProfileName(),
self._prefs.selectedProfile(),
self._keyName, bindings))
if len(bindings) > 0: if len(bindings) > 0:
keybinds = G13ToGDK(bindings) keybinds = G13ToGDK(bindings)