[][src]Trait gtk::BuilderExt

pub trait BuilderExt: 'static {
    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 expose_object<P: IsA<Object>>(&self, name: &str, object: &P);
fn extend_with_template<P: IsA<Widget>>(
        &self,
        widget: &P,
        template_type: Type,
        buffer: &str
    ) -> Result<(), Error>;
fn get_application(&self) -> Option<Application>;
fn get_objects(&self) -> Vec<Object>;
fn get_translation_domain(&self) -> Option<GString>;
fn get_type_from_name(&self, type_name: &str) -> Type;
fn set_application<P: IsA<Application>>(&self, application: &P);
fn set_translation_domain(&self, domain: Option<&str>);
fn value_from_string(
        &self,
        pspec: &ParamSpec,
        string: &str
    ) -> Result<Value, Error>;
fn value_from_string_type(
        &self,
        type_: Type,
        string: &str
    ) -> Result<Value, Error>;
fn connect_property_translation_domain_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; }

Trait containing all Builder methods.

Implementors

Builder

Required methods

fn add_from_resource(&self, resource_path: &str) -> Result<(), Error>

Parses a resource file containing a [Builder UI definition][BUILDER-UI] and merges it with the current contents of self.

Most users will probably want to use Builder::new_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

fn add_from_string(&self, buffer: &str) -> Result<(), Error>

Parses a string containing a [Builder UI definition][BUILDER-UI] and merges it with the current contents of self.

Most users will probably want to use Builder::new_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

fn add_objects_from_resource(
    &self,
    resource_path: &str,
    object_ids: &[&str]
) -> Result<(), Error>

Parses a resource file containing a [Builder 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

fn add_objects_from_string(
    &self,
    buffer: &str,
    object_ids: &[&str]
) -> Result<(), Error>

Parses a string containing a [Builder 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 expose_object<P: IsA<Object>>(&self, name: &str, object: &P)

Add object to the self 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

fn extend_with_template<P: IsA<Widget>>(
    &self,
    widget: &P,
    template_type: Type,
    buffer: &str
) -> Result<(), Error>

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

fn get_application(&self) -> Option<Application>

Gets the Application associated with the builder.

The 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 gio::Application::get_default. If you want to use another application for constructing proxies, use BuilderExt::set_application.

Returns

the application being used by the builder, or None

fn get_objects(&self) -> Vec<Object>

Gets all objects that have been constructed by self. Note that this function does not increment the reference counts of the returned objects.

Returns

a newly-allocated glib::SList containing all the objects constructed by the Builder instance. It should be freed by glib::SList::free

fn get_translation_domain(&self) -> Option<GString>

Gets the translation domain of self.

Returns

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

fn get_type_from_name(&self, type_name: &str) -> Type

Looks up a type by name, using the virtual function that Builder has for that purpose. This is mainly used when implementing the Buildable interface on a type.

type_name

type name to lookup

Returns

the glib::Type found for type_name or G_TYPE_INVALID if no type was found

fn set_application<P: IsA<Application>>(&self, application: &P)

Sets the application associated with self.

You only need this function if there is more than one gio::Application in your process. application cannot be None.

application

a Application

fn set_translation_domain(&self, domain: Option<&str>)

Sets the translation domain of self. See Builder:translation-domain.

domain

the translation domain or None

fn value_from_string(
    &self,
    pspec: &ParamSpec,
    string: &str
) -> Result<Value, Error>

This function demarshals a value from a string. This function calls gobject::Value::init on the value argument, so it need not be initialised beforehand.

This function can handle char, uchar, boolean, int, uint, long, ulong, enum, flags, float, double, string, gdk::Color, gdk::RGBA and Adjustment type values. Support for Widget type values is still to come.

Upon errors false will be returned and error will be assigned a glib::Error from the GTK_BUILDER_ERROR domain.

pspec

the gobject::ParamSpec for the property

string

the string representation of the value

value

the gobject::Value to store the result in

Returns

true on success

fn value_from_string_type(
    &self,
    type_: Type,
    string: &str
) -> Result<Value, Error>

Like BuilderExt::value_from_string, this function demarshals a value from a string, but takes a glib::Type instead of gobject::ParamSpec. This function calls gobject::Value::init on the value argument, so it need not be initialised beforehand.

Upon errors false will be returned and error will be assigned a glib::Error from the GTK_BUILDER_ERROR domain.

type_

the glib::Type of the value

string

the string representation of the value

value

the gobject::Value to store the result in

Returns

true on success

fn connect_property_translation_domain_notify<F: Fn(&Self) + 'static>(
    &self,
    f: F
) -> SignalHandlerId

Loading content...

Implementors

impl<O: IsA<Builder>> BuilderExt for O[src]

Loading content...