Trait gtk::prelude::BuilderExtManual
source · [−]pub trait BuilderExtManual: 'static {
fn object<T: IsA<Object>>(&self, name: &str) -> Option<T>;
fn add_from_file<T: AsRef<Path>>(&self, file_path: T) -> Result<(), Error>;
fn add_from_resource(&self, resource_path: &str) -> Result<(), Error>;
fn add_from_string(&self, buffer: &str) -> Result<(), Error>;
fn add_objects_from_resource(
&self,
resource_path: &str,
object_ids: &[&str]
) -> Result<(), Error>;
fn add_objects_from_string(
&self,
buffer: &str,
object_ids: &[&str]
) -> Result<(), Error>;
fn connect_signals<P: FnMut(&Builder, &str) -> Box<dyn Fn(&[Value]) -> Option<Value> + 'static>>(
&self,
func: P
);
fn extend_with_template(
&self,
widget: &impl IsA<Widget>,
template_type: Type,
buffer: &str
) -> Result<(), Error>;
}
Required Methods
Parses a resource file containing a [GtkBuilder UI definition][BUILDER-UI]
and merges it with the current contents of self
.
Most users will probably want to use Builder::from_resource()
.
If an error occurs, 0 will be returned and error
will be assigned a
glib::Error
from the GTK_BUILDER_ERROR
, G_MARKUP_ERROR
or G_RESOURCE_ERROR
domain.
It’s not really reasonable to attempt to handle failures of this
call. The only reasonable thing to do when an error is detected is
to call g_error()
.
resource_path
the path of the resource file to parse
Returns
A positive value on success, 0 if an error occurred
Parses a string containing a [GtkBuilder UI definition][BUILDER-UI]
and merges it with the current contents of self
.
Most users will probably want to use Builder::from_string()
.
Upon errors 0 will be returned and error
will be assigned a
glib::Error
from the GTK_BUILDER_ERROR
, G_MARKUP_ERROR
or
G_VARIANT_PARSE_ERROR
domain.
It’s not really reasonable to attempt to handle failures of this
call. The only reasonable thing to do when an error is detected is
to call g_error()
.
buffer
the string to parse
length
the length of buffer
(may be -1 if buffer
is nul-terminated)
Returns
A positive value on success, 0 if an error occurred
Parses a resource file containing a [GtkBuilder UI definition][BUILDER-UI]
building only the requested objects and merges
them with the current contents of self
.
Upon errors 0 will be returned and error
will be assigned a
glib::Error
from the GTK_BUILDER_ERROR
, G_MARKUP_ERROR
or G_RESOURCE_ERROR
domain.
If you are adding an object that depends on an object that is not
its child (for instance a TreeView
that depends on its
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
Returns
A positive value on success, 0 if an error occurred
Parses a string containing a [GtkBuilder UI definition][BUILDER-UI]
building only the requested objects and merges
them with the current contents of self
.
Upon errors 0 will be returned and error
will be assigned a
glib::Error
from the GTK_BUILDER_ERROR
or G_MARKUP_ERROR
domain.
If you are adding an object that depends on an object that is not
its child (for instance a TreeView
that depends on its
TreeModel
), you have to explicitly list all of them in object_ids
.
buffer
the string to parse
length
the length of buffer
(may be -1 if buffer
is nul-terminated)
object_ids
nul-terminated array of objects to build
Returns
A positive value on success, 0 if an error occurred
fn connect_signals<P: FnMut(&Builder, &str) -> Box<dyn Fn(&[Value]) -> Option<Value> + 'static>>(
&self,
func: P
)
Main private entry point for building composite container components from template XML.
This is exported purely to let gtk-builder-tool validate templates, applications have no need to call this function.
widget
the widget that is being extended
template_type
the type that the template is for
buffer
the string to parse
length
the length of buffer
(may be -1 if buffer
is nul-terminated)
Returns
A positive value on success, 0 if an error occurred