diff options
author | Cyber Phantom <inam123451@gmail.com> | 2023-02-26 03:30:32 +0530 |
---|---|---|
committer | Felipe Borges <felipeborges@gnome.org> | 2023-04-11 11:28:26 +0000 |
commit | 4b450409c5ffc24bacfbed45a966111b241be98e (patch) | |
tree | 9815d4b350ba9eab7b6d777e1fd503185e6bcc1b /panels | |
parent | 0524a6eee6e30fa9a32b299549a5faf7dd3888cc (diff) | |
download | gnome-control-center-4b450409c5ffc24bacfbed45a966111b241be98e.tar.gz |
wifi: Add a confirmation dialog when forgetting a connection
Destructive actions are supposed to have a dialog asking the user for confirmation.
This commit adds the confirmation dialog when user tries to forget a wifi network.
Fixes #2371
Diffstat (limited to 'panels')
-rw-r--r-- | panels/network/connection-editor/ce-page-details.c | 31 | ||||
-rw-r--r-- | panels/network/connection-editor/ce-page-details.h | 1 |
2 files changed, 31 insertions, 1 deletions
diff --git a/panels/network/connection-editor/ce-page-details.c b/panels/network/connection-editor/ce-page-details.c index 782d8f73b..8b4341e24 100644 --- a/panels/network/connection-editor/ce-page-details.c +++ b/panels/network/connection-editor/ce-page-details.c @@ -73,9 +73,38 @@ G_DEFINE_TYPE_WITH_CODE (CEPageDetails, ce_page_details, GTK_TYPE_GRID, G_IMPLEMENT_INTERFACE (ce_page_get_type (), ce_page_iface_init)) static void +on_forget_cb (AdwMessageDialog *dialog, + gchar *response, + CEPageDetails *self) +{ + if (g_strcmp0 (response, "forget") == 0) + net_connection_editor_forget (self->editor); +} + +static void forget_cb (CEPageDetails *self) { - net_connection_editor_forget (self->editor); + GtkWidget *dialog; + GtkNative *native; + + native = gtk_widget_get_native (GTK_WIDGET (self)); + + dialog = adw_message_dialog_new (GTK_WINDOW (native), + _("Forget Connection?"), + _("Network details for the selected networks, including passwords and any custom configuration will be lost.")); + + adw_message_dialog_add_responses (ADW_MESSAGE_DIALOG (dialog), + "cancel", _("_Cancel"), + "forget", _("Forget"), + NULL); + adw_message_dialog_set_response_appearance (ADW_MESSAGE_DIALOG (dialog), + "forget", + ADW_RESPONSE_DESTRUCTIVE); + adw_message_dialog_set_default_response (ADW_MESSAGE_DIALOG (dialog), "cancel"); + adw_message_dialog_set_close_response (ADW_MESSAGE_DIALOG (dialog), "cancel"); + + g_signal_connect (dialog, "response", G_CALLBACK (on_forget_cb), self); + gtk_window_present (GTK_WINDOW (dialog)); } static gchar * diff --git a/panels/network/connection-editor/ce-page-details.h b/panels/network/connection-editor/ce-page-details.h index 4fd660c16..59c53a0ec 100644 --- a/panels/network/connection-editor/ce-page-details.h +++ b/panels/network/connection-editor/ce-page-details.h @@ -22,6 +22,7 @@ #pragma once #include <gtk/gtk.h> +#include <adwaita.h> #include <NetworkManager.h> #include "net-connection-editor.h" |