diff --git a/src/devkit-power-source.c b/src/devkit-power-source.c index 3d309c9..f5a3720 100644 --- a/src/devkit-power-source.c +++ b/src/devkit-power-source.c @@ -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) diff --git a/src/org.freedesktop.DeviceKit.Power.Source.xml b/src/org.freedesktop.DeviceKit.Power.Source.xml index 8987229..d2c33b9 100644 --- a/src/org.freedesktop.DeviceKit.Power.Source.xml +++ b/src/org.freedesktop.DeviceKit.Power.Source.xml @@ -214,6 +214,16 @@ + + + If the power source is rechargeable. + + This property is only valid if the property + type + has the value "battery". + + + The capacity of the power source expressed as a percentage between 0 and 100.