adds rustfmt config, formats current code
This commit is contained in:
39
src/pawn.rs
39
src/pawn.rs
@@ -1,8 +1,7 @@
|
||||
|
||||
use super::*;
|
||||
|
||||
/// A wrapper around gtk::ListBox for Pawns
|
||||
#[derive(Debug,Clone)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PawnList {
|
||||
inner: gtk::ListBox,
|
||||
}
|
||||
@@ -10,7 +9,7 @@ pub struct PawnList {
|
||||
impl PawnList {
|
||||
/// Initialize from the given existing ListBox
|
||||
pub fn init(inner: gtk::ListBox) -> Self {
|
||||
PawnList{ inner }
|
||||
PawnList { inner }
|
||||
}
|
||||
|
||||
/// Adds a Pawn to the list
|
||||
@@ -22,7 +21,7 @@ impl PawnList {
|
||||
}
|
||||
|
||||
/// Application data related to a Pawn
|
||||
#[derive(Debug,Clone)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PawnData {
|
||||
pub name: String,
|
||||
pub position: Option<String>, // Content of label from CellWidget
|
||||
@@ -42,14 +41,14 @@ impl Pawn {
|
||||
let pawn_src = include_str!("../res/pawn.glade");
|
||||
let builder = gtk::Builder::new_from_string(pawn_src);
|
||||
let name = name.into();
|
||||
let label: gtk::Label =
|
||||
builder
|
||||
.get_object("name")
|
||||
.unwrap();
|
||||
let label: gtk::Label = builder.get_object("name").unwrap();
|
||||
label.set_text(&name);
|
||||
let widget: gtk::Box = builder.get_object("pawn").unwrap();
|
||||
Pawn {
|
||||
data: PawnData{ name, position: None, },
|
||||
data: PawnData {
|
||||
name,
|
||||
position: None,
|
||||
},
|
||||
widget,
|
||||
place_btn: builder.get_object("place_btn").unwrap(),
|
||||
stats_btn: builder.get_object("stats_btn").unwrap(),
|
||||
@@ -59,23 +58,17 @@ impl Pawn {
|
||||
pub fn connect_place(&self, state: AppState) {
|
||||
let name = self.data.name.clone();
|
||||
let data = self.data.clone();
|
||||
self.place_btn
|
||||
.connect_clicked(
|
||||
move |_| {
|
||||
println!("Placing {}...", name);
|
||||
let mut state = state.0.borrow_mut();
|
||||
state.pending = Some(data.clone()); // ???
|
||||
}
|
||||
);
|
||||
self.place_btn.connect_clicked(move |_| {
|
||||
println!("Placing {}...", name);
|
||||
let mut state = state.0.borrow_mut();
|
||||
state.pending = Some(data.clone()); // ???
|
||||
});
|
||||
}
|
||||
|
||||
pub fn connect_stats(&self) {
|
||||
self.stats_btn
|
||||
.connect_clicked(
|
||||
move |_| {
|
||||
println!("Showing stats...");
|
||||
}
|
||||
);
|
||||
self.stats_btn.connect_clicked(move |_| {
|
||||
println!("Showing stats...");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user