Libglade Build

Name

Libglade Build — Routines used by widget building routines

Synopsis


#include <glade/glade.h>


GtkWidget*  (*GladeNewFunc)                 (GladeXML *xml,
                                             GNode *node);
void        (*GladeBuildChildrenFunc)       (GladeXML *xml,
                                             GtkWidget *w,
                                             GNode *node,
                                             const char *longname);
GtkWidget*  glade_xml_build_widget          (GladeXML *self,
                                             GNode *node,
                                             const char *parent_long);
struct      GladeWidgetBuildData;
void        glade_register_widgets          (const GladeWidgetBuildData *widgets);

gint        glade_enum_from_string          (GtkType type,
                                             const char *string);

Description

These functions are used by the routines that are responsible for building the actual widgets from the XML node data structures.

Details

GladeNewFunc ()

GtkWidget*  (*GladeNewFunc)                 (GladeXML *xml,
                                             GNode *node);

This function signature should be used by functions that build particular widget types. The function should create the new widget and set any non standard widget parameters (ie. don't set visibility, size, etc), as this is handled by glade_xml_build_widget, which calls these functions.

xml : The GladeXML object.
node : the GNode holding the xmlNode for this widget.
Returns : the new widget.


GladeBuildChildrenFunc ()

void        (*GladeBuildChildrenFunc)       (GladeXML *xml,
                                             GtkWidget *w,
                                             GNode *node,
                                             const char *longname);

This function signature should be used by functions that are responsible for adding children to a container widget. To create each child widget, glade_xml_build_widget should be called. The GNode for the child widget will be a child of this widget's GNode.

xml : the GladeXML object.
w : this widget.
node : the GNode holding the xmlNode for this widget.
longname : the long name for this widget.


glade_xml_build_widget ()

GtkWidget*  glade_xml_build_widget          (GladeXML *self,
                                             GNode *node,
                                             const char *parent_long);

This function is not intended for people who just use libglade. Instead it is for people extending it (it is designed to be called in the child build routine defined for the parent widget). It first checks the type of the widget from the class tag, then calls the corresponding widget creation routine. This routine sets up all the settings specific to that type of widget. Then general widget settings are performed on the widget. Then it sets up accelerators for the widget, and extracts any signal information for the widget. Then it checks to see if there are any child widget nodes for this widget, and if so calls the widget's build routine, which will create the children with this function and add them to the widget in the appropriate way. Finally it returns the widget.

self : the GladeXML object.
node : the GNode holding the xmlNode of the child
parent_long : the long name of the parent object.
Returns : the newly created widget.


struct GladeWidgetBuildData

typedef struct {
  char *name;
  GladeNewFunc new;
  GladeBuildChildrenFunc build_children;
} GladeWidgetBuildData;


glade_register_widgets ()

void        glade_register_widgets          (const GladeWidgetBuildData *widgets);

This function is used to register new sets of widget building functions. each member of widgets contains the widget name, a function to build a widget of that type, and optionally a function to build the children of this widget. The child building routine would call glade_xml_build_widget on each child node to create the child before packing it.

This function is mainly useful for addon widget modules for libglade (it would get called from the glade_init_module function).

widgets : a NULL terminated array of GladeWidgetBuildData structures.


glade_enum_from_string ()

gint        glade_enum_from_string          (GtkType type,
                                             const char *string);

This helper routine is designed to be used by widget build routines to convert the string representations of enumeration values found in the XML descriptions to the integer values that can be used to configure the widget.

type : the GtkType for this flag or enum type.
string : the string representation of the enum value.
Returns : the integer value for this enumeration, or 0 if it couldn't be found.