GChildable

GChildable — A generic interface for children objects

Stability Level

Unstable, unless otherwise indicated

Synopsis


#include <gcontainer/gcontainer.h>

                    GChildable;
                    GChildableIface;

GContainerable*     g_childable_get_parent              (GChildable *childable);
void                g_childable_set_parent              (GChildable *childable,
                                                         GContainerable *parent);
void                g_childable_reparent                (GChildable *childable,
                                                         GContainerable *parent);
void                g_childable_unparent                (GChildable *childable);

void                g_childable_dispose                 (GObject *object);

Object Hierarchy

  GInterface
   +----GChildable

Prerequisites

GChildable requires GObject.

Known Implementations

GChildable is implemented by GContainer, GChild and GBin.

Properties

  "parent"                   GObject*              : Read / Write

Signals

  "parent-set"                                     : Run First

Description

The GChildable interface provides a generic interface for objects that can be children of a GContainerable. It is an interface, so can be implemented by objects at any hierarchy level.

If you prefer to derive your child object from a base class, take a look to GChild, that is the natural implementation of the GChildable interface.

Details

GChildable

typedef struct _GChildable GChildable;

Dummy type of the GChildableIface interface.


GChildableIface

typedef struct {
  GTypeInterface base_iface;


  /* Virtual Table */
  GContainerable *      (*get_parent)           (GChildable     *childable);
  void                  (*set_parent)           (GChildable     *childable,
                                                 GContainerable *parent);

  /* Signals */
  void                  (*parent_set)           (GChildable     *childable,
                                                 GContainerable *old_parent);
} GChildableIface;

The virtual methods get_parent and set_parent must be defined by all the types which implement this interface.

GTypeInterface base_iface; the base interface.
get_parent () returns the current parent.
set_parent () set the new parent.
parent_set () signal handler for the "parent_set" signals.

g_childable_get_parent ()

GContainerable*     g_childable_get_parent              (GChildable *childable);

Gets the parent of childable.

childable : a GChildable
Returns : the requested parent, or NULL on errors

g_childable_set_parent ()

void                g_childable_set_parent              (GChildable *childable,
                                                         GContainerable *parent);

Sets parent as parent of childable, properly handling the references between them.

If childable has yet a parent, this function returns with a warning.

childable : a GChildable
parent : a GContainerable

g_childable_reparent ()

void                g_childable_reparent                (GChildable *childable,
                                                         GContainerable *parent);

Moves childable from the old parent to parent, handling reference count issues to avoid destroying the object.

childable : a GChildable
parent : an object that implements GContainerable

g_childable_unparent ()

void                g_childable_unparent                (GChildable *childable);

Removes the current parent of childable, properly handling the references between them.

If childable has no parent, this function simply returns.

childable : a GChildable

g_childable_dispose ()

void                g_childable_dispose                 (GObject *object);

Convenience function to be used in the class initialization of objects implementing the GChildable interface. g_childable_dispose() automatically chain up the dispose method of the parent class of the type in the object hierarchy which implements GChildable.

object : a GObject implementing GChildable

Property Details

The "parent" property

  "parent"                   GObject*              : Read / Write

The parent of this object. The parent must implement the GContainerable interface.

Signal Details

The "parent-set" signal

void                user_function                      (GChildable *childable,
                                                        GObject    *old_parent,
                                                        gpointer    user_data)       : Run First

A new parent is set and the "parent" property was changed accordling.

childable : a GChildable
old_parent : the old parent
user_data : user data set when the signal handler was connected.