Types

Name

Types -- Handle run-time type creation.

Synopsis


#include <gtk/gtk.h>


typedef     GtkType;
enum        GtkFundamentalType;
#define     GTK_CLASS_NAME                  (class)
#define     GTK_CLASS_TYPE                  (class)
#define     GTK_TYPE_IS_OBJECT              (type)
#define     GTK_TYPE_FUNDAMENTAL_LAST
#define     GTK_TYPE_FUNDAMENTAL_MAX
#define     GTK_STRUCT_OFFSET
#define     GTK_CHECK_CAST
#define     GTK_CHECK_CLASS_CAST
#define     GTK_CHECK_TYPE
#define     GTK_CHECK_CLASS_TYPE
#define     GTK_CHECK_GET_CLASS
#define     GTK_FUNDAMENTAL_TYPE
#define     GTK_SIGNAL_FUNC                 (f)
typedef     GtkClassInitFunc;
typedef     GtkObjectInitFunc;
void        (*GtkSignalFunc)                (void);
gint        (*GtkFunction)                  (gpointer data);
void        (*GtkDestroyNotify)             (gpointer data);
void        (*GtkCallbackMarshal)           (GtkObject *object,
                                             gpointer data,
                                             guint n_args,
                                             GtkArg *args);
typedef     GtkSignalMarshaller;
void        (*GtkArgGetFunc)                (GtkObject *object,
                                             GtkArg *arg,
                                             guint arg_id);
void        (*GtkArgSetFunc)                (GtkObject *object,
                                             GtkArg *arg,
                                             guint arg_id);
typedef     GtkTypeObject;
struct      GtkArg;
#define     GTK_VALUE_CHAR                  (a)
#define     GTK_VALUE_UCHAR                 (a)
#define     GTK_VALUE_BOOL                  (a)
#define     GTK_VALUE_INT                   (a)
#define     GTK_VALUE_UINT                  (a)
#define     GTK_VALUE_LONG                  (a)
#define     GTK_VALUE_ULONG                 (a)
#define     GTK_VALUE_FLOAT                 (a)
#define     GTK_VALUE_DOUBLE                (a)
#define     GTK_VALUE_STRING                (a)
#define     GTK_VALUE_ENUM                  (a)
#define     GTK_VALUE_FLAGS                 (a)
#define     GTK_VALUE_BOXED                 (a)
#define     GTK_VALUE_POINTER               (a)
#define     GTK_VALUE_OBJECT                (a)
#define     GTK_VALUE_SIGNAL                (a)
#define     GTK_RETLOC_CHAR                 (a)
#define     GTK_RETLOC_UCHAR                (a)
#define     GTK_RETLOC_BOOL                 (a)
#define     GTK_RETLOC_INT                  (a)
#define     GTK_RETLOC_UINT                 (a)
#define     GTK_RETLOC_LONG                 (a)
#define     GTK_RETLOC_ULONG                (a)
#define     GTK_RETLOC_FLOAT                (a)
#define     GTK_RETLOC_DOUBLE               (a)
#define     GTK_RETLOC_STRING               (a)
#define     GTK_RETLOC_ENUM                 (a)
#define     GTK_RETLOC_FLAGS                (a)
#define     GTK_RETLOC_BOXED                (a)
#define     GTK_RETLOC_POINTER              (a)
#define     GTK_RETLOC_OBJECT               (a)
struct      GtkTypeInfo;
typedef     GtkTypeClass;
typedef     GtkEnumValue;
typedef     GtkFlagValue;
void        gtk_type_init                   (GTypeDebugFlags debug_flags);
GtkType     gtk_type_unique                 (GtkType parent_type,
                                             const GtkTypeInfo *gtkinfo);
gchar*      gtk_type_name                   (GtkType type);
GtkType     gtk_type_from_name              (const gchar *name);
GtkType     gtk_type_parent                 (GtkType type);
gpointer    gtk_type_class                  (GtkType type);
gpointer    gtk_type_new                    (GtkType type);
gboolean    gtk_type_is_a                   (GtkType type,
                                             GtkType is_a_type);
GtkEnumValue* gtk_type_enum_get_values      (GtkType enum_type);
GtkFlagValue* gtk_type_flags_get_values     (GtkType flags_type);
GtkEnumValue* gtk_type_enum_find_value      (GtkType enum_type,
                                             const gchar *value_name);
GtkFlagValue* gtk_type_flags_find_value     (GtkType flags_type,
                                             const gchar *value_name);

Description

Gtk's type system is extensible. Because of that, types have to be managed at runtime.

Details

GtkType

GtkType is unique integer identifying the type. The guts of the information about the type is held in a private struct named GtkTypeNode.


enum GtkFundamentalType

typedef enum	/*< skip >*/
{
  GTK_TYPE_INVALID	= G_TYPE_INVALID,
  GTK_TYPE_NONE		= G_TYPE_NONE,
  GTK_TYPE_ENUM		= G_TYPE_ENUM,
  GTK_TYPE_FLAGS	= G_TYPE_FLAGS,

  /* GtkArg types */
  GTK_TYPE_CHAR		= G_TYPE_CHAR,
  GTK_TYPE_UCHAR	= G_TYPE_UCHAR,
  GTK_TYPE_BOOL		= G_TYPE_BOOLEAN,
  GTK_TYPE_INT		= G_TYPE_INT,
  GTK_TYPE_UINT		= G_TYPE_UINT,
  GTK_TYPE_LONG		= G_TYPE_LONG,
  GTK_TYPE_ULONG	= G_TYPE_ULONG,
  GTK_TYPE_FLOAT	= G_TYPE_FLOAT,
  GTK_TYPE_DOUBLE	= G_TYPE_DOUBLE,
  GTK_TYPE_STRING	= G_TYPE_STRING,
  GTK_TYPE_BOXED	= G_TYPE_BOXED,
  GTK_TYPE_POINTER	= G_TYPE_POINTER
} GtkFundamentalType;

GtkFundamentalType is an enumerated type which lists all the possible fundamental types (e.g. char, uchar, int, long, float, etc).


GTK_CLASS_NAME()

#define GTK_CLASS_NAME(class)		(g_type_name (G_TYPE_FROM_CLASS (class)))

class : 


GTK_CLASS_TYPE()

#define GTK_CLASS_TYPE(class)		(G_TYPE_FROM_CLASS (class))

class : 


GTK_TYPE_IS_OBJECT()

#define GTK_TYPE_IS_OBJECT(type)	(g_type_is_a ((type), GTK_TYPE_OBJECT))

type : 


GTK_TYPE_FUNDAMENTAL_LAST

#define     GTK_TYPE_FUNDAMENTAL_LAST

The highest-numbered structured or flat enumerated type value.


GTK_TYPE_FUNDAMENTAL_MAX

#define     GTK_TYPE_FUNDAMENTAL_MAX

The highest maximum fundamental enumerated type value.


GTK_STRUCT_OFFSET

#define     GTK_STRUCT_OFFSET

Use in place of offsetof(), which is used if it exists.


GTK_CHECK_CAST

#define     GTK_CHECK_CAST

Cast the object in tobj into cast. If GTK_NO_CHECK_CASTS is defined, just cast it. Otherwise, check to see if we can cast tobj into a cast.


GTK_CHECK_CLASS_CAST

#define     GTK_CHECK_CLASS_CAST

Cast the object in tobj into cast. If GTK_NO_CHECK_CASTS is defined, just cast it. Otherwise, check to see if we can cast tobj into a cast.


GTK_CHECK_TYPE

#define     GTK_CHECK_TYPE

Determines whether type_object is a type of otype.


GTK_CHECK_CLASS_TYPE

#define     GTK_CHECK_CLASS_TYPE

Determines whether type_class is a type of otype.


GTK_CHECK_GET_CLASS

#define     GTK_CHECK_GET_CLASS


GTK_FUNDAMENTAL_TYPE

#define     GTK_FUNDAMENTAL_TYPE

Convert a gtk type into a fundamental type


GTK_SIGNAL_FUNC()

#define     GTK_SIGNAL_FUNC(f)

Just a macroized cast into a GtkSignalFunc

f : 


GtkClassInitFunc

typedef GBaseInitFunc		GtkClassInitFunc;

Define a function pointer.


GtkObjectInitFunc

typedef GInstanceInitFunc	GtkObjectInitFunc;

Define a function pointer.


GtkSignalFunc ()

void        (*GtkSignalFunc)                (void);

Define a function pointer.


GtkFunction ()

gint        (*GtkFunction)                  (gpointer data);

Define a function pointer.

data :gpointer
Returns :gint


GtkDestroyNotify ()

void        (*GtkDestroyNotify)             (gpointer data);

Define a function pointer.

data :gpointer


GtkCallbackMarshal ()

void        (*GtkCallbackMarshal)           (GtkObject *object,
                                             gpointer data,
                                             guint n_args,
                                             GtkArg *args);

Define a function pointer.

object :GtkObject*
data :gpointer
n_args :guint
args :GtkArg*


GtkSignalMarshaller

typedef GSignalCMarshaller          GtkSignalMarshaller;

Define a function pointer.


GtkArgGetFunc ()

void        (*GtkArgGetFunc)                (GtkObject *object,
                                             GtkArg *arg,
                                             guint arg_id);

Define a function pointer. Deprecated.

object : 
arg : 
arg_id : 


GtkArgSetFunc ()

void        (*GtkArgSetFunc)                (GtkObject *object,
                                             GtkArg *arg,
                                             guint arg_id);

Define a function pointer. Deprecated.

object : 
arg : 
arg_id : 


GtkTypeObject

typedef GTypeInstance		GtkTypeObject;

A GtkTypeObject defines the minimum structure requirements for type instances. Type instances returned from gtk_type_new() and initialized through a GtkObjectInitFunc need to directly inherit from this structure or at least copy its fields one by one.


struct GtkArg

struct GtkArg
{
  GtkType type;
  gchar *name;
  
  /* this union only defines the required storage types for
   * the possibile values, thus there is no gint enum_data field,
   * because that would just be a mere alias for gint int_data.
   * use the GTK_VALUE_*() and GTK_RETLOC_*() macros to access
   * the discrete memebers.
   */
  union {
    /* flat values */
    gchar char_data;
    guchar uchar_data;
    gboolean bool_data;
    gint int_data;
    guint uint_data;
    glong long_data;
    gulong ulong_data;
    gfloat float_data;
    gdouble double_data;
    gchar *string_data;
    GtkObject *object_data;
    gpointer pointer_data;
    
    /* structured values */
    struct {
      GtkSignalFunc f;
      gpointer d;
    } signal_data;
  } d;
};

This is a structure that we use to pass in typed values (and names).


GTK_VALUE_CHAR()

#define     GTK_VALUE_CHAR(a)

Use to get the value of a GtkArg whose GtkType is GTK_TYPE_CHAR

a : 


GTK_VALUE_UCHAR()

#define     GTK_VALUE_UCHAR(a)

Use to get the value of a GtkArg whose GtkType is GTK_TYPE_UCHAR

a : 


GTK_VALUE_BOOL()

#define     GTK_VALUE_BOOL(a)

Use to get the value of a GtkArg whose GtkType is GTK_TYPE_BOOL

a : 


GTK_VALUE_INT()

#define     GTK_VALUE_INT(a)

Use to get the value of a GtkArg whose GtkType is GTK_TYPE_INT

a : 


GTK_VALUE_UINT()

#define     GTK_VALUE_UINT(a)

Use to get the value of a GtkArg whose GtkType is GTK_TYPE_UINT

a : 


GTK_VALUE_LONG()

#define     GTK_VALUE_LONG(a)

Use to get the value of a GtkArg whose GtkType is GTK_TYPE_LONG

a : 


GTK_VALUE_ULONG()

#define     GTK_VALUE_ULONG(a)

Use to get the value of a GtkArg whose GtkType is GTK_TYPE_ULONG

a : 


GTK_VALUE_FLOAT()

#define     GTK_VALUE_FLOAT(a)

Use to get the value of a GtkArg whose GtkType is GTK_TYPE_FLOAT

a : 


GTK_VALUE_DOUBLE()

#define     GTK_VALUE_DOUBLE(a)

Use to get the value of a GtkArg whose GtkType is GTK_TYPE_DOUBLE

a : 


GTK_VALUE_STRING()

#define     GTK_VALUE_STRING(a)

Use to get the value of a GtkArg whose GtkType is GTK_TYPE_STRING

a : 


GTK_VALUE_ENUM()

#define     GTK_VALUE_ENUM(a)

Use to get the value of a GtkArg whose GtkType is GTK_TYPE_ENUM

a : 


GTK_VALUE_FLAGS()

#define     GTK_VALUE_FLAGS(a)

Use to get the value of a GtkArg whose GtkType is GTK_TYPE_FLAGS

a : 


GTK_VALUE_BOXED()

#define     GTK_VALUE_BOXED(a)

Use to get the value of a GtkArg whose GtkType is GTK_TYPE_BOXED

a : 


GTK_VALUE_POINTER()

#define     GTK_VALUE_POINTER(a)

Use to get the value of a GtkArg whose GtkType is GTK_TYPE_POINTER

a : 


GTK_VALUE_OBJECT()

#define     GTK_VALUE_OBJECT(a)

Use to get the value of a GtkArg whose GtkType is GTK_TYPE_OBJECT

a : 


GTK_VALUE_SIGNAL()

#define     GTK_VALUE_SIGNAL(a)

Use to get the value of a GtkArg whose GtkType is GTK_TYPE_SIGNAL

a : 


GTK_RETLOC_CHAR()

#define     GTK_RETLOC_CHAR(a)

If the GtkArg contains a pointer to the value, this macro will be a pointer to a GTK_TYPE_CHAR

a : 


GTK_RETLOC_UCHAR()

#define     GTK_RETLOC_UCHAR(a)

If the GtkArg contains a pointer to the value, this macro will be a pointer to a GTK_TYPE_UCHAR

a : 


GTK_RETLOC_BOOL()

#define     GTK_RETLOC_BOOL(a)

If the GtkArg contains a pointer to the value, this macro will be a pointer to a GTK_TYPE_BOOL

a : 


GTK_RETLOC_INT()

#define     GTK_RETLOC_INT(a)

If the GtkArg contains a pointer to the value, this macro will be a pointer to a GTK_TYPE_INT

a : 


GTK_RETLOC_UINT()

#define     GTK_RETLOC_UINT(a)

If the GtkArg contains a pointer to the value, this macro will be a pointer to a GTK_TYPE_UINT

a : 


GTK_RETLOC_LONG()

#define     GTK_RETLOC_LONG(a)

If the GtkArg contains a pointer to the value, this macro will be a pointer to a GTK_TYPE_LONG

a : 


GTK_RETLOC_ULONG()

#define     GTK_RETLOC_ULONG(a)

If the GtkArg contains a pointer to the value, this macro will be a pointer to a GTK_TYPE_ULONG

a : 


GTK_RETLOC_FLOAT()

#define     GTK_RETLOC_FLOAT(a)

If the GtkArg contains a pointer to the value, this macro will be a pointer to a GTK_TYPE_FLOAT

a : 


GTK_RETLOC_DOUBLE()

#define     GTK_RETLOC_DOUBLE(a)

If the GtkArg contains a pointer to the value, this macro will be a pointer to a GTK_TYPE_DOUBLE

a : 


GTK_RETLOC_STRING()

#define     GTK_RETLOC_STRING(a)

If the GtkArg contains a pointer to the value, this macro will be a pointer to a GTK_TYPE_STRING

a : 


GTK_RETLOC_ENUM()

#define     GTK_RETLOC_ENUM(a)

If the GtkArg contains a pointer to the value, this macro will be a pointer to a GTK_TYPE_ENUM

a : 


GTK_RETLOC_FLAGS()

#define     GTK_RETLOC_FLAGS(a)

If the GtkArg contains a pointer to the value, this macro will be a pointer to a GTK_TYPE_FLAGS

a : 


GTK_RETLOC_BOXED()

#define     GTK_RETLOC_BOXED(a)

If the GtkArg contains a pointer to the value, this macro will be a pointer to a GTK_TYPE_BOXED

a : 


GTK_RETLOC_POINTER()

#define     GTK_RETLOC_POINTER(a)

If the GtkArg contains a pointer to the value, this macro will be a pointer to a GTK_TYPE_POINTER

a : 


GTK_RETLOC_OBJECT()

#define     GTK_RETLOC_OBJECT(a)

If the GtkArg contains a pointer to the value, this macro will be a pointer to a GTK_TYPE_OBJECT

a : 


struct GtkTypeInfo

struct GtkTypeInfo
{
  gchar			*type_name;
  guint			 object_size;
  guint			 class_size;
  GtkClassInitFunc	 class_init_func;
  GtkObjectInitFunc	 object_init_func;
  gpointer		 reserved_1;
  gpointer		 reserved_2;
  GtkClassInitFunc	 base_class_init_func;
};

Holds information about the type. gtk_type_name returns the name. object_size is somehow set to the number of bytes that an instance of the object will occupy. class_init_func holds the type's initialization function. object_init_func holds the initialization function for an instance of the object. reserved_1 is used for GtkEnumValue to hold the enumerated values.


GtkTypeClass

typedef GTypeClass		GtkTypeClass;

The base structure for a Gtk Type. Every type inherits this as a base structure.


GtkEnumValue

typedef GEnumValue  GtkEnumValue;

A structure which contains a single enum value, and its name, and it's nickname.


GtkFlagValue

typedef GFlagsValue GtkFlagValue;


gtk_type_init ()

void        gtk_type_init                   (GTypeDebugFlags debug_flags);

Initialize the data structures associated with gtk types.

debug_flags : 


gtk_type_unique ()

GtkType     gtk_type_unique                 (GtkType parent_type,
                                             const GtkTypeInfo *gtkinfo);

Create a new, unique type.

parent_type :if zero, a fundamental type is created.
gtkinfo : 
Returns :the new GtkType.


gtk_type_name ()

gchar*      gtk_type_name                   (GtkType type);

type :a GtkType
Returns :a pointer to the name of a type, or NULL if it has none.


gtk_type_from_name ()

GtkType     gtk_type_from_name              (const gchar *name);

Get the internal representation of a type given its name.

name :the name of a gtk type
Returns :a GtkType


gtk_type_parent ()

GtkType     gtk_type_parent                 (GtkType type);

type :a GtkType
Returns :the GtkType of the parent


gtk_type_class ()

gpointer    gtk_type_class                  (GtkType type);

Return a gpointer pointing to the class of type or NULL if there was any trouble identifying type. Initialize the class if necessary.

type :a GtkType
Returns :gpointer to the klass.


gtk_type_new ()

gpointer    gtk_type_new                    (GtkType type);

Create a new object of a given type, and return a gpointer to it. Returns NULL if you give it an invalid type. It allocates the object out of the type's memory chunk if there is a memory chunk. The object has all the proper initializers called.

type :GtkType
Returns :gpointer to a GtkTypeObject


gtk_type_is_a ()

gboolean    gtk_type_is_a                   (GtkType type,
                                             GtkType is_a_type);

Look in the type hierarchy to see if type has is_a_type among its ancestors. Do so with a simple lookup, not a loop.

type :GtkType
is_a_type :GtkType
Returns : 


gtk_type_enum_get_values ()

GtkEnumValue* gtk_type_enum_get_values      (GtkType enum_type);

If enum_type has values, then return a pointer to all of them.

enum_type :GtkType
Returns :GtkEnumValue*


gtk_type_flags_get_values ()

GtkFlagValue* gtk_type_flags_get_values     (GtkType flags_type);

If flags_type has values, then return a pointer to all of them.

flags_type : 
Returns :GtkFlagValue*


gtk_type_enum_find_value ()

GtkEnumValue* gtk_type_enum_find_value      (GtkType enum_type,
                                             const gchar *value_name);

Return a pointer to one of enum_type's GtkEnumValues's whose name (or nickname) matches value_name.

enum_type :GtkType
value_name : 
Returns :GtkEnumValue*


gtk_type_flags_find_value ()

GtkFlagValue* gtk_type_flags_find_value     (GtkType flags_type,
                                             const gchar *value_name);

Return a pointer to one of flag_type's GtkFlagValue's whose name (or nickname) matches value_name.

flags_type : 
value_name : 
Returns :GtkFlagValue*