Added a confirmation dialog before removing an account. Fixes #51

This commit is contained in:
Dennis Fink 2017-10-30 17:08:19 +01:00 committed by fiaxh
parent 193ca0b671
commit a45ba28541

View file

@ -126,15 +126,23 @@ public class Dialog : Gtk.Dialog {
} }
private void remove_account(AccountRow account_item) { private void remove_account(AccountRow account_item) {
account_list.remove(account_item); Gtk.MessageDialog msg = new Gtk.MessageDialog (
account_list.queue_draw(); this, Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL,
if (account_item.account.enabled) account_disabled(account_item.account); Gtk.MessageType.WARNING, Gtk.ButtonsType.YES_NO,
account_item.account.remove(); _("Delete Account"));
if (account_list.get_row_at_index(0) != null) { msg.format_secondary_markup(_("Do you really want to delete <b>%s</b>? This action is irreversible!"), account_item.jid_label.get_text());
account_list.select_row(account_list.get_row_at_index(0)); if (msg.run() == Gtk.ResponseType.YES) {
} else { account_list.remove(account_item);
main_stack.set_visible_child_name("no_accounts"); account_list.queue_draw();
if (account_item.account.enabled) account_disabled(account_item.account);
account_item.account.remove();
if (account_list.get_row_at_index(0) != null) {
account_list.select_row(account_list.get_row_at_index(0));
} else {
main_stack.set_visible_child_name("no_accounts");
}
} }
msg.close();
} }
private void on_account_list_row_selected(ListBoxRow? row) { private void on_account_list_row_selected(ListBoxRow? row) {