forked from drath/libratbag
tools/ratbagd.py: sync with Piper
This commit is contained in:
committed by
Benjamin Tissoires
parent
5828355426
commit
d06cdcc53c
@@ -314,7 +314,8 @@ class RatbagdDevice(_RatbagdDBus):
|
||||
profile.connect("notify::is-active", self._on_active_profile_changed)
|
||||
|
||||
def _on_active_profile_changed(self, profile, pspec):
|
||||
self.emit("active-profile-changed", self._profiles[profile.index])
|
||||
if profile.is_active:
|
||||
self.emit("active-profile-changed", self._profiles[profile.index])
|
||||
|
||||
@GObject.Property
|
||||
def id(self):
|
||||
@@ -393,6 +394,7 @@ class RatbagdProfile(_RatbagdDBus):
|
||||
def __init__(self, object_path):
|
||||
_RatbagdDBus.__init__(self, "Profile", object_path)
|
||||
self._dirty = False
|
||||
self._active = self._get_dbus_property("IsActive")
|
||||
|
||||
# FIXME: if we start adding and removing objects from any of these
|
||||
# lists, things will break!
|
||||
@@ -417,6 +419,14 @@ class RatbagdProfile(_RatbagdDBus):
|
||||
self._dirty = True
|
||||
self.notify("dirty")
|
||||
|
||||
def _on_properties_changed(self, proxy, changed_props, invalidated_props):
|
||||
if "IsActive" in changed_props.keys():
|
||||
active = changed_props["IsActive"]
|
||||
if active != self._active:
|
||||
self._active = active
|
||||
self.notify("is-active")
|
||||
self._on_obj_notify(None, None)
|
||||
|
||||
@GObject.Property
|
||||
def capabilities(self):
|
||||
"""The capabilities of this profile as an array. Capabilities not
|
||||
@@ -497,13 +507,12 @@ class RatbagdProfile(_RatbagdDBus):
|
||||
@GObject.Property
|
||||
def is_active(self):
|
||||
"""Returns True if the profile is currenly active, false otherwise."""
|
||||
return self._get_dbus_property("IsActive")
|
||||
return self._active
|
||||
|
||||
def set_active(self):
|
||||
"""Set this profile to be the active profile."""
|
||||
ret = self._dbus_call("SetActive", "")
|
||||
self._set_dbus_property("IsActive", "b", True, readwrite=False)
|
||||
self.notify("is-active")
|
||||
return ret
|
||||
|
||||
|
||||
@@ -515,10 +524,20 @@ class RatbagdResolution(_RatbagdDBus):
|
||||
|
||||
def __init__(self, object_path):
|
||||
_RatbagdDBus.__init__(self, "Resolution", object_path)
|
||||
self._active = self._get_dbus_property("IsActive")
|
||||
self._default = self._get_dbus_property("IsDefault")
|
||||
|
||||
def _on_properties_changed(self, proxy, changed_props, invalidated_props):
|
||||
if "IsActive" in changed_props.keys():
|
||||
self.notify("is-active")
|
||||
active = changed_props["IsActive"]
|
||||
if active != self._active:
|
||||
self._active = active
|
||||
self.notify("is-active")
|
||||
elif "IsDefault" in changed_props.keys():
|
||||
default = changed_props["IsDefault"]
|
||||
if default != self._default:
|
||||
self._default = default
|
||||
self.notify("is-default")
|
||||
|
||||
@GObject.Property
|
||||
def index(self):
|
||||
@@ -575,13 +594,13 @@ class RatbagdResolution(_RatbagdDBus):
|
||||
def is_active(self):
|
||||
"""True if this is the currently active resolution, False
|
||||
otherwise"""
|
||||
return self._get_dbus_property("IsActive")
|
||||
return self._active
|
||||
|
||||
@GObject.Property
|
||||
def is_default(self):
|
||||
"""True if this is the currently default resolution, False
|
||||
otherwise"""
|
||||
return self._get_dbus_property("IsDefault")
|
||||
return self._default
|
||||
|
||||
def set_default(self):
|
||||
"""Set this resolution to be the default."""
|
||||
|
||||
Reference in New Issue
Block a user