| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright (c) 2020 Bastien Nocera <hadess@hadess.net> | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify it | ||
| 5 | * under the terms of the GNU General Public License version 3 as published by | ||
| 6 | * the Free Software Foundation. | ||
| 7 | * | ||
| 8 | */ | ||
| 9 | |||
| 10 | #include "ppd-profile.h" | ||
| 11 | #include "ppd-enums.h" | ||
| 12 | |||
| 13 | const char * | ||
| 14 | 4506 | ppd_profile_to_str (PpdProfile profile) | |
| 15 | { | ||
| 16 | 4506 | g_autoptr(GFlagsClass) klass = g_type_class_ref (PPD_TYPE_PROFILE); | |
| 17 | 4506 | GFlagsValue *value = g_flags_get_first_value (klass, profile); | |
| 18 |
2/2✓ Branch 0 taken 4504 times.
✓ Branch 1 taken 2 times.
|
4506 | const gchar *name = value ? value->value_nick : ""; |
| 19 |
1/2✓ Branch 0 taken 4506 times.
✗ Branch 1 not taken.
|
4506 | return name; |
| 20 | } | ||
| 21 | |||
| 22 | PpdProfile | ||
| 23 | 138 | ppd_profile_from_str (const char *str) | |
| 24 | { | ||
| 25 | 138 | g_autoptr(GFlagsClass) klass = g_type_class_ref (PPD_TYPE_PROFILE); | |
| 26 | 138 | GFlagsValue *value = g_flags_get_value_by_nick (klass, str); | |
| 27 |
1/2✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
|
138 | PpdProfile profile = value ? value->value : PPD_PROFILE_UNSET; |
| 28 |
1/2✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
|
138 | return profile; |
| 29 | } | ||
| 30 | |||
| 31 | gboolean | ||
| 32 | 422 | ppd_profile_has_single_flag (PpdProfile profile) | |
| 33 | { | ||
| 34 | 422 | g_autoptr(GFlagsClass) klass = g_type_class_ref (PPD_TYPE_PROFILE); | |
| 35 | 422 | GFlagsValue *value = g_flags_get_first_value (klass, profile); | |
| 36 |
2/4✓ Branch 0 taken 422 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 422 times.
✗ Branch 3 not taken.
|
422 | if (value && value->value == profile) |
| 37 | 422 | return TRUE; | |
| 38 | |||
| 39 | return FALSE; | ||
| 40 | } | ||
| 41 | |||
| 42 | const char * | ||
| 43 | 48 | ppd_power_changed_reason_to_str (PpdPowerChangedReason reason) | |
| 44 | { | ||
| 45 | 48 | g_autoptr(GEnumClass) klass = g_type_class_ref (PPD_TYPE_POWER_CHANGED_REASON); | |
| 46 | 48 | GEnumValue *value = g_enum_get_value (klass, reason); | |
| 47 |
1/2✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
|
48 | const gchar *name = value ? value->value_nick : ""; |
| 48 |
1/2✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
|
48 | return name; |
| 49 | } | ||
| 50 |