feat!(ccs): Replace run function with AppRunner trait

This commit is contained in:
Michael Aaron Murphy 2022-01-25 20:47:32 +01:00
parent 52df3570ec
commit 1ac913d5c4
No known key found for this signature in database
GPG key ID: B2732D4240C9212C
3 changed files with 30 additions and 14 deletions

View file

@ -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);