pub struct AsyncComponentBuilder<C: AsyncComponent> {
    pub root: C::Root,
    /* private fields */
}
Expand description

A component that is ready for docking and launch.

Fields§

§root: C::Root

The root widget of the component.

Implementations§

Configure the root widget before launching.

Access the root widget before the component is initialized.

Change the priority at which the messages of this component are handled.

  • Use [glib::PRIORITY_HIGH] for high priority event sources.
  • Use [glib::PRIORITY_LOW] for very low priority background tasks.
  • Use [glib::PRIORITY_DEFAULT_IDLE] for default priority idle functions.
  • Use [glib::PRIORITY_HIGH_IDLE] for high priority idle functions.

Attach the component’s root widget to a given container.

Set the component’s root widget transient for a given window. This function doesn’t require a gtk::Window as parameter, but instead uses RelmWidgetExt::toplevel_window() to retrieve the toplevel window of any gtk::Widget. Therefore, you don’t have to pass a window to every component.

If the root widget is a native dialog, such as gtk::FileChooserNative, you should use transient_for_native instead.

Set the component’s root widget transient for a given window. This function doesn’t require a gtk::Window as parameter, but instead uses RelmWidgetExt::toplevel_window() to retrieve the toplevel window of any gtk::Widget. Therefore, you don’t have to pass a window to every component.

Applicable to native dialogs only, such as gtk::FileChooserNative. If the root widget is a non-native dialog, you should use transient_for instead.

Starts the component, passing ownership to a future attached to a [gtk::glib::MainContext].

Examples found in repository?
src/app.rs (line 129)
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
    pub fn run_async_with_args<C, S>(self, payload: C::Init, args: &[S])
    where
        C: AsyncComponent,
        C::Root: IsA<gtk::Window> + WidgetExt,
        S: AsRef<str>,
    {
        use std::cell::Cell;

        let Self { app } = self;

        let payload = Cell::new(Some(payload));

        app.connect_activate(move |app| {
            if let Some(payload) = payload.take() {
                assert!(
                    app.is_registered(),
                    "App should be already registered when activated"
                );

                let builder = AsyncComponentBuilder::<C>::default();
                let connector = builder.launch(payload);

                // Run late initialization for transient windows for example.
                crate::late_initialization::run_late_init();

                let mut controller = connector.detach();
                let window = controller.widget().clone();

                controller.detach_runtime();

                app.add_window(window.as_ref());
                window.show();
            } else {
                panic!("Can't start Relm4 applications twice");
            }
        });

        app.run_with_args(args);
    }

Trait Implementations§

Formats the value using the given formatter. Read more

Prepares a component for initialization.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Returns the position. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Returns the position. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more