Commit 5877a274 authored by Eisha Chen-yen-su's avatar Eisha Chen-yen-su

Use BackendCommand::Randomize

This uses BackendCommand::Randomize when the user click on the button
"Randomize".
parent 14e3a15e
......@@ -14,7 +14,7 @@ pub fn launch() {
gtk::Application::new("org.gnome.Automata", gio::ApplicationFlags::empty())
.expect("Could not create application");
let (cmd_sender, cmd_receiver) = channel::<String>();
let (cmd_sender, cmd_receiver) = channel::<BackendCommand>();
let cmd_sender = Arc::new(RwLock::new(cmd_sender));
let (update_sender, update_receiver) = channel::<BackendUpdate>();
......
......@@ -5,11 +5,11 @@ use image::{ImageBuffer, Luma};
use super::foundry::Grid;
use super::bkmessages::BackendUpdate;
use super::bkmessages::{BackendCommand, BackendUpdate};
const image_buffer_path: &str = "/tmp/automata_buffer.png";
pub fn launch(cmd_chan: Receiver<String>, update_chan: Sender<BackendUpdate>) {
pub fn launch(cmd_chan: Receiver<BackendCommand>, update_chan: Sender<BackendUpdate>) {
thread::spawn(move || {
let mut grid: Option<Grid> = None;
......
......@@ -4,10 +4,10 @@ use gtk::prelude::*;
use std::sync::mpsc::{Receiver, Sender};
use std::sync::{Arc, RwLock};
use bkmessages::BackendUpdate;
use bkmessages::{BackendCommand, BackendUpdate};
pub fn new_window(
cmd_chan: Arc<RwLock<Sender<String>>>,
cmd_chan: Arc<RwLock<Sender<BackendCommand>>>,
update_chan: Arc<RwLock<Receiver<BackendUpdate>>>,
) -> gtk::ApplicationWindow {
let builder: gtk::Builder =
......@@ -27,7 +27,7 @@ pub fn new_window(
.get_object("randomize_button")
.expect("randomize_button not found");
btn_rand.connect_clicked(clone!(cmd_chan, update_chan => move |_| {
cmd_chan.read().unwrap().send(String::from("Button clicked!")).unwrap();
cmd_chan.read().unwrap().send(BackendCommand::Randomize).unwrap();
let mut path = String::new();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment