diff --git a/config.c b/config.c index c4c932a9..062fe9b6 100644 --- a/config.c +++ b/config.c @@ -29,7 +29,7 @@ void conf_radiobutton_handler(dlgcontrol *ctrl, dlgparam *dlg, * is the one selected. */ if (event == EVENT_REFRESH) { - int val = conf_get_int(conf, ctrl->radio.context.i); + int val = conf_get_int(conf, ctrl->context.i); for (button = 0; button < ctrl->radio.nbuttons; button++) if (val == ctrl->radio.buttondata[button].i) break; @@ -39,7 +39,7 @@ void conf_radiobutton_handler(dlgcontrol *ctrl, dlgparam *dlg, } else if (event == EVENT_VALCHANGE) { button = dlg_radiobutton_get(ctrl, dlg); assert(button >= 0 && button < ctrl->radio.nbuttons); - conf_set_int(conf, ctrl->radio.context.i, + conf_set_int(conf, ctrl->context.i, ctrl->radio.buttondata[button].i); } } @@ -56,7 +56,7 @@ void conf_radiobutton_bool_handler(dlgcontrol *ctrl, dlgparam *dlg, * config option. */ if (event == EVENT_REFRESH) { - int val = conf_get_bool(conf, ctrl->radio.context.i); + int val = conf_get_bool(conf, ctrl->context.i); for (button = 0; button < ctrl->radio.nbuttons; button++) if (val == ctrl->radio.buttondata[button].i) break; @@ -66,7 +66,7 @@ void conf_radiobutton_bool_handler(dlgcontrol *ctrl, dlgparam *dlg, } else if (event == EVENT_VALCHANGE) { button = dlg_radiobutton_get(ctrl, dlg); assert(button >= 0 && button < ctrl->radio.nbuttons); - conf_set_bool(conf, ctrl->radio.context.i, + conf_set_bool(conf, ctrl->context.i, ctrl->radio.buttondata[button].i); } } @@ -83,7 +83,7 @@ void conf_checkbox_handler(dlgcontrol *ctrl, dlgparam *dlg, * For a standard checkbox, the context parameter gives the * primary key (CONF_foo), optionally ORed with CHECKBOX_INVERT. */ - key = ctrl->checkbox.context.i; + key = ctrl->context.i; if (key & CHECKBOX_INVERT) { key &= ~CHECKBOX_INVERT; invert = true; @@ -120,8 +120,8 @@ void conf_editbox_handler(dlgcontrol *ctrl, dlgparam *dlg, * context2 == -1000, then typing 1.2 into the box will set * the field to 1200.) */ - int key = ctrl->editbox.context.i; - int length = ctrl->editbox.context2.i; + int key = ctrl->context.i; + int length = ctrl->context2.i; Conf *conf = (Conf *)data; if (length > 0) { @@ -156,7 +156,7 @@ void conf_editbox_handler(dlgcontrol *ctrl, dlgparam *dlg, void conf_filesel_handler(dlgcontrol *ctrl, dlgparam *dlg, void *data, int event) { - int key = ctrl->fileselect.context.i; + int key = ctrl->context.i; Conf *conf = (Conf *)data; if (event == EVENT_REFRESH) { @@ -172,7 +172,7 @@ void conf_filesel_handler(dlgcontrol *ctrl, dlgparam *dlg, void conf_fontsel_handler(dlgcontrol *ctrl, dlgparam *dlg, void *data, int event) { - int key = ctrl->fontselect.context.i; + int key = ctrl->context.i; Conf *conf = (Conf *)data; if (event == EVENT_REFRESH) { @@ -274,7 +274,7 @@ static void config_protocols_handler(dlgcontrol *ctrl, dlgparam *dlg, { Conf *conf = (Conf *)data; int curproto = conf_get_int(conf, CONF_protocol); - struct hostport *hp = (struct hostport *)ctrl->generic.context.p; + struct hostport *hp = (struct hostport *)ctrl->context.p; if (event == EVENT_REFRESH) { /* @@ -716,7 +716,7 @@ static void sshbug_handler(dlgcontrol *ctrl, dlgparam *dlg, * spurious SELCHANGE we trigger in the process will overwrite * the value we wanted to keep. */ - int oldconf = conf_get_int(conf, ctrl->listbox.context.i); + int oldconf = conf_get_int(conf, ctrl->context.i); dlg_update_start(ctrl, dlg); dlg_listbox_clear(ctrl, dlg); dlg_listbox_addwithid(ctrl, dlg, "Auto", AUTO); @@ -734,7 +734,7 @@ static void sshbug_handler(dlgcontrol *ctrl, dlgparam *dlg, i = AUTO; else i = dlg_listbox_getid(ctrl, dlg, i); - conf_set_int(conf, ctrl->listbox.context.i, i); + conf_set_int(conf, ctrl->context.i, i); } } @@ -749,7 +749,7 @@ static void sshbug_handler_manual_only(dlgcontrol *ctrl, dlgparam *dlg, */ Conf *conf = (Conf *)data; if (event == EVENT_REFRESH) { - int oldconf = conf_get_int(conf, ctrl->listbox.context.i); + int oldconf = conf_get_int(conf, ctrl->context.i); dlg_update_start(ctrl, dlg); dlg_listbox_clear(ctrl, dlg); dlg_listbox_addwithid(ctrl, dlg, "Off", FORCE_OFF); @@ -765,7 +765,7 @@ static void sshbug_handler_manual_only(dlgcontrol *ctrl, dlgparam *dlg, i = FORCE_OFF; else i = dlg_listbox_getid(ctrl, dlg, i); - conf_set_int(conf, ctrl->listbox.context.i, i); + conf_set_int(conf, ctrl->context.i, i); } } @@ -818,7 +818,7 @@ static void sessionsaver_handler(dlgcontrol *ctrl, dlgparam *dlg, { Conf *conf = (Conf *)data; struct sessionsaver_data *ssd = - (struct sessionsaver_data *)ctrl->generic.context.p; + (struct sessionsaver_data *)ctrl->context.p; if (event == EVENT_REFRESH) { if (ctrl == ssd->editbox) { @@ -959,7 +959,7 @@ static void charclass_handler(dlgcontrol *ctrl, dlgparam *dlg, { Conf *conf = (Conf *)data; struct charclass_data *ccd = - (struct charclass_data *)ctrl->generic.context.p; + (struct charclass_data *)ctrl->context.p; if (event == EVENT_REFRESH) { if (ctrl == ccd->listbox) { @@ -1008,7 +1008,7 @@ static void colour_handler(dlgcontrol *ctrl, dlgparam *dlg, { Conf *conf = (Conf *)data; struct colour_data *cd = - (struct colour_data *)ctrl->generic.context.p; + (struct colour_data *)ctrl->context.p; bool update = false, clear = false; int r, g, b; @@ -1117,7 +1117,7 @@ static void ttymodes_handler(dlgcontrol *ctrl, dlgparam *dlg, { Conf *conf = (Conf *)data; struct ttymodes_data *td = - (struct ttymodes_data *)ctrl->generic.context.p; + (struct ttymodes_data *)ctrl->context.p; if (event == EVENT_REFRESH) { if (ctrl == td->listbox) { @@ -1202,7 +1202,7 @@ static void environ_handler(dlgcontrol *ctrl, dlgparam *dlg, { Conf *conf = (Conf *)data; struct environ_data *ed = - (struct environ_data *)ctrl->generic.context.p; + (struct environ_data *)ctrl->context.p; if (event == EVENT_REFRESH) { if (ctrl == ed->listbox) { @@ -1278,7 +1278,7 @@ static void portfwd_handler(dlgcontrol *ctrl, dlgparam *dlg, { Conf *conf = (Conf *)data; struct portfwd_data *pfd = - (struct portfwd_data *)ctrl->generic.context.p; + (struct portfwd_data *)ctrl->context.p; if (event == EVENT_REFRESH) { if (ctrl == pfd->listbox) { @@ -1442,7 +1442,7 @@ static void manual_hostkey_handler(dlgcontrol *ctrl, dlgparam *dlg, { Conf *conf = (Conf *)data; struct manual_hostkey_data *mh = - (struct manual_hostkey_data *)ctrl->generic.context.p; + (struct manual_hostkey_data *)ctrl->context.p; if (event == EVENT_REFRESH) { if (ctrl == mh->listbox) { @@ -1504,9 +1504,9 @@ static void clipboard_selector_handler(dlgcontrol *ctrl, dlgparam *dlg, void *data, int event) { Conf *conf = (Conf *)data; - int setting = ctrl->generic.context.i; + int setting = ctrl->context.i; #ifdef NAMED_CLIPBOARDS - int strsetting = ctrl->editbox.context2.i; + int strsetting = ctrl->context2.i; #endif static const struct { @@ -1614,7 +1614,7 @@ static void serial_parity_handler(dlgcontrol *ctrl, dlgparam *dlg, {"Mark", SER_PAR_MARK}, {"Space", SER_PAR_SPACE}, }; - int mask = ctrl->listbox.context.i; + int mask = ctrl->context.i; int i, j; Conf *conf = (Conf *)data; @@ -1668,7 +1668,7 @@ static void serial_flow_handler(dlgcontrol *ctrl, dlgparam *dlg, {"RTS/CTS", SER_FLOW_RTSCTS}, {"DSR/DTR", SER_FLOW_DSRDTR}, }; - int mask = ctrl->listbox.context.i; + int mask = ctrl->context.i; int i, j; Conf *conf = (Conf *)data; @@ -1743,7 +1743,7 @@ void proxy_type_handler(dlgcontrol *ctrl, dlgparam *dlg, ADD(PROXY_SSH_EXEC, "SSH to proxy and execute a command"); ADD(PROXY_SSH_SUBSYSTEM, "SSH to proxy and invoke a subsystem"); } - if (ctrl->generic.context.i & PROXY_UI_FLAG_LOCAL) { + if (ctrl->context.i & PROXY_UI_FLAG_LOCAL) { ADD(PROXY_CMD, "Local (run a subprogram to connect)"); } ADD(PROXY_TELNET, "'Telnet' (send an ad-hoc command)"); @@ -1805,11 +1805,11 @@ void setup_config_box(struct controlbox *b, bool midsession, HELPCTX(no_help), sessionsaver_handler, P(ssd)); ssd->okbutton->button.isdefault = true; - ssd->okbutton->generic.column = 3; + ssd->okbutton->column = 3; ssd->cancelbutton = ctrl_pushbutton(s, "Cancel", 'c', HELPCTX(no_help), sessionsaver_handler, P(ssd)); ssd->cancelbutton->button.iscancel = true; - ssd->cancelbutton->generic.column = 4; + ssd->cancelbutton->column = 4; /* We carefully don't close the 5-column part, so that platform- * specific add-ons can put extra buttons alongside Open and Cancel. */ @@ -1831,12 +1831,12 @@ void setup_config_box(struct controlbox *b, bool midsession, c = ctrl_editbox(s, HOST_BOX_TITLE, 'n', 100, HELPCTX(session_hostname), config_host_handler, I(0), I(0)); - c->generic.column = 0; + c->column = 0; hp->host = c; c = ctrl_editbox(s, PORT_BOX_TITLE, 'p', 100, HELPCTX(session_hostname), config_port_handler, I(0), I(0)); - c->generic.column = 1; + c->column = 1; hp->port = c; ctrl_columns(s, 1, 100); @@ -1845,7 +1845,7 @@ void setup_config_box(struct controlbox *b, bool midsession, c = ctrl_radiobuttons(s, NULL, NO_SHORTCUT, 3, HELPCTX(session_hostname), config_protocols_handler, P(hp), NULL); - c->generic.column = 0; + c->column = 0; hp->protradio = c; c->radio.buttons = sresize(c->radio.buttons, PROTOCOL_LIMIT, char *); c->radio.shortcuts = sresize(c->radio.shortcuts, PROTOCOL_LIMIT, char); @@ -1880,10 +1880,10 @@ void setup_config_box(struct controlbox *b, bool midsession, config_protocols_handler, P(hp)); hp->protlist = c; /* droplist is populated in config_protocols_handler */ - c->generic.column = 1; + c->column = 1; /* Vertically centre the two protocol controls w.r.t. each other */ - hp->protlist->generic.align_next_to = hp->protradio; + hp->protlist->align_next_to = hp->protradio; ctrl_columns(s, 1, 100); } @@ -1899,7 +1899,7 @@ void setup_config_box(struct controlbox *b, bool midsession, ssd->editbox = ctrl_editbox(s, "Saved Sessions", 'e', 100, HELPCTX(session_saved), sessionsaver_handler, P(ssd), P(NULL)); - ssd->editbox->generic.column = 0; + ssd->editbox->column = 0; /* Reset columns so that the buttons are alongside the list, rather * than alongside that edit box. */ ctrl_columns(s, 1, 100); @@ -1907,13 +1907,13 @@ void setup_config_box(struct controlbox *b, bool midsession, ssd->listbox = ctrl_listbox(s, NULL, NO_SHORTCUT, HELPCTX(session_saved), sessionsaver_handler, P(ssd)); - ssd->listbox->generic.column = 0; + ssd->listbox->column = 0; ssd->listbox->listbox.height = 7; if (!midsession) { ssd->loadbutton = ctrl_pushbutton(s, "Load", 'l', HELPCTX(session_saved), sessionsaver_handler, P(ssd)); - ssd->loadbutton->generic.column = 1; + ssd->loadbutton->column = 1; } else { /* We can't offer the Load button mid-session, as it would allow the * user to load and subsequently save settings they can't see. (And @@ -1925,12 +1925,12 @@ void setup_config_box(struct controlbox *b, bool midsession, ssd->savebutton = ctrl_pushbutton(s, "Save", 'v', HELPCTX(session_saved), sessionsaver_handler, P(ssd)); - ssd->savebutton->generic.column = 1; + ssd->savebutton->column = 1; if (!midsession) { ssd->delbutton = ctrl_pushbutton(s, "Delete", 'd', HELPCTX(session_saved), sessionsaver_handler, P(ssd)); - ssd->delbutton->generic.column = 1; + ssd->delbutton->column = 1; } else { /* Disable the Delete button mid-session too, for UI consistency. */ ssd->delbutton = NULL; @@ -2207,11 +2207,11 @@ void setup_config_box(struct controlbox *b, bool midsession, c = ctrl_editbox(s, "Columns", 'm', 100, HELPCTX(window_size), conf_editbox_handler, I(CONF_width), I(-1)); - c->generic.column = 0; + c->column = 0; c = ctrl_editbox(s, "Rows", 'r', 100, HELPCTX(window_size), conf_editbox_handler, I(CONF_height),I(-1)); - c->generic.column = 1; + c->column = 1; ctrl_columns(s, 1, 100); } @@ -2394,11 +2394,11 @@ void setup_config_box(struct controlbox *b, bool midsession, ccd->editbox = ctrl_editbox(s, "Set to class", 't', 50, HELPCTX(copy_charclasses), charclass_handler, P(ccd), P(NULL)); - ccd->editbox->generic.column = 0; + ccd->editbox->column = 0; ccd->button = ctrl_pushbutton(s, "Set", 's', HELPCTX(copy_charclasses), charclass_handler, P(ccd)); - ccd->button->generic.column = 1; + ccd->button->column = 1; ctrl_columns(s, 1, 100); /* @@ -2435,22 +2435,22 @@ void setup_config_box(struct controlbox *b, bool midsession, cd = (struct colour_data *)ctrl_alloc(b, sizeof(struct colour_data)); cd->listbox = ctrl_listbox(s, "Select a colour to adjust:", 'u', HELPCTX(colours_config), colour_handler, P(cd)); - cd->listbox->generic.column = 0; + cd->listbox->column = 0; cd->listbox->listbox.height = 7; c = ctrl_text(s, "RGB value:", HELPCTX(colours_config)); - c->generic.column = 1; + c->column = 1; cd->redit = ctrl_editbox(s, "Red", 'r', 50, HELPCTX(colours_config), colour_handler, P(cd), P(NULL)); - cd->redit->generic.column = 1; + cd->redit->column = 1; cd->gedit = ctrl_editbox(s, "Green", 'n', 50, HELPCTX(colours_config), colour_handler, P(cd), P(NULL)); - cd->gedit->generic.column = 1; + cd->gedit->column = 1; cd->bedit = ctrl_editbox(s, "Blue", 'e', 50, HELPCTX(colours_config), colour_handler, P(cd), P(NULL)); - cd->bedit->generic.column = 1; + cd->bedit->column = 1; cd->button = ctrl_pushbutton(s, "Modify", 'm', HELPCTX(colours_config), colour_handler, P(cd)); - cd->button->generic.column = 1; + cd->button->column = 1; ctrl_columns(s, 1, 100); /* @@ -2550,19 +2550,19 @@ void setup_config_box(struct controlbox *b, bool midsession, ed->varbox = ctrl_editbox(s, "Variable", 'v', 60, HELPCTX(telnet_environ), environ_handler, P(ed), P(NULL)); - ed->varbox->generic.column = 0; + ed->varbox->column = 0; ed->valbox = ctrl_editbox(s, "Value", 'l', 60, HELPCTX(telnet_environ), environ_handler, P(ed), P(NULL)); - ed->valbox->generic.column = 0; + ed->valbox->column = 0; ed->addbutton = ctrl_pushbutton(s, "Add", 'd', HELPCTX(telnet_environ), environ_handler, P(ed)); - ed->addbutton->generic.column = 1; + ed->addbutton->column = 1; ed->rembutton = ctrl_pushbutton(s, "Remove", 'r', HELPCTX(telnet_environ), environ_handler, P(ed)); - ed->rembutton->generic.column = 1; + ed->rembutton->column = 1; ctrl_columns(s, 1, 100); ed->listbox = ctrl_listbox(s, NULL, NO_SHORTCUT, HELPCTX(telnet_environ), @@ -2591,13 +2591,13 @@ void setup_config_box(struct controlbox *b, bool midsession, HELPCTX(proxy_main), conf_editbox_handler, I(CONF_proxy_host), I(1)); - c->generic.column = 0; + c->column = 0; c = ctrl_editbox(s, "Port", 'p', 100, HELPCTX(proxy_main), conf_editbox_handler, I(CONF_proxy_port), I(-1)); - c->generic.column = 1; + c->column = 1; ctrl_columns(s, 1, 100); ctrl_editbox(s, "Exclude Hosts/IPs", 'e', 100, HELPCTX(proxy_exclude), @@ -2803,7 +2803,7 @@ void setup_config_box(struct controlbox *b, bool midsession, ctrl_columns(s, 2, 75, 25); c = ctrl_text(s, "Host keys or fingerprints to accept:", HELPCTX(ssh_kex_manual_hostkeys)); - c->generic.column = 0; + c->column = 0; /* You want to select from the list, _then_ hit Remove. So * tab order should be that way round. */ mh = (struct manual_hostkey_data *) @@ -2811,8 +2811,8 @@ void setup_config_box(struct controlbox *b, bool midsession, mh->rembutton = ctrl_pushbutton(s, "Remove", 'r', HELPCTX(ssh_kex_manual_hostkeys), manual_hostkey_handler, P(mh)); - mh->rembutton->generic.column = 1; - mh->rembutton->generic.tabdelay = true; + mh->rembutton->column = 1; + mh->rembutton->delay_taborder = true; mh->listbox = ctrl_listbox(s, NULL, NO_SHORTCUT, HELPCTX(ssh_kex_manual_hostkeys), manual_hostkey_handler, P(mh)); @@ -2826,11 +2826,11 @@ void setup_config_box(struct controlbox *b, bool midsession, mh->keybox = ctrl_editbox(s, "Key", 'k', 80, HELPCTX(ssh_kex_manual_hostkeys), manual_hostkey_handler, P(mh), P(NULL)); - mh->keybox->generic.column = 0; + mh->keybox->column = 0; mh->addbutton = ctrl_pushbutton(s, "Add key", 'y', HELPCTX(ssh_kex_manual_hostkeys), manual_hostkey_handler, P(mh)); - mh->addbutton->generic.column = 1; + mh->addbutton->column = 1; ctrl_columns(s, 1, 100); } @@ -3007,12 +3007,12 @@ void setup_config_box(struct controlbox *b, bool midsession, td->listbox->listbox.percentages[1] = 60; ctrl_columns(s, 2, 75, 25); c = ctrl_text(s, "For selected mode, send:", HELPCTX(ssh_ttymodes)); - c->generic.column = 0; + c->column = 0; td->setbutton = ctrl_pushbutton(s, "Set", 's', HELPCTX(ssh_ttymodes), ttymodes_handler, P(td)); - td->setbutton->generic.column = 1; - td->setbutton->generic.tabdelay = true; + td->setbutton->column = 1; + td->setbutton->delay_taborder = true; ctrl_columns(s, 1, 100); /* column break */ /* Bit of a hack to get the value radio buttons and * edit-box on the same row. */ @@ -3024,12 +3024,12 @@ void setup_config_box(struct controlbox *b, bool midsession, "Nothing", NO_SHORTCUT, P(NULL), "This:", NO_SHORTCUT, P(NULL), NULL); - td->valradio->generic.column = 0; + td->valradio->column = 0; td->valbox = ctrl_editbox(s, NULL, NO_SHORTCUT, 100, HELPCTX(ssh_ttymodes), ttymodes_handler, P(td), P(NULL)); - td->valbox->generic.column = 1; - td->valbox->generic.align_next_to = td->valradio; + td->valbox->column = 1; + td->valbox->align_next_to = td->valradio; ctrl_tabdelay(s, td->setbutton); } @@ -3074,15 +3074,15 @@ void setup_config_box(struct controlbox *b, bool midsession, ctrl_columns(s, 3, 55, 20, 25); c = ctrl_text(s, "Forwarded ports:", HELPCTX(ssh_tunnels_portfwd)); - c->generic.column = COLUMN_FIELD(0,2); + c->column = COLUMN_FIELD(0,2); /* You want to select from the list, _then_ hit Remove. So tab order * should be that way round. */ pfd = (struct portfwd_data *)ctrl_alloc(b,sizeof(struct portfwd_data)); pfd->rembutton = ctrl_pushbutton(s, "Remove", 'r', HELPCTX(ssh_tunnels_portfwd), portfwd_handler, P(pfd)); - pfd->rembutton->generic.column = 2; - pfd->rembutton->generic.tabdelay = true; + pfd->rembutton->column = 2; + pfd->rembutton->delay_taborder = true; pfd->listbox = ctrl_listbox(s, NULL, NO_SHORTCUT, HELPCTX(ssh_tunnels_portfwd), portfwd_handler, P(pfd)); @@ -3098,12 +3098,12 @@ void setup_config_box(struct controlbox *b, bool midsession, pfd->addbutton = ctrl_pushbutton(s, "Add", 'd', HELPCTX(ssh_tunnels_portfwd), portfwd_handler, P(pfd)); - pfd->addbutton->generic.column = 2; - pfd->addbutton->generic.tabdelay = true; + pfd->addbutton->column = 2; + pfd->addbutton->delay_taborder = true; pfd->sourcebox = ctrl_editbox(s, "Source port", 's', 40, HELPCTX(ssh_tunnels_portfwd), portfwd_handler, P(pfd), P(NULL)); - pfd->sourcebox->generic.column = 0; + pfd->sourcebox->column = 0; pfd->destbox = ctrl_editbox(s, "Destination", 'i', 67, HELPCTX(ssh_tunnels_portfwd), portfwd_handler, P(pfd), P(NULL)); @@ -3426,7 +3426,7 @@ static void ca_ok_handler(dlgcontrol *ctrl, dlgparam *dp, static void ca_name_handler(dlgcontrol *ctrl, dlgparam *dp, void *data, int event) { - struct ca_state *st = (struct ca_state *)ctrl->generic.context.p; + struct ca_state *st = (struct ca_state *)ctrl->context.p; if (event == EVENT_REFRESH) { dlg_editbox_set(ctrl, dp, st->name); } else if (event == EVENT_VALCHANGE) { @@ -3447,7 +3447,7 @@ static void ca_name_handler(dlgcontrol *ctrl, dlgparam *dp, static void ca_reclist_handler(dlgcontrol *ctrl, dlgparam *dp, void *data, int event) { - struct ca_state *st = (struct ca_state *)ctrl->generic.context.p; + struct ca_state *st = (struct ca_state *)ctrl->context.p; if (event == EVENT_REFRESH) { dlg_update_start(ctrl, dp); dlg_listbox_clear(ctrl, dp); @@ -3464,7 +3464,7 @@ static void ca_reclist_handler(dlgcontrol *ctrl, dlgparam *dp, static void ca_load_handler(dlgcontrol *ctrl, dlgparam *dp, void *data, int event) { - struct ca_state *st = (struct ca_state *)ctrl->generic.context.p; + struct ca_state *st = (struct ca_state *)ctrl->context.p; if (event == EVENT_ACTION) { ca_load_selected_record(st, dp); } @@ -3473,7 +3473,7 @@ static void ca_load_handler(dlgcontrol *ctrl, dlgparam *dp, static void ca_save_handler(dlgcontrol *ctrl, dlgparam *dp, void *data, int event) { - struct ca_state *st = (struct ca_state *)ctrl->generic.context.p; + struct ca_state *st = (struct ca_state *)ctrl->context.p; if (event == EVENT_ACTION) { host_ca *hca = snew(host_ca); memset(hca, 0, sizeof(*hca)); @@ -3499,7 +3499,7 @@ static void ca_save_handler(dlgcontrol *ctrl, dlgparam *dp, static void ca_delete_handler(dlgcontrol *ctrl, dlgparam *dp, void *data, int event) { - struct ca_state *st = (struct ca_state *)ctrl->generic.context.p; + struct ca_state *st = (struct ca_state *)ctrl->context.p; if (event == EVENT_ACTION) { int i = dlg_listbox_index(st->ca_reclist, dp); if (i < 0) { @@ -3526,7 +3526,7 @@ static void ca_delete_handler(dlgcontrol *ctrl, dlgparam *dp, static void ca_pubkey_handler(dlgcontrol *ctrl, dlgparam *dp, void *data, int event) { - struct ca_state *st = (struct ca_state *)ctrl->generic.context.p; + struct ca_state *st = (struct ca_state *)ctrl->context.p; if (event == EVENT_REFRESH) { dlg_editbox_set(ctrl, dp, st->pubkey); } else if (event == EVENT_VALCHANGE) { @@ -3538,7 +3538,7 @@ static void ca_pubkey_handler(dlgcontrol *ctrl, dlgparam *dp, static void ca_wclist_handler(dlgcontrol *ctrl, dlgparam *dp, void *data, int event) { - struct ca_state *st = (struct ca_state *)ctrl->generic.context.p; + struct ca_state *st = (struct ca_state *)ctrl->context.p; if (event == EVENT_REFRESH) { dlg_update_start(ctrl, dp); dlg_listbox_clear(ctrl, dp); @@ -3552,7 +3552,7 @@ static void ca_wclist_handler(dlgcontrol *ctrl, dlgparam *dp, static void ca_wc_edit_handler(dlgcontrol *ctrl, dlgparam *dp, void *data, int event) { - struct ca_state *st = (struct ca_state *)ctrl->generic.context.p; + struct ca_state *st = (struct ca_state *)ctrl->context.p; if (event == EVENT_REFRESH) { dlg_editbox_set(ctrl, dp, st->wc); } else if (event == EVENT_VALCHANGE) { @@ -3564,7 +3564,7 @@ static void ca_wc_edit_handler(dlgcontrol *ctrl, dlgparam *dp, static void ca_wc_add_handler(dlgcontrol *ctrl, dlgparam *dp, void *data, int event) { - struct ca_state *st = (struct ca_state *)ctrl->generic.context.p; + struct ca_state *st = (struct ca_state *)ctrl->context.p; if (event == EVENT_ACTION) { if (!st->wc) { dlg_beep(dp); @@ -3585,7 +3585,7 @@ static void ca_wc_add_handler(dlgcontrol *ctrl, dlgparam *dp, static void ca_wc_rem_handler(dlgcontrol *ctrl, dlgparam *dp, void *data, int event) { - struct ca_state *st = (struct ca_state *)ctrl->generic.context.p; + struct ca_state *st = (struct ca_state *)ctrl->context.p; if (event == EVENT_ACTION) { int i = dlg_listbox_index(st->ca_wclist, dp); if (i < 0) { @@ -3626,7 +3626,7 @@ void setup_ca_config_box(struct controlbox *b) c = ctrl_pushbutton(s, "Done", 'o', HELPCTX(no_help), ca_ok_handler, P(st)); c->button.isdefault = true; - c->generic.column = 4; + c->column = 4; /* Load/save box, as similar as possible to the main saved sessions one */ s = ctrl_getset(b, "Main", "loadsave", @@ -3635,7 +3635,7 @@ void setup_ca_config_box(struct controlbox *b) c = ctrl_editbox(s, "Name for this CA (shown in log messages)", 'n', 100, HELPCTX(no_help), ca_name_handler, P(st), P(NULL)); - c->generic.column = 0; + c->column = 0; st->ca_name_edit = c; /* Reset columns so that the buttons are alongside the list, rather * than alongside that edit box. */ @@ -3643,18 +3643,18 @@ void setup_ca_config_box(struct controlbox *b) ctrl_columns(s, 2, 75, 25); c = ctrl_listbox(s, NULL, NO_SHORTCUT, HELPCTX(no_help), ca_reclist_handler, P(st)); - c->generic.column = 0; + c->column = 0; c->listbox.height = 6; st->ca_reclist = c; c = ctrl_pushbutton(s, "Load", 'l', HELPCTX(no_help), ca_load_handler, P(st)); - c->generic.column = 1; + c->column = 1; c = ctrl_pushbutton(s, "Save", 'v', HELPCTX(no_help), ca_save_handler, P(st)); - c->generic.column = 1; + c->column = 1; c = ctrl_pushbutton(s, "Delete", 'd', HELPCTX(no_help), ca_delete_handler, P(st)); - c->generic.column = 1; + c->column = 1; /* Box containing the details of a specific CA record */ s = ctrl_getset(b, "Main", "details", "Details of a host CA record"); @@ -3668,12 +3668,12 @@ void setup_ca_config_box(struct controlbox *b) ctrl_columns(s, 3, 70, 15, 15); c = ctrl_editbox(s, "Hostname pattern to add", 'h', 100, HELPCTX(no_help), ca_wc_edit_handler, P(st), P(NULL)); - c->generic.column = 0; + c->column = 0; st->ca_wc_edit = c; c = ctrl_pushbutton(s, "Add", NO_SHORTCUT, HELPCTX(no_help), ca_wc_add_handler, P(st)); - c->generic.column = 1; + c->column = 1; c = ctrl_pushbutton(s, "Remove", NO_SHORTCUT, HELPCTX(no_help), ca_wc_rem_handler, P(st)); - c->generic.column = 2; + c->column = 2; } diff --git a/defs.h b/defs.h index 063c05cd..cd7d0f4d 100644 --- a/defs.h +++ b/defs.h @@ -172,7 +172,7 @@ typedef struct NTRUKeyPair NTRUKeyPair; typedef struct NTRUEncodeSchedule NTRUEncodeSchedule; typedef struct dlgparam dlgparam; -typedef union control dlgcontrol; +typedef struct dlgcontrol dlgcontrol; typedef struct settings_w settings_w; typedef struct settings_r settings_r; diff --git a/dialog.c b/dialog.c index 79ef7a10..13317833 100644 --- a/dialog.c +++ b/dialog.c @@ -214,14 +214,14 @@ static dlgcontrol *ctrl_new(struct controlset *s, int type, /* * Fill in the standard fields. */ - c->generic.type = type; - c->generic.tabdelay = false; - c->generic.column = COLUMN_FIELD(0, s->ncolumns); - c->generic.helpctx = helpctx; - c->generic.handler = handler; - c->generic.context = context; - c->generic.label = NULL; - c->generic.align_next_to = NULL; + c->type = type; + c->delay_taborder = false; + c->column = COLUMN_FIELD(0, s->ncolumns); + c->helpctx = helpctx; + c->handler = handler; + c->context = context; + c->label = NULL; + c->align_next_to = NULL; return c; } @@ -252,12 +252,12 @@ dlgcontrol *ctrl_editbox(struct controlset *s, const char *label, intorptr context, intorptr context2) { dlgcontrol *c = ctrl_new(s, CTRL_EDITBOX, helpctx, handler, context); - c->editbox.label = label ? dupstr(label) : NULL; + c->label = label ? dupstr(label) : NULL; c->editbox.shortcut = shortcut; c->editbox.percentwidth = percentage; c->editbox.password = false; c->editbox.has_list = false; - c->editbox.context2 = context2; + c->context2 = context2; return c; } @@ -267,12 +267,12 @@ dlgcontrol *ctrl_combobox(struct controlset *s, const char *label, intorptr context, intorptr context2) { dlgcontrol *c = ctrl_new(s, CTRL_EDITBOX, helpctx, handler, context); - c->editbox.label = label ? dupstr(label) : NULL; + c->label = label ? dupstr(label) : NULL; c->editbox.shortcut = shortcut; c->editbox.percentwidth = percentage; c->editbox.password = false; c->editbox.has_list = true; - c->editbox.context2 = context2; + c->context2 = context2; return c; } @@ -289,7 +289,7 @@ dlgcontrol *ctrl_radiobuttons(struct controlset *s, const char *label, va_list ap; int i; dlgcontrol *c = ctrl_new(s, CTRL_RADIO, helpctx, handler, context); - c->radio.label = label ? dupstr(label) : NULL; + c->label = label ? dupstr(label) : NULL; c->radio.shortcut = shortcut; c->radio.ncolumns = ncolumns; /* @@ -333,7 +333,7 @@ dlgcontrol *ctrl_pushbutton(struct controlset *s, const char *label, handler_fn handler, intorptr context) { dlgcontrol *c = ctrl_new(s, CTRL_BUTTON, helpctx, handler, context); - c->button.label = label ? dupstr(label) : NULL; + c->label = label ? dupstr(label) : NULL; c->button.shortcut = shortcut; c->button.isdefault = false; c->button.iscancel = false; @@ -345,7 +345,7 @@ dlgcontrol *ctrl_listbox(struct controlset *s, const char *label, handler_fn handler, intorptr context) { dlgcontrol *c = ctrl_new(s, CTRL_LISTBOX, helpctx, handler, context); - c->listbox.label = label ? dupstr(label) : NULL; + c->label = label ? dupstr(label) : NULL; c->listbox.shortcut = shortcut; c->listbox.height = 5; /* *shrug* a plausible default */ c->listbox.draglist = false; @@ -362,7 +362,7 @@ dlgcontrol *ctrl_droplist(struct controlset *s, const char *label, handler_fn handler, intorptr context) { dlgcontrol *c = ctrl_new(s, CTRL_LISTBOX, helpctx, handler, context); - c->listbox.label = label ? dupstr(label) : NULL; + c->label = label ? dupstr(label) : NULL; c->listbox.shortcut = shortcut; c->listbox.height = 0; /* means it's a drop-down list */ c->listbox.draglist = false; @@ -379,7 +379,7 @@ dlgcontrol *ctrl_draglist(struct controlset *s, const char *label, handler_fn handler, intorptr context) { dlgcontrol *c = ctrl_new(s, CTRL_LISTBOX, helpctx, handler, context); - c->listbox.label = label ? dupstr(label) : NULL; + c->label = label ? dupstr(label) : NULL; c->listbox.shortcut = shortcut; c->listbox.height = 5; /* *shrug* a plausible default */ c->listbox.draglist = true; @@ -397,7 +397,7 @@ dlgcontrol *ctrl_filesel(struct controlset *s, const char *label, handler_fn handler, intorptr context) { dlgcontrol *c = ctrl_new(s, CTRL_FILESELECT, helpctx, handler, context); - c->fileselect.label = label ? dupstr(label) : NULL; + c->label = label ? dupstr(label) : NULL; c->fileselect.shortcut = shortcut; c->fileselect.filter = filter; c->fileselect.for_writing = write; @@ -410,7 +410,7 @@ dlgcontrol *ctrl_fontsel(struct controlset *s, const char *label, handler_fn handler, intorptr context) { dlgcontrol *c = ctrl_new(s, CTRL_FONTSELECT, helpctx, handler, context); - c->fontselect.label = label ? dupstr(label) : NULL; + c->label = label ? dupstr(label) : NULL; c->fontselect.shortcut = shortcut; return c; } @@ -426,7 +426,7 @@ dlgcontrol *ctrl_text(struct controlset *s, const char *text, intorptr helpctx) { dlgcontrol *c = ctrl_new(s, CTRL_TEXT, helpctx, NULL, P(NULL)); - c->text.label = dupstr(text); + c->label = dupstr(text); return c; } @@ -435,7 +435,7 @@ dlgcontrol *ctrl_checkbox(struct controlset *s, const char *label, handler_fn handler, intorptr context) { dlgcontrol *c = ctrl_new(s, CTRL_CHECKBOX, helpctx, handler, context); - c->checkbox.label = label ? dupstr(label) : NULL; + c->label = label ? dupstr(label) : NULL; c->checkbox.shortcut = shortcut; return c; } @@ -444,8 +444,8 @@ void ctrl_free(dlgcontrol *ctrl) { int i; - sfree(ctrl->generic.label); - switch (ctrl->generic.type) { + sfree(ctrl->label); + switch (ctrl->type) { case CTRL_RADIO: for (i = 0; i < ctrl->radio.nbuttons; i++) sfree(ctrl->radio.buttons[i]); diff --git a/dialog.h b/dialog.h index 28d0916c..51d481fa 100644 --- a/dialog.h +++ b/dialog.h @@ -104,317 +104,292 @@ enum { typedef void (*handler_fn)(dlgcontrol *ctrl, dlgparam *dp, void *data, int event); -#define STANDARD_PREFIX \ - int type; \ - char *label; \ - bool tabdelay; \ - int column; \ - handler_fn handler; \ - intorptr context; \ - intorptr helpctx; \ - dlgcontrol *align_next_to - -union control { +struct dlgcontrol { /* - * The first possibility in this union is the generic header - * shared by all the structures, which we are therefore allowed - * to access through any one of them. + * Generic fields shared by all the control types. */ - struct { - int type; - /* - * Every control except CTRL_COLUMNS has _some_ sort of - * label. By putting it in the `generic' union as well as - * everywhere else, we avoid having to have an irritating - * switch statement when we go through and deallocate all - * the memory in a config-box structure. - * - * Yes, this does mean that any non-NULL value in this - * field is expected to be dynamically allocated and - * freeable. - * - * For CTRL_COLUMNS, this field MUST be NULL. - */ - char *label; - /* - * If `tabdelay' is non-zero, it indicates that this - * particular control should not yet appear in the tab - * order. A subsequent CTRL_TABDELAY entry will place it. - */ - bool tabdelay; - /* - * Indicate which column(s) this control occupies. This can - * be unpacked into starting column and column span by the - * COLUMN macros above. - */ - int column; - /* - * Most controls need to provide a function which gets - * called when that control's setting is changed, or when - * the control's setting needs initialising. - * - * The `data' parameter points to the writable data being - * modified as a result of the configuration activity; for - * example, the PuTTY `Conf' structure, although not - * necessarily. - * - * The `dlg' parameter is passed back to the platform- - * specific routines to read and write the actual control - * state. - */ - handler_fn handler; - /* - * Almost all of the above functions will find it useful to - * be able to store a piece of `void *' or `int' data. - */ - intorptr context; - /* - * For any control, we also allow the storage of a piece of - * data for use by context-sensitive help. For example, on - * Windows you can click the magic question mark and then - * click a control, and help for that control should spring - * up. Hence, here is a slot in which to store per-control - * data that a particular platform-specific driver can use - * to ensure it brings up the right piece of help text. - */ - intorptr helpctx; - /* - * Setting this to non-NULL coerces two controls to have their - * y-coordinates adjusted so that they can sit alongside each - * other and look nicely aligned, even if they're different - * heights. - * - * Set this field on the _second_ control of the pair (in - * terms of order in the data structure), so that when it's - * instantiated, the first one is already there to be referred - * to. - */ - dlgcontrol *align_next_to; - } generic; - struct { - STANDARD_PREFIX; - dlgcontrol *ctrl; - } tabdelay; - struct { - STANDARD_PREFIX; - } text; - struct { - STANDARD_PREFIX; - char shortcut; /* keyboard shortcut */ - /* - * Percentage of the dialog-box width used by the edit box. - * If this is set to 100, the label is on its own line; - * otherwise the label is on the same line as the box - * itself. - */ - int percentwidth; - bool password; /* details of input are hidden */ - /* - * A special case of the edit box is the combo box, which - * has a drop-down list built in. (Note that a _non_- - * editable drop-down list is done as a special case of a - * list box.) - * - * Don't try setting has_list and password on the same - * control; front ends are not required to support that - * combination. - */ - bool has_list; - /* - * Edit boxes tend to need two items of context, so here's - * a spare. - */ - intorptr context2; - } editbox; - struct { - STANDARD_PREFIX; - /* - * `shortcut' here is a single keyboard shortcut which is - * expected to select the whole group of radio buttons. It - * can be NO_SHORTCUT if required, and there is also a way - * to place individual shortcuts on each button; see below. - */ - char shortcut; - /* - * There are separate fields for `ncolumns' and `nbuttons' - * for several reasons. - * - * Firstly, we sometimes want the last of a set of buttons - * to have a longer label than the rest; we achieve this by - * setting `ncolumns' higher than `nbuttons', and the - * layout code is expected to understand that the final - * button should be given all the remaining space on the - * line. This sounds like a ludicrously specific special - * case (if we're doing this sort of thing, why not have - * the general ability to have a particular button span - * more than one column whether it's the last one or not?) - * but actually it's reasonably common for the sort of - * three-way control you get a lot of in PuTTY: `yes' - * versus `no' versus `some more complex way to decide'. - * - * Secondly, setting `nbuttons' higher than `ncolumns' lets - * us have more than one line of radio buttons for a single - * setting. A very important special case of this is - * setting `ncolumns' to 1, so that each button is on its - * own line. - */ - int ncolumns; - int nbuttons; - /* - * This points to a dynamically allocated array of `char *' - * pointers, each of which points to a dynamically - * allocated string. - */ - char **buttons; /* `nbuttons' button labels */ - /* - * This points to a dynamically allocated array of `char' - * giving the individual keyboard shortcuts for each radio - * button. The array may be NULL if none are required. - */ - char *shortcuts; /* `nbuttons' shortcuts; may be NULL */ - /* - * This points to a dynamically allocated array of - * intorptr, giving helpful data for each button. - */ - intorptr *buttondata; /* `nbuttons' entries; may be NULL */ - } radio; - struct { - STANDARD_PREFIX; - char shortcut; - } checkbox; - struct { - STANDARD_PREFIX; - char shortcut; - /* - * At least Windows has the concept of a `default push - * button', which gets implicitly pressed when you hit - * Return even if it doesn't have the input focus. - */ - bool isdefault; - /* - * Also, the reverse of this: a default cancel-type button, - * which is implicitly pressed when you hit Escape. - */ - bool iscancel; - } button; - struct { - STANDARD_PREFIX; - char shortcut; /* keyboard shortcut */ - /* - * Height of the list box, in approximate number of lines. - * If this is zero, the list is a drop-down list. - */ - int height; /* height in lines */ - /* - * If this is set, the list elements can be reordered by - * the user (by drag-and-drop or by Up and Down buttons, - * whatever the per-platform implementation feels - * comfortable with). This is not guaranteed to work on a - * drop-down list, so don't try it! - */ - bool draglist; - /* - * If this is non-zero, the list can have more than one - * element selected at a time. This is not guaranteed to - * work on a drop-down list, so don't try it! - * - * Different non-zero values request slightly different - * types of multi-selection (this may well be meaningful - * only in GTK, so everyone else can ignore it if they - * want). 1 means the list box expects to have individual - * items selected, whereas 2 means it expects the user to - * want to select a large contiguous range at a time. - */ - int multisel; - /* - * Percentage of the dialog-box width used by the list box. - * If this is set to 100, the label is on its own line; - * otherwise the label is on the same line as the box - * itself. Setting this to anything other than 100 is not - * guaranteed to work on a _non_-drop-down list, so don't - * try it! - */ - int percentwidth; - /* - * Some list boxes contain strings that contain tab - * characters. If `ncols' is greater than 0, then - * `percentages' is expected to be non-zero and to contain - * the respective widths of `ncols' columns, which together - * will exactly fit the width of the list box. Otherwise - * `percentages' must be NULL. - * - * There should never be more than one column in a - * drop-down list (one with height==0), because front ends - * may have to implement it as a special case of an - * editable combo box. - */ - int ncols; /* number of columns */ - int *percentages; /* % width of each column */ - /* - * Flag which can be set to false to suppress the horizontal - * scroll bar if a list box entry goes off the right-hand - * side. - */ - bool hscroll; - } listbox; - struct { - STANDARD_PREFIX; - char shortcut; - /* - * `filter' dictates what type of files will be selected by - * default; for example, when selecting private key files - * the file selector would do well to only show .PPK files - * (on those systems where this is the chosen extension). - * - * The precise contents of `filter' are platform-defined, - * unfortunately. The special value NULL means `all files' - * and is always a valid fallback. - * - * Unlike almost all strings in this structure, this value - * is NOT expected to require freeing (although of course - * you can always use ctrl_alloc if you do need to create - * one on the fly). This is because the likely mode of use - * is to define string constants in a platform-specific - * header file, and directly reference those. Or worse, a - * particular platform might choose to cast integers into - * this pointer type... - */ - char const *filter; - /* - * Some systems like to know whether a file selector is - * choosing a file to read or one to write (and possibly - * create). - */ - bool for_writing; - /* - * On at least some platforms, the file selector is a - * separate dialog box, and contains a user-settable title. - * - * This value _is_ expected to require freeing. - */ - char *title; - } fileselect; - struct { - /* In this variant, `label' MUST be NULL. */ - STANDARD_PREFIX; - int ncols; /* number of columns */ - int *percentages; /* % width of each column */ - /* - * Every time this control type appears, exactly one of - * `ncols' and the previous number of columns MUST be one. - * Attempting to allow a seamless transition from a four- - * to a five-column layout, for example, would be way more - * trouble than it was worth. If you must lay things out - * like that, define eight unevenly sized columns and use - * column-spanning a lot. But better still, just don't. - * - * `percentages' may be NULL if ncols==1, to save space. - */ - } columns; - struct { - STANDARD_PREFIX; - char shortcut; - } fontselect; + int type; + /* + * Every control except CTRL_COLUMNS has _some_ sort of label. By + * putting it in the `generic' union as well as everywhere else, + * we avoid having to have an irritating switch statement when we + * go through and deallocate all the memory in a config-box + * structure. + * + * Yes, this does mean that any non-NULL value in this field is + * expected to be dynamically allocated and freeable. + * + * For CTRL_COLUMNS, this field MUST be NULL. + */ + char *label; + /* + * If `delay_taborder' is true, it indicates that this particular + * control should not yet appear in the tab order. A subsequent + * CTRL_TABDELAY entry will place it. + */ + bool delay_taborder; + /* + * Indicate which column(s) this control occupies. This can be + * unpacked into starting column and column span by the COLUMN + * macros above. + */ + int column; + /* + * Most controls need to provide a function which gets called when + * that control's setting is changed, or when the control's + * setting needs initialising. + * + * The `data' parameter points to the writable data being modified + * as a result of the configuration activity; for example, the + * PuTTY `Conf' structure, although not necessarily. + * + * The `dlg' parameter is passed back to the platform- specific + * routines to read and write the actual control state. + */ + handler_fn handler; + /* + * Almost all of the above functions will find it useful to be + * able to store one or two pieces of `void *' or `int' data. + */ + intorptr context, context2; + /* + * For any control, we also allow the storage of a piece of data + * for use by context-sensitive help. For example, on Windows you + * can click the magic question mark and then click a control, and + * help for that control should spring up. Hence, here is a slot + * in which to store per-control data that a particular + * platform-specific driver can use to ensure it brings up the + * right piece of help text. + */ + intorptr helpctx; + /* + * Setting this to non-NULL coerces two controls to have their + * y-coordinates adjusted so that they can sit alongside each + * other and look nicely aligned, even if they're different + * heights. + * + * Set this field on the _second_ control of the pair (in terms of + * order in the data structure), so that when it's instantiated, + * the first one is already there to be referred to. + */ + dlgcontrol *align_next_to; + + /* + * Union of further fields specific to each control type. + */ + union { + struct { /* for CTRL_TABDELAY */ + dlgcontrol *ctrl; + } tabdelay; + struct { /* for CTRL_EDITBOX */ + char shortcut; /* keyboard shortcut */ + /* + * Percentage of the dialog-box width used by the edit + * box. If this is set to 100, the label is on its own + * line; otherwise the label is on the same line as the + * box itself. + */ + int percentwidth; + bool password; /* details of input are hidden */ + /* + * A special case of the edit box is the combo box, which + * has a drop-down list built in. (Note that a _non_- + * editable drop-down list is done as a special case of a + * list box.) + * + * Don't try setting has_list and password on the same + * control; front ends are not required to support that + * combination. + */ + bool has_list; + } editbox; + struct { /* for CTRL_RADIO */ + /* + * `shortcut' here is a single keyboard shortcut which is + * expected to select the whole group of radio buttons. It + * can be NO_SHORTCUT if required, and there is also a way + * to place individual shortcuts on each button; see + * below. + */ + char shortcut; + /* + * There are separate fields for `ncolumns' and `nbuttons' + * for several reasons. + * + * Firstly, we sometimes want the last of a set of buttons + * to have a longer label than the rest; we achieve this + * by setting `ncolumns' higher than `nbuttons', and the + * layout code is expected to understand that the final + * button should be given all the remaining space on the + * line. This sounds like a ludicrously specific special + * case (if we're doing this sort of thing, why not have + * the general ability to have a particular button span + * more than one column whether it's the last one or not?) + * but actually it's reasonably common for the sort of + * three-way control you get a lot of in PuTTY: `yes' + * versus `no' versus `some more complex way to decide'. + * + * Secondly, setting `nbuttons' higher than `ncolumns' + * lets us have more than one line of radio buttons for a + * single setting. A very important special case of this + * is setting `ncolumns' to 1, so that each button is on + * its own line. + */ + int ncolumns; + int nbuttons; + /* + * This points to a dynamically allocated array of `char *' + * pointers, each of which points to a dynamically + * allocated string. + */ + char **buttons; /* `nbuttons' button labels */ + /* + * This points to a dynamically allocated array of `char' + * giving the individual keyboard shortcuts for each radio + * button. The array may be NULL if none are required. + */ + char *shortcuts; /* `nbuttons' shortcuts; may be NULL */ + /* + * This points to a dynamically allocated array of + * intorptr, giving helpful data for each button. + */ + intorptr *buttondata; /* `nbuttons' entries; may be NULL */ + } radio; + struct { /* for CTRL_CHECKBOX */ + char shortcut; + } checkbox; + struct { /* for CTRL_BUTTON */ + char shortcut; + /* + * At least Windows has the concept of a `default push + * button', which gets implicitly pressed when you hit + * Return even if it doesn't have the input focus. + */ + bool isdefault; + /* + * Also, the reverse of this: a default cancel-type + * button, which is implicitly pressed when you hit + * Escape. + */ + bool iscancel; + } button; + struct { /* for CTRL_LISTBOX */ + char shortcut; /* keyboard shortcut */ + /* + * Height of the list box, in approximate number of lines. + * If this is zero, the list is a drop-down list. + */ + int height; /* height in lines */ + /* + * If this is set, the list elements can be reordered by + * the user (by drag-and-drop or by Up and Down buttons, + * whatever the per-platform implementation feels + * comfortable with). This is not guaranteed to work on a + * drop-down list, so don't try it! + */ + bool draglist; + /* + * If this is non-zero, the list can have more than one + * element selected at a time. This is not guaranteed to + * work on a drop-down list, so don't try it! + * + * Different non-zero values request slightly different + * types of multi-selection (this may well be meaningful + * only in GTK, so everyone else can ignore it if they + * want). 1 means the list box expects to have individual + * items selected, whereas 2 means it expects the user to + * want to select a large contiguous range at a time. + */ + int multisel; + /* + * Percentage of the dialog-box width used by the list + * box. If this is set to 100, the label is on its own + * line; otherwise the label is on the same line as the + * box itself. Setting this to anything other than 100 is + * not guaranteed to work on a _non_-drop-down list, so + * don't try it! + */ + int percentwidth; + /* + * Some list boxes contain strings that contain tab + * characters. If `ncols' is greater than 0, then + * `percentages' is expected to be non-zero and to contain + * the respective widths of `ncols' columns, which + * together will exactly fit the width of the list box. + * Otherwise `percentages' must be NULL. + * + * There should never be more than one column in a + * drop-down list (one with height==0), because front ends + * may have to implement it as a special case of an + * editable combo box. + */ + int ncols; /* number of columns */ + int *percentages; /* % width of each column */ + /* + * Flag which can be set to false to suppress the + * horizontal scroll bar if a list box entry goes off the + * right-hand side. + */ + bool hscroll; + } listbox; + struct { /* for CTRL_FILESELECT */ + char shortcut; + /* + * `filter' dictates what type of files will be selected + * by default; for example, when selecting private key + * files the file selector would do well to only show .PPK + * files (on those systems where this is the chosen + * extension). + * + * The precise contents of `filter' are platform-defined, + * unfortunately. The special value NULL means `all files' + * and is always a valid fallback. + * + * Unlike almost all strings in this structure, this value + * is NOT expected to require freeing (although of course + * you can always use ctrl_alloc if you do need to create + * one on the fly). This is because the likely mode of use + * is to define string constants in a platform-specific + * header file, and directly reference those. Or worse, a + * particular platform might choose to cast integers into + * this pointer type... + */ + char const *filter; + /* + * Some systems like to know whether a file selector is + * choosing a file to read or one to write (and possibly + * create). + */ + bool for_writing; + /* + * On at least some platforms, the file selector is a + * separate dialog box, and contains a user-settable + * title. + * + * This value _is_ expected to require freeing. + */ + char *title; + } fileselect; + struct { /* for CTRL_COLUMNS */ + /* In this variant, `label' MUST be NULL. */ + int ncols; /* number of columns */ + int *percentages; /* % width of each column */ + /* + * Every time this control type appears, exactly one of + * `ncols' and the previous number of columns MUST be one. + * Attempting to allow a seamless transition from a four- + * to a five-column layout, for example, would be way more + * trouble than it was worth. If you must lay things out + * like that, define eight unevenly sized columns and use + * column-spanning a lot. But better still, just don't. + * + * `percentages' may be NULL if ncols==1, to save space. + */ + } columns; + struct { /* for CTRL_FONTSELECT */ + char shortcut; + } fontselect; + }; }; #undef STANDARD_PREFIX diff --git a/unix/config-gtk.c b/unix/config-gtk.c index 5f3d7e0b..0ffb1ad9 100644 --- a/unix/config-gtk.c +++ b/unix/config-gtk.c @@ -14,7 +14,7 @@ static void about_handler(dlgcontrol *ctrl, dlgparam *dlg, void *data, int event) { if (event == EVENT_ACTION) { - about_box(ctrl->generic.context.p); + about_box(ctrl->context.p); } } @@ -31,7 +31,7 @@ void gtk_setup_config_box(struct controlbox *b, bool midsession, void *win) s = ctrl_getset(b, "", "", ""); c = ctrl_pushbutton(s, "About", 'a', HELPCTX(no_help), about_handler, P(win)); - c->generic.column = 0; + c->column = 0; } /* @@ -50,8 +50,8 @@ void gtk_setup_config_box(struct controlbox *b, bool midsession, void *win) */ for (i = 0; i < s->ncontrols; i++) { c = s->ctrls[i]; - if (c->generic.type == CTRL_CHECKBOX && - c->generic.context.i == CONF_scrollbar) { + if (c->type == CTRL_CHECKBOX && + c->context.i == CONF_scrollbar) { /* * Control i is the scrollbar checkbox. * Control s->ncontrols-1 is the scrollbar-on-left one. diff --git a/unix/config-unix.c b/unix/config-unix.c index 43d43bbd..179d8a9c 100644 --- a/unix/config-unix.c +++ b/unix/config-unix.c @@ -28,7 +28,7 @@ void unix_setup_config_box(struct controlbox *b, bool midsession, int protocol) * control. */ s = ctrl_getset(b, "Terminal", "printing", "Remote-controlled printing"); - assert(s->ncontrols == 1 && s->ctrls[0]->generic.type == CTRL_EDITBOX); + assert(s->ncontrols == 1 && s->ctrls[0]->type == CTRL_EDITBOX); s->ctrls[0]->editbox.has_list = false; /* @@ -39,9 +39,9 @@ void unix_setup_config_box(struct controlbox *b, bool midsession, int protocol) s = ctrl_getset(b, "Connection/Proxy", "basics", NULL); for (i = 0; i < s->ncontrols; i++) { c = s->ctrls[i]; - if (c->generic.type == CTRL_LISTBOX && - c->generic.handler == proxy_type_handler) { - c->generic.context.i |= PROXY_UI_FLAG_LOCAL; + if (c->type == CTRL_LISTBOX && + c->handler == proxy_type_handler) { + c->context.i |= PROXY_UI_FLAG_LOCAL; break; } } diff --git a/unix/dialog.c b/unix/dialog.c index 08572297..f6c5ab54 100644 --- a/unix/dialog.c +++ b/unix/dialog.c @@ -268,7 +268,7 @@ dlgcontrol *dlg_last_focused(dlgcontrol *ctrl, dlgparam *dp) void dlg_radiobutton_set(dlgcontrol *ctrl, dlgparam *dp, int which) { struct uctrl *uc = dlg_find_byctrl(dp, ctrl); - assert(uc->ctrl->generic.type == CTRL_RADIO); + assert(uc->ctrl->type == CTRL_RADIO); assert(uc->buttons != NULL); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(uc->buttons[which]), true); } @@ -278,7 +278,7 @@ int dlg_radiobutton_get(dlgcontrol *ctrl, dlgparam *dp) struct uctrl *uc = dlg_find_byctrl(dp, ctrl); int i; - assert(uc->ctrl->generic.type == CTRL_RADIO); + assert(uc->ctrl->type == CTRL_RADIO); assert(uc->buttons != NULL); for (i = 0; i < uc->nbuttons; i++) if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(uc->buttons[i]))) @@ -289,14 +289,14 @@ int dlg_radiobutton_get(dlgcontrol *ctrl, dlgparam *dp) void dlg_checkbox_set(dlgcontrol *ctrl, dlgparam *dp, bool checked) { struct uctrl *uc = dlg_find_byctrl(dp, ctrl); - assert(uc->ctrl->generic.type == CTRL_CHECKBOX); + assert(uc->ctrl->type == CTRL_CHECKBOX); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(uc->toplevel), checked); } bool dlg_checkbox_get(dlgcontrol *ctrl, dlgparam *dp) { struct uctrl *uc = dlg_find_byctrl(dp, ctrl); - assert(uc->ctrl->generic.type == CTRL_CHECKBOX); + assert(uc->ctrl->type == CTRL_CHECKBOX); return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(uc->toplevel)); } @@ -305,7 +305,7 @@ void dlg_editbox_set(dlgcontrol *ctrl, dlgparam *dp, char const *text) struct uctrl *uc = dlg_find_byctrl(dp, ctrl); GtkWidget *entry; char *tmpstring; - assert(uc->ctrl->generic.type == CTRL_EDITBOX); + assert(uc->ctrl->type == CTRL_EDITBOX); #if GTK_CHECK_VERSION(2,4,0) if (uc->combo) @@ -341,7 +341,7 @@ void dlg_editbox_set(dlgcontrol *ctrl, dlgparam *dp, char const *text) char *dlg_editbox_get(dlgcontrol *ctrl, dlgparam *dp) { struct uctrl *uc = dlg_find_byctrl(dp, ctrl); - assert(uc->ctrl->generic.type == CTRL_EDITBOX); + assert(uc->ctrl->type == CTRL_EDITBOX); #if GTK_CHECK_VERSION(2,4,0) if (uc->combo) { @@ -371,8 +371,8 @@ void dlg_listbox_clear(dlgcontrol *ctrl, dlgparam *dp) { struct uctrl *uc = dlg_find_byctrl(dp, ctrl); - assert(uc->ctrl->generic.type == CTRL_EDITBOX || - uc->ctrl->generic.type == CTRL_LISTBOX); + assert(uc->ctrl->type == CTRL_EDITBOX || + uc->ctrl->type == CTRL_LISTBOX); #if !GTK_CHECK_VERSION(2,4,0) if (uc->menu) { @@ -399,8 +399,8 @@ void dlg_listbox_del(dlgcontrol *ctrl, dlgparam *dp, int index) { struct uctrl *uc = dlg_find_byctrl(dp, ctrl); - assert(uc->ctrl->generic.type == CTRL_EDITBOX || - uc->ctrl->generic.type == CTRL_LISTBOX); + assert(uc->ctrl->type == CTRL_EDITBOX || + uc->ctrl->type == CTRL_LISTBOX); #if !GTK_CHECK_VERSION(2,4,0) if (uc->menu) { @@ -446,8 +446,8 @@ void dlg_listbox_addwithid(dlgcontrol *ctrl, dlgparam *dp, { struct uctrl *uc = dlg_find_byctrl(dp, ctrl); - assert(uc->ctrl->generic.type == CTRL_EDITBOX || - uc->ctrl->generic.type == CTRL_LISTBOX); + assert(uc->ctrl->type == CTRL_EDITBOX || + uc->ctrl->type == CTRL_LISTBOX); /* * This routine is long and complicated in both GTK 1 and 2, @@ -569,7 +569,7 @@ void dlg_listbox_addwithid(dlgcontrol *ctrl, dlgparam *dp, * Now go through text and divide it into columns at the tabs, * as necessary. */ - cols = (uc->ctrl->generic.type == CTRL_LISTBOX ? ctrl->listbox.ncols : 1); + cols = (uc->ctrl->type == CTRL_LISTBOX ? ctrl->listbox.ncols : 1); cols = cols ? cols : 1; for (i = 0; i < cols; i++) { int collen = strcspn(text, "\t"); @@ -593,8 +593,8 @@ int dlg_listbox_getid(dlgcontrol *ctrl, dlgparam *dp, int index) { struct uctrl *uc = dlg_find_byctrl(dp, ctrl); - assert(uc->ctrl->generic.type == CTRL_EDITBOX || - uc->ctrl->generic.type == CTRL_LISTBOX); + assert(uc->ctrl->type == CTRL_EDITBOX || + uc->ctrl->type == CTRL_LISTBOX); #if !GTK_CHECK_VERSION(2,4,0) if (uc->menu || uc->list) { @@ -632,8 +632,8 @@ int dlg_listbox_index(dlgcontrol *ctrl, dlgparam *dp) { struct uctrl *uc = dlg_find_byctrl(dp, ctrl); - assert(uc->ctrl->generic.type == CTRL_EDITBOX || - uc->ctrl->generic.type == CTRL_LISTBOX); + assert(uc->ctrl->type == CTRL_EDITBOX || + uc->ctrl->type == CTRL_LISTBOX); #if !GTK_CHECK_VERSION(2,4,0) if (uc->menu || uc->list) { @@ -716,16 +716,16 @@ bool dlg_listbox_issel(dlgcontrol *ctrl, dlgparam *dp, int index) { struct uctrl *uc = dlg_find_byctrl(dp, ctrl); - assert(uc->ctrl->generic.type == CTRL_EDITBOX || - uc->ctrl->generic.type == CTRL_LISTBOX); + assert(uc->ctrl->type == CTRL_EDITBOX || + uc->ctrl->type == CTRL_LISTBOX); #if !GTK_CHECK_VERSION(2,4,0) if (uc->menu || uc->list) { GList *children; GtkWidget *item, *activeitem; - assert(uc->ctrl->generic.type == CTRL_EDITBOX || - uc->ctrl->generic.type == CTRL_LISTBOX); + assert(uc->ctrl->type == CTRL_EDITBOX || + uc->ctrl->type == CTRL_LISTBOX); assert(uc->menu != NULL || uc->list != NULL); children = gtk_container_children(GTK_CONTAINER(uc->menu ? uc->menu : @@ -773,8 +773,8 @@ void dlg_listbox_select(dlgcontrol *ctrl, dlgparam *dp, int index) { struct uctrl *uc = dlg_find_byctrl(dp, ctrl); - assert(uc->ctrl->generic.type == CTRL_EDITBOX || - uc->ctrl->generic.type == CTRL_LISTBOX); + assert(uc->ctrl->type == CTRL_EDITBOX || + uc->ctrl->type == CTRL_LISTBOX); #if !GTK_CHECK_VERSION(2,4,0) if (uc->optmenu) { @@ -841,7 +841,7 @@ void dlg_text_set(dlgcontrol *ctrl, dlgparam *dp, char const *text) { struct uctrl *uc = dlg_find_byctrl(dp, ctrl); - assert(uc->ctrl->generic.type == CTRL_TEXT); + assert(uc->ctrl->type == CTRL_TEXT); assert(uc->text != NULL); gtk_label_set_text(GTK_LABEL(uc->text), text); @@ -851,7 +851,7 @@ void dlg_label_change(dlgcontrol *ctrl, dlgparam *dp, char const *text) { struct uctrl *uc = dlg_find_byctrl(dp, ctrl); - switch (uc->ctrl->generic.type) { + switch (uc->ctrl->type) { case CTRL_BUTTON: gtk_label_set_text(GTK_LABEL(uc->toplevel), text); shortcut_highlight(uc->toplevel, ctrl->button.shortcut); @@ -891,7 +891,7 @@ void dlg_filesel_set(dlgcontrol *ctrl, dlgparam *dp, Filename *fn) /* We must copy fn->path before passing it to gtk_entry_set_text. * See comment in dlg_editbox_set() for the reasons. */ char *duppath = dupstr(fn->path); - assert(uc->ctrl->generic.type == CTRL_FILESELECT); + assert(uc->ctrl->type == CTRL_FILESELECT); assert(uc->entry != NULL); gtk_entry_set_text(GTK_ENTRY(uc->entry), duppath); sfree(duppath); @@ -900,7 +900,7 @@ void dlg_filesel_set(dlgcontrol *ctrl, dlgparam *dp, Filename *fn) Filename *dlg_filesel_get(dlgcontrol *ctrl, dlgparam *dp) { struct uctrl *uc = dlg_find_byctrl(dp, ctrl); - assert(uc->ctrl->generic.type == CTRL_FILESELECT); + assert(uc->ctrl->type == CTRL_FILESELECT); assert(uc->entry != NULL); return filename_from_str(gtk_entry_get_text(GTK_ENTRY(uc->entry))); } @@ -911,7 +911,7 @@ void dlg_fontsel_set(dlgcontrol *ctrl, dlgparam *dp, FontSpec *fs) /* We must copy fs->name before passing it to gtk_entry_set_text. * See comment in dlg_editbox_set() for the reasons. */ char *dupname = dupstr(fs->name); - assert(uc->ctrl->generic.type == CTRL_FONTSELECT); + assert(uc->ctrl->type == CTRL_FONTSELECT); assert(uc->entry != NULL); gtk_entry_set_text(GTK_ENTRY(uc->entry), dupname); sfree(dupname); @@ -920,7 +920,7 @@ void dlg_fontsel_set(dlgcontrol *ctrl, dlgparam *dp, FontSpec *fs) FontSpec *dlg_fontsel_get(dlgcontrol *ctrl, dlgparam *dp) { struct uctrl *uc = dlg_find_byctrl(dp, ctrl); - assert(uc->ctrl->generic.type == CTRL_FONTSELECT); + assert(uc->ctrl->type == CTRL_FONTSELECT); assert(uc->entry != NULL); return fontspec_new(gtk_entry_get_text(GTK_ENTRY(uc->entry))); } @@ -950,7 +950,7 @@ void dlg_set_focus(dlgcontrol *ctrl, dlgparam *dp) { struct uctrl *uc = dlg_find_byctrl(dp, ctrl); - switch (ctrl->generic.type) { + switch (ctrl->type) { case CTRL_CHECKBOX: case CTRL_BUTTON: /* Check boxes and buttons get the focus _and_ get toggled. */ @@ -1082,15 +1082,15 @@ void dlg_refresh(dlgcontrol *ctrl, dlgparam *dp) struct uctrl *uc; if (ctrl) { - if (ctrl->generic.handler != NULL) - ctrl->generic.handler(ctrl, dp, dp->data, EVENT_REFRESH); + if (ctrl->handler != NULL) + ctrl->handler(ctrl, dp, dp->data, EVENT_REFRESH); } else { int i; for (i = 0; (uc = index234(dp->byctrl, i)) != NULL; i++) { assert(uc->ctrl != NULL); - if (uc->ctrl->generic.handler != NULL) - uc->ctrl->generic.handler(uc->ctrl, dp, + if (uc->ctrl->handler != NULL) + uc->ctrl->handler(uc->ctrl, dp, dp->data, EVENT_REFRESH); } } @@ -1221,14 +1221,14 @@ static void button_clicked(GtkButton *button, gpointer data) { struct dlgparam *dp = (struct dlgparam *)data; struct uctrl *uc = dlg_find_bywidget(dp, GTK_WIDGET(button)); - uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_ACTION); + uc->ctrl->handler(uc->ctrl, dp, dp->data, EVENT_ACTION); } static void button_toggled(GtkToggleButton *tb, gpointer data) { struct dlgparam *dp = (struct dlgparam *)data; struct uctrl *uc = dlg_find_bywidget(dp, GTK_WIDGET(tb)); - uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_VALCHANGE); + uc->ctrl->handler(uc->ctrl, dp, dp->data, EVENT_VALCHANGE); } static gboolean editbox_key(GtkWidget *widget, GdkEventKey *event, @@ -1259,7 +1259,7 @@ static void editbox_changed(GtkEditable *ed, gpointer data) struct dlgparam *dp = (struct dlgparam *)data; if (!(dp->flags & FLAG_UPDATING_COMBO_LIST)) { struct uctrl *uc = dlg_find_bywidget(dp, GTK_WIDGET(ed)); - uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_VALCHANGE); + uc->ctrl->handler(uc->ctrl, dp, dp->data, EVENT_VALCHANGE); } } @@ -1268,7 +1268,7 @@ static gboolean editbox_lostfocus(GtkWidget *ed, GdkEventFocus *event, { struct dlgparam *dp = (struct dlgparam *)data; struct uctrl *uc = dlg_find_bywidget(dp, GTK_WIDGET(ed)); - uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_REFRESH); + uc->ctrl->handler(uc->ctrl, dp, dp->data, EVENT_REFRESH); return false; } @@ -1404,7 +1404,7 @@ static gboolean listitem_button_release(GtkWidget *item, GdkEventButton *event, struct dlgparam *dp = (struct dlgparam *)data; struct uctrl *uc = dlg_find_bywidget(dp, GTK_WIDGET(item)); if (uc->nclicks>1) { - uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_ACTION); + uc->ctrl->handler(uc->ctrl, dp, dp->data, EVENT_ACTION); return true; } return false; @@ -1415,7 +1415,7 @@ static void list_selchange(GtkList *list, gpointer data) struct dlgparam *dp = (struct dlgparam *)data; struct uctrl *uc = dlg_find_bywidget(dp, GTK_WIDGET(list)); if (!uc) return; - uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_SELCHANGE); + uc->ctrl->handler(uc->ctrl, dp, dp->data, EVENT_SELCHANGE); } static void draglist_move(struct dlgparam *dp, struct uctrl *uc, int direction) @@ -1440,7 +1440,7 @@ static void draglist_move(struct dlgparam *dp, struct uctrl *uc, int direction) children = g_list_append(children, child); gtk_list_insert_items(GTK_LIST(uc->list), children, index + direction); gtk_list_select_item(GTK_LIST(uc->list), index + direction); - uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_VALCHANGE); + uc->ctrl->handler(uc->ctrl, dp, dp->data, EVENT_VALCHANGE); } static void draglist_up(GtkButton *button, gpointer data) @@ -1469,7 +1469,7 @@ static void listbox_doubleclick(GtkTreeView *treeview, GtkTreePath *path, struct dlgparam *dp = (struct dlgparam *)data; struct uctrl *uc = dlg_find_bywidget(dp, GTK_WIDGET(treeview)); if (uc) - uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_ACTION); + uc->ctrl->handler(uc->ctrl, dp, dp->data, EVENT_ACTION); } static void listbox_selchange(GtkTreeSelection *treeselection, @@ -1479,7 +1479,7 @@ static void listbox_selchange(GtkTreeSelection *treeselection, GtkTreeView *tree = gtk_tree_selection_get_tree_view(treeselection); struct uctrl *uc = dlg_find_bywidget(dp, GTK_WIDGET(tree)); if (uc) - uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_SELCHANGE); + uc->ctrl->handler(uc->ctrl, dp, dp->data, EVENT_SELCHANGE); } struct draglist_valchange_ctx { @@ -1492,7 +1492,7 @@ static gboolean draglist_valchange(gpointer data) struct draglist_valchange_ctx *ctx = (struct draglist_valchange_ctx *)data; - ctx->uc->ctrl->generic.handler(ctx->uc->ctrl, ctx->dp, + ctx->uc->ctrl->handler(ctx->uc->ctrl, ctx->dp, ctx->dp->data, EVENT_VALCHANGE); sfree(ctx); @@ -1547,7 +1547,7 @@ static void menuitem_activate(GtkMenuItem *item, gpointer data) GtkWidget *menushell = GTK_WIDGET(item)->parent; gpointer optmenu = g_object_get_data(G_OBJECT(menushell), "user-data"); struct uctrl *uc = dlg_find_bywidget(dp, GTK_WIDGET(optmenu)); - uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_SELCHANGE); + uc->ctrl->handler(uc->ctrl, dp, dp->data, EVENT_SELCHANGE); } #else @@ -1557,7 +1557,7 @@ static void droplist_selchange(GtkComboBox *combo, gpointer data) struct dlgparam *dp = (struct dlgparam *)data; struct uctrl *uc = dlg_find_bywidget(dp, GTK_WIDGET(combo)); if (uc) - uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_SELCHANGE); + uc->ctrl->handler(uc->ctrl, dp, dp->data, EVENT_SELCHANGE); } #endif /* !GTK_CHECK_VERSION(2,4,0) */ @@ -1631,7 +1631,7 @@ static void colourchoose_response(GtkDialog *dialog, dp->coloursel_result.ok = false; } - uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_CALLBACK); + uc->ctrl->handler(uc->ctrl, dp, dp->data, EVENT_CALLBACK); gtk_widget_destroy(GTK_WIDGET(dialog)); } @@ -1668,7 +1668,7 @@ static void coloursel_ok(GtkButton *button, gpointer data) } #endif dp->coloursel_result.ok = true; - uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_CALLBACK); + uc->ctrl->handler(uc->ctrl, dp, dp->data, EVENT_CALLBACK); } static void coloursel_cancel(GtkButton *button, gpointer data) @@ -1677,7 +1677,7 @@ static void coloursel_cancel(GtkButton *button, gpointer data) gpointer coloursel = g_object_get_data(G_OBJECT(button), "user-data"); struct uctrl *uc = g_object_get_data(G_OBJECT(coloursel), "user-data"); dp->coloursel_result.ok = false; - uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_CALLBACK); + uc->ctrl->handler(uc->ctrl, dp, dp->data, EVENT_CALLBACK); } #endif /* end of coloursel response handlers */ @@ -1687,7 +1687,7 @@ static void filefont_clicked(GtkButton *button, gpointer data) struct dlgparam *dp = (struct dlgparam *)data; struct uctrl *uc = dlg_find_bywidget(dp, GTK_WIDGET(button)); - if (uc->ctrl->generic.type == CTRL_FILESELECT) { + if (uc->ctrl->type == CTRL_FILESELECT) { #ifdef USE_GTK_FILE_CHOOSER_DIALOG GtkWidget *filechoose = gtk_file_chooser_dialog_new (uc->ctrl->fileselect.title, GTK_WINDOW(dp->window), @@ -1723,7 +1723,7 @@ static void filefont_clicked(GtkButton *button, gpointer data) #endif } - if (uc->ctrl->generic.type == CTRL_FONTSELECT) { + if (uc->ctrl->type == CTRL_FONTSELECT) { const gchar *fontname = gtk_entry_get_text(GTK_ENTRY(uc->entry)); #if !GTK_CHECK_VERSION(2,0,0) @@ -1822,7 +1822,7 @@ static void label_sizealloc(GtkWidget *widget, GtkAllocation *alloc, struct uctrl *uc = dlg_find_bywidget(dp, widget); gtk_widget_set_size_request(uc->text, alloc->width, -1); - gtk_label_set_text(GTK_LABEL(uc->text), uc->ctrl->generic.label); + gtk_label_set_text(GTK_LABEL(uc->text), uc->ctrl->label); g_signal_handler_disconnect(G_OBJECT(uc->text), uc->textsig); } #endif @@ -1882,7 +1882,7 @@ GtkWidget *layout_ctrls( bool left = false; GtkWidget *w = NULL; - switch (ctrl->generic.type) { + switch (ctrl->type) { case CTRL_COLUMNS: { static const int simplecols[1] = { 100 }; columns_set_cols(cols, ctrl->columns.ncols, @@ -1916,9 +1916,9 @@ GtkWidget *layout_ctrls( uc->label = NULL; uc->nclicks = 0; - switch (ctrl->generic.type) { + switch (ctrl->type) { case CTRL_BUTTON: - w = gtk_button_new_with_label(ctrl->generic.label); + w = gtk_button_new_with_label(ctrl->label); if (win) { gtk_widget_set_can_default(w, true); if (ctrl->button.isdefault) @@ -1934,7 +1934,7 @@ GtkWidget *layout_ctrls( ctrl->button.shortcut, SHORTCUT_UCTRL, uc); break; case CTRL_CHECKBOX: - w = gtk_check_button_new_with_label(ctrl->generic.label); + w = gtk_check_button_new_with_label(ctrl->label); g_signal_connect(G_OBJECT(w), "toggled", G_CALLBACK(button_toggled), dp); g_signal_connect(G_OBJECT(w), "focus_in_event", @@ -1952,8 +1952,8 @@ GtkWidget *layout_ctrls( GSList *group; w = columns_new(0); - if (ctrl->generic.label) { - GtkWidget *label = gtk_label_new(ctrl->generic.label); + if (ctrl->label) { + GtkWidget *label = gtk_label_new(ctrl->label); columns_add(COLUMNS(w), label, 0, 1); columns_force_left_align(COLUMNS(w), label); gtk_widget_show(label); @@ -2069,10 +2069,10 @@ GtkWidget *layout_ctrls( gtk_entry_set_width_chars(GTK_ENTRY(w), 1); #endif - if (ctrl->generic.label) { + if (ctrl->label) { GtkWidget *label, *container; - label = gtk_label_new(ctrl->generic.label); + label = gtk_label_new(ctrl->label); shortcut_add(scs, label, ctrl->editbox.shortcut, SHORTCUT_FOCUS, uc->entry); @@ -2105,20 +2105,20 @@ GtkWidget *layout_ctrls( case CTRL_FONTSELECT: { GtkWidget *ww; const char *browsebtn = - (ctrl->generic.type == CTRL_FILESELECT ? + (ctrl->type == CTRL_FILESELECT ? "Browse..." : "Change..."); gint percentages[] = { 75, 25 }; w = columns_new(4); columns_set_cols(COLUMNS(w), 2, percentages); - if (ctrl->generic.label) { - ww = gtk_label_new(ctrl->generic.label); + if (ctrl->label) { + ww = gtk_label_new(ctrl->label); columns_add(COLUMNS(w), ww, 0, 2); columns_force_left_align(COLUMNS(w), ww); gtk_widget_show(ww); shortcut_add(scs, ww, - (ctrl->generic.type == CTRL_FILESELECT ? + (ctrl->type == CTRL_FILESELECT ? ctrl->fileselect.shortcut : ctrl->fontselect.shortcut), SHORTCUT_UCTRL, uc); @@ -2404,10 +2404,10 @@ GtkWidget *layout_ctrls( #endif } - if (ctrl->generic.label) { + if (ctrl->label) { GtkWidget *label, *container; - label = gtk_label_new(ctrl->generic.label); + label = gtk_label_new(ctrl->label); #if GTK_CHECK_VERSION(3,0,0) gtk_label_set_width_chars(GTK_LABEL(label), 3); #endif @@ -2477,7 +2477,7 @@ GtkWidget *layout_ctrls( * wrapping labels behave sensibly. So now we can just do * the obvious thing. */ - uc->text = w = gtk_label_new(uc->ctrl->generic.label); + uc->text = w = gtk_label_new(uc->ctrl->label); #endif align_label_left(GTK_LABEL(w)); gtk_label_set_line_wrap(GTK_LABEL(w), true); @@ -2487,11 +2487,11 @@ GtkWidget *layout_ctrls( assert(w != NULL); columns_add(cols, w, - COLUMN_START(ctrl->generic.column), - COLUMN_SPAN(ctrl->generic.column)); + COLUMN_START(ctrl->column), + COLUMN_SPAN(ctrl->column)); if (left) columns_force_left_align(cols, w); - if (ctrl->generic.align_next_to) { + if (ctrl->align_next_to) { /* * Implement align_next_to by simply forcing the two * controls to have the same height of size allocation. At @@ -2502,7 +2502,7 @@ GtkWidget *layout_ctrls( * reasonably well. */ struct uctrl *uc2 = dlg_find_byctrl( - dp, ctrl->generic.align_next_to); + dp, ctrl->align_next_to); assert(uc2); columns_force_same_height(cols, w, uc2->toplevel); @@ -2657,7 +2657,7 @@ gint win_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data) * Precisely what this is depends on the type of * control. */ - switch (sc->uc->ctrl->generic.type) { + switch (sc->uc->ctrl->type) { case CTRL_CHECKBOX: case CTRL_BUTTON: /* Check boxes and buttons get the focus _and_ get toggled. */ @@ -3243,9 +3243,9 @@ GtkWidget *create_config_box(const char *title, Conf *conf, if (*s->pathname) { for (j = 0; j < s->ncontrols; j++) - if (s->ctrls[j]->generic.type != CTRL_TABDELAY && - s->ctrls[j]->generic.type != CTRL_COLUMNS && - s->ctrls[j]->generic.type != CTRL_TEXT) { + if (s->ctrls[j]->type != CTRL_TABDELAY && + s->ctrls[j]->type != CTRL_COLUMNS && + s->ctrls[j]->type != CTRL_TEXT) { dlg_set_focus(s->ctrls[j], dp); dp->lastfocus = s->ctrls[j]; done = true; @@ -3287,7 +3287,7 @@ static void messagebox_handler(dlgcontrol *ctrl, dlgparam *dp, void *data, int event) { if (event == EVENT_ACTION) - dlg_end(dp, ctrl->generic.context.i); + dlg_end(dp, ctrl->context.i); } static const struct message_box_button button_array_yn[] = { @@ -3355,7 +3355,7 @@ static GtkWidget *create_message_box_general( c = ctrl_pushbutton(s0, button->title, button->shortcut, HELPCTX(no_help), messagebox_handler, I(button->value)); - c->generic.column = index++; + c->column = index++; if (button->type > 0) c->button.isdefault = true; @@ -4025,7 +4025,7 @@ void showeventlog(eventlog_stuff *es, void *parentwin) ctrl_columns(s0, 3, 33, 34, 33); c = ctrl_pushbutton(s0, "Close", 'c', HELPCTX(no_help), eventlog_ok_handler, P(NULL)); - c->button.column = 1; + c->column = 1; c->button.isdefault = true; s1 = ctrl_getset(es->eventbox, "x", "", ""); diff --git a/windows/config.c b/windows/config.c index 4f6e6c5c..d8915728 100644 --- a/windows/config.c +++ b/windows/config.c @@ -13,7 +13,7 @@ static void about_handler(dlgcontrol *ctrl, dlgparam *dlg, void *data, int event) { - HWND *hwndp = (HWND *)ctrl->generic.context.p; + HWND *hwndp = (HWND *)ctrl->context.p; if (event == EVENT_ACTION) { modal_about_box(*hwndp); @@ -23,7 +23,7 @@ static void about_handler(dlgcontrol *ctrl, dlgparam *dlg, static void help_handler(dlgcontrol *ctrl, dlgparam *dlg, void *data, int event) { - HWND *hwndp = (HWND *)ctrl->generic.context.p; + HWND *hwndp = (HWND *)ctrl->context.p; if (event == EVENT_ACTION) { show_help(*hwndp); @@ -56,11 +56,11 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, bool has_help, s = ctrl_getset(b, "", "", ""); c = ctrl_pushbutton(s, "About", 'a', HELPCTX(no_help), about_handler, P(hwndp)); - c->generic.column = 0; + c->column = 0; if (has_help) { c = ctrl_pushbutton(s, "Help", 'h', HELPCTX(no_help), help_handler, P(hwndp)); - c->generic.column = 1; + c->column = 1; } } @@ -82,8 +82,8 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, bool has_help, int i; for (i = 0; i < s->ncontrols; i++) { c = s->ctrls[i]; - if (c->generic.type == CTRL_CHECKBOX && - c->generic.context.i == CONF_scrollbar) { + if (c->type == CTRL_CHECKBOX && + c->context.i == CONF_scrollbar) { /* * Control i is the scrollbar checkbox. * Control s->ncontrols-1 is the scrollbar-in-FS one. @@ -134,9 +134,9 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, bool has_help, int i; for (i = 0; i < s->ncontrols; i++) { c = s->ctrls[i]; - if (c->generic.type == CTRL_RADIO && - c->generic.context.i == CONF_beep) { - assert(c->generic.handler == conf_radiobutton_handler); + if (c->type == CTRL_RADIO && + c->context.i == CONF_beep) { + assert(c->handler == conf_radiobutton_handler); c->radio.nbuttons += 2; c->radio.buttons = sresize(c->radio.buttons, c->radio.nbuttons, char *); @@ -233,9 +233,9 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, bool has_help, int i; for (i = 0; i < s->ncontrols; i++) { c = s->ctrls[i]; - if (c->generic.type == CTRL_RADIO && - c->generic.context.i == CONF_vtmode) { - assert(c->generic.handler == conf_radiobutton_handler); + if (c->type == CTRL_RADIO && + c->context.i == CONF_vtmode) { + assert(c->handler == conf_radiobutton_handler); c->radio.nbuttons += 3; c->radio.buttons = sresize(c->radio.buttons, c->radio.nbuttons, char *); @@ -362,9 +362,9 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, bool has_help, s = ctrl_getset(b, "Connection/Proxy", "basics", NULL); for (i = 0; i < s->ncontrols; i++) { c = s->ctrls[i]; - if (c->generic.type == CTRL_LISTBOX && - c->generic.handler == proxy_type_handler) { - c->generic.context.i |= PROXY_UI_FLAG_LOCAL; + if (c->type == CTRL_LISTBOX && + c->handler == proxy_type_handler) { + c->context.i |= PROXY_UI_FLAG_LOCAL; break; } } diff --git a/windows/controls.c b/windows/controls.c index 7543eb13..d458496c 100644 --- a/windows/controls.c +++ b/windows/controls.c @@ -1415,7 +1415,7 @@ void winctrl_layout(struct dlgparam *dp, struct winctrls *wc, * CTRL_COLUMNS and doesn't require any control creation at * all. */ - if (ctrl->generic.type == CTRL_COLUMNS) { + if (ctrl->type == CTRL_COLUMNS) { assert((ctrl->columns.ncols == 1) ^ (ncols == 1)); if (ncols == 1) { @@ -1455,10 +1455,10 @@ void winctrl_layout(struct dlgparam *dp, struct winctrls *wc, } continue; - } else if (ctrl->generic.type == CTRL_TABDELAY) { + } else if (ctrl->type == CTRL_TABDELAY) { int i; - assert(!ctrl->generic.tabdelay); + assert(!ctrl->delay_taborder); ctrl = ctrl->tabdelay.ctrl; for (i = 0; i < ntabdelays; i++) @@ -1478,8 +1478,8 @@ void winctrl_layout(struct dlgparam *dp, struct winctrls *wc, */ int col; - colstart = COLUMN_START(ctrl->generic.column); - colspan = COLUMN_SPAN(ctrl->generic.column); + colstart = COLUMN_START(ctrl->column); + colspan = COLUMN_SPAN(ctrl->column); pos = columns[colstart]; /* structure copy */ pos.width = columns[colstart+colspan-1].width + @@ -1494,7 +1494,7 @@ void winctrl_layout(struct dlgparam *dp, struct winctrls *wc, * tabdelay list, and unset pos.hwnd to inhibit actual * control creation. */ - if (ctrl->generic.tabdelay) { + if (ctrl->delay_taborder) { assert(ntabdelays < lenof(tabdelays)); tabdelays[ntabdelays] = pos; /* structure copy */ tabdelayed[ntabdelays] = ctrl; @@ -1522,13 +1522,13 @@ void winctrl_layout(struct dlgparam *dp, struct winctrls *wc, * Now we're ready to actually create the control, by * switching on its type. */ - switch (ctrl->generic.type) { + switch (ctrl->type) { case CTRL_TEXT: { char *wrapped, *escaped; int lines; num_ids = 1; wrapped = staticwrap(&pos, cp->hwnd, - ctrl->generic.label, &lines); + ctrl->label, &lines); escaped = shortcut_escape(wrapped, NO_SHORTCUT); statictext(&pos, escaped, lines, base_id); sfree(escaped); @@ -1537,7 +1537,7 @@ void winctrl_layout(struct dlgparam *dp, struct winctrls *wc, } case CTRL_EDITBOX: num_ids = 2; /* static, edit */ - escaped = shortcut_escape(ctrl->editbox.label, + escaped = shortcut_escape(ctrl->label, ctrl->editbox.shortcut); shortcuts[nshortcuts++] = ctrl->editbox.shortcut; if (ctrl->editbox.percentwidth == 100) { @@ -1564,7 +1564,7 @@ void winctrl_layout(struct dlgparam *dp, struct winctrls *wc, struct radio *buttons; int i; - escaped = shortcut_escape(ctrl->radio.label, + escaped = shortcut_escape(ctrl->label, ctrl->radio.shortcut); shortcuts[nshortcuts++] = ctrl->radio.shortcut; @@ -1596,14 +1596,14 @@ void winctrl_layout(struct dlgparam *dp, struct winctrls *wc, } case CTRL_CHECKBOX: num_ids = 1; - escaped = shortcut_escape(ctrl->checkbox.label, + escaped = shortcut_escape(ctrl->label, ctrl->checkbox.shortcut); shortcuts[nshortcuts++] = ctrl->checkbox.shortcut; checkbox(&pos, escaped, base_id); sfree(escaped); break; case CTRL_BUTTON: - escaped = shortcut_escape(ctrl->button.label, + escaped = shortcut_escape(ctrl->label, ctrl->button.shortcut); shortcuts[nshortcuts++] = ctrl->button.shortcut; if (ctrl->button.iscancel) @@ -1614,7 +1614,7 @@ void winctrl_layout(struct dlgparam *dp, struct winctrls *wc, break; case CTRL_LISTBOX: num_ids = 2; - escaped = shortcut_escape(ctrl->listbox.label, + escaped = shortcut_escape(ctrl->label, ctrl->listbox.shortcut); shortcuts[nshortcuts++] = ctrl->listbox.shortcut; if (ctrl->listbox.draglist) { @@ -1664,7 +1664,7 @@ void winctrl_layout(struct dlgparam *dp, struct winctrls *wc, break; case CTRL_FILESELECT: num_ids = 3; - escaped = shortcut_escape(ctrl->fileselect.label, + escaped = shortcut_escape(ctrl->label, ctrl->fileselect.shortcut); shortcuts[nshortcuts++] = ctrl->fileselect.shortcut; editbutton(&pos, escaped, base_id, base_id+1, @@ -1673,7 +1673,7 @@ void winctrl_layout(struct dlgparam *dp, struct winctrls *wc, break; case CTRL_FONTSELECT: num_ids = 3; - escaped = shortcut_escape(ctrl->fontselect.label, + escaped = shortcut_escape(ctrl->label, ctrl->fontselect.shortcut); shortcuts[nshortcuts++] = ctrl->fontselect.shortcut; statictext(&pos, escaped, 1, base_id); @@ -1708,7 +1708,7 @@ void winctrl_layout(struct dlgparam *dp, struct winctrls *wc, if (actual_base_id == base_id) base_id += num_ids; - if (ctrl->generic.align_next_to) { + if (ctrl->align_next_to) { /* * Implement align_next_to by looking at the y extents * of the two controls now that both are created, and @@ -1716,7 +1716,7 @@ void winctrl_layout(struct dlgparam *dp, struct winctrls *wc, * centred on a common horizontal line. */ struct winctrl *c2 = winctrl_findbyctrl( - wc, ctrl->generic.align_next_to); + wc, ctrl->align_next_to); HWND win1 = GetDlgItem(pos.hwnd, c->align_id); HWND win2 = GetDlgItem(pos.hwnd, c2->align_id); RECT rect1, rect2; @@ -1839,7 +1839,7 @@ bool winctrl_handle_command(struct dlgparam *dp, UINT msg, ctrl = c->ctrl; id = LOWORD(wParam) - c->base_id; - if (!ctrl || !ctrl->generic.handler) + if (!ctrl || !ctrl->handler) return false; /* nothing we can do here */ /* @@ -1855,7 +1855,7 @@ bool winctrl_handle_command(struct dlgparam *dp, UINT msg, /* * Now switch on the control type and the message. */ - switch (ctrl->generic.type) { + switch (ctrl->type) { case CTRL_EDITBOX: if (msg == WM_COMMAND && !ctrl->editbox.has_list && (HIWORD(wParam) == EN_SETFOCUS || HIWORD(wParam) == EN_KILLFOCUS)) @@ -1866,7 +1866,7 @@ bool winctrl_handle_command(struct dlgparam *dp, UINT msg, if (msg == WM_COMMAND && !ctrl->editbox.has_list && HIWORD(wParam) == EN_CHANGE) - ctrl->generic.handler(ctrl, dp, dp->data, EVENT_VALCHANGE); + ctrl->handler(ctrl, dp, dp->data, EVENT_VALCHANGE); if (msg == WM_COMMAND && ctrl->editbox.has_list) { if (HIWORD(wParam) == CBN_SELCHANGE) { @@ -1882,11 +1882,11 @@ bool winctrl_handle_command(struct dlgparam *dp, UINT msg, index, (LPARAM)text); SetDlgItemText(dp->hwnd, c->base_id+1, text); sfree(text); - ctrl->generic.handler(ctrl, dp, dp->data, EVENT_VALCHANGE); + ctrl->handler(ctrl, dp, dp->data, EVENT_VALCHANGE); } else if (HIWORD(wParam) == CBN_EDITCHANGE) { - ctrl->generic.handler(ctrl, dp, dp->data, EVENT_VALCHANGE); + ctrl->handler(ctrl, dp, dp->data, EVENT_VALCHANGE); } else if (HIWORD(wParam) == CBN_KILLFOCUS) { - ctrl->generic.handler(ctrl, dp, dp->data, EVENT_REFRESH); + ctrl->handler(ctrl, dp, dp->data, EVENT_REFRESH); } } @@ -1906,7 +1906,7 @@ bool winctrl_handle_command(struct dlgparam *dp, UINT msg, (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED) && IsDlgButtonChecked(dp->hwnd, LOWORD(wParam))) { - ctrl->generic.handler(ctrl, dp, dp->data, EVENT_VALCHANGE); + ctrl->handler(ctrl, dp, dp->data, EVENT_VALCHANGE); } break; case CTRL_CHECKBOX: @@ -1916,7 +1916,7 @@ bool winctrl_handle_command(struct dlgparam *dp, UINT msg, if (msg == WM_COMMAND && (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED)) { - ctrl->generic.handler(ctrl, dp, dp->data, EVENT_VALCHANGE); + ctrl->handler(ctrl, dp, dp->data, EVENT_VALCHANGE); } break; case CTRL_BUTTON: @@ -1926,7 +1926,7 @@ bool winctrl_handle_command(struct dlgparam *dp, UINT msg, if (msg == WM_COMMAND && (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED)) { - ctrl->generic.handler(ctrl, dp, dp->data, EVENT_ACTION); + ctrl->handler(ctrl, dp, dp->data, EVENT_ACTION); } break; case CTRL_LISTBOX: @@ -1944,14 +1944,14 @@ bool winctrl_handle_command(struct dlgparam *dp, UINT msg, pret = handle_prefslist(c->data, NULL, 0, (msg != WM_COMMAND), dp->hwnd, wParam, lParam); if (pret & 2) - ctrl->generic.handler(ctrl, dp, dp->data, EVENT_VALCHANGE); + ctrl->handler(ctrl, dp, dp->data, EVENT_VALCHANGE); ret = pret & 1; } else { if (msg == WM_COMMAND && HIWORD(wParam) == LBN_DBLCLK) { SetCapture(dp->hwnd); - ctrl->generic.handler(ctrl, dp, dp->data, EVENT_ACTION); + ctrl->handler(ctrl, dp, dp->data, EVENT_ACTION); } else if (msg == WM_COMMAND && HIWORD(wParam) == LBN_SELCHANGE) { - ctrl->generic.handler(ctrl, dp, dp->data, EVENT_SELCHANGE); + ctrl->handler(ctrl, dp, dp->data, EVENT_SELCHANGE); } } break; @@ -1963,7 +1963,7 @@ bool winctrl_handle_command(struct dlgparam *dp, UINT msg, (HIWORD(wParam) == BN_SETFOCUS || HIWORD(wParam) == BN_KILLFOCUS)) winctrl_set_focus(ctrl, dp, HIWORD(wParam) == BN_SETFOCUS); if (msg == WM_COMMAND && id == 1 && HIWORD(wParam) == EN_CHANGE) - ctrl->generic.handler(ctrl, dp, dp->data, EVENT_VALCHANGE); + ctrl->handler(ctrl, dp, dp->data, EVENT_VALCHANGE); if (id == 2 && (msg == WM_COMMAND && (HIWORD(wParam) == BN_CLICKED || @@ -1988,7 +1988,7 @@ bool winctrl_handle_command(struct dlgparam *dp, UINT msg, of.Flags = 0; if (request_file(NULL, &of, false, ctrl->fileselect.for_writing)) { SetDlgItemText(dp->hwnd, c->base_id + 1, filename); - ctrl->generic.handler(ctrl, dp, dp->data, EVENT_VALCHANGE); + ctrl->handler(ctrl, dp, dp->data, EVENT_VALCHANGE); } } break; @@ -2033,7 +2033,7 @@ bool winctrl_handle_command(struct dlgparam *dp, UINT msg, dlg_fontsel_set(ctrl, dp, fs); fontspec_free(fs); - ctrl->generic.handler(ctrl, dp, dp->data, EVENT_VALCHANGE); + ctrl->handler(ctrl, dp, dp->data, EVENT_VALCHANGE); } } break; @@ -2064,7 +2064,7 @@ bool winctrl_handle_command(struct dlgparam *dp, UINT msg, dp->coloursel_result.ok = true; } else dp->coloursel_result.ok = false; - ctrl->generic.handler(ctrl, dp, dp->data, EVENT_CALLBACK); + ctrl->handler(ctrl, dp, dp->data, EVENT_CALLBACK); } return ret; @@ -2095,10 +2095,10 @@ bool winctrl_context_help(struct dlgparam *dp, HWND hwnd, int id) * This is the Windows front end, so we're allowed to assume * `helpctx.p' is a context string. */ - if (!c->ctrl || !c->ctrl->generic.helpctx.p) + if (!c->ctrl || !c->ctrl->helpctx.p) return false; /* no help available for this ctrl */ - launch_help(hwnd, c->ctrl->generic.helpctx.p); + launch_help(hwnd, c->ctrl->helpctx.p); return true; } @@ -2133,7 +2133,7 @@ bool dlg_is_visible(dlgcontrol *ctrl, dlgparam *dp) void dlg_radiobutton_set(dlgcontrol *ctrl, dlgparam *dp, int whichbutton) { struct winctrl *c = dlg_findbyctrl(dp, ctrl); - assert(c && c->ctrl->generic.type == CTRL_RADIO); + assert(c && c->ctrl->type == CTRL_RADIO); CheckRadioButton(dp->hwnd, c->base_id + 1, c->base_id + c->ctrl->radio.nbuttons, @@ -2144,7 +2144,7 @@ int dlg_radiobutton_get(dlgcontrol *ctrl, dlgparam *dp) { struct winctrl *c = dlg_findbyctrl(dp, ctrl); int i; - assert(c && c->ctrl->generic.type == CTRL_RADIO); + assert(c && c->ctrl->type == CTRL_RADIO); for (i = 0; i < c->ctrl->radio.nbuttons; i++) if (IsDlgButtonChecked(dp->hwnd, c->base_id + 1 + i)) return i; @@ -2154,28 +2154,28 @@ int dlg_radiobutton_get(dlgcontrol *ctrl, dlgparam *dp) void dlg_checkbox_set(dlgcontrol *ctrl, dlgparam *dp, bool checked) { struct winctrl *c = dlg_findbyctrl(dp, ctrl); - assert(c && c->ctrl->generic.type == CTRL_CHECKBOX); + assert(c && c->ctrl->type == CTRL_CHECKBOX); CheckDlgButton(dp->hwnd, c->base_id, checked); } bool dlg_checkbox_get(dlgcontrol *ctrl, dlgparam *dp) { struct winctrl *c = dlg_findbyctrl(dp, ctrl); - assert(c && c->ctrl->generic.type == CTRL_CHECKBOX); + assert(c && c->ctrl->type == CTRL_CHECKBOX); return 0 != IsDlgButtonChecked(dp->hwnd, c->base_id); } void dlg_editbox_set(dlgcontrol *ctrl, dlgparam *dp, char const *text) { struct winctrl *c = dlg_findbyctrl(dp, ctrl); - assert(c && c->ctrl->generic.type == CTRL_EDITBOX); + assert(c && c->ctrl->type == CTRL_EDITBOX); SetDlgItemText(dp->hwnd, c->base_id+1, text); } char *dlg_editbox_get(dlgcontrol *ctrl, dlgparam *dp) { struct winctrl *c = dlg_findbyctrl(dp, ctrl); - assert(c && c->ctrl->generic.type == CTRL_EDITBOX); + assert(c && c->ctrl->type == CTRL_EDITBOX); return GetDlgItemText_alloc(dp->hwnd, c->base_id+1); } @@ -2185,10 +2185,10 @@ void dlg_listbox_clear(dlgcontrol *ctrl, dlgparam *dp) struct winctrl *c = dlg_findbyctrl(dp, ctrl); int msg; assert(c && - (c->ctrl->generic.type == CTRL_LISTBOX || - (c->ctrl->generic.type == CTRL_EDITBOX && + (c->ctrl->type == CTRL_LISTBOX || + (c->ctrl->type == CTRL_EDITBOX && c->ctrl->editbox.has_list))); - msg = (c->ctrl->generic.type==CTRL_LISTBOX && c->ctrl->listbox.height!=0 ? + msg = (c->ctrl->type==CTRL_LISTBOX && c->ctrl->listbox.height!=0 ? LB_RESETCONTENT : CB_RESETCONTENT); SendDlgItemMessage(dp->hwnd, c->base_id+1, msg, 0, 0); } @@ -2198,10 +2198,10 @@ void dlg_listbox_del(dlgcontrol *ctrl, dlgparam *dp, int index) struct winctrl *c = dlg_findbyctrl(dp, ctrl); int msg; assert(c && - (c->ctrl->generic.type == CTRL_LISTBOX || - (c->ctrl->generic.type == CTRL_EDITBOX && + (c->ctrl->type == CTRL_LISTBOX || + (c->ctrl->type == CTRL_EDITBOX && c->ctrl->editbox.has_list))); - msg = (c->ctrl->generic.type==CTRL_LISTBOX && c->ctrl->listbox.height!=0 ? + msg = (c->ctrl->type==CTRL_LISTBOX && c->ctrl->listbox.height!=0 ? LB_DELETESTRING : CB_DELETESTRING); SendDlgItemMessage(dp->hwnd, c->base_id+1, msg, index, 0); } @@ -2211,10 +2211,10 @@ void dlg_listbox_add(dlgcontrol *ctrl, dlgparam *dp, char const *text) struct winctrl *c = dlg_findbyctrl(dp, ctrl); int msg; assert(c && - (c->ctrl->generic.type == CTRL_LISTBOX || - (c->ctrl->generic.type == CTRL_EDITBOX && + (c->ctrl->type == CTRL_LISTBOX || + (c->ctrl->type == CTRL_EDITBOX && c->ctrl->editbox.has_list))); - msg = (c->ctrl->generic.type==CTRL_LISTBOX && c->ctrl->listbox.height!=0 ? + msg = (c->ctrl->type==CTRL_LISTBOX && c->ctrl->listbox.height!=0 ? LB_ADDSTRING : CB_ADDSTRING); SendDlgItemMessage(dp->hwnd, c->base_id+1, msg, 0, (LPARAM)text); } @@ -2232,12 +2232,12 @@ void dlg_listbox_addwithid(dlgcontrol *ctrl, dlgparam *dp, struct winctrl *c = dlg_findbyctrl(dp, ctrl); int msg, msg2, index; assert(c && - (c->ctrl->generic.type == CTRL_LISTBOX || - (c->ctrl->generic.type == CTRL_EDITBOX && + (c->ctrl->type == CTRL_LISTBOX || + (c->ctrl->type == CTRL_EDITBOX && c->ctrl->editbox.has_list))); - msg = (c->ctrl->generic.type==CTRL_LISTBOX && c->ctrl->listbox.height!=0 ? + msg = (c->ctrl->type==CTRL_LISTBOX && c->ctrl->listbox.height!=0 ? LB_ADDSTRING : CB_ADDSTRING); - msg2 = (c->ctrl->generic.type==CTRL_LISTBOX && c->ctrl->listbox.height!=0 ? + msg2 = (c->ctrl->type==CTRL_LISTBOX && c->ctrl->listbox.height!=0 ? LB_SETITEMDATA : CB_SETITEMDATA); index = SendDlgItemMessage(dp->hwnd, c->base_id+1, msg, 0, (LPARAM)text); SendDlgItemMessage(dp->hwnd, c->base_id+1, msg2, index, (LPARAM)id); @@ -2247,7 +2247,7 @@ int dlg_listbox_getid(dlgcontrol *ctrl, dlgparam *dp, int index) { struct winctrl *c = dlg_findbyctrl(dp, ctrl); int msg; - assert(c && c->ctrl->generic.type == CTRL_LISTBOX); + assert(c && c->ctrl->type == CTRL_LISTBOX); msg = (c->ctrl->listbox.height != 0 ? LB_GETITEMDATA : CB_GETITEMDATA); return SendDlgItemMessage(dp->hwnd, c->base_id+1, msg, index, 0); @@ -2258,7 +2258,7 @@ int dlg_listbox_index(dlgcontrol *ctrl, dlgparam *dp) { struct winctrl *c = dlg_findbyctrl(dp, ctrl); int msg, ret; - assert(c && c->ctrl->generic.type == CTRL_LISTBOX); + assert(c && c->ctrl->type == CTRL_LISTBOX); if (c->ctrl->listbox.multisel) { assert(c->ctrl->listbox.height != 0); /* not combo box */ ret = SendDlgItemMessage(dp->hwnd, c->base_id+1, LB_GETSELCOUNT, 0, 0); @@ -2276,7 +2276,7 @@ int dlg_listbox_index(dlgcontrol *ctrl, dlgparam *dp) bool dlg_listbox_issel(dlgcontrol *ctrl, dlgparam *dp, int index) { struct winctrl *c = dlg_findbyctrl(dp, ctrl); - assert(c && c->ctrl->generic.type == CTRL_LISTBOX && + assert(c && c->ctrl->type == CTRL_LISTBOX && c->ctrl->listbox.multisel && c->ctrl->listbox.height != 0); return @@ -2287,7 +2287,7 @@ void dlg_listbox_select(dlgcontrol *ctrl, dlgparam *dp, int index) { struct winctrl *c = dlg_findbyctrl(dp, ctrl); int msg; - assert(c && c->ctrl->generic.type == CTRL_LISTBOX && + assert(c && c->ctrl->type == CTRL_LISTBOX && !c->ctrl->listbox.multisel); msg = (c->ctrl->listbox.height != 0 ? LB_SETCURSEL : CB_SETCURSEL); SendDlgItemMessage(dp->hwnd, c->base_id+1, msg, index, 0); @@ -2296,7 +2296,7 @@ void dlg_listbox_select(dlgcontrol *ctrl, dlgparam *dp, int index) void dlg_text_set(dlgcontrol *ctrl, dlgparam *dp, char const *text) { struct winctrl *c = dlg_findbyctrl(dp, ctrl); - assert(c && c->ctrl->generic.type == CTRL_TEXT); + assert(c && c->ctrl->type == CTRL_TEXT); SetDlgItemText(dp->hwnd, c->base_id, text); } @@ -2307,7 +2307,7 @@ void dlg_label_change(dlgcontrol *ctrl, dlgparam *dp, char const *text) int id = -1; assert(c); - switch (c->ctrl->generic.type) { + switch (c->ctrl->type) { case CTRL_EDITBOX: escaped = shortcut_escape(text, c->ctrl->editbox.shortcut); id = c->base_id; @@ -2348,7 +2348,7 @@ void dlg_label_change(dlgcontrol *ctrl, dlgparam *dp, char const *text) void dlg_filesel_set(dlgcontrol *ctrl, dlgparam *dp, Filename *fn) { struct winctrl *c = dlg_findbyctrl(dp, ctrl); - assert(c && c->ctrl->generic.type == CTRL_FILESELECT); + assert(c && c->ctrl->type == CTRL_FILESELECT); SetDlgItemText(dp->hwnd, c->base_id+1, fn->path); } @@ -2357,7 +2357,7 @@ Filename *dlg_filesel_get(dlgcontrol *ctrl, dlgparam *dp) struct winctrl *c = dlg_findbyctrl(dp, ctrl); char *tmp; Filename *ret; - assert(c && c->ctrl->generic.type == CTRL_FILESELECT); + assert(c && c->ctrl->type == CTRL_FILESELECT); tmp = GetDlgItemText_alloc(dp->hwnd, c->base_id+1); ret = filename_from_str(tmp); sfree(tmp); @@ -2368,7 +2368,7 @@ void dlg_fontsel_set(dlgcontrol *ctrl, dlgparam *dp, FontSpec *fs) { char *buf, *boldstr; struct winctrl *c = dlg_findbyctrl(dp, ctrl); - assert(c && c->ctrl->generic.type == CTRL_FONTSELECT); + assert(c && c->ctrl->type == CTRL_FONTSELECT); fontspec_free((FontSpec *)c->data); c->data = fontspec_copy(fs); @@ -2389,7 +2389,7 @@ void dlg_fontsel_set(dlgcontrol *ctrl, dlgparam *dp, FontSpec *fs) FontSpec *dlg_fontsel_get(dlgcontrol *ctrl, dlgparam *dp) { struct winctrl *c = dlg_findbyctrl(dp, ctrl); - assert(c && c->ctrl->generic.type == CTRL_FONTSELECT); + assert(c && c->ctrl->type == CTRL_FONTSELECT); return fontspec_copy((FontSpec *)c->data); } @@ -2401,7 +2401,7 @@ FontSpec *dlg_fontsel_get(dlgcontrol *ctrl, dlgparam *dp) void dlg_update_start(dlgcontrol *ctrl, dlgparam *dp) { struct winctrl *c = dlg_findbyctrl(dp, ctrl); - if (c && c->ctrl->generic.type == CTRL_LISTBOX) { + if (c && c->ctrl->type == CTRL_LISTBOX) { SendDlgItemMessage(dp->hwnd, c->base_id+1, WM_SETREDRAW, false, 0); } } @@ -2409,7 +2409,7 @@ void dlg_update_start(dlgcontrol *ctrl, dlgparam *dp) void dlg_update_done(dlgcontrol *ctrl, dlgparam *dp) { struct winctrl *c = dlg_findbyctrl(dp, ctrl); - if (c && c->ctrl->generic.type == CTRL_LISTBOX) { + if (c && c->ctrl->type == CTRL_LISTBOX) { HWND hw = GetDlgItem(dp->hwnd, c->base_id+1); SendMessage(hw, WM_SETREDRAW, true, 0); InvalidateRect(hw, NULL, true); @@ -2423,7 +2423,7 @@ void dlg_set_focus(dlgcontrol *ctrl, dlgparam *dp) HWND ctl; if (!c) return; - switch (ctrl->generic.type) { + switch (ctrl->type) { case CTRL_EDITBOX: id = c->base_id + 1; break; case CTRL_RADIO: for (id = c->base_id + ctrl->radio.nbuttons; id > 1; id--) @@ -2487,8 +2487,8 @@ void dlg_refresh(dlgcontrol *ctrl, dlgparam *dp) for (i = 0; (c = winctrl_findbyindex(dp->controltrees[j], i)) != NULL; i++) { - if (c->ctrl && c->ctrl->generic.handler != NULL) - c->ctrl->generic.handler(c->ctrl, dp, + if (c->ctrl && c->ctrl->handler != NULL) + c->ctrl->handler(c->ctrl, dp, dp->data, EVENT_REFRESH); } } @@ -2496,8 +2496,8 @@ void dlg_refresh(dlgcontrol *ctrl, dlgparam *dp) /* * Send EVENT_REFRESH to a specific control. */ - if (ctrl->generic.handler != NULL) - ctrl->generic.handler(ctrl, dp, dp->data, EVENT_REFRESH); + if (ctrl->handler != NULL) + ctrl->handler(ctrl, dp, dp->data, EVENT_REFRESH); } }