show key name instead of code in button page

This commit is contained in:
Kyoken
2022-11-15 16:28:11 +03:00
committed by Yaroslav Chvanov
parent 04896cf4c2
commit cb6db2ffc5
2 changed files with 8 additions and 6 deletions

View File

@@ -296,13 +296,14 @@ class ButtonDialog(Gtk.Dialog):
def _on_macro_set(self, macro):
# A macro has been set; update accordingly.
if RatbagdButton.ActionType.MACRO in self._button.action_types: # macro is supported
self._action_type = RatbagdButton.ActionType.MACRO
self._mapping = macro
else:
if (RatbagdButton.ActionType.KEY in self._button.action_types and
len(macro.keys) == 2): # single key (press + release events)
self._action_type = RatbagdButton.ActionType.KEY
type_, value = macro.keys[0]
self._mapping = value
else:
self._action_type = RatbagdButton.ActionType.MACRO
self._mapping = macro
self.stack.set_visible_child_name("overview")
self._release_grab()

View File

@@ -1,11 +1,12 @@
# SPDX-License-Identifier: GPL-2.0-or-later
from gettext import gettext as _
from evdev import ecodes
from .buttondialog import ButtonDialog
from .mousemap import MouseMap
from .optionbutton import OptionButton
from .ratbagd import RatbagdButton
from .ratbagd import RatbagdButton, RatbagdMacro
import gi
gi.require_version("Gtk", "3.0")
@@ -81,7 +82,7 @@ class ButtonsPage(Gtk.Box):
elif action_type == RatbagdButton.ActionType.MACRO:
label = _("Macro: {}").format(str(ratbagd_button.macro))
elif action_type == RatbagdButton.ActionType.KEY:
label = _("Key: {}").format(str(ratbagd_button.key))
label = _("Key: {}").format(ecodes.KEY[ratbagd_button.key][RatbagdMacro._PREFIX_LEN:])
elif action_type == RatbagdButton.ActionType.NONE:
# Translators: the button is turned disabled, e.g. off.
label = _("Disabled")