[PATCH] 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.
---
 clients/tui/nmtui-connect.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/clients/tui/nmtui-connect.c b/clients/tui/nmtui-connect.c
index 1ea20305e..ea332096c 100644
--- a/clients/tui/nmtui-connect.c
+++ b/clients/tui/nmtui-connect.c
@@ -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);
 }
-- 
2.26.2



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]