gdritter repos palladio / 299b311
Fix all the bugs I caused on the bus Getty Ritter 5 years ago
5 changed file(s) with 25 addition(s) and 25 deletion(s). Collapse all Expand all
1313 serde_derive = "*"
1414 zip = "0.3"
1515 image = "*"
16 cairo-rs = "0.2.0"
16 cairo-rs = "0.2.0"
17 clap = "*"
11 extern crate clap;
22
3 use self::clap;
43 use constants;
54
65 pub struct Cfg {
7 file_path: Option<&'static str>,
6 pub file_path: Option<String>,
87 }
98
10 fn palladio_args() -> Cfg {
9 pub fn palladio_args() -> Cfg {
1110 let matches =
1211 clap::App::new(constants::PROGRAM_NAME)
13 .version(constants::VERSION)
14 .author(constants::AUTHOR)
12 .version(constants::PROGRAM_VERSION)
13 .author(constants::PROGRAM_AUTHOR)
1514
1615 .arg(clap::Arg::with_name("i")
1716 .short("i")
2019 .help("The document to load on starting"))
2120 .get_matches();
2221
23 let file_path = matches.value_of("input");
22 let file_path = matches.value_of("input").map(|x| x.to_owned());
2423 Cfg { file_path }
2524 }
99 }
1010
1111 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 {
1414 None => State {
15 document: document.default(),
16 save_state = SaveState::Unsaved,
17 }
15 document: Document::default(),
16 save_state: SaveState::Unsaved,
17 },
1818 Some(path) => {
19 let mut f = File::open(path)?;
19 let mut f = ::std::fs::File::open(path)?;
2020 State {
21 document: Document::open_from_file(&mut f)?;
21 document: Document::open_from_file(&mut f)?,
2222 save_state: SaveState::Saved,
2323 }
24 }
25 }
24 },
25 })
2626 }
2727 }
2828
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";
44
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";
77
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";
142142 gtk::FileChooserAction::Open,
143143 );
144144
145 open_dialog.add_button(
145 save_dialog.add_button(
146146 strings::CANCEL_DIALOG_BTN,
147147 gtk::ResponseType::Cancel.into(),
148148 );
149 open_dialog.add_button(
149 save_dialog.add_button(
150150 strings::OPEN_DIALOG_BTN,
151151 gtk::ResponseType::Ok.into(),
152152 );