Build an interface from a UI definition description. More...
Inherits Glib::Object.
Public Member Functions | |
virtual | ~Builder () |
GtkBuilder* | gobj () |
Provides access to the underlying C GObject. | |
const GtkBuilder* | gobj () const |
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. | |
bool | add_from_file (const std::string& filename) |
Parses a file containing a GtkBuilder UI definition, and merges it with the current contents of the builder. | |
bool | add_from_file (const std::string& filename, const char* object_id) |
Parses a file containing a GtkBuilder UI definition, building only the requested object, and merges it with the current contents of the builder. | |
bool | add_from_file (const std::string& filename, const Glib::ustring& object_id) |
Parses a file containing a GtkBuilder UI definition, building only the requested object, and merges it with the current contents of the builder. | |
bool | add_from_file (const std::string& filename, const Glib::StringArrayHandle& object_ids) |
Parses a file containing a <link linkend="BUILDER-UI">GtkBuilder UI definition</link> building only the requested objects and merges them with the current contents of builder. | |
bool | add_from_string (const Glib::ustring& buffer) |
Parses a string containing a GtkBuilder UI definition and merges it with the current contents of the builder. | |
bool | add_from_string (const Glib::ustring& buffer, const char* object_id) |
Parses a string containing a GtkBuilder UI definition, building only the requested object, and merges it with the current contents of the builder. | |
bool | add_from_string (const Glib::ustring& buffer, const Glib::ustring& object_id) |
Parses a string containing a GtkBuilder UI definition, building only the requested object, and merges it with the current contents of the builder. | |
bool | add_from_string (const Glib::ustring& buffer, const Glib::StringArrayHandle& object_ids) |
Parses a string containing a GtkBuilder UI definition, building only the requested objects, and merges it with the current contents of the builder. | |
bool | add_from_string (const char* buffer, gsize length) |
Parses a string containing a GtkBuilder UI definition and merges it with the current contents of the builder. | |
Glib::RefPtr< Glib::Object > | get_object (const Glib::ustring& name) |
Gets the object named 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. | |
void | set_translation_domain (const Glib::ustring& domain) |
Sets the translation domain of builder. | |
Glib::ustring | get_translation_domain () const |
Gets the translation domain of builder. | |
Static Public Member Functions | |
static Glib::RefPtr< Builder > | create () |
Creates a new builder object. | |
static Glib::RefPtr< Builder > | create_from_file (const std::string& filename) |
Parses a file containing a GtkBuilder UI definition. | |
static Glib::RefPtr< Builder > | create_from_file (const std::string& filename, const Glib::ustring& object_id) |
Parses a file containing a GtkBuilder UI definition, building only the requested object. | |
static Glib::RefPtr< Builder > | create_from_file (const std::string& filename, const char* object_id) |
Parses a file containing a GtkBuilder UI definition, building only the requested object. | |
static Glib::RefPtr< Builder > | create_from_file (const std::string& filename, const Glib::StringArrayHandle& object_ids) |
Parses a file containing a GtkBuilder UI definition, building only the requested objects. | |
static Glib::RefPtr< Builder > | create_from_string (const Glib::ustring& buffer) |
Parses a string containing a GtkBuilder UI definition. | |
static Glib::RefPtr< Builder > | create_from_string (const Glib::ustring& buffer, const char* object_id) |
Parses a string containing a GtkBuilder UI definition building only the requested object. | |
static Glib::RefPtr< Builder > | create_from_string (const Glib::ustring& buffer, const Glib::ustring& object_id) |
Parses a string containing a GtkBuilder UI definition building only the requested object. | |
static Glib::RefPtr< Builder > | create_from_string (const Glib::ustring& buffer, const Glib::StringArrayHandle& object_ids) |
Parses a string containing a GtkBuilder UI definition building only the requested objects. | |
Protected Member Functions | |
Builder () | |
Gtk::Widget* | get_widget_checked (const Glib::ustring& name, GType type) |
GtkWidget* | get_cwidget (const Glib::ustring& name) |
Related Functions | |
(Note that these are not member functions.) | |
Glib::RefPtr< Gtk::Builder > | wrap (GtkBuilder* object, bool take_copy=false) |
A Glib::wrap() method for this object. |
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.
virtual Gtk::Builder::~Builder | ( | ) | [virtual] |
Gtk::Builder::Builder | ( | ) | [protected] |
bool Gtk::Builder::add_from_file | ( | const std::string & | filename, | |
const Glib::StringArrayHandle & | object_ids | |||
) |
Parses a file containing a <link linkend="BUILDER-UI">GtkBuilder UI definition</link> building only the requested objects and merges them with the current contents of builder.
Upon errors 0 will be returned and error will be assigned a Error from the Gtk::BUILDER_ERROR, MARKUP_ERROR or FILE_ERROR domain.
<note>
If you are adding an object that depends on an object that is not its child (for instance a Gtk::TreeView that depends on its Gtk::TreeModel), you have to explicitely list all of them in object_ids.
</note>
filename | The name of the file to parse. | |
object_ids | Nul-terminated array of objects to build. |
bool Gtk::Builder::add_from_file | ( | const std::string & | filename, | |
const Glib::ustring & | object_id | |||
) |
Parses a file containing a GtkBuilder UI definition, building only the requested object, and merges it with the current contents of the builder.
If you are adding an object that depends on an object that is not its child (for instance a GtkTreeView that depends on its GtkTreeModel), you have to explicitely list all of them.
buffer | The file to parse. | |
The | object to build. |
BuilderError,Glib::MarkupError,Glib::MarkupError |
bool Gtk::Builder::add_from_file | ( | const std::string & | filename, | |
const char * | object_id | |||
) |
Parses a file containing a GtkBuilder UI definition, building only the requested object, and merges it with the current contents of the builder.
If you are adding an object that depends on an object that is not its child (for instance a GtkTreeView that depends on its GtkTreeModel), you have to explicitely list all of them.
buffer | The file to parse. | |
The | object to build. |
BuilderError,Glib::MarkupError,Glib::MarkupError |
bool Gtk::Builder::add_from_file | ( | const std::string & | filename | ) |
Parses a file containing a GtkBuilder UI definition, and merges it with the current contents of the builder.
buffer | The file to parse. |
BuilderError,Glib::MarkupError,Glib::MarkupError |
bool Gtk::Builder::add_from_string | ( | const char * | buffer, | |
gsize | length | |||
) |
Parses a string containing a GtkBuilder UI definition and merges it with the current contents of the builder.
buffer | The string to parse. | |
length | The length of buffer (may be -1 if is nul-terminated). |
BuilderError,Glib::MarkupError |
bool Gtk::Builder::add_from_string | ( | const Glib::ustring & | buffer, | |
const Glib::StringArrayHandle & | object_ids | |||
) |
Parses a string containing a GtkBuilder UI definition, building only the requested objects, and merges it with the current contents of the builder.
buffer | The string to parse. | |
The | objects to build. |
BuilderError,Glib::MarkupError |
bool Gtk::Builder::add_from_string | ( | const Glib::ustring & | buffer, | |
const Glib::ustring & | object_id | |||
) |
Parses a string containing a GtkBuilder UI definition, building only the requested object, and merges it with the current contents of the builder.
buffer | The string to parse. | |
The | object to build. |
BuilderError,Glib::MarkupError |
bool Gtk::Builder::add_from_string | ( | const Glib::ustring & | buffer, | |
const char * | object_id | |||
) |
Parses a string containing a GtkBuilder UI definition, building only the requested object, and merges it with the current contents of the builder.
buffer | The string to parse. | |
The | object to build. |
BuilderError,Glib::MarkupError |
bool Gtk::Builder::add_from_string | ( | const Glib::ustring & | buffer | ) |
Parses a string containing a GtkBuilder UI definition and merges it with the current contents of the builder.
buffer | The string to parse. |
BuilderError,Glib::MarkupError |
static Glib::RefPtr<Builder> Gtk::Builder::create | ( | ) | [static] |
Creates a new builder object.
static Glib::RefPtr<Builder> Gtk::Builder::create_from_file | ( | const std::string & | filename, | |
const Glib::StringArrayHandle & | object_ids | |||
) | [static] |
Parses a file containing a GtkBuilder UI definition, building only the requested objects.
If you are adding an object that depends on an object that is not its child (for instance a GtkTreeView that depends on its GtkTreeModel), you have to explicitely list all of them.
filename | the name of the file to parse. | |
object_ids | The objects to build. |
BuilderError,Glib::MarkupError,Glib::FileError |
static Glib::RefPtr<Builder> Gtk::Builder::create_from_file | ( | const std::string & | filename, | |
const char * | object_id | |||
) | [static] |
Parses a file containing a GtkBuilder UI definition, building only the requested object.
If you are adding an object that depends on an object that is not its child (for instance a GtkTreeView that depends on its GtkTreeModel), you have to explicitely list all of them.
filename | the name of the file to parse. | |
object_id | The object to build. |
BuilderError,Glib::MarkupError,Glib::FileError |
static Glib::RefPtr<Builder> Gtk::Builder::create_from_file | ( | const std::string & | filename, | |
const Glib::ustring & | object_id | |||
) | [static] |
Parses a file containing a GtkBuilder UI definition, building only the requested object.
If you are adding an object that depends on an object that is not its child (for instance a GtkTreeView that depends on its GtkTreeModel), you have to explicitely list all of them.
filename | the name of the file to parse. | |
object_id | The object to build. |
BuilderError,Glib::MarkupError,Glib::FileError |
static Glib::RefPtr<Builder> Gtk::Builder::create_from_file | ( | const std::string & | filename | ) | [static] |
Parses a file containing a GtkBuilder UI definition.
filename | the name of the file to parse. |
BuilderError,Glib::MarkupError,Glib::FileError |
static Glib::RefPtr<Builder> Gtk::Builder::create_from_string | ( | const Glib::ustring & | buffer, | |
const Glib::StringArrayHandle & | object_ids | |||
) | [static] |
Parses a string containing a GtkBuilder UI definition building only the requested objects.
If you are adding an object that depends on an object that is not its child (for instance a GtkTreeView that depends on its GtkTreeModel), you have to explicitely list all of them.
buffer | the string to parse | |
object_ids | The objects to build. |
BuilderError,Glib::MarkupError |
static Glib::RefPtr<Builder> Gtk::Builder::create_from_string | ( | const Glib::ustring & | buffer, | |
const Glib::ustring & | object_id | |||
) | [static] |
Parses a string containing a GtkBuilder UI definition building only the requested object.
buffer | The string to parse. | |
object_id | The object to build. |
BuilderError,Glib::MarkupError |
static Glib::RefPtr<Builder> Gtk::Builder::create_from_string | ( | const Glib::ustring & | buffer, | |
const char * | object_id | |||
) | [static] |
Parses a string containing a GtkBuilder UI definition building only the requested object.
buffer | The string to parse. | |
object_id | The object to build. |
BuilderError,Glib::MarkupError |
static Glib::RefPtr<Builder> Gtk::Builder::create_from_string | ( | const Glib::ustring & | buffer | ) | [static] |
Parses a string containing a GtkBuilder UI definition.
buffer,: | the string to parse |
BuilderError,Glib::MarkupError |
GtkWidget* Gtk::Builder::get_cwidget | ( | const Glib::ustring & | name | ) | [protected] |
Glib::RefPtr<Glib::Object> Gtk::Builder::get_object | ( | const Glib::ustring & | name | ) |
Gets the object named name.
Note that this function does not increment the reference count of the returned object.
name | Name of object to get. |
0
if it could not be found in the object tree. Glib::ustring Gtk::Builder::get_translation_domain | ( | ) | const |
Gets the translation domain of builder.
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.
name | The name of the widget. |
widget | A pointer to the widget, or 0 on failure. |
Gtk::Widget* Gtk::Builder::get_widget_checked | ( | const Glib::ustring & | name, | |
GType | type | |||
) | [protected] |
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);
name | The name of the widget. |
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 | ) |
Sets the translation domain of builder.
See Gtk::Builder:translation-domain.
domain | The translation domain or 0 . |
Glib::RefPtr< Gtk::Builder > wrap | ( | GtkBuilder * | object, | |
bool | take_copy = false | |||
) | [related] |
A Glib::wrap() method for this object.
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. |