mirror of
https://gitlab.freedesktop.org/upower/power-profiles-daemon.git
synced 2026-05-05 02:57:59 +02:00
main: Add helper to verify that PpdProfile is a single profile
In certain places in the codebase, we expect PpdProfile to be a value representing a single profile, so add a helper that we can use to verify that.
This commit is contained in:
parent
5a0cbd173f
commit
1ffbea1905
2 changed files with 15 additions and 0 deletions
|
|
@ -29,3 +29,15 @@ ppd_profile_from_str (const char *str)
|
|||
g_type_class_unref (klass);
|
||||
return profile;
|
||||
}
|
||||
|
||||
gboolean
|
||||
ppd_profile_has_single_flag (PpdProfile profile)
|
||||
{
|
||||
GFlagsClass *klass = g_type_class_ref (PPD_TYPE_PROFILE);
|
||||
GFlagsValue *value = g_flags_get_first_value (klass, profile);
|
||||
gboolean ret = FALSE;
|
||||
if (value && value->value == profile)
|
||||
ret = TRUE;
|
||||
g_type_class_unref (klass);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
/**
|
||||
* PpdProfile:
|
||||
* @PPD_PROFILE_POWER_SAVER: "power-saver", the battery saving profile
|
||||
|
|
@ -30,3 +32,4 @@ 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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue