feat!(ccs): Replace run function with AppRunner trait
This commit is contained in:
parent
52df3570ec
commit
1ac913d5c4
3 changed files with 30 additions and 14 deletions
|
|
@ -1,11 +1,13 @@
|
|||
// Copyright 2022 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
mod app_runner;
|
||||
mod macros;
|
||||
|
||||
use gtk4::prelude::*;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
pub use self::app_runner::AppRunner;
|
||||
pub use gtk4 as gtk;
|
||||
pub use relm4_macros::view;
|
||||
|
||||
|
|
@ -198,16 +200,6 @@ pub fn forward<I: 'static, O: 'static, F: (Fn(I) -> O) + 'static>(
|
|||
})
|
||||
}
|
||||
|
||||
/// Convenience function for launching an application.
|
||||
pub fn run<F: Fn(gtk4::Application) + 'static>(func: F) {
|
||||
use gtk4::prelude::*;
|
||||
let app = gtk4::Application::new(None, Default::default());
|
||||
|
||||
app.connect_activate(move |app| func(app.clone()));
|
||||
|
||||
app.run();
|
||||
}
|
||||
|
||||
/// Convenience function for spawning tasks on the local executor
|
||||
pub fn spawn_local<F: std::future::Future<Output = ()> + 'static>(func: F) {
|
||||
gtk4::glib::MainContext::default().spawn_local(func);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue