Commit 6ee5c993 authored by Julian Sparber's avatar Julian Sparber

accountsettings: show confirm dialog when deleting account

* Minor fix: disable add/delete button while loading (with spinner)

https://gitlab.gnome.org/World/fractal/issues/21
parent 9a2dada9
......@@ -139,6 +139,7 @@
<object class="GtkBox" id="account_settings_email">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">6</property>
<property name="hexpand">True</property>
</object>
<packing>
......@@ -166,6 +167,7 @@
<object class="GtkBox" id="account_settings_phone">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">6</property>
<property name="hexpand">True</property>
</object>
<packing>
......
......@@ -86,6 +86,9 @@ pub fn backend_loop(rx: Receiver<BKResponse>) {
let u = Some(username);
APPOP!(set_username, (u));
}
Ok(BKResponse::AccountDestruction) => {
APPOP!(account_destruction_logoff);
}
Ok(BKResponse::Avatar(path)) => {
let av = Some(path);
APPOP!(set_avatar, (av));
......@@ -192,6 +195,11 @@ pub fn backend_loop(rx: Receiver<BKResponse>) {
}
// errors
Ok(BKResponse::AccountDestructionError(err)) => {
let error = gettext("Couldn't delete the account");
println!("ERROR: {:?}", err);
APPOP!(show_error_dialog, (error));
},
Ok(BKResponse::ChangePasswordError(err)) => {
let error = gettext("Couldn't change the password");
println!("ERROR: {:?}", err);
......
......@@ -182,6 +182,9 @@ impl AppOp {
let password_btn_stack = self.ui.builder
.get_object::<gtk::Stack>("account_settings_password_stack")
.expect("Can't find account_settings_password_stack in ui file.");
let destruction_flag = self.ui.builder
.get_object::<gtk::CheckButton>("account_settings_delete_check")
.expect("Can't find account_settings_delete_check in ui file.");
stack.set_visible_child_name("loading");
self.get_three_pid();
......@@ -204,6 +207,7 @@ impl AppOp {
password_btn_stack.set_visible_child_name("label");
password_btn.set_sensitive(true);
destruction_flag.set_active(false);
destruction_btn.set_sensitive(false);
destruction_entry.set_text("");
......@@ -431,11 +435,35 @@ impl AppOp {
let mark = self.ui.builder
.get_object::<gtk::CheckButton>("account_settings_delete_check")
.expect("Can't find account_settings_delete_check in ui file.");
let parent = self.ui.builder
.get_object::<gtk::Dialog>("account_settings_dialog")
.expect("Can't find account_settings_dialog in ui file.");
let msg = String::from("Are you sure you wan't do delete your account?");
let flags = gtk::DialogFlags::MODAL | gtk::DialogFlags::DESTROY_WITH_PARENT;
let dialog = gtk::MessageDialog::new(Some(&parent), flags, gtk::MessageType::Warning, gtk::ButtonsType::None, &msg);
dialog.add_button("Confirm", gtk::ResponseType::Ok.into());
dialog.add_button("Cancel", gtk::ResponseType::Cancel.into());
let flag = mark.get_active();
if let Some(password) = entry.get_text() {
if let Some(mxid) = self.uid.clone() {
let _ = self.backend.send(BKCommand::AccountDestruction(mxid, password, flag));
let backend = self.backend.clone();
dialog.connect_response(clone!(mxid, password, flag => move |w, r| {
match gtk::ResponseType::from(r) {
gtk::ResponseType::Ok => {
let _ = backend.send(BKCommand::AccountDestruction(mxid.clone(), password.clone(), flag));
},
_ => {}
}
w.destroy();
}));
dialog.show_all();
}
}
}
pub fn account_destruction_logoff(&self) {
/* Do logout */
}
}
......@@ -198,6 +198,7 @@ impl<'a> Address<'a> {
let spinner = gtk::Spinner::new();
spinner.start();
w.set_image(&spinner);
w.set_sensitive(false);
entry.set_editable(false);
backend.send(
BKCommand::DeleteThreePID(String::from("msisdn"), address)).unwrap();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment