mirror of
https://github.com/libratbag/piper.git
synced 2026-02-19 23:23:51 -05:00
resolutionrow: listen for external resolution changes
This adds some duplicated code. TODO: refactor this file.
This commit is contained in:
@@ -46,6 +46,9 @@ class ResolutionRow(Gtk.ListBoxRow):
|
||||
self._disabled_handler = connect_signal_with_weak_ref(
|
||||
self, resolution, "notify::is-disabled", self._on_status_changed
|
||||
)
|
||||
connect_signal_with_weak_ref(
|
||||
self, resolution, "notify::resolution", self._on_profile_resolution_changed
|
||||
)
|
||||
|
||||
# Get resolution capabilities and update internal values.
|
||||
if RatbagdResolution.CAP_SEPARATE_XY_RESOLUTION in resolution.capabilities:
|
||||
@@ -155,3 +158,11 @@ class ResolutionRow(Gtk.ListBoxRow):
|
||||
# Only update new resolution if changed
|
||||
if new_res != self._resolution.resolution:
|
||||
self._resolution.resolution = new_res
|
||||
|
||||
def _on_profile_resolution_changed(
|
||||
self, resolution: RatbagdResolution, pspec: GObject.ParamSpec
|
||||
) -> None:
|
||||
with self.scale.handler_block(self._scale_handler):
|
||||
res = resolution.resolution[0]
|
||||
self.scale.set_value(res)
|
||||
self.dpi_label.set_text(f"{res} DPI")
|
||||
|
||||
Reference in New Issue
Block a user