Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
steam-runtime-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
steamrt
steam-runtime-tools
Commits
a27e34f0
Commit
a27e34f0
authored
5 years ago
by
Jeremy Whiting
Browse files
Options
Downloads
Patches
Plain Diff
Add srt_enum_value_to_nick to get string for enumeration value.
parent
bec73f3b
No related branches found
Branches containing commit
Tags
v0.20210608.3
Tags containing commit
1 merge request
!90
Make stringification of enums, flags less repetitive
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
steam-runtime-tools/utils-internal.h
+4
-0
4 additions, 0 deletions
steam-runtime-tools/utils-internal.h
steam-runtime-tools/utils.c
+34
-0
34 additions, 0 deletions
steam-runtime-tools/utils.c
with
38 additions
and
0 deletions
steam-runtime-tools/utils-internal.h
+
4
−
0
View file @
a27e34f0
...
...
@@ -48,3 +48,7 @@ G_GNUC_INTERNAL const char *_srt_find_myself (const char **helpers_path_out,
G_GNUC_INTERNAL
gboolean
_srt_process_timeout_wait_status
(
int
wait_status
,
int
*
exit_status
,
int
*
terminating_signal
);
const
char
*
srt_enum_value_to_nick
(
GType
enum_type
,
int
value
);
This diff is collapsed.
Click to expand it.
steam-runtime-tools/utils.c
+
34
−
0
View file @
a27e34f0
...
...
@@ -409,6 +409,40 @@ _srt_filter_gameoverlayrenderer (const gchar *input)
return
ret
;
}
/**
* srt_enum_value_to_nick
* @enum_type: The type of the enumeration.
* @value: The enumeration value to stringify.
*
* Get the #GEnumValue.value-nick of a given enumeration value.
* For example, `srt_enum_value_to_nick (SRT_TYPE_WINDOW_SYSTEM, SRT_WINDOW_SYSTEM_EGL_X11)`
* returns `"egl-x11"`.
*
* Returns: (transfer none): A string representation
* of the given enumeration value.
*/
const
char
*
srt_enum_value_to_nick
(
GType
enum_type
,
int
value
)
{
GEnumClass
*
class
;
GEnumValue
*
enum_value
;
const
char
*
result
;
g_return_val_if_fail
(
G_TYPE_IS_ENUM
(
enum_type
),
NULL
);
class
=
g_type_class_ref
(
enum_type
);
enum_value
=
g_enum_get_value
(
class
,
value
);
if
(
enum_value
!=
NULL
)
result
=
enum_value
->
value_nick
;
else
result
=
NULL
;
g_type_class_unref
(
class
);
return
result
;
}
#if !GLIB_CHECK_VERSION(2, 36, 0)
static
void
_srt_constructor
(
void
)
__attribute__
((
__constructor__
));
static
void
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment