Fix all the bugs I caused on the bus
Getty Ritter
6 years ago
13 | 13 |
serde_derive = "*"
|
14 | 14 |
zip = "0.3"
|
15 | 15 |
image = "*"
|
16 | |
cairo-rs = "0.2.0"⏎
|
| 16 |
cairo-rs = "0.2.0"
|
| 17 |
clap = "*"
|
1 | 1 |
extern crate clap;
|
2 | 2 |
|
3 | |
use self::clap;
|
4 | 3 |
use constants;
|
5 | 4 |
|
6 | 5 |
pub struct Cfg {
|
7 | |
file_path: Option<&'static str>,
|
| 6 |
pub file_path: Option<String>,
|
8 | 7 |
}
|
9 | 8 |
|
10 | |
fn palladio_args() -> Cfg {
|
| 9 |
pub fn palladio_args() -> Cfg {
|
11 | 10 |
let matches =
|
12 | 11 |
clap::App::new(constants::PROGRAM_NAME)
|
13 | |
.version(constants::VERSION)
|
14 | |
.author(constants::AUTHOR)
|
| 12 |
.version(constants::PROGRAM_VERSION)
|
| 13 |
.author(constants::PROGRAM_AUTHOR)
|
15 | 14 |
|
16 | 15 |
.arg(clap::Arg::with_name("i")
|
17 | 16 |
.short("i")
|
|
20 | 19 |
.help("The document to load on starting"))
|
21 | 20 |
.get_matches();
|
22 | 21 |
|
23 | |
let file_path = matches.value_of("input");
|
| 22 |
let file_path = matches.value_of("input").map(|x| x.to_owned());
|
24 | 23 |
Cfg { file_path }
|
25 | 24 |
}
|
9 | 9 |
}
|
10 | 10 |
|
11 | 11 |
impl State {
|
12 | |
fn new(conf: cfg::Cfg) -> Result<State, Error> {
|
13 | |
match conf.file_path {
|
| 12 |
pub fn new(conf: cfg::Cfg) -> Result<State, Error> {
|
| 13 |
Ok(match conf.file_path {
|
14 | 14 |
None => State {
|
15 | |
document: document.default(),
|
16 | |
save_state = SaveState::Unsaved,
|
17 | |
}
|
| 15 |
document: Document::default(),
|
| 16 |
save_state: SaveState::Unsaved,
|
| 17 |
},
|
18 | 18 |
Some(path) => {
|
19 | |
let mut f = File::open(path)?;
|
| 19 |
let mut f = ::std::fs::File::open(path)?;
|
20 | 20 |
State {
|
21 | |
document: Document::open_from_file(&mut f)?;
|
| 21 |
document: Document::open_from_file(&mut f)?,
|
22 | 22 |
save_state: SaveState::Saved,
|
23 | 23 |
}
|
24 | |
}
|
25 | |
}
|
| 24 |
},
|
| 25 |
})
|
26 | 26 |
}
|
27 | 27 |
}
|
28 | 28 |
|
1 | |
static OPEN_BTN: &'static str = "Open";
|
2 | |
static SAVE_BTN: &'static str = "Save";
|
3 | |
static SAVE_AS_BTN: &'static str = "Save As";
|
| 1 |
pub static OPEN_BTN: &'static str = "Open";
|
| 2 |
pub static SAVE_BTN: &'static str = "Save";
|
| 3 |
pub static SAVE_AS_BTN: &'static str = "Save As";
|
4 | 4 |
|
5 | |
static OPEN_DIALOG_BTN: &'static str = "Open";
|
6 | |
static CANCEL_DIALOG_BTN: &'static str = "Cancel";
|
| 5 |
pub static OPEN_DIALOG_BTN: &'static str = "Open";
|
| 6 |
pub static CANCEL_DIALOG_BTN: &'static str = "Cancel";
|
7 | 7 |
|
8 | |
static TILESET_LABEL: &'static str = "Tileset";
|
9 | |
static TILESET_LOAD_BTN: &'static str = "Load Tileset Image";
|
| 8 |
pub static TILESET_LABEL: &'static str = "Tileset";
|
| 9 |
pub static TILESET_LOAD_BTN: &'static str = "Load Tileset Image";
|
142 | 142 |
gtk::FileChooserAction::Open,
|
143 | 143 |
);
|
144 | 144 |
|
145 | |
open_dialog.add_button(
|
| 145 |
save_dialog.add_button(
|
146 | 146 |
strings::CANCEL_DIALOG_BTN,
|
147 | 147 |
gtk::ResponseType::Cancel.into(),
|
148 | 148 |
);
|
149 | |
open_dialog.add_button(
|
| 149 |
save_dialog.add_button(
|
150 | 150 |
strings::OPEN_DIALOG_BTN,
|
151 | 151 |
gtk::ResponseType::Ok.into(),
|
152 | 152 |
);
|