From 853e6ae4546607ee64c0675c6de0564f04147c57 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Wed, 29 Apr 2026 11:30:33 +0700 Subject: [PATCH] popup: confirmation dialog before Forget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Forget destroys the saved passphrase irreversibly. A stray click on the ✕ next to a known network would wipe credentials with no recovery and (until the previous commit) no error feedback either. Add an elm_popup confirmation that names the SSID before invoking Forget. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/e_mod_popup.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/e_mod_popup.c b/src/e_mod_popup.c index c55a9f3..3bd28bc 100644 --- a/src/e_mod_popup.c +++ b/src/e_mod_popup.c @@ -152,12 +152,53 @@ _on_net_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED) iwd_network_connect(n); } +static void _forget_confirm_yes(void *data, Evas_Object *obj, void *ev EINA_UNUSED) +{ + /* The popup that owns the button is on `obj`'s parent chain — close it. */ + Iwd_Network *n = data; + if (n) iwd_network_forget(n); + Evas_Object *pp = evas_object_data_get(obj, "_eiwd_confirm_popup"); + if (pp) evas_object_del(pp); +} + +static void _forget_confirm_no(void *data EINA_UNUSED, Evas_Object *obj, void *ev EINA_UNUSED) +{ + Evas_Object *pp = evas_object_data_get(obj, "_eiwd_confirm_popup"); + if (pp) evas_object_del(pp); +} + static void _on_net_forget(void *data, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED) { Iwd_Network *n = data; if (!n) return; - iwd_network_forget(n); + + /* Forget destroys the saved passphrase irreversibly — confirm first. + * A stray click on the ✕ next to a known network would otherwise wipe + * credentials with no recovery. */ + Evas_Object *parent = _popup ? _popup->box : e_comp->elm; + Evas_Object *pp = elm_popup_add(parent); + char msg[256]; + snprintf(msg, sizeof(msg), + "Forget saved network %s?
" + "The passphrase will be permanently deleted.", + n->ssid ? n->ssid : "(hidden)"); + elm_object_part_text_set(pp, "title,text", "Forget network"); + elm_object_text_set(pp, msg); + + Evas_Object *yes = elm_button_add(pp); + elm_object_text_set(yes, "Forget"); + evas_object_data_set(yes, "_eiwd_confirm_popup", pp); + evas_object_smart_callback_add(yes, "clicked", _forget_confirm_yes, n); + elm_object_part_content_set(pp, "button1", yes); + + Evas_Object *no = elm_button_add(pp); + elm_object_text_set(no, "Cancel"); + evas_object_data_set(no, "_eiwd_confirm_popup", pp); + evas_object_smart_callback_add(no, "clicked", _forget_confirm_no, NULL); + elm_object_part_content_set(pp, "button2", no); + + evas_object_show(pp); } static void