Function Macro

GObjectDEFINE_DYNAMIC_TYPE_EXTENDED

since: 2.14

Declaration [src]

#define G_DEFINE_DYNAMIC_TYPE_EXTENDED (
  TypeName,
  type_name,
  TYPE_PARENT,
  flags,
  CODE
)

Description [src]

A more general version of G_DEFINE_DYNAMIC_TYPE() which allows to specify GTypeFlags and custom code.

G_DEFINE_DYNAMIC_TYPE_EXTENDED (GtkGadget,
                                gtk_gadget,
                                GTK_TYPE_THING,
                                0,
                                G_IMPLEMENT_INTERFACE_DYNAMIC (TYPE_GIZMO,
                                                               gtk_gadget_gizmo_init));

expands to

static void     gtk_gadget_init              (GtkGadget      *self);
static void     gtk_gadget_class_init        (GtkGadgetClass *klass);
static void     gtk_gadget_class_finalize    (GtkGadgetClass *klass);

static gpointer gtk_gadget_parent_class = NULL;
static GType    gtk_gadget_type_id = 0;

static void     gtk_gadget_class_intern_init (gpointer klass)
{
  gtk_gadget_parent_class = g_type_class_peek_parent (klass);
  gtk_gadget_class_init ((GtkGadgetClass*) klass);
}

GType
gtk_gadget_get_type (void)
{
  return gtk_gadget_type_id;
}

static void
gtk_gadget_register_type (GTypeModule *type_module)
{
  const GTypeInfo g_define_type_info = {
    sizeof (GtkGadgetClass),
    (GBaseInitFunc) NULL,
    (GBaseFinalizeFunc) NULL,
    (GClassInitFunc) gtk_gadget_class_intern_init,
    (GClassFinalizeFunc) gtk_gadget_class_finalize,
    NULL,   // class_data
    sizeof (GtkGadget),
    0,      // n_preallocs
    (GInstanceInitFunc) gtk_gadget_init,
    NULL    // value_table
  };
  gtk_gadget_type_id = g_type_module_register_type (type_module,
                                                    GTK_TYPE_THING,
                                                    "GtkGadget",
                                                    &g_define_type_info,
                                                    (GTypeFlags) flags);
  {
    const GInterfaceInfo g_implement_interface_info = {
      (GInterfaceInitFunc) gtk_gadget_gizmo_init
    };
    g_type_module_add_interface (type_module, g_define_type_id, TYPE_GIZMO, &g_implement_interface_info);
  }
}

Available since: 2.14

This function is not directly available to language bindings.

Parameters

TypeName

Type: -

The name of the new type, in Camel case.

type_name

Type: -

The name of the new type, in lowercase, with words separated by ‘_’.

TYPE_PARENT

Type: -

The GType of the parent type.

flags

Type: -

GTypeFlags to pass to g_type_module_register_type().

CODE

Type: -

Custom code that gets inserted in the *_get_type() function.