confirmation dialog added.

This commit is contained in:
Martin Brodbeck 2021-02-02 09:52:50 +01:00
parent fca2e0a993
commit 637d0ffc74
2 changed files with 25 additions and 3 deletions

View File

@ -451,6 +451,24 @@ fn fix_db_entries(tx: &Transaction, book_entries: &Vec<BookEntry>) -> Statistics
}
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();
conn.execute("PRAGMA foreign_keys = 0", NO_PARAMS).unwrap();
@ -465,6 +483,7 @@ fn main() {
pocketbook::dialog(
pocketbook::Icon::Info,
"The database seems to be ok.\nNothing had to be fixed.",
&["OK"],
);
} else {
pocketbook::dialog(
@ -473,6 +492,7 @@ fn main() {
"Authors fixed: {}\nBooks cleaned from DB: {}",
&stat.authors_fixed, &stat.ghost_books_cleaned
),
&["OK"],
);
}
} else {

View File

@ -12,7 +12,7 @@ pub enum Icon {
WLan,
}
pub fn dialog(icon: Icon, text: &str) {
pub fn dialog(icon: Icon, text: &str, buttons: &[&str]) -> i32 {
let iconstr = match icon {
Icon::None => "0",
Icon::Info => "1",
@ -22,8 +22,10 @@ pub fn dialog(icon: Icon, text: &str) {
Icon::WLan => "5",
};
Command::new(DIALOG_PATH)
.args(&[iconstr, "", text, "OK"])
let res = Command::new(DIALOG_PATH)
.args([&[iconstr, "", text], buttons].concat())
.output()
.unwrap();
res.status.code().unwrap_or(-1)
}