Ardour  8.7-14-g57a6773833
Gtk::Builder Class Reference

#include <builder.h>

Inheritance diagram for Gtk::Builder:
[legend]

Public Member Functions

virtual ~Builder ()
 
GtkBuildergobj ()
 Provides access to the underlying C GObject. More...
 
const GtkBuildergobj () const
 Provides access to the underlying C GObject. More...
 
GtkBuildergobj_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)
 
bool add_from_file (const std::string &filename, const char *object_id)
 
bool add_from_file (const std::string &filename, const Glib::ustring &object_id)
 
bool add_from_file (const std::string &filename, const Glib::StringArrayHandle &object_ids)
 
bool add_from_string (const Glib::ustring &buffer)
 
bool add_from_string (const Glib::ustring &buffer, const char *object_id)
 
bool add_from_string (const Glib::ustring &buffer, const Glib::ustring &object_id)
 
bool add_from_string (const Glib::ustring &buffer, const Glib::StringArrayHandle &object_ids)
 
bool add_from_string (const char *buffer, gsize length)
 
Glib::RefPtr< Glib::Object > get_object (const Glib::ustring &name)
 
template<class T_Widget >
void get_widget (const Glib::ustring &name, T_Widget *&widget)
 
template<class T_Widget >
void get_widget_derived (const Glib::ustring &name, T_Widget *&widget)
 
void set_translation_domain (const Glib::ustring &domain)
 
Glib::ustring get_translation_domain () const
 
Glib::PropertyProxy< Glib::ustring > property_translation_domain ()
 
Glib::PropertyProxy_ReadOnly< Glib::ustring > property_translation_domain () const
 

Static Public Member Functions

static GType get_type () G_GNUC_CONST
 
static Glib::RefPtr< Buildercreate ()
 
static Glib::RefPtr< Buildercreate_from_file (const std::string &filename)
 
static Glib::RefPtr< Buildercreate_from_file (const std::string &filename, const Glib::ustring &object_id)
 
static Glib::RefPtr< Buildercreate_from_file (const std::string &filename, const char *object_id)
 
static Glib::RefPtr< Buildercreate_from_file (const std::string &filename, const Glib::StringArrayHandle &object_ids)
 
static Glib::RefPtr< Buildercreate_from_string (const Glib::ustring &buffer)
 
static Glib::RefPtr< Buildercreate_from_string (const Glib::ustring &buffer, const char *object_id)
 
static Glib::RefPtr< Buildercreate_from_string (const Glib::ustring &buffer, const Glib::ustring &object_id)
 
static Glib::RefPtr< Buildercreate_from_string (const Glib::ustring &buffer, const Glib::StringArrayHandle &object_ids)
 

Protected Member Functions

 Builder ()
 
Gtk::Widgetget_widget_checked (const Glib::ustring &name, GType type)
 
GtkWidgetget_cwidget (const Glib::ustring &name)
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gtk::Builderwrap (GtkBuilder *object, bool take_copy=false)
 

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.

Definition at line 109 of file builder.h.

Constructor & Destructor Documentation

◆ ~Builder()

virtual Gtk::Builder::~Builder ( )
virtual

◆ Builder()

Gtk::Builder::Builder ( )
protected

Member Function Documentation

◆ add_from_file() [1/4]

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.

Parameters
filenameThe file to parse.
Returns
true on success or false if an error occurred.
Exceptions
BuilderError,Glib::MarkupError,Glib::MarkupError

◆ add_from_file() [2/4]

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.

Parameters
filenameThe file to parse.
object_idThe object to build.
Returns
true on success or false if an error occurred.
Exceptions
BuilderError,Glib::MarkupError,Glib::MarkupError

◆ add_from_file() [3/4]

bool Gtk::Builder::add_from_file ( const std::string &  filename,
const Glib::StringArrayHandle &  object_ids 
)

Parses a file containing a GtkBuilder UI definition 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.
Parameters
filenameThe name of the file to parse.
object_idsNul-terminated array of objects to build.
Returns
A positive value on success, 0 if an error occurred.

◆ add_from_file() [4/4]

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.

Parameters
filenameThe file to parse.
object_idThe object to build.
Returns
true on success or false if an error occurred.
Exceptions
BuilderError,Glib::MarkupError,Glib::MarkupError

◆ add_from_string() [1/5]

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.

Parameters
bufferThe string to parse.
lengthThe length of buffer (may be -1 if buffer is nul-terminated).
Returns
true on success or false if an error occurred.
Exceptions
BuilderError,Glib::MarkupError

◆ add_from_string() [2/5]

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.

Parameters
bufferThe string to parse.
Returns
true on success or false if an error occurred.
Exceptions
BuilderError,Glib::MarkupError

◆ add_from_string() [3/5]

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.

Parameters
bufferThe string to parse.
object_idThe object to build.
Returns
true on success or false if an error occurred.
Exceptions
BuilderError,Glib::MarkupError

◆ add_from_string() [4/5]

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.

Parameters
bufferThe string to parse.
object_idsThe objects to build.
Returns
true on success or false if an error occurred.
Exceptions
BuilderError,Glib::MarkupError

◆ add_from_string() [5/5]

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.

Parameters
bufferThe string to parse.
object_idThe object to build.
Returns
true on success or false if an error occurred.
Exceptions
BuilderError,Glib::MarkupError

◆ create()

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

Creates a new builder object.

◆ create_from_file() [1/4]

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

Parses a file containing a GtkBuilder UI definition.

Parameters
filenamethe name of the file to parse.
Returns
A new Builder object, or a null pointer if an error occurred.
Exceptions
BuilderError,Glib::MarkupError,Glib::FileError

◆ create_from_file() [2/4]

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.

Parameters
filenamethe name of the file to parse.
object_idThe object to build.
Returns
A new Builder object, or a null pointer if an error occurred.
Exceptions
BuilderError,Glib::MarkupError,Glib::FileError

◆ create_from_file() [3/4]

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.

Parameters
filenamethe name of the file to parse.
object_idsThe objects to build.
Returns
A new Builder object, or a null pointer if an error occurred.
Exceptions
BuilderError,Glib::MarkupError,Glib::FileError

◆ create_from_file() [4/4]

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.

Parameters
filenamethe name of the file to parse.
object_idThe object to build.
Returns
A new Builder object, or a null pointer if an error occurred.
Exceptions
BuilderError,Glib::MarkupError,Glib::FileError

◆ create_from_string() [1/4]

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

Parses a string containing a GtkBuilder UI definition.

Parameters
bufferthe string to parse
Returns
A new Builder object, or a null pointer if an error occurred.
Exceptions
BuilderError,Glib::MarkupError

◆ create_from_string() [2/4]

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.

Parameters
bufferThe string to parse.
object_idThe object to build.
Returns
A new Builder object, or a null pointer if an error occurred.
Exceptions
BuilderError,Glib::MarkupError

◆ create_from_string() [3/4]

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.

Parameters
bufferthe string to parse
object_idsThe objects to build.
Returns
A new Builder object, or a null pointer if an error occurred.
Exceptions
BuilderError,Glib::MarkupError

◆ create_from_string() [4/4]

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.

Parameters
bufferThe string to parse.
object_idThe object to build.
Returns
A new Builder object, or a null pointer if an error occurred.
Exceptions
BuilderError,Glib::MarkupError

◆ get_cwidget()

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

◆ get_object()

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.

Parameters
nameName of object to get.
Returns
The object named name or 0 if it could not be found in the object tree.

◆ get_translation_domain()

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

Gets the translation domain of builder.

Returns
The translation domain. This string is owned by the builder object and must not be modified or freed.

◆ get_type()

static GType Gtk::Builder::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ get_widget()

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
nameThe name of the widget.
widgetA pointer to the widget, or 0 on failure.

Definition at line 404 of file builder.h.

◆ get_widget_checked()

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

◆ get_widget_derived()

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
Definition: ardour_ui.h:188

For instance:

Gtk::DerivedBox* pBox = 0;
refXml->get_widget_derived("mybox", pBox);
Parameters
nameThe name of the widget.
widgetA pointer to the widget, or 0 on failure.

Definition at line 433 of file builder.h.

◆ gobj() [1/2]

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

Provides access to the underlying C GObject.

Definition at line 148 of file builder.h.

◆ gobj() [2/2]

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

Provides access to the underlying C GObject.

Definition at line 151 of file builder.h.

◆ gobj_copy()

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.

◆ property_translation_domain() [1/2]

Glib::PropertyProxy< Glib::ustring > Gtk::Builder::property_translation_domain ( )

The translation domain used by gettext.

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_translation_domain() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::Builder::property_translation_domain ( ) const

The translation domain used by gettext.

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ set_translation_domain()

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

Sets the translation domain of builder. See Gtk::Builder::property_translation_domain().

Parameters
domainThe translation domain or 0.

Friends And Related Function Documentation

◆ wrap()

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

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

Parameters
objectThe C instance.
take_copyFalse 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: