Get the step increment from the Gtk.Adjustment instead of relying on a
magic number (500), which was wrong to begin with (actual value is 100).
Round the received float value to the nearest multiple of the step
increment, instead of rounding it down.
This fixes control of the slider through the arrow keys and improves the
accuracy of the "step snapping" when clicking the slider.
As a result, the UI now allows the user to pass values with a step (100)
instead of page (500) resolution to libratbag but that shouldn't be an
issue as drivers are expected to support any integer value within the
range 0-10000; see ratbag_led_set_effect_duration().
* Add dpi_entry GtkEntry objects to UI file and Python.
Find and apply closest resolution in self.resolutions.
[Needed?] Store value on textbox focus in.
[Needed?] Do not apply DPI value if the same as previous value.
DPI entry and resolution sliders affect each others' values.
* Remove pointless recursive logic.
Remove focus methods.
* Calculate DPI text box width based on max supported resolution.
* Renamed methods/signals to be consistent with current convention.
* Add a 'focus-in-event' signal to the DPI entry field.
Pass reference to ResolutionsPage when initialising ResolutionRow.
Use reference to invoke `ResolutionsPage._on_row_activated()`.
Do not toggle Revealer on DPI entry text box focus-in-event if Revealer is already expanded.
Grammar: dpi -> DPI
* Add type hints.
Prefix unused vars with underscores.
Actioned suggested import order from linter.
* Actually apply the closest res value (oops).
Apply the res value on focus-out-event.
* Toggle allow editing of DPI entry if 'disable' button clicked.
* Use set_sensitive() on DPI entry.
* rm pointless var.
* Create custom class for DPI text entry to circumvent assertion warning.
Grab DPIEntry focus when revealing ResolutionRow.
Revert import order.
Removed unused 'previous DPI value' var.
Remove 'private' convention underscore from ResolutionsPage._on_row_activate().
Remove callback method for DPI entry on ResolutionRow.
UI file uses DPIEntry.
Remove insert-text signal for DPIEntry from UI file.
* Line lengths
* Removed unused import.
Underscored unused parameter (PEP convention).
* Reverted underscore convention as to not break existing stuff.
* Use underscore convention, but also use it when invoking the method.
* Renamed handler name for ResolutionsPage to match method.
* Clarified docstring.
---------
Co-authored-by: Dan <64416644+brittle-bones@users.noreply.github.com>
Following GNOME Control Center. :)
By the way, this does not (and did not) do anything on Wayland, it will
only can only work on Wayland with GDK 4 API.
find_program(required: true) exits with the meson error message if the
program is not found so we never get to our pretty error message.
Fix this and make the message an actual error too.
Also indent the else condition correctly while we're here.
Following my design choice to disable all unavailable actions instead of
hiding them.
Another way to go here would be to move the deleted snippet to
_on_profile_notify_disabled(), so that the button is not hidden after
removing a profile from a full profile list.
I'd argue this is a bit more Pythonic to do for dicts on top of being
slightly more performant.
Still, I must say all of this repeated handling is kind of ugly.