GladeXML

Name

GladeXML — Allows dynamic loading of user interfaces from XML descriptions.

Synopsis


#include <glade/glade.h>


struct      GladeXML;
struct      GladeXMLClass;
GladeXML*   glade_xml_new                   (const char *fname,
                                             const char *root);
void        glade_xml_construct             (GladeXML *self,
                                             const char *fname,
                                             const char *root);
void        glade_xml_signal_connect        (GladeXML *self,
                                             const char *signalname,
                                             GtkSignalFunc func);
void        glade_xml_signal_autoconnect    (GladeXML *self);
GtkWidget*  glade_xml_get_widget            (GladeXML *self,
                                             const char *name);
GtkWidget*  glade_xml_get_widget_by_long_name
                                            (GladeXML *self,
                                             const char *longname);
const char* glade_get_widget_name           (GtkWidget *widget);
const char* glade_get_widget_long_name      (GtkWidget *widget);
GladeXML*   glade_get_widget_tree           (GtkWidget *widget);


Object Hierarchy


  GtkObject
   +----GtkData
         +----GladeXML

Description

This object represents an `instantiation' of an XML interface description. When one of these objects is created, the XML file is read, and the interface is created. The GladeXML object then provides an interface for accessing the widgets in the interface by the names assigned to them inside the XML description.

The GladeXML object can also be used to connect handlers to the named signals in the description. Libglade also provides an interface by which it can look up the signal handler names in the program's symbol table and automatically connect as many handlers up as it can that way.

Details

struct GladeXML

struct GladeXML {
  GtkData parent;

  char *filename;
};


struct GladeXMLClass

struct GladeXMLClass {
  GtkDataClass parent_class;
};


glade_xml_new ()

GladeXML*   glade_xml_new                   (const char *fname,
                                             const char *root);

Creates a new GladeXML object (and the corresponding widgets) from the XML file fname. Optionally it will only build the interface from the widget node root (if it is not NULL). This feature is useful if you only want to build say a toolbar or menu from the XML file, but not the window it is embedded in. Note also that the XML parse tree is cached to speed up creating another GladeXML object for the same file

fname : the XML file name.
root : the widget node in fname to start building from (or NULL)
Returns : the newly created GladeXML object.


glade_xml_construct ()

void        glade_xml_construct             (GladeXML *self,
                                             const char *fname,
                                             const char *root);

This routine can be used by bindings (such as gtk--) to help construct a GladeXML object, if it is needed.

self : the GladeXML object
fname : the XML filename
root : the root widget node (or NULL for none)


glade_xml_signal_connect ()

void        glade_xml_signal_connect        (GladeXML *self,
                                             const char *signalname,
                                             GtkSignalFunc func);

In the glade interface descriptions, signal handlers are specified for widgets by name. This function allows you to connect a C function to all signals in the GladeXML file with the given signal handler name.

self : the GladeXML object
signalname : the signal handler name
func : the signal handler function


glade_xml_signal_autoconnect ()

void        glade_xml_signal_autoconnect    (GladeXML *self);

This function is a variation of glade_xml_signal_connect. It uses gmodule's introspective features (by openning the module NULL) to look at the application's symbol table. From here it tries to match the signal handler names given in the interface description with symbols in the application and connects the signals.

Note that this function will not work correctly if gmodule is not supported on the platform.

self : the GladeXML object.


glade_xml_get_widget ()

GtkWidget*  glade_xml_get_widget            (GladeXML *self,
                                             const char *name);

This function is used to get a pointer to the GtkWidget corresponding to name in the interface description. You would use this if you have to do anything to the widget after loading.

self : the GladeXML object.
name : the name of the widget.
Returns : the widget matching name, or NULL if none exists.


glade_xml_get_widget_by_long_name ()

GtkWidget*  glade_xml_get_widget_by_long_name
                                            (GladeXML *self,
                                             const char *longname);

This function is used to get a pointer to the GtkWidget corresponding to longname in the interface description. You would use this if you have to do anything to the widget after loading. This function differs from glade_xml_get_widget, in that you have to give the long form of the widget name, with all its parent widget names, separated by periods.

self : the GladeXML object.
longname : the long name of the widget (eg toplevel.parent.widgetname).
Returns : the widget matching longname, or NULL if none exists.


glade_get_widget_name ()

const char* glade_get_widget_name           (GtkWidget *widget);

Used to get the name of a widget that was generated by a GladeXML object.

widget : the widget
Returns : the name of the widget.


glade_get_widget_long_name ()

const char* glade_get_widget_long_name      (GtkWidget *widget);

Used to get the long name of a widget that was generated by a GladeXML object.

widget : the widget
Returns : the long name of the widget.


glade_get_widget_tree ()

GladeXML*   glade_get_widget_tree           (GtkWidget *widget);

This function is used to get the GladeXML object that built this widget.

widget : the widget
Returns : the GladeXML object that built this widget.