comparison pui-types.c.in @ 10:adba37525ee5

Notify about required session or system restarts Follow all PackageKit transactions and indicate when a session or system restart is required. Generate enum types with glib-mkenums.
author Guido Berhoerster <guido+pui@berhoerster.name>
date Fri, 06 Jul 2018 14:12:46 +0200
parents
children
comparison
equal deleted inserted replaced
9:b571e7ade208 10:adba37525ee5
1 /*** BEGIN file-header ***/
2 #include "pui-types.h"
3 /*** END file-header ***/
4
5 /*** BEGIN file-production ***/
6
7 /* enumerations from "@filename@" */
8 #include "@filename@"
9 /*** END file-production ***/
10
11 /*** BEGIN value-header ***/
12
13 GType
14 @enum_name@_get_type (void)
15 {
16 static volatile gsize g_define_type_id__volatile;
17 GType g_@type@_type_id;
18
19 if (g_once_init_enter(&g_define_type_id__volatile)) {
20 static const G@Type@Value values[] = {
21 /*** END value-header ***/
22
23 /*** BEGIN value-production ***/
24 { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
25 /*** END value-production ***/
26
27 /*** BEGIN value-tail ***/
28 { 0 }
29 };
30
31 g_@type@_type_id = g_@type@_register_static(
32 g_intern_static_string("@EnumName@"), values);
33
34 g_once_init_leave(&g_define_type_id__volatile,
35 g_@type@_type_id);
36 }
37
38 return (g_define_type_id__volatile);
39 }
40 /*** END value-tail ***/
41
42 /*** BEGIN file-tail ***/
43
44 gchar *
45 pui_types_enum_to_string(GType type, gint value)
46 {
47 GTypeClass *type_class;
48 GEnumValue *enum_value;
49
50 type_class = g_type_class_ref(type);
51
52 g_return_val_if_fail(G_IS_ENUM_CLASS(type_class), NULL);
53
54 enum_value = g_enum_get_value(G_ENUM_CLASS(type_class), value);
55 if (enum_value == NULL) {
56 return (g_strdup_printf("%d", value));
57 }
58
59 return (g_strdup(enum_value->value_nick));
60 }
61 /*** END file-tail ***/