Skip to main content

BuilderExt

Trait BuilderExt 

Source
pub trait BuilderExt: IsA<Builder> + 'static {
    // Provided methods
    fn expose_object(&self, name: &str, object: &impl IsA<Object>) { ... }
    fn application(&self) -> Option<Application> { ... }
    fn objects(&self) -> Vec<Object> { ... }
    fn translation_domain(&self) -> Option<GString> { ... }
    fn type_from_name(&self, type_name: &str) -> Type { ... }
    fn set_application(&self, application: &impl IsA<Application>) { ... }
    fn set_translation_domain(&self, domain: Option<&str>) { ... }
    fn value_from_string(
        &self,
        pspec: impl AsRef<ParamSpec>,
        string: &str,
    ) -> Result<Value, Error> { ... }
    fn value_from_string_type(
        &self,
        type_: Type,
        string: &str,
    ) -> Result<Value, Error> { ... }
    fn connect_translation_domain_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId { ... }
}
Expand description

Trait containing all Builder methods.

§Implementors

Builder

Provided Methods§

Source

fn expose_object(&self, name: &str, object: &impl IsA<Object>)

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

Source

fn 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::default(). If you want to use another application for constructing proxies, use set_application().

§Returns

the application being used by the builder, or None

Source

fn 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 GSList containing all the objects constructed by the Builder instance. It should be freed by g_slist_free()

Source

fn 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.

Source

fn 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 GType found for type_name or G_TYPE_INVALID if no type was found

Source

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

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

Source

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

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

§domain

the translation domain or None

Source

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

This function demarshals a value from a string. This function calls [glib::Value::init()][crate::glib::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, GdkColor, 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 glib::ParamSpec for the property

§string

the string representation of the value

§Returns

true on success

§value

the glib::Value to store the result in

Source

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

Like value_from_string(), this function demarshals a value from a string, but takes a GType instead of glib::ParamSpec. This function calls [glib::Value::init()][crate::glib::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 GType of the value

§string

the string representation of the value

§Returns

true on success

§value

the glib::Value to store the result in

Source

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§