Constructor

GObjectObjectnew

Declaration

GObject*
g_object_new (
  GType object_type,
  const gchar* first_property_name,
  ...
)

Description

Creates a new instance of a GObject subtype and sets its properties.

Construction parameters (see #G_PARAM_CONSTRUCT, #G_PARAM_CONSTRUCT_ONLY) which are not explicitly specified are set to their default values. Any private data for the object is guaranteed to be initialized with zeros, as per g_type_create_instance().

Note that in C, small integer types in variable argument lists are promoted up to #gint or #guint as appropriate, and read back accordingly. #gint is 32 bits on every platform on which GLib is currently supported. This means that you can use C expressions of type #gint with g_object_new() and properties of type #gint or #guint or smaller. Specifically, you can use integer literals with these property types.

When using property types of #gint64 or #guint64, you must ensure that the value that you provide is 64 bit. This means that you should use a cast or make use of the G_GINT64_CONSTANT or G_GUINT64_CONSTANT macros.

Similarly, #gfloat is promoted to #gdouble, so you must ensure that the value you provide is a #gdouble, even for a property of type #gfloat.

Parameters

object_type GType
 

The type id of the GObject subtype to instantiate.

first_property_name const gchar*
 

The name of the first property.

 The data is owned by the caller of the function.
 The string is a NUL terminated UTF-8 string.
... none
 

The value of the first property, followed optionally by more name/value pairs, followed by NULL.

Return value

Returns: GObject
 

A new instance of object_type.

 The caller of the function takes ownership of the data, and is responsible for freeing it.