nmtui: show error on connection deactivation failure

When a failure occurs on deactivation of a connection, no error was
shown on the TUI client. It was not obvious if anything was actually
happening after pressing the <Deactivate> button.

This patch shows the error in a dialog just like we do when a failure
occurs on activation of a connection.

https://mail.gnome.org/archives/networkmanager-list/2020-May/msg00004.html
This commit is contained in:
Olivier Gayot 2020-05-09 17:19:11 +02:00 committed by Thomas Haller
parent 779e5c0efb
commit 0b9f0b3080
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -221,6 +221,17 @@ add_and_activate_callback (GObject *client,
nmt_sync_op_complete_pointer (op, ac, NULL);
}
static void
deactivate_connection (NMActiveConnection *ac)
{
GError *error = NULL;
if (!nm_client_deactivate_connection (nm_client, ac, NULL, &error)) {
nmt_newt_message_dialog (_("Could not deactivate connection: %s"), error->message);
g_clear_error (&error);
}
}
static void
activate_connection (NMConnection *connection,
NMDevice *device,
@ -349,7 +360,7 @@ listbox_activated (NmtNewtListbox *listbox,
return;
if (ac)
nm_client_deactivate_connection (nm_client, ac, NULL, NULL);
deactivate_connection (ac);
else
activate_connection (connection, device, specific_object);
}