Shell

Struct Shell 

Source
pub struct Shell { /* private fields */ }
Expand description

Main runtime for managing Wayland layer-shell surfaces with Slint UI

Manages surface lifecycle, event loop integration, and component instantiation. Supports multiple surfaces across monitors, dynamic spawning, and popup windows.

Create via Shell::from_file(), from_source(), or from_compilation().

Implementations§

Source§

impl Shell

Source

pub fn from_file(path: impl AsRef<Path>) -> ShellBuilder

Creates a shell builder from a Slint file path

Source

pub fn from_file_with_compiler( path: impl AsRef<Path>, compiler: Compiler, ) -> ShellBuilder

Creates a shell builder from a Slint file path with a custom compiler

Useful for configuring include paths, style overrides, or compilation settings.

Source

pub fn from_source(code: impl Into<String>) -> ShellBuilder

Creates a shell builder from Slint source code

Source

pub fn from_source_with_compiler( code: impl Into<String>, compiler: Compiler, ) -> ShellBuilder

Creates a shell builder from Slint source code with a custom compiler

Source

pub fn from_compilation(result: Rc<CompilationResult>) -> ShellBuilder

Creates a shell builder from a pre-compiled Slint compilation result

Source

pub fn builder() -> ShellBuilder

Creates an empty shell builder for manual configuration

Source

pub fn compile_file( path: impl AsRef<Path>, ) -> Result<Rc<CompilationResult>, Error>

Compiles a Slint file and returns the compilation result

Source

pub fn compile_source( code: impl Into<String>, ) -> Result<Rc<CompilationResult>, Error>

Compiles Slint source code and returns the compilation result

Source

pub fn from_config(config: ShellConfig) -> Result<Shell, Error>

Creates a shell from a complete configuration object

Source

pub fn control(&self) -> ShellControl

Returns a control handle for sending commands to the shell

Source

pub fn surface_names(&self) -> Vec<&str>

Returns the names of all registered surfaces

Source

pub fn has_surface(&self, name: &str) -> bool

Checks if a surface with the given name exists

Source

pub fn event_loop_handle(&self) -> EventLoopHandle

Returns a handle to the event loop for registering custom event sources

Source

pub fn run(&mut self) -> Result<(), Error>

Starts the event loop and runs the shell until exit

Source

pub fn spawn_surface( &mut self, definition: SurfaceDefinition, ) -> Result<Vec<Handle<Surface>>, Error>

Spawns a new surface at runtime from the given definition

The surface is instantiated on outputs according to its OutputPolicy.

Source

pub fn despawn_surface(&mut self, handle: Handle<Surface>) -> Result<(), Error>

Removes and destroys a surface by its handle

Source

pub fn on_output_connected<F>(&mut self, handler: F) -> Result<(), Error>
where F: Fn(&OutputInfo) + 'static,

Registers a handler called when a new output (monitor) is connected

Surfaces with OutputPolicy::All spawn automatically on new outputs.

Source

pub fn on_output_disconnected<F>(&mut self, handler: F) -> Result<(), Error>
where F: Fn(Handle<Output>) + 'static,

Registers a handler called when an output is disconnected

Source

pub fn get_surface_handle(&self, name: &str) -> Option<Handle<Surface>>

Returns the handle for a surface by name

Source

pub fn get_surface_name(&self, handle: Handle<Surface>) -> Option<&str>

Returns the name of a surface by its handle

Source

pub fn with_surface<F, R>(&self, name: &str, f: F) -> Result<R, Error>
where F: FnOnce(&ComponentInstance) -> R,

Executes a function with access to a surface component instance by name

Source

pub fn with_all_surfaces<F>(&self, f: F)

Executes a function with each surface name and component instance

Source

pub fn with_output<F, R>( &self, handle: Handle<Output>, f: F, ) -> Result<R, Error>
where F: FnOnce(&ComponentInstance) -> R,

Executes a function with access to a surface on a specific output

Source

pub fn with_all_outputs<F>(&self, f: F)

Executes a function with each output handle and component instance

Source

pub fn compilation_result(&self) -> &Rc<CompilationResult>

Returns the Slint compilation result used by this shell

Source

pub fn popup(&self, component_name: impl Into<String>) -> PopupBuilder<'_>

Creates a popup builder for showing a popup window

Source

pub fn output_registry(&self) -> OutputRegistry

Returns the registry of all connected outputs

Source

pub fn get_output_info(&self, handle: Handle<Output>) -> Option<OutputInfo>

Returns information about a specific output by handle

Source

pub fn all_output_info(&self) -> Vec<OutputInfo>

Returns information about all connected outputs

Source

pub fn select(&self, selector: impl Into<Selector>) -> Selection<'_>

Creates a selection for targeting specific surfaces by criteria

Trait Implementations§

Auto Trait Implementations§

§

impl Freeze for Shell

§

impl !RefUnwindSafe for Shell

§

impl !Send for Shell

§

impl !Sync for Shell

§

impl Unpin for Shell

§

impl !UnwindSafe for Shell

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more