williamr@2
|
1 |
/* GObject - GLib Type, Object, Parameter and Signal Library
|
williamr@2
|
2 |
* Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
|
williamr@2
|
3 |
* Portions copyright (c) 2006 Nokia Corporation. All rights reserved.
|
williamr@2
|
4 |
*
|
williamr@2
|
5 |
* This library is free software; you can redistribute it and/or
|
williamr@2
|
6 |
* modify it under the terms of the GNU Lesser General Public
|
williamr@2
|
7 |
* License as published by the Free Software Foundation; either
|
williamr@2
|
8 |
* version 2 of the License, or (at your option) any later version.
|
williamr@2
|
9 |
*
|
williamr@2
|
10 |
* This library is distributed in the hope that it will be useful,
|
williamr@2
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
williamr@2
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
williamr@2
|
13 |
* Lesser General Public License for more details.
|
williamr@2
|
14 |
*
|
williamr@2
|
15 |
* You should have received a copy of the GNU Lesser General
|
williamr@2
|
16 |
* Public License along with this library; if not, write to the
|
williamr@2
|
17 |
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
williamr@2
|
18 |
* Boston, MA 02111-1307, USA.
|
williamr@2
|
19 |
*/
|
williamr@2
|
20 |
#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
|
williamr@2
|
21 |
#error "Only <glib-object.h> can be included directly."
|
williamr@2
|
22 |
#endif
|
williamr@2
|
23 |
|
williamr@2
|
24 |
#ifndef __G_ENUMS_H__
|
williamr@2
|
25 |
#define __G_ENUMS_H__
|
williamr@2
|
26 |
|
williamr@2
|
27 |
#include <_ansi.h>
|
williamr@2
|
28 |
#include <gobject/gtype.h>
|
williamr@2
|
29 |
|
williamr@2
|
30 |
G_BEGIN_DECLS
|
williamr@2
|
31 |
|
williamr@2
|
32 |
/* --- type macros --- */
|
williamr@2
|
33 |
#define G_TYPE_IS_ENUM(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_ENUM)
|
williamr@2
|
34 |
#define G_ENUM_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_ENUM, GEnumClass))
|
williamr@2
|
35 |
#define G_IS_ENUM_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_ENUM))
|
williamr@2
|
36 |
#define G_ENUM_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
|
williamr@2
|
37 |
#define G_ENUM_CLASS_TYPE_NAME(class) (g_type_name (G_ENUM_CLASS_TYPE (class)))
|
williamr@2
|
38 |
#define G_TYPE_IS_FLAGS(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_FLAGS)
|
williamr@2
|
39 |
#define G_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_FLAGS, GFlagsClass))
|
williamr@2
|
40 |
#define G_IS_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_FLAGS))
|
williamr@2
|
41 |
#define G_FLAGS_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
|
williamr@2
|
42 |
#define G_FLAGS_CLASS_TYPE_NAME(class) (g_type_name (G_FLAGS_CLASS_TYPE (class)))
|
williamr@2
|
43 |
#define G_VALUE_HOLDS_ENUM(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ENUM))
|
williamr@2
|
44 |
#define G_VALUE_HOLDS_FLAGS(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLAGS))
|
williamr@2
|
45 |
|
williamr@2
|
46 |
|
williamr@2
|
47 |
/* --- enum/flag values & classes --- */
|
williamr@2
|
48 |
typedef struct _GEnumClass GEnumClass;
|
williamr@2
|
49 |
typedef struct _GFlagsClass GFlagsClass;
|
williamr@2
|
50 |
typedef struct _GEnumValue GEnumValue;
|
williamr@2
|
51 |
typedef struct _GFlagsValue GFlagsValue;
|
williamr@2
|
52 |
struct _GEnumClass
|
williamr@2
|
53 |
{
|
williamr@2
|
54 |
GTypeClass g_type_class;
|
williamr@2
|
55 |
|
williamr@2
|
56 |
/*< public >*/
|
williamr@2
|
57 |
gint minimum;
|
williamr@2
|
58 |
gint maximum;
|
williamr@2
|
59 |
guint n_values;
|
williamr@2
|
60 |
GEnumValue *values;
|
williamr@2
|
61 |
};
|
williamr@2
|
62 |
struct _GFlagsClass
|
williamr@2
|
63 |
{
|
williamr@2
|
64 |
GTypeClass g_type_class;
|
williamr@2
|
65 |
|
williamr@2
|
66 |
/*< public >*/
|
williamr@2
|
67 |
guint mask;
|
williamr@2
|
68 |
guint n_values;
|
williamr@2
|
69 |
GFlagsValue *values;
|
williamr@2
|
70 |
};
|
williamr@2
|
71 |
struct _GEnumValue
|
williamr@2
|
72 |
{
|
williamr@2
|
73 |
gint value;
|
williamr@2
|
74 |
gchar *value_name;
|
williamr@2
|
75 |
gchar *value_nick;
|
williamr@2
|
76 |
};
|
williamr@2
|
77 |
struct _GFlagsValue
|
williamr@2
|
78 |
{
|
williamr@2
|
79 |
guint value;
|
williamr@2
|
80 |
gchar *value_name;
|
williamr@2
|
81 |
gchar *value_nick;
|
williamr@2
|
82 |
};
|
williamr@2
|
83 |
|
williamr@2
|
84 |
|
williamr@2
|
85 |
/* --- prototypes --- */
|
williamr@2
|
86 |
IMPORT_C GEnumValue* g_enum_get_value (GEnumClass *enum_class,
|
williamr@2
|
87 |
gint value);
|
williamr@2
|
88 |
IMPORT_C GEnumValue* g_enum_get_value_by_name (GEnumClass *enum_class,
|
williamr@2
|
89 |
const gchar *name);
|
williamr@2
|
90 |
IMPORT_C GEnumValue* g_enum_get_value_by_nick (GEnumClass *enum_class,
|
williamr@2
|
91 |
const gchar *nick);
|
williamr@2
|
92 |
IMPORT_C GFlagsValue* g_flags_get_first_value (GFlagsClass *flags_class,
|
williamr@2
|
93 |
guint value);
|
williamr@2
|
94 |
IMPORT_C GFlagsValue* g_flags_get_value_by_name (GFlagsClass *flags_class,
|
williamr@2
|
95 |
const gchar *name);
|
williamr@2
|
96 |
IMPORT_C GFlagsValue* g_flags_get_value_by_nick (GFlagsClass *flags_class,
|
williamr@2
|
97 |
const gchar *nick);
|
williamr@2
|
98 |
IMPORT_C void g_value_set_enum (GValue *value,
|
williamr@2
|
99 |
gint v_enum);
|
williamr@2
|
100 |
IMPORT_C gint g_value_get_enum (const GValue *value);
|
williamr@2
|
101 |
IMPORT_C void g_value_set_flags (GValue *value,
|
williamr@2
|
102 |
guint v_flags);
|
williamr@2
|
103 |
IMPORT_C guint g_value_get_flags (const GValue *value);
|
williamr@2
|
104 |
|
williamr@2
|
105 |
|
williamr@2
|
106 |
|
williamr@2
|
107 |
/* --- registration functions --- */
|
williamr@2
|
108 |
/* const_static_values is a NULL terminated array of enum/flags
|
williamr@2
|
109 |
* values that is taken over!
|
williamr@2
|
110 |
*/
|
williamr@2
|
111 |
IMPORT_C GType g_enum_register_static (const gchar *name,
|
williamr@2
|
112 |
const GEnumValue *const_static_values);
|
williamr@2
|
113 |
IMPORT_C GType g_flags_register_static (const gchar *name,
|
williamr@2
|
114 |
const GFlagsValue *const_static_values);
|
williamr@2
|
115 |
/* functions to complete the type information
|
williamr@2
|
116 |
* for enums/flags implemented by plugins
|
williamr@2
|
117 |
*/
|
williamr@2
|
118 |
IMPORT_C void g_enum_complete_type_info (GType g_enum_type,
|
williamr@2
|
119 |
GTypeInfo *info,
|
williamr@2
|
120 |
const GEnumValue *const_values);
|
williamr@2
|
121 |
IMPORT_C void g_flags_complete_type_info (GType g_flags_type,
|
williamr@2
|
122 |
GTypeInfo *info,
|
williamr@2
|
123 |
const GFlagsValue *const_values);
|
williamr@2
|
124 |
|
williamr@2
|
125 |
G_END_DECLS
|
williamr@2
|
126 |
|
williamr@2
|
127 |
#endif /* __G_ENUMS_H__ */
|