Clean up old warnings and set up tasks to build all active projects #287
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -3540,6 +3540,7 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
name = "screenplay"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-std",
|
||||
"glib",
|
||||
"gtk4",
|
||||
]
|
||||
|
@ -7,5 +7,6 @@ license = "GPL-3.0-only"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
async-std = "1.13.0"
|
||||
glib = { version = "0.18" }
|
||||
gtk = { version = "0.7", package = "gtk4" }
|
||||
|
@ -67,7 +67,7 @@ impl Screenplay {
|
||||
pub fn new(gtk_app: >k::Application, screens: Vec<Screen>) -> Result<Self, Error> {
|
||||
let window = gtk::ApplicationWindow::new(gtk_app);
|
||||
|
||||
let (sender, receiver) = gtk::glib::MainContext::channel(gtk::glib::Priority::DEFAULT);
|
||||
let (sender, receiver) = async_std::channel::unbounded();
|
||||
|
||||
let layout = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
@ -89,11 +89,15 @@ impl Screenplay {
|
||||
layout.append(&frame);
|
||||
|
||||
listbox.connect_row_activated(move |_, row| {
|
||||
match row.index() {
|
||||
-1 => sender.send(Action::Deselect),
|
||||
idx => sender.send(Action::SelectPage(idx as usize)),
|
||||
}
|
||||
.unwrap()
|
||||
let sender = sender.clone();
|
||||
let row = row.clone();
|
||||
glib::spawn_future_local(async move {
|
||||
match row.index() {
|
||||
-1 => sender.send(Action::Deselect).await,
|
||||
idx => sender.send(Action::SelectPage(idx as usize)).await,
|
||||
}
|
||||
.unwrap()
|
||||
});
|
||||
});
|
||||
|
||||
screens.iter().for_each(|Screen { title, .. }| {
|
||||
@ -107,8 +111,14 @@ impl Screenplay {
|
||||
let storybook = Self { frame, screens };
|
||||
|
||||
{
|
||||
let mut storybook = storybook.clone();
|
||||
receiver.attach(None, move |message| storybook.process_action(message));
|
||||
glib::spawn_future_local({
|
||||
let mut storybook = storybook.clone();
|
||||
async move {
|
||||
while let Ok(msg) = receiver.recv().await {
|
||||
storybook.process_action(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Ok(storybook)
|
||||
|
Loading…
Reference in New Issue
Block a user