/* * Callback to give to curses_widget_set_click_cb, for textboxes * that pop up a list of options from which the user can select. */ static int cb_click_select_option(struct curses_widget *w) { struct dfui_field *fi = w->userdata; struct dfui_option *o; struct curses_form *cf; struct curses_widget *button, *cw; cf = curses_form_new("* select *"); for (o = dfui_field_option_get_first(fi); o != NULL; o = dfui_option_get_next(o)) { button = curses_form_widget_add(cf, 1, cf->height++, 0, CURSES_BUTTON, dfui_option_get_value(o), 0, CURSES_WIDGET_WIDEN); curses_widget_set_click_cb(button, cb_click_close_form); } curses_form_finalize(cf); curses_form_draw(cf); curses_form_refresh(cf); cw = curses_form_frob(cf); curses_textbox_set_text(w, cw->text); curses_form_free(cf); curses_form_refresh(NULL); return(0); }
static struct dfui_response * #ifdef SIGNAL_HANDLING present_form(struct dfui_connection *c, struct dfui_form *f) #else present_form(struct dfui_connection *c __unused, struct dfui_form *f) #endif { struct dfui_response *r = NULL; struct curses_form *cf; struct curses_widget *cw; cf = curses_form_construct_from_dfui_form(f); curses_form_draw(cf); curses_form_refresh(cf); cw = curses_form_frob(cf); #ifdef SIGNAL_HANDLING if (caught_signal) abort_frontend(c); #endif r = response_construct_from_curses_form(f, cf, cw); curses_form_free(cf); curses_form_refresh(NULL); return(r); } static void usage(char **argv) { fprintf(stderr, _("Usage: %s " "[-b backdrop] [-r rendezvous] [-t npipe|tcp]\n"), argv[0]);