From f4f9c9fa3ccdf6430bb4fba2548464f91cc8504c Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 26 Apr 2016 23:22:07 +0200 Subject: [PATCH] tui: quit from top-level form when exiting The top-level form was left on screen after exit (this is visible only on some types of terminal as vt100), breaking automated tests. Fixes: b2fb80928e27dc29240e604bab4f391302fc71f3 --- clients/tui/nmtui.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/clients/tui/nmtui.c b/clients/tui/nmtui.c index 4ed74d408..70cad5d6a 100644 --- a/clients/tui/nmtui.c +++ b/clients/tui/nmtui.c @@ -61,6 +61,18 @@ static const struct { nmtui_hostname } }; static const int num_subprograms = G_N_ELEMENTS (subprograms); +static NmtNewtForm *toplevel_form; + +static NmtNewtForm * +quit_func (int argc, char **argv) +{ + if (toplevel_form) + nmt_newt_form_quit (toplevel_form); + + nmtui_quit (); + + return NULL; +} static void main_list_activated (NmtNewtWidget *widget, NmtNewtListbox *listbox) @@ -115,7 +127,7 @@ nmtui_main (gboolean is_top, int argc, char **argv) subprograms[i].func); } nmt_newt_listbox_append (listbox, "", NULL); - nmt_newt_listbox_append (listbox, _("Quit"), nmtui_quit); + nmt_newt_listbox_append (listbox, _("Quit"), quit_func); widget = nmt_newt_button_box_new (NMT_NEWT_BUTTON_BOX_HORIZONTAL); nmt_newt_grid_add (grid, widget, 0, 2); @@ -125,6 +137,8 @@ nmtui_main (gboolean is_top, int argc, char **argv) g_signal_connect (ok, "activated", G_CALLBACK (main_list_activated), listbox); + toplevel_form = form; + return form; }