ui: add wifi_hidden_prompt dialog

Modal SSID + optional passphrase prompt with the same callback shape as
wifi_auth_prompt. Used by the upcoming popup "Hidden..." button.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
nemunaire 2026-04-09 12:02:41 +07:00
commit dcf0fd00a0
5 changed files with 153 additions and 7 deletions

View file

@ -3,6 +3,7 @@
typedef struct _Auth_Ctx
{
Evas_Object *win; /* top-level window hosting the popup */
Evas_Object *popup;
Evas_Object *entry;
Wifi_Auth_Cb cb;
@ -16,7 +17,7 @@ _finish(Auth_Ctx *c, Eina_Bool ok, const char *pass)
if (c->fired) return;
c->fired = EINA_TRUE;
if (c->cb) c->cb(c->data, pass, ok);
evas_object_del(c->popup);
if (c->win) evas_object_del(c->win);
free(c);
}
@ -40,14 +41,28 @@ _on_del(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *ev EI
_finish(data, EINA_FALSE, NULL);
}
void
wifi_auth_prompt(Evas_Object *parent, const char *ssid,
Evas_Object *
wifi_auth_prompt(Evas_Object *parent EINA_UNUSED, const char *ssid,
Wifi_Auth_Cb cb, void *data)
{
Auth_Ctx *c = calloc(1, sizeof(*c));
c->cb = cb; c->data = data;
Evas_Object *p = elm_popup_add(parent);
/* A floating top-level window so the popup is actually visible —
* elm_popup parented to a gadcon popup's sub-canvas never shows. */
Evas_Object *win = elm_win_add(NULL, "eiwd-auth", ELM_WIN_DIALOG_BASIC);
elm_win_title_set(win, "iwd Wi-Fi");
elm_win_autodel_set(win, EINA_TRUE);
elm_win_center(win, EINA_TRUE, EINA_TRUE);
evas_object_resize(win, 360, 200);
c->win = win;
Evas_Object *bg = elm_bg_add(win);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
evas_object_show(bg);
Evas_Object *p = elm_popup_add(win);
c->popup = p;
char title[256];
snprintf(title, sizeof(title), "Connect to %s", ssid ? ssid : "network");
@ -79,8 +94,10 @@ wifi_auth_prompt(Evas_Object *parent, const char *ssid,
elm_object_part_content_set(p, "button2", bok);
evas_object_smart_callback_add(bok, "clicked", _on_ok, c);
evas_object_event_callback_add(p, EVAS_CALLBACK_DEL, _on_del, c);
evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _on_del, c);
evas_object_show(p);
evas_object_show(win);
elm_object_focus_set(entry, EINA_TRUE);
return win;
}