LedsPage: move LED mode to string to the bindings

This is more consistent with RatbagdButton, and one less translatable
file.
This commit is contained in:
Jente Hidskes
2017-08-17 18:29:47 +02:00
parent 2c522002e6
commit b7a67340a0
2 changed files with 9 additions and 17 deletions

View File

@@ -14,8 +14,6 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from gettext import gettext as _
from .leddialog import LedDialog
from .mousemap import MouseMap
from .optionbutton import OptionButton
@@ -53,7 +51,7 @@ class LedsPage(Gtk.Box):
def _set_profile(self, profile):
self._profile = profile
for led in profile.leds:
mode = self._mode_to_string(led.mode)
mode = RatbagdLed.LED_DESCRIPTION[led.mode]
button = OptionButton(mode)
button.connect("clicked", self._on_button_clicked, led)
led.connect("notify::mode", self._on_led_mode_changed, button)
@@ -70,7 +68,7 @@ class LedsPage(Gtk.Box):
self._set_profile(profile)
def _on_led_mode_changed(self, led, pspec, button):
mode = self._mode_to_string(led.mode)
mode = RatbagdLed.LED_DESCRIPTION[led.mode]
button.set_label(mode)
def _on_button_clicked(self, button, led):
@@ -89,16 +87,3 @@ class LedsPage(Gtk.Box):
led.brightness = dialog.brightness
led.effect_rate = dialog.effect_rate
dialog.destroy()
def _mode_to_string(self, mode):
# Converts a RatbagdLed mode to a string.
if mode == RatbagdLed.MODE_ON:
return _("Solid")
elif mode == RatbagdLed.MODE_CYCLE:
return _("Cycle")
elif mode == RatbagdLed.MODE_BREATHING:
return _("Breathing")
elif mode == RatbagdLed.MODE_OFF:
return _("Off")
else:
return _("N/A")

View File

@@ -742,6 +742,13 @@ class RatbagdLed(_RatbagdDBus):
MODE_CYCLE = 2
MODE_BREATHING = 3
LED_DESCRIPTION = {
MODE_OFF: _("Off"),
MODE_ON: _("Solid"),
MODE_CYCLE: _("Cycle"),
MODE_BREATHING: _("Breathing"),
}
def __init__(self, object_path):
_RatbagdDBus.__init__(self, "Led", object_path)