ppd-profile: Write PpdPowerChangedReason as string in debug statements

This commit is contained in:
Marco Trevisan (Treviño) 2024-04-04 01:47:08 +02:00
parent 301af78dce
commit d41b0f0f81
3 changed files with 13 additions and 1 deletions

View file

@ -1071,7 +1071,8 @@ upower_battery_set_power_changed_reason (PpdApp *data,
return;
data->power_changed_reason = reason;
g_info ("Power Changed because of reason %d", reason);
g_info ("Power Changed because of reason %s",
ppd_power_changed_reason_to_str (reason));
for (guint i = 0; i < data->actions->len; i++) {
g_autoptr(GError) error = NULL;

View file

@ -38,3 +38,12 @@ ppd_profile_has_single_flag (PpdProfile profile)
return FALSE;
}
const char *
ppd_power_changed_reason_to_str (PpdPowerChangedReason reason)
{
g_autoptr(GEnumClass) klass = g_type_class_ref (PPD_TYPE_POWER_CHANGED_REASON);
GEnumValue *value = g_enum_get_value (klass, reason);
const gchar *name = value ? value->value_nick : "";
return name;
}

View file

@ -67,3 +67,5 @@ typedef enum{
const char *ppd_profile_to_str (PpdProfile profile);
PpdProfile ppd_profile_from_str (const char *str);
gboolean ppd_profile_has_single_flag (PpdProfile profile);
const char *ppd_power_changed_reason_to_str (PpdPowerChangedReason reason);