logo top
Main Page   Widgets   Namespaces   Book  

Gtk::Builder Class Reference

Inheritance diagram for Gtk::Builder:

Inheritance graph
[legend]
List of all members.

Detailed Description

Build an interface from a UI definition description.

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

Since gtkmm 2.12:


Public Member Functions

bool add_from_file (const std::string& filename)
bool add_from_string (const char* buffer, gsize length)
bool add_from_string (const Glib::ustring& buffer)
Glib::RefPtr<Glib::Objectget_object (const Glib::ustring& name)
Glib::ustring get_translation_domain () const
GType get_type_from_name (const Glib::ustring& type_name)
template<class T_Widget>
void get_widget (const Glib::ustring& name, T_Widget*& widget)
 Get a widget from the Builder file.
template<class T_Widget>
void get_widget_derived (const Glib::ustring& name, T_Widget*& widget)
 This provides a pointer to a widget whose details are specified in the GtkBuilder file, but which is implemented by your own derived class.
const GtkBuilder* gobj () const
 Provides access to the underlying C GObject.
GtkBuilder* gobj ()
 Provides access to the underlying C GObject.
GtkBuilder* gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
void set_translation_domain (const Glib::ustring& domain)
virtual ~Builder ()

Static Public Member Functions

static Glib::RefPtr<Buildercreate ()
static Glib::RefPtr<Buildercreate_from_file (const std::string& filename)
static Glib::RefPtr<Buildercreate_from_string (const Glib::ustring& buffer)

Protected Member Functions

 Builder ()
GtkWidget* get_cwidget (const Glib::ustring& name)
Gtk::Widgetget_widget_checked (const Glib::ustring& name, GType type)

Related Functions

(Note that these are not member functions.)

Glib::RefPtr<Gtk::Builderwrap (GtkBuilder* object, bool take_copy=false)
 A Glib::wrap() method for this object.


Constructor & Destructor Documentation

virtual Gtk::Builder::~Builder (  )  [virtual]

Gtk::Builder::Builder (  )  [protected]


Member Function Documentation

bool Gtk::Builder::add_from_file ( const std::string &  filename  ) 

bool Gtk::Builder::add_from_string ( const char *  buffer,
gsize  length 
)

bool Gtk::Builder::add_from_string ( const Glib::ustring buffer  ) 

static Glib::RefPtr<Builder> Gtk::Builder::create (  )  [static]

static Glib::RefPtr<Builder> Gtk::Builder::create_from_file ( const std::string &  filename  )  [static]

static Glib::RefPtr<Builder> Gtk::Builder::create_from_string ( const Glib::ustring buffer  )  [static]

GtkWidget* Gtk::Builder::get_cwidget ( const Glib::ustring name  )  [protected]

Glib::RefPtr<Glib::Object> Gtk::Builder::get_object ( const Glib::ustring name  ) 

Glib::ustring Gtk::Builder::get_translation_domain (  )  const

GType Gtk::Builder::get_type_from_name ( const Glib::ustring type_name  ) 

template <class T_Widget>
void Gtk::Builder::get_widget ( const Glib::ustring name,
T_Widget *&  widget 
) [inline]

Get a widget from the Builder file.

For instance:

 Gtk::Table* pTable = 0;
 refXml->get_widget("mytable", pTable);
This method prints a warning message to the console if the widget doesn't exist or has the wrong type, so you don't need to check that manually.

Note that you are responsible for deleting top-level widgets (windows and dialogs) instantiated by the Builder object. Other widgets are instantiated as managed so they will be deleted automatically if you add them to a container widget.

Parameters:
name The name of the widget.
Return values:
widget A pointer to the widget, or 0 on failure.

Gtk::Widget* Gtk::Builder::get_widget_checked ( const Glib::ustring name,
GType  type 
) [protected]

template <class T_Widget>
void Gtk::Builder::get_widget_derived ( const Glib::ustring name,
T_Widget *&  widget 
) [inline]

This provides a pointer to a widget whose details are specified in the GtkBuilder file, but which is implemented by your own derived class.

Your class must have a constructor like so:

 DerivedDialog::DerivedDialog(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& refBuilder)
 : Gtk::Dialog(cobject) //Calls the base class constructor

For instance:

 Gtk::DerivedBox* pBox = 0;
 refXml->get_widget_derived("mybox", pBox);

Parameters:
name The name of the widget.
Return values:
widget A pointer to the widget, or 0 on failure.

const GtkBuilder* Gtk::Builder::gobj (  )  const [inline]

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

GtkBuilder* Gtk::Builder::gobj (  )  [inline]

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

GtkBuilder* Gtk::Builder::gobj_copy (  ) 

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

void Gtk::Builder::set_translation_domain ( const Glib::ustring domain  ) 


Friends And Related Function Documentation

Glib::RefPtr<Gtk::Builder> wrap ( GtkBuilder *  object,
bool  take_copy = false 
) [related]

A Glib::wrap() method for this object.

Parameters:
object The C instance.
take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns:
A C++ instance that wraps this C instance.


The documentation for this class was generated from the following file:
Generated for gtkmm 2.4 by Doxygen 1.5.1 © 1997-2001