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 | 4475 | ppd_profile_to_str (PpdProfile profile) | |
15 | { | ||
16 | 4475 | g_autoptr(GFlagsClass) klass = g_type_class_ref (PPD_TYPE_PROFILE); | |
17 | 4475 | GFlagsValue *value = g_flags_get_first_value (klass, profile); | |
18 |
1/2✓ Branch 0 taken 4475 times.
✗ Branch 1 not taken.
|
4475 | const gchar *name = value ? value->value_nick : ""; |
19 |
1/2✓ Branch 0 taken 4475 times.
✗ Branch 1 not taken.
|
4475 | return name; |
20 | } | ||
21 | |||
22 | PpdProfile | ||
23 | 134 | ppd_profile_from_str (const char *str) | |
24 | { | ||
25 | 134 | g_autoptr(GFlagsClass) klass = g_type_class_ref (PPD_TYPE_PROFILE); | |
26 | 134 | GFlagsValue *value = g_flags_get_value_by_nick (klass, str); | |
27 |
2/2✓ Branch 0 taken 132 times.
✓ Branch 1 taken 2 times.
|
134 | PpdProfile profile = value ? value->value : PPD_PROFILE_UNSET; |
28 |
1/2✓ Branch 0 taken 134 times.
✗ Branch 1 not taken.
|
134 | return profile; |
29 | } | ||
30 | |||
31 | gboolean | ||
32 | 388 | ppd_profile_has_single_flag (PpdProfile profile) | |
33 | { | ||
34 | 388 | g_autoptr(GFlagsClass) klass = g_type_class_ref (PPD_TYPE_PROFILE); | |
35 | 388 | GFlagsValue *value = g_flags_get_first_value (klass, profile); | |
36 |
2/4✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 388 times.
✗ Branch 3 not taken.
|
388 | if (value && value->value == profile) |
37 | 388 | return TRUE; | |
38 | |||
39 | return FALSE; | ||
40 | } | ||
41 | |||
42 | const char * | ||
43 | 40 | ppd_power_changed_reason_to_str (PpdPowerChangedReason reason) | |
44 | { | ||
45 | 40 | g_autoptr(GEnumClass) klass = g_type_class_ref (PPD_TYPE_POWER_CHANGED_REASON); | |
46 | 40 | GEnumValue *value = g_enum_get_value (klass, reason); | |
47 |
1/2✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
|
40 | const gchar *name = value ? value->value_nick : ""; |
48 |
1/2✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
|
40 | return name; |
49 | } | ||
50 |