confirmation dialog added.
This commit is contained in:
parent
fca2e0a993
commit
637d0ffc74
2 changed files with 25 additions and 3 deletions
20
src/main.rs
20
src/main.rs
|
@ -451,6 +451,24 @@ fn fix_db_entries(tx: &Transaction, book_entries: &Vec<BookEntry>) -> Statistics
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
if cfg!(target_arch = "arm") {
|
||||||
|
let res = pocketbook::dialog(
|
||||||
|
pocketbook::Icon::None,
|
||||||
|
"PocketBook has sometimes problems parsing metadata.\n\
|
||||||
|
This app tries to fix some of these issues.\n\
|
||||||
|
(Note: The database file explore-3.db will be altered!)\n\
|
||||||
|
\n\
|
||||||
|
Please be patient - this might take a while.\n\
|
||||||
|
You will see a blank screen during the process.\n\
|
||||||
|
\n\
|
||||||
|
Proceed?",
|
||||||
|
&["Cancel", "Yes"],
|
||||||
|
);
|
||||||
|
if res == 1 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut conn = Connection::open("/mnt/ext1/system/explorer-3/explorer-3.db").unwrap();
|
let mut conn = Connection::open("/mnt/ext1/system/explorer-3/explorer-3.db").unwrap();
|
||||||
|
|
||||||
conn.execute("PRAGMA foreign_keys = 0", NO_PARAMS).unwrap();
|
conn.execute("PRAGMA foreign_keys = 0", NO_PARAMS).unwrap();
|
||||||
|
@ -465,6 +483,7 @@ fn main() {
|
||||||
pocketbook::dialog(
|
pocketbook::dialog(
|
||||||
pocketbook::Icon::Info,
|
pocketbook::Icon::Info,
|
||||||
"The database seems to be ok.\nNothing had to be fixed.",
|
"The database seems to be ok.\nNothing had to be fixed.",
|
||||||
|
&["OK"],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
pocketbook::dialog(
|
pocketbook::dialog(
|
||||||
|
@ -473,6 +492,7 @@ fn main() {
|
||||||
"Authors fixed: {}\nBooks cleaned from DB: {}",
|
"Authors fixed: {}\nBooks cleaned from DB: {}",
|
||||||
&stat.authors_fixed, &stat.ghost_books_cleaned
|
&stat.authors_fixed, &stat.ghost_books_cleaned
|
||||||
),
|
),
|
||||||
|
&["OK"],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -12,7 +12,7 @@ pub enum Icon {
|
||||||
WLan,
|
WLan,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dialog(icon: Icon, text: &str) {
|
pub fn dialog(icon: Icon, text: &str, buttons: &[&str]) -> i32 {
|
||||||
let iconstr = match icon {
|
let iconstr = match icon {
|
||||||
Icon::None => "0",
|
Icon::None => "0",
|
||||||
Icon::Info => "1",
|
Icon::Info => "1",
|
||||||
|
@ -22,8 +22,10 @@ pub fn dialog(icon: Icon, text: &str) {
|
||||||
Icon::WLan => "5",
|
Icon::WLan => "5",
|
||||||
};
|
};
|
||||||
|
|
||||||
Command::new(DIALOG_PATH)
|
let res = Command::new(DIALOG_PATH)
|
||||||
.args(&[iconstr, "", text, "OK"])
|
.args([&[iconstr, "", text], buttons].concat())
|
||||||
.output()
|
.output()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
res.status.code().unwrap_or(-1)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue