<refentry id="gobject-Enumeration-and-Flag-Types">
<refmeta>
<refentrytitle role="top_of_page" id="gobject-Enumeration-and-Flag-Types.top_of_page">Enumeration and Flag Types</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GOBJECT Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>Enumeration and Flag Types</refname>
<refpurpose>Enumeration and flags types</refpurpose>
</refnamediv>

<refsynopsisdiv id="gobject-Enumeration-and-Flag-Types.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>

#include &lt;glib-object.h&gt;

                    <link linkend="GEnumClass">GEnumClass</link>;
                    <link linkend="GFlagsClass">GFlagsClass</link>;
#define             <link linkend="G-ENUM-CLASS-TYPE--CAPS">G_ENUM_CLASS_TYPE</link>                   (class)
#define             <link linkend="G-ENUM-CLASS-TYPE-NAME--CAPS">G_ENUM_CLASS_TYPE_NAME</link>              (class)
#define             <link linkend="G-TYPE-IS-ENUM--CAPS">G_TYPE_IS_ENUM</link>                      (type)
#define             <link linkend="G-ENUM-CLASS--CAPS">G_ENUM_CLASS</link>                        (class)
#define             <link linkend="G-IS-ENUM-CLASS--CAPS">G_IS_ENUM_CLASS</link>                     (class)
#define             <link linkend="G-TYPE-IS-FLAGS--CAPS">G_TYPE_IS_FLAGS</link>                     (type)
#define             <link linkend="G-FLAGS-CLASS--CAPS">G_FLAGS_CLASS</link>                       (class)
#define             <link linkend="G-IS-FLAGS-CLASS--CAPS">G_IS_FLAGS_CLASS</link>                    (class)
#define             <link linkend="G-FLAGS-CLASS-TYPE--CAPS">G_FLAGS_CLASS_TYPE</link>                  (class)
#define             <link linkend="G-FLAGS-CLASS-TYPE-NAME--CAPS">G_FLAGS_CLASS_TYPE_NAME</link>             (class)
                    <link linkend="GEnumValue">GEnumValue</link>;
                    <link linkend="GFlagsValue">GFlagsValue</link>;
<link linkend="GEnumValue">GEnumValue</link>*         <link linkend="g-enum-get-value">g_enum_get_value</link>                    (<link linkend="GEnumClass">GEnumClass</link> *enum_class,
                                                         <link linkend="gint">gint</link> value);
<link linkend="GEnumValue">GEnumValue</link>*         <link linkend="g-enum-get-value-by-name">g_enum_get_value_by_name</link>            (<link linkend="GEnumClass">GEnumClass</link> *enum_class,
                                                         const <link linkend="gchar">gchar</link> *name);
<link linkend="GEnumValue">GEnumValue</link>*         <link linkend="g-enum-get-value-by-nick">g_enum_get_value_by_nick</link>            (<link linkend="GEnumClass">GEnumClass</link> *enum_class,
                                                         const <link linkend="gchar">gchar</link> *nick);
<link linkend="GFlagsValue">GFlagsValue</link>*        <link linkend="g-flags-get-first-value">g_flags_get_first_value</link>             (<link linkend="GFlagsClass">GFlagsClass</link> *flags_class,
                                                         <link linkend="guint">guint</link> value);
<link linkend="GFlagsValue">GFlagsValue</link>*        <link linkend="g-flags-get-value-by-name">g_flags_get_value_by_name</link>           (<link linkend="GFlagsClass">GFlagsClass</link> *flags_class,
                                                         const <link linkend="gchar">gchar</link> *name);
<link linkend="GFlagsValue">GFlagsValue</link>*        <link linkend="g-flags-get-value-by-nick">g_flags_get_value_by_nick</link>           (<link linkend="GFlagsClass">GFlagsClass</link> *flags_class,
                                                         const <link linkend="gchar">gchar</link> *nick);
<link linkend="GType">GType</link>               <link linkend="g-enum-register-static">g_enum_register_static</link>              (const <link linkend="gchar">gchar</link> *name,
                                                         const <link linkend="GEnumValue">GEnumValue</link> *const_static_values);
<link linkend="GType">GType</link>               <link linkend="g-flags-register-static">g_flags_register_static</link>             (const <link linkend="gchar">gchar</link> *name,
                                                         const <link linkend="GFlagsValue">GFlagsValue</link> *const_static_values);
<link linkend="void">void</link>                <link linkend="g-enum-complete-type-info">g_enum_complete_type_info</link>           (<link linkend="GType">GType</link> g_enum_type,
                                                         <link linkend="GTypeInfo">GTypeInfo</link> *info,
                                                         const <link linkend="GEnumValue">GEnumValue</link> *const_values);
<link linkend="void">void</link>                <link linkend="g-flags-complete-type-info">g_flags_complete_type_info</link>          (<link linkend="GType">GType</link> g_flags_type,
                                                         <link linkend="GTypeInfo">GTypeInfo</link> *info,
                                                         const <link linkend="GFlagsValue">GFlagsValue</link> *const_values);
</synopsis>
</refsynopsisdiv>









<refsect1 id="gobject-Enumeration-and-Flag-Types.description" role="desc">
<title role="desc.title">Description</title>
<para>
<link linkend="glib-mkenums">glib-mkenums</link>
<parameter>title</parameter>: Enumeration and Flag Types
</para>
<para>
The GLib type system provides fundamental types for enumeration and
flags types. (Flags types are like enumerations, but allow their
values to be combined by bitwise or). A registered enumeration or
flags type associates a name and a nickname with each allowed
value, and the methods <link linkend="g-enum-get-value-by-name"><function>g_enum_get_value_by_name()</function></link>,
<link linkend="g-enum-get-value-by-nick"><function>g_enum_get_value_by_nick()</function></link>, <link linkend="g-flags-get-value-by-name"><function>g_flags_get_value_by_name()</function></link> and
<link linkend="g-flags-get-value-by-nick"><function>g_flags_get_value_by_nick()</function></link> can look up values by their name or
nickname.  When an enumeration or flags type is registered with the
GLib type system, it can be used as value type for object
properties, using <link linkend="g-param-spec-enum"><function>g_param_spec_enum()</function></link> or <link linkend="g-param-spec-flags"><function>g_param_spec_flags()</function></link>.
</para>
<para>
GObject ships with a utility called <link
linkend="glib-mkenums">glib-mkenums</link> that can construct
suitable type registration functions from C enumeration
definitions.</para>
<para>
</para>
</refsect1>

<refsect1 id="gobject-Enumeration-and-Flag-Types.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="GEnumClass" role="struct">
<title>GEnumClass</title>
<indexterm zone="GEnumClass"><primary sortas="EnumClass">GEnumClass</primary></indexterm><programlisting>typedef struct {
  GTypeClass  g_type_class;

  gint	      minimum;
  gint	      maximum;
  guint	      n_values;
  GEnumValue *values;
} GEnumClass;
</programlisting>
<para>
The class of an enumeration type holds information about its 
possible values.</para>
<para>
</para><variablelist role="struct">
<varlistentry>
<term><link linkend="GTypeClass">GTypeClass</link>&#160;<structfield>g_type_class</structfield>;</term>
<listitem><simpara> the parent class
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><link linkend="gint">gint</link>&#160;<structfield>minimum</structfield>;</term>
<listitem><simpara> the smallest possible value.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><link linkend="gint">gint</link>&#160;<structfield>maximum</structfield>;</term>
<listitem><simpara> the largest possible value.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><link linkend="guint">guint</link>&#160;<structfield>n_values</structfield>;</term>
<listitem><simpara> the number of possible values.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><link linkend="GEnumValue">GEnumValue</link>&#160;*<structfield>values</structfield>;</term>
<listitem><simpara> an array of <link linkend="GEnumValue"><type>GEnumValue</type></link> structs describing the 
 individual values.
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="GFlagsClass" role="struct">
<title>GFlagsClass</title>
<indexterm zone="GFlagsClass"><primary sortas="FlagsClass">GFlagsClass</primary></indexterm><programlisting>typedef struct {
  GTypeClass   g_type_class;
  
  guint	       mask;
  guint	       n_values;
  GFlagsValue *values;
} GFlagsClass;
</programlisting>
<para>
The class of a flags type holds information about its 
possible values.</para>
<para>
</para><variablelist role="struct">
<varlistentry>
<term><link linkend="GTypeClass">GTypeClass</link>&#160;<structfield>g_type_class</structfield>;</term>
<listitem><simpara> the parent class
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><link linkend="guint">guint</link>&#160;<structfield>mask</structfield>;</term>
<listitem><simpara> a mask covering all possible values.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><link linkend="guint">guint</link>&#160;<structfield>n_values</structfield>;</term>
<listitem><simpara> the number of possible values.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><link linkend="GFlagsValue">GFlagsValue</link>&#160;*<structfield>values</structfield>;</term>
<listitem><simpara> an array of <link linkend="GFlagsValue"><type>GFlagsValue</type></link> structs describing the 
 individual values.
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="G-ENUM-CLASS-TYPE--CAPS" role="macro">
<title>G_ENUM_CLASS_TYPE()</title>
<indexterm zone="G-ENUM-CLASS-TYPE--CAPS"><primary sortas="ENUM_CLASS_TYPE">G_ENUM_CLASS_TYPE</primary></indexterm><programlisting>#define G_ENUM_CLASS_TYPE(class)       (G_TYPE_FROM_CLASS (class))
</programlisting>
<para>
Get the type identifier from a given <link linkend="GEnumClass"><type>GEnumClass</type></link> structure.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>class</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GEnumClass"><type>GEnumClass</type></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="G-ENUM-CLASS-TYPE-NAME--CAPS" role="macro">
<title>G_ENUM_CLASS_TYPE_NAME()</title>
<indexterm zone="G-ENUM-CLASS-TYPE-NAME--CAPS"><primary sortas="ENUM_CLASS_TYPE_NAME">G_ENUM_CLASS_TYPE_NAME</primary></indexterm><programlisting>#define G_ENUM_CLASS_TYPE_NAME(class)  (g_type_name (G_ENUM_CLASS_TYPE (class)))
</programlisting>
<para>
Get the static type name from a given <link linkend="GEnumClass"><type>GEnumClass</type></link> structure.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>class</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GEnumClass"><type>GEnumClass</type></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="G-TYPE-IS-ENUM--CAPS" role="macro">
<title>G_TYPE_IS_ENUM()</title>
<indexterm zone="G-TYPE-IS-ENUM--CAPS"><primary sortas="TYPE_IS_ENUM">G_TYPE_IS_ENUM</primary></indexterm><programlisting>#define G_TYPE_IS_ENUM(type)	       (G_TYPE_FUNDAMENTAL (type) == G_TYPE_ENUM)
</programlisting>
<para>
Checks whether <parameter>type</parameter> "is a" <link linkend="G-TYPE-ENUM--CAPS"><literal>G_TYPE_ENUM</literal></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>type</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GType"><type>GType</type></link> ID.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="G-ENUM-CLASS--CAPS" role="macro">
<title>G_ENUM_CLASS()</title>
<indexterm zone="G-ENUM-CLASS--CAPS"><primary sortas="ENUM_CLASS">G_ENUM_CLASS</primary></indexterm><programlisting>#define G_ENUM_CLASS(class)	       (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_ENUM, GEnumClass))
</programlisting>
<para>
Casts a derived <link linkend="GEnumClass"><type>GEnumClass</type></link> structure into a <link linkend="GEnumClass"><type>GEnumClass</type></link> structure.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>class</parameter>&#160;:</term>
<listitem><simpara> a valid <link linkend="GEnumClass"><type>GEnumClass</type></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="G-IS-ENUM-CLASS--CAPS" role="macro">
<title>G_IS_ENUM_CLASS()</title>
<indexterm zone="G-IS-ENUM-CLASS--CAPS"><primary sortas="IS_ENUM_CLASS">G_IS_ENUM_CLASS</primary></indexterm><programlisting>#define G_IS_ENUM_CLASS(class)	       (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_ENUM))
</programlisting>
<para>
Checks whether <parameter>class</parameter> "is a" valid <link linkend="GEnumClass"><type>GEnumClass</type></link> structure of type <link linkend="G-TYPE-ENUM--CAPS"><literal>G_TYPE_ENUM</literal></link>
or derived.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>class</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GEnumClass"><type>GEnumClass</type></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="G-TYPE-IS-FLAGS--CAPS" role="macro">
<title>G_TYPE_IS_FLAGS()</title>
<indexterm zone="G-TYPE-IS-FLAGS--CAPS"><primary sortas="TYPE_IS_FLAGS">G_TYPE_IS_FLAGS</primary></indexterm><programlisting>#define G_TYPE_IS_FLAGS(type)	       (G_TYPE_FUNDAMENTAL (type) == G_TYPE_FLAGS)
</programlisting>
<para>
Checks whether <parameter>type</parameter> "is a" <link linkend="G-TYPE-FLAGS--CAPS"><literal>G_TYPE_FLAGS</literal></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>type</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GType"><type>GType</type></link> ID.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="G-FLAGS-CLASS--CAPS" role="macro">
<title>G_FLAGS_CLASS()</title>
<indexterm zone="G-FLAGS-CLASS--CAPS"><primary sortas="FLAGS_CLASS">G_FLAGS_CLASS</primary></indexterm><programlisting>#define G_FLAGS_CLASS(class)	       (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_FLAGS, GFlagsClass))
</programlisting>
<para>
Casts a derived <link linkend="GFlagsClass"><type>GFlagsClass</type></link> structure into a <link linkend="GFlagsClass"><type>GFlagsClass</type></link> structure.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>class</parameter>&#160;:</term>
<listitem><simpara> a valid <link linkend="GFlagsClass"><type>GFlagsClass</type></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="G-IS-FLAGS-CLASS--CAPS" role="macro">
<title>G_IS_FLAGS_CLASS()</title>
<indexterm zone="G-IS-FLAGS-CLASS--CAPS"><primary sortas="IS_FLAGS_CLASS">G_IS_FLAGS_CLASS</primary></indexterm><programlisting>#define G_IS_FLAGS_CLASS(class)        (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_FLAGS))
</programlisting>
<para>
Checks whether <parameter>class</parameter> "is a" valid <link linkend="GFlagsClass"><type>GFlagsClass</type></link> structure of type <link linkend="G-TYPE-FLAGS--CAPS"><literal>G_TYPE_FLAGS</literal></link>
or derived.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>class</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GFlagsClass"><type>GFlagsClass</type></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="G-FLAGS-CLASS-TYPE--CAPS" role="macro">
<title>G_FLAGS_CLASS_TYPE()</title>
<indexterm zone="G-FLAGS-CLASS-TYPE--CAPS"><primary sortas="FLAGS_CLASS_TYPE">G_FLAGS_CLASS_TYPE</primary></indexterm><programlisting>#define G_FLAGS_CLASS_TYPE(class)      (G_TYPE_FROM_CLASS (class))
</programlisting>
<para>
Get the type identifier from a given <link linkend="GFlagsClass"><type>GFlagsClass</type></link> structure.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>class</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GFlagsClass"><type>GFlagsClass</type></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="G-FLAGS-CLASS-TYPE-NAME--CAPS" role="macro">
<title>G_FLAGS_CLASS_TYPE_NAME()</title>
<indexterm zone="G-FLAGS-CLASS-TYPE-NAME--CAPS"><primary sortas="FLAGS_CLASS_TYPE_NAME">G_FLAGS_CLASS_TYPE_NAME</primary></indexterm><programlisting>#define G_FLAGS_CLASS_TYPE_NAME(class) (g_type_name (G_FLAGS_CLASS_TYPE (class)))
</programlisting>
<para>
Get the static type name from a given <link linkend="GFlagsClass"><type>GFlagsClass</type></link> structure.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>class</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GFlagsClass"><type>GFlagsClass</type></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="GEnumValue" role="struct">
<title>GEnumValue</title>
<indexterm zone="GEnumValue"><primary sortas="EnumValue">GEnumValue</primary></indexterm><programlisting>typedef struct {
  gint	 value;
  const gchar *value_name;
  const gchar *value_nick;
} GEnumValue;
</programlisting>
<para>
A structure which contains a single enum value, its name, and its
nickname.</para>
<para>
</para><variablelist role="struct">
<varlistentry>
<term><link linkend="gint">gint</link>&#160;<structfield>value</structfield>;</term>
<listitem><simpara> the enum value
</simpara></listitem>
</varlistentry>
<varlistentry>
<term>const&#160;<link linkend="gchar">gchar</link>&#160;*<structfield>value_name</structfield>;</term>
<listitem><simpara> the name of the value
</simpara></listitem>
</varlistentry>
<varlistentry>
<term>const&#160;<link linkend="gchar">gchar</link>&#160;*<structfield>value_nick</structfield>;</term>
<listitem><simpara> the nickname of the value
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="GFlagsValue" role="struct">
<title>GFlagsValue</title>
<indexterm zone="GFlagsValue"><primary sortas="FlagsValue">GFlagsValue</primary></indexterm><programlisting>typedef struct {
  guint	 value;
  const gchar *value_name;
  const gchar *value_nick;
} GFlagsValue;
</programlisting>
<para>
A structure which contains a single flags value, its name, and its
nickname.</para>
<para>
</para><variablelist role="struct">
<varlistentry>
<term><link linkend="guint">guint</link>&#160;<structfield>value</structfield>;</term>
<listitem><simpara> the flags value
</simpara></listitem>
</varlistentry>
<varlistentry>
<term>const&#160;<link linkend="gchar">gchar</link>&#160;*<structfield>value_name</structfield>;</term>
<listitem><simpara> the name of the value
</simpara></listitem>
</varlistentry>
<varlistentry>
<term>const&#160;<link linkend="gchar">gchar</link>&#160;*<structfield>value_nick</structfield>;</term>
<listitem><simpara> the nickname of the value
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="g-enum-get-value" role="function">
<title>g_enum_get_value ()</title>
<indexterm zone="g-enum-get-value"><primary sortas="enum_get_value">g_enum_get_value</primary></indexterm><programlisting><link linkend="GEnumValue">GEnumValue</link>*         g_enum_get_value                    (<link linkend="GEnumClass">GEnumClass</link> *enum_class,
                                                         <link linkend="gint">gint</link> value);</programlisting>
<para>
Returns the <link linkend="GEnumValue"><type>GEnumValue</type></link> for a value.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>enum_class</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GEnumClass"><type>GEnumClass</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>value</parameter>&#160;:</term>
<listitem><simpara> the value to look up
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the <link linkend="GEnumValue"><type>GEnumValue</type></link> for <parameter>value</parameter>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link> if <parameter>value</parameter> is not a
         member of the enumeration
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-enum-get-value-by-name" role="function">
<title>g_enum_get_value_by_name ()</title>
<indexterm zone="g-enum-get-value-by-name"><primary sortas="enum_get_value_by_name">g_enum_get_value_by_name</primary></indexterm><programlisting><link linkend="GEnumValue">GEnumValue</link>*         g_enum_get_value_by_name            (<link linkend="GEnumClass">GEnumClass</link> *enum_class,
                                                         const <link linkend="gchar">gchar</link> *name);</programlisting>
<para>
Looks up a <link linkend="GEnumValue"><type>GEnumValue</type></link> by name.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>enum_class</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GEnumClass"><type>GEnumClass</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>name</parameter>&#160;:</term>
<listitem><simpara> the name to look up
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the <link linkend="GEnumValue"><type>GEnumValue</type></link> with name <parameter>name</parameter>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link> if the
         enumeration doesn't have a member with that name
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-enum-get-value-by-nick" role="function">
<title>g_enum_get_value_by_nick ()</title>
<indexterm zone="g-enum-get-value-by-nick"><primary sortas="enum_get_value_by_nick">g_enum_get_value_by_nick</primary></indexterm><programlisting><link linkend="GEnumValue">GEnumValue</link>*         g_enum_get_value_by_nick            (<link linkend="GEnumClass">GEnumClass</link> *enum_class,
                                                         const <link linkend="gchar">gchar</link> *nick);</programlisting>
<para>
Looks up a <link linkend="GEnumValue"><type>GEnumValue</type></link> by nickname.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>enum_class</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GEnumClass"><type>GEnumClass</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>nick</parameter>&#160;:</term>
<listitem><simpara> the nickname to look up
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the <link linkend="GEnumValue"><type>GEnumValue</type></link> with nickname <parameter>nick</parameter>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link> if the
         enumeration doesn't have a member with that nickname
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-flags-get-first-value" role="function">
<title>g_flags_get_first_value ()</title>
<indexterm zone="g-flags-get-first-value"><primary sortas="flags_get_first_value">g_flags_get_first_value</primary></indexterm><programlisting><link linkend="GFlagsValue">GFlagsValue</link>*        g_flags_get_first_value             (<link linkend="GFlagsClass">GFlagsClass</link> *flags_class,
                                                         <link linkend="guint">guint</link> value);</programlisting>
<para>
Returns the first <link linkend="GFlagsValue"><type>GFlagsValue</type></link> which is set in <parameter>value</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>flags_class</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GFlagsClass"><type>GFlagsClass</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>value</parameter>&#160;:</term>
<listitem><simpara> the value
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the first <link linkend="GFlagsValue"><type>GFlagsValue</type></link> which is set in <parameter>value</parameter>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link> if
         none is set
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-flags-get-value-by-name" role="function">
<title>g_flags_get_value_by_name ()</title>
<indexterm zone="g-flags-get-value-by-name"><primary sortas="flags_get_value_by_name">g_flags_get_value_by_name</primary></indexterm><programlisting><link linkend="GFlagsValue">GFlagsValue</link>*        g_flags_get_value_by_name           (<link linkend="GFlagsClass">GFlagsClass</link> *flags_class,
                                                         const <link linkend="gchar">gchar</link> *name);</programlisting>
<para>
Looks up a <link linkend="GFlagsValue"><type>GFlagsValue</type></link> by name.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>flags_class</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GFlagsClass"><type>GFlagsClass</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>name</parameter>&#160;:</term>
<listitem><simpara> the name to look up
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the <link linkend="GFlagsValue"><type>GFlagsValue</type></link> with name <parameter>name</parameter>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link> if there is no
         flag with that name
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-flags-get-value-by-nick" role="function">
<title>g_flags_get_value_by_nick ()</title>
<indexterm zone="g-flags-get-value-by-nick"><primary sortas="flags_get_value_by_nick">g_flags_get_value_by_nick</primary></indexterm><programlisting><link linkend="GFlagsValue">GFlagsValue</link>*        g_flags_get_value_by_nick           (<link linkend="GFlagsClass">GFlagsClass</link> *flags_class,
                                                         const <link linkend="gchar">gchar</link> *nick);</programlisting>
<para>
Looks up a <link linkend="GFlagsValue"><type>GFlagsValue</type></link> by nickname.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>flags_class</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GFlagsClass"><type>GFlagsClass</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>nick</parameter>&#160;:</term>
<listitem><simpara> the nickname to look up
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the <link linkend="GFlagsValue"><type>GFlagsValue</type></link> with nickname <parameter>nick</parameter>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link> if there is
         no flag with that nickname
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-enum-register-static" role="function">
<title>g_enum_register_static ()</title>
<indexterm zone="g-enum-register-static"><primary sortas="enum_register_static">g_enum_register_static</primary></indexterm><programlisting><link linkend="GType">GType</link>               g_enum_register_static              (const <link linkend="gchar">gchar</link> *name,
                                                         const <link linkend="GEnumValue">GEnumValue</link> *const_static_values);</programlisting>
<para>
Registers a new static enumeration type with the name <parameter>name</parameter>.
</para>
<para>
It is normally more convenient to let <link
linkend="glib-mkenums">glib-mkenums</link> generate a
<link linkend="my-enum-get-type"><function>my_enum_get_type()</function></link> function from a usual C enumeration definition
than to write one yourself using <link linkend="g-enum-register-static"><function>g_enum_register_static()</function></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>name</parameter>&#160;:</term>
<listitem><simpara> A nul-terminated string used as the name of the new type.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>const_static_values</parameter>&#160;:</term>
<listitem><simpara> An array of <link linkend="GEnumValue"><type>GEnumValue</type></link> structs for the possible
 enumeration values. The array is terminated by a struct with all
 members being 0. GObject keeps a reference to the data, so it cannot
 be stack-allocated.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> The new type identifier.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-flags-register-static" role="function">
<title>g_flags_register_static ()</title>
<indexterm zone="g-flags-register-static"><primary sortas="flags_register_static">g_flags_register_static</primary></indexterm><programlisting><link linkend="GType">GType</link>               g_flags_register_static             (const <link linkend="gchar">gchar</link> *name,
                                                         const <link linkend="GFlagsValue">GFlagsValue</link> *const_static_values);</programlisting>
<para>
Registers a new static flags type with the name <parameter>name</parameter>.
</para>
<para>
It is normally more convenient to let <link
linkend="glib-mkenums">glib-mkenums</link> generate a
<link linkend="my-flags-get-type"><function>my_flags_get_type()</function></link> function from a usual C enumeration definition
than to write one yourself using <link linkend="g-flags-register-static"><function>g_flags_register_static()</function></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>name</parameter>&#160;:</term>
<listitem><simpara> A nul-terminated string used as the name of the new type.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>const_static_values</parameter>&#160;:</term>
<listitem><simpara> An array of <link linkend="GFlagsValue"><type>GFlagsValue</type></link> structs for the possible
 flags values. The array is terminated by a struct with all members being 0.
 GObject keeps a reference to the data, so it cannot be stack-allocated.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> The new type identifier.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-enum-complete-type-info" role="function">
<title>g_enum_complete_type_info ()</title>
<indexterm zone="g-enum-complete-type-info"><primary sortas="enum_complete_type_info">g_enum_complete_type_info</primary></indexterm><programlisting><link linkend="void">void</link>                g_enum_complete_type_info           (<link linkend="GType">GType</link> g_enum_type,
                                                         <link linkend="GTypeInfo">GTypeInfo</link> *info,
                                                         const <link linkend="GEnumValue">GEnumValue</link> *const_values);</programlisting>
<para>
This function is meant to be called from the <link linkend="complete-type-info"><function>complete_type_info()</function></link>
function of a <link linkend="GTypePlugin"><type>GTypePlugin</type></link> implementation, as in the following
example:
</para>
<para>
<informalexample><programlisting>
static void
my_enum_complete_type_info (GTypePlugin     *plugin,
                            GType            g_type,
                            GTypeInfo       *info,
                            GTypeValueTable *value_table)
{
  static const GEnumValue values[] = {
    { MY_ENUM_FOO, "MY_ENUM_FOO", "foo" },
    { MY_ENUM_BAR, "MY_ENUM_BAR", "bar" },
    { 0, NULL, NULL }
  };

  g_enum_complete_type_info (type, info, values);
}
</programlisting></informalexample></para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>g_enum_type</parameter>&#160;:</term>
<listitem><simpara> the type identifier of the type being completed
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>info</parameter>&#160;:</term>
<listitem><simpara> the <link linkend="GTypeInfo"><type>GTypeInfo</type></link> struct to be filled in
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>const_values</parameter>&#160;:</term>
<listitem><simpara> An array of <link linkend="GEnumValue"><type>GEnumValue</type></link> structs for the possible
 enumeration values. The array is terminated by a struct with all
 members being 0.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-flags-complete-type-info" role="function">
<title>g_flags_complete_type_info ()</title>
<indexterm zone="g-flags-complete-type-info"><primary sortas="flags_complete_type_info">g_flags_complete_type_info</primary></indexterm><programlisting><link linkend="void">void</link>                g_flags_complete_type_info          (<link linkend="GType">GType</link> g_flags_type,
                                                         <link linkend="GTypeInfo">GTypeInfo</link> *info,
                                                         const <link linkend="GFlagsValue">GFlagsValue</link> *const_values);</programlisting>
<para>
This function is meant to be called from the <link linkend="complete-type-info"><function>complete_type_info()</function></link>
function of a <link linkend="GTypePlugin"><type>GTypePlugin</type></link> implementation, see the example for
<link linkend="g-enum-complete-type-info"><function>g_enum_complete_type_info()</function></link> above.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>g_flags_type</parameter>&#160;:</term>
<listitem><simpara> the type identifier of the type being completed
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>info</parameter>&#160;:</term>
<listitem><simpara> the <link linkend="GTypeInfo"><type>GTypeInfo</type></link> struct to be filled in
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>const_values</parameter>&#160;:</term>
<listitem><simpara> An array of <link linkend="GFlagsValue"><type>GFlagsValue</type></link> structs for the possible
 enumeration values. The array is terminated by a struct with all
 members being 0.
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>



<refsect1 id="gobject-Enumeration-and-Flag-Types.see-also">
<title>See Also</title>
#GParamSpecEnum, <link linkend="GParamSpecFlags"><type>GParamSpecFlags</type></link>, <link linkend="g-param-spec-enum"><function>g_param_spec_enum()</function></link>,
<link linkend="g-param-spec-flags"><function>g_param_spec_flags()</function></link>,
</refsect1>

</refentry>
