mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-01-04 18:50:11 +01:00
export battery-is-rechargeable so we can export if we think it can be recharged
This commit is contained in:
parent
4433bd3379
commit
a1f9c05280
2 changed files with 22 additions and 0 deletions
|
|
@ -63,6 +63,7 @@ struct DevkitPowerSourcePrivate
|
|||
DevkitPowerType type;
|
||||
|
||||
gboolean line_power_online;
|
||||
gboolean battery_is_rechargeable;
|
||||
DevkitPowerState battery_state;
|
||||
DevkitPowerTechnology battery_technology;
|
||||
|
||||
|
|
@ -94,6 +95,7 @@ enum
|
|||
PROP_TYPE,
|
||||
PROP_LINE_POWER_ONLINE,
|
||||
PROP_BATTERY_CAPACITY,
|
||||
PROP_BATTERY_IS_RECHARGEABLE,
|
||||
PROP_BATTERY_STATE,
|
||||
PROP_BATTERY_ENERGY,
|
||||
PROP_BATTERY_ENERGY_EMPTY,
|
||||
|
|
@ -154,6 +156,9 @@ get_property (GObject *object,
|
|||
case PROP_LINE_POWER_ONLINE:
|
||||
g_value_set_boolean (value, source->priv->line_power_online);
|
||||
break;
|
||||
case PROP_BATTERY_IS_RECHARGEABLE:
|
||||
g_value_set_boolean (value, source->priv->battery_is_rechargeable);
|
||||
break;
|
||||
case PROP_BATTERY_STATE:
|
||||
g_value_set_string (value, devkit_power_convert_state_to_text (source->priv->battery_state));
|
||||
break;
|
||||
|
|
@ -255,6 +260,10 @@ devkit_power_source_class_init (DevkitPowerSourceClass *klass)
|
|||
object_class,
|
||||
PROP_BATTERY_ENERGY,
|
||||
g_param_spec_double ("battery-energy", NULL, NULL, 0, G_MAXDOUBLE, 0, G_PARAM_READABLE));
|
||||
g_object_class_install_property (
|
||||
object_class,
|
||||
PROP_BATTERY_IS_RECHARGEABLE,
|
||||
g_param_spec_boolean ("battery-is-rechargeable", NULL, NULL, FALSE, G_PARAM_READABLE));
|
||||
g_object_class_install_property (
|
||||
object_class,
|
||||
PROP_BATTERY_STATE,
|
||||
|
|
@ -516,6 +525,9 @@ update_battery (DevkitPowerSource *source)
|
|||
if (is_charging)
|
||||
source->priv->battery_energy_rate *= -1.0;
|
||||
|
||||
/* assume true for laptops */
|
||||
source->priv->battery_is_rechargeable = TRUE;
|
||||
|
||||
/* get a precise percentage */
|
||||
source->priv->battery_percentage = 100.0 * source->priv->battery_energy / source->priv->battery_energy_full;
|
||||
if (source->priv->battery_percentage < 0)
|
||||
|
|
|
|||
|
|
@ -214,6 +214,16 @@
|
|||
</doc:para></doc:description></doc:doc>
|
||||
</property>
|
||||
|
||||
<property name="battery-is-rechargeable" type="b" access="read">
|
||||
<doc:doc><doc:description><doc:para>
|
||||
If the power source is rechargeable.
|
||||
</doc:para><doc:para>
|
||||
This property is only valid if the property
|
||||
<doc:ref type="property" to="Source:type">type</doc:ref>
|
||||
has the value "battery".
|
||||
</doc:para></doc:description></doc:doc>
|
||||
</property>
|
||||
|
||||
<property name="battery-capacity" type="d" access="read">
|
||||
<doc:doc><doc:description><doc:para>
|
||||
The capacity of the power source expressed as a percentage between 0 and 100.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue