Xfce Foundation Classes
Main Page  | IndexNamespace List  |  Alphabetical List  |  Class List  |  File List


Xfc::Gtk::Builder Class Reference

A GtkBuilder is an auxiliary object that reads textual descriptions of a user interface and instantiates the described objects. More...

#include <builder.hh>

Inheritance diagram for Xfc::Gtk::Builder:
Xfc::G::Object Xfc::G::TypeInstance Xfc::Trackable

List of all members.

Public Member Functions


Detailed Description

A GtkBuilder is an auxiliary object that reads textual descriptions of a user interface and instantiates the described objects.

A GtkBuilder holds a reference to all objects that it has constructed and drops these references when it is finalized. This finalization can cause the destruction of non-widget objects or widgets which are not contained in a toplevel window. For toplevel windows constructed by a builder, it is the responsibility of the user to call Gtk::Widget::destroy() to get rid of them and all the widgets they contain.


Member Function Documentation

void Xfc::Gtk::Builder::add_from_file ( const String filename  ) 

Parses a file containing a GtkBuilder UI definition and merges it with the current contents of builder.

Parameters:
filename name of the file to parse
Exceptions:
G::Error on some kind of error
void Xfc::Gtk::Builder::add_from_string ( const String buffer  ) 

Parses a string containing a GtkBuilder UI definition and merges it with the current contents of builder.

Parameters:
the string to parse
Exceptions:
G::Error on some kind of error
G::Object* Xfc::Gtk::Builder::get_object ( const String name  )  const

Gets the object named name.

Note that this function does not increment the reference count of the returned object.

Parameters:
name of the object to get (dismiss when done)
Returns:
the object named name or NULL if it could not be found in the object tree.
G::SList<GObject> Xfc::Gtk::Builder::get_objects (  )  const

Gets all objects that have been constructed by builder.

Note:
that this function does not increment the reference counts of the returned objects.
Returns:
a newly-allocated GSList containing all the objects constructed by the GtkBuilder instance. It should be freed by g_slist_free()
String Xfc::Gtk::Builder::get_translation_domain (  )  const

Gets the translation domain of builder.

Returns:
the translation domain.
GType Xfc::Gtk::Builder::get_type_from_name ( const String type_name  )  const

Looks up a type by name, using the virtual function that GtkBuilder has for that purpose.

This is mainly used when implementing the GtkBuildable interface on a type.

template<typename WidgetType >
bool Xfc::Gtk::Builder::get_widget ( const String name,
WidgetType *&  widget 
) const [inline]

Gets a pointer to the Gtk::Widget corresponding to name in the interface description.

Parameters:
name The name of the widget in the XML description.
widget A reference to a pointer to hold the widget matching name, or null if none exists.
Returns:
true if successful, false if no widget exists.

To use this method WidgetType must be one of the standard XFC widgets.

Example: Connecting a "clicked" signal handler to a Gtk::Button.

        Gtk::Button *button;
        if (xml->get_widget("my_button", button))
        {
            button->signal_clicked().connect(sigc::mem_fun(this, &MyWindow::on_my_button_clicked));
        }
Gtk::Widget* Xfc::Gtk::Builder::get_widget ( const String name  )  const

Gets a pointer to the Gtk::Widget corresponding to name in the interface description.

Parameters:
name The name of the widget in the XML description.
Returns:
A pointer to the widget matching name, or null if none exists.
template<typename DerivedType >
bool Xfc::Gtk::Builder::get_widget_derived ( const String name,
DerivedType *&  widget 
) const [inline]

Gets a pointer to the Gtk::Widget corresponding to name in the interface description.

Parameters:
name The name of the widget in the XML description.
widget A reference to a pointer to hold the widget matching name, or null if none exists.
Returns:
true if successful, false if no widget exists.

To use this method DerivedType must be a user-defined widget class that derives from one of the standard XFC widgets. The derived widget class must declare it's constructor with the following signature:

Example: Instantiating a main application window from an XML description.

        MyWindow *window;
        if (xml->get_widget_derived("MyWindow", window))
        {
            window->signal_destroy().connect(sigc::ptr_fun(&Xfc::Main::quit));
            window->show();
            run();
        }
void Xfc::Gtk::Builder::set_translation_domain ( const String domain  ) 

Sets the translation domain of builder.

Parameters:
domain the translation domain

The documentation for this class was generated from the following file:
Xfce Foundation Classes
Copyright © 2004-2005 The XFC Development Team XFC 4.3