Libglade - Graphical Interface Description Loader API | ||||
---|---|---|---|---|
Top | Description | Object Hierarchy |
Synopsis
#include <glade/glade-xml.h> GladeXML; GladeXMLClass; GladeXML * glade_xml_new (const char *fname, const char *root, const char *domain); GladeXML * glade_xml_new_from_buffer (const char *buffer, int size, const char *root, const char *domain); gboolean glade_xml_construct (GladeXML *self, const char *fname, const char *root, const char *domain); gboolean glade_xml_construct_from_buffer (GladeXML *self, const char *buffer, int size, const char *root, const char *domain); void glade_xml_signal_connect (GladeXML *self, const char *handlername, GCallback func); void glade_xml_signal_connect_data (GladeXML *self, const char *handlername, GCallback func, gpointer user_data); void glade_xml_signal_autoconnect (GladeXML *self); GtkWidget * glade_xml_get_widget (GladeXML *self, const char *name); GList * glade_xml_get_widget_prefix (GladeXML *self, const char *name); const char * glade_get_widget_name (GtkWidget *widget); GladeXML * glade_get_widget_tree (GtkWidget *widget); void (*GladeXMLConnectFunc) (const gchar *handler_name, GObject *object, const gchar *signal_name, const gchar *signal_data, GObject *connect_object, gboolean after, gpointer user_data); void glade_xml_signal_connect_full (GladeXML *self, const gchar *handler_name, GladeXMLConnectFunc func, gpointer user_data); void glade_xml_signal_autoconnect_full (GladeXML *self, GladeXMLConnectFunc func, gpointer user_data); GtkWidget * (*GladeXMLCustomWidgetHandler) (GladeXML *xml, gchar *func_name, gchar *name, gchar *string1, gchar *string2, gint int1, gint int2, gpointer user_data); void glade_set_custom_handler (GladeXMLCustomWidgetHandler handler, gpointer user_data);
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
GladeXMLClass
typedef struct { GObjectClass parent_class; /* Virtual function: gets the appropriate gtype for the typename.*/ GType (* lookup_type) (GladeXML*self, const char *gtypename); } GladeXMLClass;
glade_xml_new ()
GladeXML * glade_xml_new (const char *fname, const char *root, const char *domain);
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
glade_xml_new_from_buffer ()
GladeXML * glade_xml_new_from_buffer (const char *buffer, int size, const char *root, const char *domain);
Creates a new GladeXML object (and the corresponding widgets) from the
buffer buffer
. 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 document, but not the
window it is embedded in.
glade_xml_construct ()
gboolean glade_xml_construct (GladeXML *self, const char *fname, const char *root, const char *domain);
This routine can be used by bindings (such as gtkmm) to help construct a GladeXML object, if it is needed.
glade_xml_construct_from_buffer ()
gboolean glade_xml_construct_from_buffer (GladeXML *self, const char *buffer, int size, const char *root, const char *domain);
In order to use this method you must already have a GladeXML object. This two step creation process is typically used only by language bindings, such as gtkmm, while constructing GladeXML objects from compiled-in buffers, at runtime.
glade_xml_signal_connect ()
void glade_xml_signal_connect (GladeXML *self, const char *handlername, GCallback 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.
|
the GladeXML object |
|
the signal handler name |
|
the signal handler function |
glade_xml_signal_connect_data ()
void glade_xml_signal_connect_data (GladeXML *self, const char *handlername, GCallback func, gpointer user_data);
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.
It differs from glade_xml_signal_connect since it allows you to specify the data parameter for the signal handler. It is also a small demonstration of how to use glade_xml_signal_connect_full.
|
the GladeXML object |
|
the signal handler name |
|
the signal handler function |
|
the signal handler data |
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.
You should add gmodule-export-2.0 to your pkg-config checks to ensure that your application's executable exports the signal handlers. This is not necessary if the signal handlers are in a shared library.
Note that this function will not work correctly if gmodule is not supported on the platform.
|
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.
|
the GladeXML object. |
|
the name of the widget. |
Returns : |
the widget matching name , or NULL if none exists.
|
glade_xml_get_widget_prefix ()
GList * glade_xml_get_widget_prefix (GladeXML *self, const char *name);
This function is used to get a list of pointers to the GtkWidget(s)
with names that start with the string name
in the interface description.
You would use this if you have to do something to all of these widgets
after loading.
|
the GladeXML object. |
|
the name of the widget. |
Returns : |
A list of the widget that match name as the start of their
name, 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.
|
the widget |
Returns : |
the 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.
|
the widget |
Returns : |
the GladeXML object that built this widget. |
GladeXMLConnectFunc ()
void (*GladeXMLConnectFunc) (const gchar *handler_name, GObject *object, const gchar *signal_name, const gchar *signal_data, GObject *connect_object, gboolean after, gpointer user_data);
This is the signature of a function used to connect signals. It is used by the glade_xml_signal_connect_full and glade_xml_signal_autoconnect_full functions. It is mainly intented for interpreted language bindings, but could be useful where the programmer wants more control over the signal connection process.
|
the name of the handler function to connect. |
|
the object to connect the signal to. |
|
the name of the signal. |
|
the string value of the signal data given in the XML file. |
|
non NULL if g_signal_connect_object should be used. |
|
TRUE if the connection should be made with g_signal_connect_after. |
|
the user data argument. |
glade_xml_signal_connect_full ()
void glade_xml_signal_connect_full (GladeXML *self, const gchar *handler_name, GladeXMLConnectFunc func, gpointer user_data);
This function is similar to glade_xml_signal_connect, except that it allows you to give an arbitrary function that will be used for actually connecting the signals. This is mainly useful for writers of interpreted language bindings, or applications where you need more control over the signal connection process.
|
the GladeXML object. |
|
the name of the signal handler that we want to connect. |
|
the function to use to connect the signals. |
|
arbitrary data to pass to the connect function. |
glade_xml_signal_autoconnect_full ()
void glade_xml_signal_autoconnect_full (GladeXML *self, GladeXMLConnectFunc func, gpointer user_data);
This function is similar to glade_xml_signal_connect_full, except that it will try to connect all signals in the interface, not just a single named handler. It can be thought of the interpeted language binding version of glade_xml_signal_autoconnect, except that it does not require gmodule to function correctly.
|
the GladeXML object. |
|
the function used to connect the signals. |
|
arbitrary data that will be passed to the connection function. |
GladeXMLCustomWidgetHandler ()
GtkWidget * (*GladeXMLCustomWidgetHandler) (GladeXML *xml, gchar *func_name, gchar *name, gchar *string1, gchar *string2, gint int1, gint int2, gpointer user_data);
This prototype is for a function that creates custom widgets.
|
the GladeXML object. |
|
the function name. |
|
the name of the widget to be created. |
|
the string1 property. |
|
the string2 property. |
|
the int1 property. |
|
the int2 property. |
|
the data passed to glade_set_custom_handler()
|
Returns : |
the GtkWidget. |
glade_set_custom_handler ()
void glade_set_custom_handler (GladeXMLCustomWidgetHandler handler, gpointer user_data);
Calling this function allows you to override the default behaviour when a Custom widget is found in an interface. This could be used by a language binding to call some other function, or to limit what functions can be called to create custom widgets.
|
the custom widget handler |
|
user data passed to the custom handler |