gtkmm
3.12.0
|
Build an interface from a UI definition description. More...
#include <gtkmm/builder.h>
Public Member Functions | |
virtual | ~Builder () |
GtkBuilder* | gobj () |
Provides access to the underlying C GObject. More... | |
const GtkBuilder* | gobj () const |
Provides access to the underlying C GObject. More... | |
GtkBuilder* | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More... | |
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. More... | |
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. More... | |
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. More... | |
bool | add_from_file (const std::string& filename, const std::vector< Glib::ustring >& object_ids) |
Parses a file containing a [GtkBuilder UI definition][BUILDER-UI] building only the requested objects and merges them with the current contents of builder. More... | |
bool | add_from_resource (const std::string& resource_path) |
Parses a resource file containing a GtkBuilder UI definition, and merges it with the current contents of the builder. More... | |
bool | add_from_resource (const std::string& resource_path, const char* object_id) |
Parses a resource file containing a GtkBuilder UI definition, building only the requested object, and merges it with the current contents of the builder. More... | |
bool | add_from_resource (const std::string& resource_path, const Glib::ustring& object_id) |
Parses a resource file containing a GtkBuilder UI definition, building only the requested object, and merges it with the current contents of the builder. More... | |
bool | add_from_resource (const std::string& resource_path, const std::vector< Glib::ustring >& object_ids) |
Parses a resource file containing a [GtkBuilder UI definition][BUILDER-UI] building only the requested objects and merges them with the current contents of builder. More... | |
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. More... | |
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. More... | |
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. More... | |
bool | add_from_string (const Glib::ustring& buffer, const std::vector< Glib::ustring >& 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. More... | |
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. More... | |
void | expose_object (const Glib::ustring& name, const Glib::RefPtr< Glib::Object >& object) |
Add object to the builder object pool so it can be referenced just like any other object built by builder. More... | |
void | expose_widget (const Glib::ustring& name, Widget& widget) |
Add widget to the builder object pool so it can be referenced just like any other object built by builder. More... | |
Glib::RefPtr< Glib::Object > | get_object (const Glib::ustring& name) |
Gets the object named name. More... | |
Glib::RefPtr< const Glib::Object > | get_object (const Glib::ustring& name) const |
Gets the object named name. More... | |
template<class T_Widget > | |
void | get_widget (const Glib::ustring& name, T_Widget*& widget) |
Get a widget from the Builder file. More... | |
template<class T_Widget > | |
void | get_widget (const Glib::ustring& name, const T_Widget*& widget) const |
See the non-const version. More... | |
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. More... | |
template<class T_Widget > | |
void | get_widget_derived (const Glib::ustring& name, const T_Widget*& widget) const |
See the non-const version. More... | |
std::vector< Glib::RefPtr < Glib::Object > > | get_objects () |
Gets all objects that have been constructed by the Gtk::Builder. More... | |
std::vector< Glib::RefPtr < const Glib::Object > > | get_objects () const |
Gets all objects that have been constructed by the Gtk::Builder. More... | |
void | set_translation_domain (const Glib::ustring& domain) |
Sets the translation domain of builder. More... | |
Glib::ustring | get_translation_domain () const |
Gets the translation domain of builder. More... | |
void | set_application (const Glib::RefPtr< Application >& application) |
Sets the application associated with builder. More... | |
Glib::RefPtr< Application > | get_application () |
Gets the Gtk::Application associated with the builder. More... | |
Glib::RefPtr< const Application > | get_application () const |
Gets the Gtk::Application associated with the builder. More... | |
Glib::PropertyProxy < Glib::ustring > | property_translation_domain () |
The translation domain used by gettext. More... | |
Glib::PropertyProxy_ReadOnly < Glib::ustring > | property_translation_domain () const |
The translation domain used by gettext. More... | |
Static Public Member Functions | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. More... | |
static Glib::RefPtr< Builder > | create () |
Creates a new builder object. More... | |
static Glib::RefPtr< Builder > | create_from_file (const std::string& filename) |
Parses a file containing a GtkBuilder UI definition. More... | |
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. More... | |
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. More... | |
static Glib::RefPtr< Builder > | create_from_file (const std::string& filename, const std::vector< Glib::ustring >& object_ids) |
Parses a file containing a GtkBuilder UI definition, building only the requested objects. More... | |
static Glib::RefPtr< Builder > | create_from_resource (const std::string& resource_path) |
Parses a resource file containing a GtkBuilder UI definition. More... | |
static Glib::RefPtr< Builder > | create_from_resource (const std::string& resource_path, const Glib::ustring& object_id) |
Parses a resource file containing a GtkBuilder UI definition, building only the requested object. More... | |
static Glib::RefPtr< Builder > | create_from_resource (const std::string& resource_path, const char* object_id) |
Parses a resource file containing a GtkBuilder UI definition, building only the requested object. More... | |
static Glib::RefPtr< Builder > | create_from_resource (const std::string& resource_path, const std::vector< Glib::ustring >& object_ids) |
Parses a resource file containing a GtkBuilder UI definition, building only the requested objects. More... | |
static Glib::RefPtr< Builder > | create_from_string (const Glib::ustring& buffer) |
Parses a string containing a GtkBuilder UI definition. More... | |
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. More... | |
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. More... | |
static Glib::RefPtr< Builder > | create_from_string (const Glib::ustring& buffer, const std::vector< Glib::ustring >& object_ids) |
Parses a string containing a GtkBuilder UI definition building only the requested objects. More... | |
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. More... | |
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 |
|
protected |
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.
filename | The file to parse. |
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.
filename | The file to parse. |
object_id | The object to build. |
BuilderError,Glib::MarkupError,Glib::MarkupError |
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.
filename | The file to parse. |
object_id | The object to build. |
BuilderError,Glib::MarkupError,Glib::MarkupError |
bool Gtk::Builder::add_from_file | ( | const std::string & | filename, |
const std::vector< Glib::ustring > & | object_ids | ||
) |
Parses a file containing a [GtkBuilder UI definition][BUILDER-UI] 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.
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 explicitly list all of them in object_ids.
filename | The name of the file to parse. |
object_ids | Nul-terminated array of objects to build. |
bool Gtk::Builder::add_from_resource | ( | const std::string & | resource_path) |
Parses a resource file containing a GtkBuilder UI definition, and merges it with the current contents of the builder.
resource_path | The path of the resource file to parse. |
BuilderError,Glib::MarkupError,Gio::ResourceError |
bool Gtk::Builder::add_from_resource | ( | const std::string & | resource_path, |
const char * | object_id | ||
) |
Parses a resource 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.
resource_path | The path of the resource file to parse. |
object_id | The object to build. |
BuilderError,Glib::MarkupError,Gio::ResourceError |
bool Gtk::Builder::add_from_resource | ( | const std::string & | resource_path, |
const Glib::ustring & | object_id | ||
) |
Parses a resource 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.
resource_path | The path of the resource file to parse. |
object_id | The object to build. |
BuilderError,Glib::MarkupError,Gio::ResourceError |
bool Gtk::Builder::add_from_resource | ( | const std::string & | resource_path, |
const std::vector< Glib::ustring > & | object_ids | ||
) |
Parses a resource file containing a [GtkBuilder UI definition][BUILDER-UI] 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 RESOURCE_ERROR domain.
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 explicitly list all of them in object_ids.
resource_path | The path of the resource file to parse. |
object_ids | Nul-terminated array of objects to build. |
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 |
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. |
object_id | The object 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. |
object_id | The object to build. |
BuilderError,Glib::MarkupError |
bool Gtk::Builder::add_from_string | ( | const Glib::ustring & | buffer, |
const std::vector< Glib::ustring > & | 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. |
object_ids | The objects to build. |
BuilderError,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 buffer is nul-terminated). |
BuilderError,Glib::MarkupError |
|
static |
Creates a new builder object.
|
static |
Parses a file containing a GtkBuilder UI definition.
filename | the name of the file to parse. |
BuilderError,Glib::MarkupError,Glib::FileError |
|
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 |
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 |
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 |
Parses a resource file containing a GtkBuilder UI definition.
resource_path | The path of the resource file to parse. |
BuilderError,Glib::MarkupError,Gio::ResourceError |
|
static |
Parses a resource 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.
resource_path | The path of the resource file to parse. |
object_id | The object to build. |
BuilderError,Glib::MarkupError,Gio::ResourceError |
|
static |
Parses a resource 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.
resource_path | The path of the resource file to parse. |
object_id | The object to build. |
BuilderError,Glib::MarkupError,Gio::ResourceError |
|
static |
Parses a resource 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.
resource_path | The path of the resource file to parse. |
object_ids | The objects to build. |
BuilderError,Glib::MarkupError,Gio::ResourceError |
|
static |
Parses a string containing a GtkBuilder UI definition.
buffer,: | the string to parse |
BuilderError,Glib::MarkupError |
|
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 |
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 |
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 |
void Gtk::Builder::expose_object | ( | const Glib::ustring & | name, |
const Glib::RefPtr< Glib::Object > & | object | ||
) |
Add object to the builder object pool so it can be referenced just like any other object built by builder.
name | The name of the object exposed to the builder. |
object | The object to expose. |
void Gtk::Builder::expose_widget | ( | const Glib::ustring & | name, |
Widget& | widget | ||
) |
Add widget to the builder object pool so it can be referenced just like any other object built by builder.
name | The name of the widget exposed to the builder. |
widget | The widget to expose. |
Glib::RefPtr<Application> Gtk::Builder::get_application | ( | ) |
Gets the Gtk::Application associated with the builder.
The Gtk::Application is used for creating action proxies as requested from XML that the builder is loading.
By default, the builder uses the default application: the one from Glib::application_get_default(). If you want to use another application for constructing proxies, use set_application().
0
. Glib::RefPtr<const Application> Gtk::Builder::get_application | ( | ) | const |
Gets the Gtk::Application associated with the builder.
The Gtk::Application is used for creating action proxies as requested from XML that the builder is loading.
By default, the builder uses the default application: the one from Glib::application_get_default(). If you want to use another application for constructing proxies, use set_application().
0
.
|
protected |
Glib::RefPtr<Glib::Object> Gtk::Builder::get_object | ( | const Glib::ustring & | name) |
Gets the object named name.
name | Name of object to get. |
0
if it could not be found in the object tree. Glib::RefPtr<const Glib::Object> Gtk::Builder::get_object | ( | const Glib::ustring & | name) | const |
Gets the object named name.
name | Name of object to get. |
0
if it could not be found in the object tree. std::vector<Glib::RefPtr<Glib::Object> > Gtk::Builder::get_objects | ( | ) |
Gets all objects that have been constructed by the Gtk::Builder.
std::vector<Glib::RefPtr<const Glib::Object> > Gtk::Builder::get_objects | ( | ) | const |
Gets all objects that have been constructed by the Gtk::Builder.
Glib::ustring Gtk::Builder::get_translation_domain | ( | ) | const |
Gets the translation domain of builder.
|
static |
Get the GType for this class, for use with the underlying GObject type system.
|
inline |
Get a widget from the Builder file.
For instance:
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. |
|
inline |
See the non-const version.
|
protected |
|
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:
For instance:
name | The name of the widget. |
widget | A pointer to the widget, or 0 on failure. |
|
inline |
See the non-const version.
|
inline |
Provides access to the underlying C GObject.
|
inline |
Provides access to the underlying C GObject.
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.
Glib::PropertyProxy< Glib::ustring > Gtk::Builder::property_translation_domain | ( | ) |
The translation domain used by gettext.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::Builder::property_translation_domain | ( | ) | const |
The translation domain used by gettext.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
void Gtk::Builder::set_application | ( | const Glib::RefPtr< Application >& | application) |
Sets the application associated with builder.
You only need this function if there is more than one Application in your process. application cannot be 0
.
application | A Gtk::Application. |
void Gtk::Builder::set_translation_domain | ( | const Glib::ustring & | domain) |
Sets the translation domain of builder.
See Gtk::Builder::property_translation_domain().
domain | The translation domain or 0 . |
|
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. |