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
impl Shell
Sourcepub fn from_file(path: impl AsRef<Path>) -> ShellBuilder
pub fn from_file(path: impl AsRef<Path>) -> ShellBuilder
Creates a shell builder from a Slint file path
Sourcepub fn from_file_with_compiler(
path: impl AsRef<Path>,
compiler: Compiler,
) -> ShellBuilder
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.
Sourcepub fn from_source(code: impl Into<String>) -> ShellBuilder
pub fn from_source(code: impl Into<String>) -> ShellBuilder
Creates a shell builder from Slint source code
Sourcepub fn from_source_with_compiler(
code: impl Into<String>,
compiler: Compiler,
) -> ShellBuilder
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
Sourcepub fn from_compilation(result: Rc<CompilationResult>) -> ShellBuilder
pub fn from_compilation(result: Rc<CompilationResult>) -> ShellBuilder
Creates a shell builder from a pre-compiled Slint compilation result
Sourcepub fn builder() -> ShellBuilder
pub fn builder() -> ShellBuilder
Creates an empty shell builder for manual configuration
Sourcepub fn compile_file(
path: impl AsRef<Path>,
) -> Result<Rc<CompilationResult>, Error>
pub fn compile_file( path: impl AsRef<Path>, ) -> Result<Rc<CompilationResult>, Error>
Compiles a Slint file and returns the compilation result
Sourcepub fn compile_source(
code: impl Into<String>,
) -> Result<Rc<CompilationResult>, Error>
pub fn compile_source( code: impl Into<String>, ) -> Result<Rc<CompilationResult>, Error>
Compiles Slint source code and returns the compilation result
Sourcepub fn from_config(config: ShellConfig) -> Result<Shell, Error>
pub fn from_config(config: ShellConfig) -> Result<Shell, Error>
Creates a shell from a complete configuration object
Sourcepub fn control(&self) -> ShellControl
pub fn control(&self) -> ShellControl
Returns a control handle for sending commands to the shell
Sourcepub fn popups(&self) -> PopupShell
pub fn popups(&self) -> PopupShell
Access popup management API
pub fn create_session_lock( &self, component: impl Into<String>, ) -> Result<SessionLock, Error>
pub fn create_session_lock_with_config( &self, builder: SessionLockBuilder, ) -> Result<SessionLock, Error>
Sourcepub fn surface_names(&self) -> Vec<&str>
pub fn surface_names(&self) -> Vec<&str>
Returns the names of all registered surfaces
Sourcepub fn has_surface(&self, name: &str) -> bool
pub fn has_surface(&self, name: &str) -> bool
Checks if a surface with the given name exists
Sourcepub fn event_loop_handle(&self) -> EventLoopHandle
pub fn event_loop_handle(&self) -> EventLoopHandle
Returns a handle to the event loop for registering custom event sources
Sourcepub fn spawn_surface(
&mut self,
definition: SurfaceDefinition,
) -> Result<Vec<Handle<Surface>>, Error>
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.
Sourcepub fn despawn_surface(&mut self, handle: Handle<Surface>) -> Result<(), Error>
pub fn despawn_surface(&mut self, handle: Handle<Surface>) -> Result<(), Error>
Removes and destroys a surface by its handle
Sourcepub fn on_output_connected<F>(&mut self, handler: F) -> Result<(), Error>where
F: Fn(&OutputInfo) + 'static,
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.
Sourcepub fn on_output_disconnected<F>(&mut self, handler: F) -> Result<(), Error>
pub fn on_output_disconnected<F>(&mut self, handler: F) -> Result<(), Error>
Registers a handler called when an output is disconnected
Sourcepub fn get_surface_handle(&self, name: &str) -> Option<Handle<Surface>>
pub fn get_surface_handle(&self, name: &str) -> Option<Handle<Surface>>
Returns the handle for a surface by name
Sourcepub fn get_surface_name(&self, handle: Handle<Surface>) -> Option<&str>
pub fn get_surface_name(&self, handle: Handle<Surface>) -> Option<&str>
Returns the name of a surface by its handle
Sourcepub fn with_surface<F, R>(&self, name: &str, f: F) -> Result<R, Error>where
F: FnOnce(&ComponentInstance) -> R,
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
Sourcepub fn with_all_surfaces<F>(&self, f: F)
pub fn with_all_surfaces<F>(&self, f: F)
Executes a function with each surface name and component instance
Sourcepub fn with_output<F, R>(
&self,
handle: Handle<Output>,
f: F,
) -> Result<R, Error>where
F: FnOnce(&ComponentInstance) -> R,
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
Sourcepub fn with_all_outputs<F>(&self, f: F)
pub fn with_all_outputs<F>(&self, f: F)
Executes a function with each output handle and component instance
Sourcepub fn compilation_result(&self) -> &Rc<CompilationResult>
pub fn compilation_result(&self) -> &Rc<CompilationResult>
Returns the Slint compilation result used by this shell
Sourcepub fn output_registry(&self) -> OutputRegistry
pub fn output_registry(&self) -> OutputRegistry
Returns the registry of all connected outputs
Sourcepub fn get_output_info(&self, handle: Handle<Output>) -> Option<OutputInfo>
pub fn get_output_info(&self, handle: Handle<Output>) -> Option<OutputInfo>
Returns information about a specific output by handle
Sourcepub fn all_output_info(&self) -> Vec<OutputInfo>
pub fn all_output_info(&self) -> Vec<OutputInfo>
Returns information about all connected outputs
Sourcepub fn select(&self, selector: impl Into<Selector>) -> Selection<'_>
pub fn select(&self, selector: impl Into<Selector>) -> Selection<'_>
Creates a selection for targeting specific surfaces by criteria
Sourcepub fn select_lock(&self, selector: impl Into<Selector>) -> LockSelection<'_>
pub fn select_lock(&self, selector: impl Into<Selector>) -> LockSelection<'_>
Creates a selection for targeting session lock surfaces by criteria
Trait Implementations§
Source§impl ShellRuntime for Shell
impl ShellRuntime for Shell
type LoopHandle = EventLoopHandle
type Context<'a> = ShellEventContext<'a>
fn event_loop_handle(&self) -> <Shell as ShellRuntime>::LoopHandle
fn with_component<F>(&self, name: &str, f: F)where
F: FnMut(&ComponentInstance),
fn with_all_components<F>(&self, f: F)
fn run(&mut self) -> Result<(), Error>
Auto Trait Implementations§
impl !RefUnwindSafe for Shell
impl !Send for Shell
impl !Sync for Shell
impl !UnwindSafe for Shell
impl Freeze for Shell
impl Unpin for Shell
impl UnsafeUnpin for Shell
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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