diff options
Diffstat (limited to 'lib/bluetooth/battery.vala')
-rw-r--r-- | lib/bluetooth/battery.vala | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/bluetooth/battery.vala b/lib/bluetooth/battery.vala new file mode 100644 index 0000000..9fdd70d --- /dev/null +++ b/lib/bluetooth/battery.vala @@ -0,0 +1,33 @@ +/** + * Object representing a [[https://github.com/bluez/bluez/blob/master/doc/org.bluez.Battery.rst|battery]]. + */ +internal class AstalBluetooth.Battery : Object { + private IBattery proxy; + + internal ObjectPath object_path { owned get; private set; } + + internal Battery(IBattery proxy) { + this.proxy = proxy; + this.object_path = (ObjectPath)proxy.g_object_path; + proxy.g_properties_changed.connect((props) => { + var map = (HashTable<string, Variant>)props; + foreach (var key in map.get_keys()) { + var prop = kebab_case(key); + if (get_class().find_property(prop) != null) { + notify_property(prop); + } + } + }); + } + + /** + * The percentage of battery left as an unsigned 8-bit integer. + */ + public uint percentage { get { return proxy.percentage; } } + + /** + * Describes where the battery information comes from. + */ + public string source { owned get { return proxy.source; } } + +} |