mirror of
https://github.com/dguglielmi/sunny-overlay.git
synced 2025-12-06 11:42:40 +01:00
171 lines
8.8 KiB
Diff
171 lines
8.8 KiB
Diff
From 271207eb35831a0b8e00b0d3d53041bf765bbd85 Mon Sep 17 00:00:00 2001
|
|
From: Jente Hidskes <hjdskes@gmail.com>
|
|
Date: Sat, 11 Nov 2017 17:52:59 +0100
|
|
Subject: [PATCH 28/30] LedDialog: use new effect duration in ms
|
|
|
|
libratbag/libratbag#422 introduced effect duration in ms for LEDs as opposed to
|
|
effect rate in Hz, as was discussed in #175. This commit updates Piper's
|
|
UI to reflect these changes.
|
|
|
|
Fixes #175.
|
|
---
|
|
data/ui/LedDialog.ui | 30 ++++++++++++++++--------------
|
|
piper/leddialog.py | 16 ++++++++++++----
|
|
piper/ledspage.py | 2 +-
|
|
3 files changed, 29 insertions(+), 19 deletions(-)
|
|
|
|
diff --git a/data/ui/LedDialog.ui b/data/ui/LedDialog.ui
|
|
index 408fb0a..0c1e422 100644
|
|
--- a/data/ui/LedDialog.ui
|
|
+++ b/data/ui/LedDialog.ui
|
|
@@ -7,11 +7,11 @@
|
|
<property name="step_increment">1</property>
|
|
<property name="page_increment">10</property>
|
|
</object>
|
|
- <object class="GtkAdjustment" id="adjustment_effect_rate">
|
|
- <property name="lower">100</property>
|
|
- <property name="upper">20000</property>
|
|
- <property name="step_increment">50</property>
|
|
- <property name="page_increment">50</property>
|
|
+ <object class="GtkAdjustment" id="adjustment_effect_duration">
|
|
+ <property name="lower">0</property>
|
|
+ <property name="upper">10000</property>
|
|
+ <property name="step_increment">100</property>
|
|
+ <property name="page_increment">500</property>
|
|
</object>
|
|
<template class="LedDialog" parent="GtkDialog">
|
|
<property name="width_request">400</property>
|
|
@@ -132,11 +132,12 @@
|
|
<object class="GtkScale">
|
|
<property name="visible">True</property>
|
|
<property name="can_focus">True</property>
|
|
- <property name="tooltip_text" translatable="yes">Choose an effect rate for the LED</property>
|
|
- <property name="adjustment">adjustment_effect_rate</property>
|
|
+ <property name="tooltip_text" translatable="yes">Choose an effect duration for the LED</property>
|
|
+ <property name="adjustment">adjustment_effect_duration</property>
|
|
<property name="round_digits">0</property>
|
|
<property name="digits">0</property>
|
|
<property name="value_pos">right</property>
|
|
+ <signal name="change-value" handler="_on_change_value" swapped="no"/>
|
|
</object>
|
|
<packing>
|
|
<property name="expand">True</property>
|
|
@@ -149,7 +150,7 @@
|
|
<property name="visible">True</property>
|
|
<property name="can_focus">False</property>
|
|
<property name="halign">end</property>
|
|
- <property name="label" translatable="yes">Hz</property>
|
|
+ <property name="label" translatable="yes">ms</property>
|
|
<property name="justify">right</property>
|
|
<property name="track_visited_links">False</property>
|
|
<style>
|
|
@@ -171,7 +172,7 @@
|
|
<object class="GtkLabel">
|
|
<property name="visible">True</property>
|
|
<property name="can_focus">False</property>
|
|
- <property name="label" translatable="yes">Effect rate</property>
|
|
+ <property name="label" translatable="yes">Effect duration</property>
|
|
<property name="track_visited_links">False</property>
|
|
</object>
|
|
</child>
|
|
@@ -297,11 +298,12 @@
|
|
<object class="GtkScale">
|
|
<property name="visible">True</property>
|
|
<property name="can_focus">True</property>
|
|
- <property name="tooltip_text" translatable="yes">Choose an effect rate for the LED</property>
|
|
- <property name="adjustment">adjustment_effect_rate</property>
|
|
+ <property name="tooltip_text" translatable="yes">Choose an effect duration for the LED</property>
|
|
+ <property name="adjustment">adjustment_effect_duration</property>
|
|
<property name="round_digits">0</property>
|
|
<property name="digits">0</property>
|
|
<property name="value_pos">right</property>
|
|
+ <signal name="change-value" handler="_on_change_value" swapped="no"/>
|
|
</object>
|
|
<packing>
|
|
<property name="expand">True</property>
|
|
@@ -314,7 +316,7 @@
|
|
<property name="visible">True</property>
|
|
<property name="can_focus">False</property>
|
|
<property name="halign">end</property>
|
|
- <property name="label" translatable="yes">Hz</property>
|
|
+ <property name="label" translatable="yes">ms</property>
|
|
<property name="justify">right</property>
|
|
<property name="track_visited_links">False</property>
|
|
<style>
|
|
@@ -336,7 +338,7 @@
|
|
<object class="GtkLabel">
|
|
<property name="visible">True</property>
|
|
<property name="can_focus">False</property>
|
|
- <property name="label" translatable="yes">Effect rate</property>
|
|
+ <property name="label" translatable="yes">Effect duration</property>
|
|
<property name="track_visited_links">False</property>
|
|
</object>
|
|
</child>
|
|
@@ -363,7 +365,7 @@
|
|
<object class="GtkImage" id="led_off_image">
|
|
<property name="visible">True</property>
|
|
<property name="can_focus">False</property>
|
|
- <property name="resource">/org/freedesktop/Piper/led-off.svg</property>
|
|
+ <property name="resource">/org/freedesktop/Piper/led-off.svg</property>
|
|
</object>
|
|
<packing>
|
|
<property name="expand">True</property>
|
|
diff --git a/piper/leddialog.py b/piper/leddialog.py
|
|
index c8c73a5..50a58d1 100644
|
|
--- a/piper/leddialog.py
|
|
+++ b/piper/leddialog.py
|
|
@@ -33,7 +33,7 @@ class LedDialog(Gtk.Dialog):
|
|
colorchooser = GtkTemplate.Child()
|
|
colorbutton = GtkTemplate.Child()
|
|
adjustment_brightness = GtkTemplate.Child()
|
|
- adjustment_effect_rate = GtkTemplate.Child()
|
|
+ adjustment_effect_duration = GtkTemplate.Child()
|
|
led_off_image = GtkTemplate.Child()
|
|
|
|
def __init__(self, ratbagd_led, *args, **kwargs):
|
|
@@ -59,13 +59,21 @@ class LedDialog(Gtk.Dialog):
|
|
self.colorchooser.set_rgba(rgba)
|
|
self.colorbutton.set_rgba(rgba)
|
|
self.adjustment_brightness.set_value(self._led.brightness)
|
|
- self.adjustment_effect_rate.set_value(self._led.effect_rate)
|
|
+ self.adjustment_effect_duration.set_value(self._led.effect_duration)
|
|
|
|
sp = Gtk.CssProvider()
|
|
sp.load_from_data("* { background: #565854}".encode())
|
|
Gtk.StyleContext.add_provider(self.led_off_image.get_style_context(),
|
|
sp, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
|
|
|
|
+ @GtkTemplate.Callback
|
|
+ def _on_change_value(self, scale, scroll, value):
|
|
+ # Round the value resulting from a scroll event to the nearest multiple
|
|
+ # of 500. This is to work around the Gtk.Scale not snapping to its
|
|
+ # Gtk.Adjustment's step_increment.
|
|
+ scale.set_value(int(value - (value % 500)))
|
|
+ return True
|
|
+
|
|
def _get_led_color_as_rgba(self):
|
|
# Helper function to convert ratbagd's 0-255 color range to a Gdk.RGBA
|
|
# with a 0.0-1.0 color range.
|
|
@@ -90,5 +98,5 @@ class LedDialog(Gtk.Dialog):
|
|
return self.adjustment_brightness.get_value()
|
|
|
|
@GObject.Property
|
|
- def effect_rate(self):
|
|
- return self.adjustment_effect_rate.get_value()
|
|
+ def effect_duration(self):
|
|
+ return self.adjustment_effect_duration.get_value()
|
|
diff --git a/piper/ledspage.py b/piper/ledspage.py
|
|
index 7994b53..af50773 100644
|
|
--- a/piper/ledspage.py
|
|
+++ b/piper/ledspage.py
|
|
@@ -87,5 +87,5 @@ class LedsPage(Gtk.Box):
|
|
led.mode = dialog.mode
|
|
led.color = dialog.color
|
|
led.brightness = dialog.brightness
|
|
- led.effect_rate = dialog.effect_rate
|
|
+ led.effect_duration = dialog.effect_duration
|
|
dialog.destroy()
|
|
--
|
|
2.16.1
|
|
|