dbus: org.freedesktop.UPower.Device: deprecate CapacityLevel property

This property is duplicated from BatteryLevel and confuses the user.
This commit is contained in:
Kate Hsuan 2025-11-19 15:05:57 +08:00
parent 391e3323f0
commit 09ada726f7
2 changed files with 35 additions and 0 deletions

View file

@ -935,6 +935,7 @@ method return sender=:1.386 -> dest=:1.477 reply_serial=2
</property>
<property name="CapacityLevel" type="s" access="read">
<annotation name="org.freedesktop.DBus.Deprecated" value="true"/>
<doc:doc>
<doc:description>
<doc:para>
@ -960,6 +961,15 @@ method return sender=:1.386 -> dest=:1.477 reply_serial=2
<doc:term>Full</doc:term>
</doc:item>
</doc:list>
<doc:para>
DEPRECATED
</doc:para>
<doc:para>
This property is deprecated since it is duplicated from the 'BatteryLevel' property.
</doc:para>
<doc:para>
Since 1.91.0
</doc:para>
</doc:description>
</doc:doc>
</property>

View file

@ -349,7 +349,15 @@ up_device_to_text (UpDevice *device)
g_string_append_printf (string, " voltage-min-design: %g V\n", up_exported_device_get_voltage_min_design (priv->proxy_device));
if (up_exported_device_get_voltage_max_design (priv->proxy_device) > 0)
g_string_append_printf (string, " voltage-max-design: %g V\n", up_exported_device_get_voltage_max_design (priv->proxy_device));
/* Suppress the warning about the deprecated property CapacityLevel */
/* DEPRECATED. This property is deprecated since it is duplicated from the 'BatteryLevel' property.
* since 1.91.0 */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
capacity_level = up_exported_device_get_capacity_level (priv->proxy_device);
#pragma GCC diagnostic pop
if (capacity_level != NULL && capacity_level[0] != '\0')
g_string_append_printf (string, " capacity-level: %s\n", capacity_level);
}
@ -733,9 +741,15 @@ up_device_set_property (GObject *object, guint prop_id, const GValue *value, GPa
case PROP_VOLTAGE_MAX_DESIGN:
up_exported_device_set_voltage_max_design (device->priv->proxy_device, g_value_get_double (value));
break;
/* Suppress the warning about the deprecated property CapacityLevel */
/* DEPRECATED. This property is deprecated since it is duplicated from the 'BatteryLevel' property.
* since 1.91.0 */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
case PROP_CAPACITY_LEVEL:
up_exported_device_set_capacity_level (device->priv->proxy_device, g_value_get_string (value));
break;
#pragma GCC diagnostic pop
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -871,9 +885,15 @@ up_device_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe
case PROP_VOLTAGE_MAX_DESIGN:
g_value_set_double (value, up_exported_device_get_voltage_max_design (device->priv->proxy_device));
break;
/* Suppress the warning about the deprecated property CapacityLevel */
/* DEPRECATED. This property is deprecated since it is duplicated from the 'BatteryLevel' property.
* since 1.91.0 */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
case PROP_CAPACITY_LEVEL:
g_value_set_string (value, up_exported_device_get_capacity_level (device->priv->proxy_device));
break;
#pragma GCC diagnostic pop
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -1381,6 +1401,11 @@ up_device_class_init (UpDeviceClass *klass)
* Unknown, Critical, Low, Normal, High, and Full.
*
* Since: 1.90.10
*
* DEPRECATED.
* This property is deprecated since it is duplicated from the 'BatteryLevel' property.
*
* Since 1.91.0
**/
g_object_class_install_property (object_class,
PROP_CAPACITY_LEVEL,