Index: trunk/src/buffer.c =================================================================== --- trunk/src/buffer.c (revision 21482) +++ trunk/src/buffer.c (revision 21483) @@ -875,7 +875,7 @@ if ((!force) && ((exist = pcb_fopen(name, "r")))) { fclose(exist); - if (pcb_gui->confirm_dialog(_("File exists! Ok to overwrite?"), 0)) + if (pcb_hid_message_box("warning", "Buffer: overwrite file", "File exists! Ok to overwrite?", "cancel", 0, "yes", 1, NULL) == 1) pcb_save_buffer_elements(name, fmt); } else Index: trunk/src/change.c =================================================================== --- trunk/src/change.c (revision 21482) +++ trunk/src/change.c (revision 21483) @@ -762,7 +762,7 @@ if ((parent_subc != NULL) && !PCB_FLAG_TEST(PCB_FLAG_FLOATER, obj) && !PCB_FLAG_TEST(PCB_FLAG_DYNTEXT, obj)) goto term_name; /* special case: dyntext floaters are rarely temrinals */ if ((parent_subc != NULL) && PCB_FLAG_TEST(PCB_FLAG_DYNTEXT, obj) && (strstr(((pcb_text_t *)obj)->TextString, "%a.parent.refdes%"))) { - if (pcb_gui->confirm_dialog("Text object seems to be a refdes text", "edit the text (template)", "edit subcircuit refdes")) { + if (pcb_hid_message_box("question", "Text edit: refdes or template?", "Text object seems to be a refdes text", "edit the text (template)", 0, "edit subcircuit refdes", 1, NULL) == 1) { obj = (pcb_any_obj_t *)parent_subc; goto subc_name; } Index: trunk/src/data.c =================================================================== --- trunk/src/data.c (revision 21482) +++ trunk/src/data.c (revision 21483) @@ -722,12 +722,14 @@ ctx->inited = 1; } if (pcb_gui->progress(ctx->at, ctx->total, "Clipping polygons...") != 0) { - if (pcb_gui->confirm_dialog("The only way to cancel poly clipping is to quit pcb-rnd.\nAre you sure you want to quit?", "yes, quit", "no, continue", NULL) != 0) { + int rv = pcb_hid_message_box("warning", "Stop poly clipping", "The only way to cancel poly clipping is to quit pcb-rnd.\nAre you sure you want to quit?", "yes, quit pcb-rnd", 1, "no, continue clipping", 2, NULL); + if (rv == 1) { + exit(1); + } + else { /* Have to recreate the dialog next time, that's the only way to get it out from the cancel state */ pcb_gui->progress(0, 0, NULL); } - else - exit(1); } } } Index: trunk/src/file_act.c =================================================================== --- trunk/src/file_act.c (revision 21482) +++ trunk/src/file_act.c (revision 21483) @@ -85,7 +85,7 @@ break; case F_Layout: - if (!PCB->Changed || pcb_gui->confirm_dialog("OK to override layout data?", 0)) + if (!PCB->Changed || pcb_hid_message_box("warning", "File overwrite", "OK to override layout data?", "cancel", 0, "ok", 1, NULL)) pcb_load_pcb(name, format, pcb_true, 0); break; @@ -103,7 +103,7 @@ break; case F_Revert: - if (PCB->Filename && (!PCB->Changed || pcb_gui->confirm_dialog("OK to override changes?", 0))) + if (PCB->Filename && (!PCB->Changed || (pcb_hid_message_box("warning", "Revert: lose data", "Really revert all modifications?", "no", 0, "yes", 1, NULL) == 1))) pcb_revert_pcb(); break; } @@ -122,7 +122,7 @@ PCB_ACT_MAY_CONVARG(1, FGW_STR, New, argument_name = argv[1].val.str); - if (!PCB->Changed || pcb_gui->confirm_dialog("OK to clear layout data?", 0)) { + if (!PCB->Changed || (pcb_hid_message_box("warning", "New pcb", "OK to clear layout data?", "cancel", 0, "yes", 1, NULL) == 1)) { if (argument_name) name = pcb_strdup(argument_name); else Index: trunk/src/hid.h =================================================================== --- trunk/src/hid.h (revision 21482) +++ trunk/src/hid.h (revision 21483) @@ -570,5 +570,11 @@ Returns NULL on cancel. The caller needs to free the returned string */ char *pcb_hid_prompt_for(const char *msg, const char *default_string, const char *title); +/* Present a dialog box with a message and variable number of buttons. If icon + is not NULL, attempt to draw the named icon on the left. The vararg part is + one or more buttons, as a list of "char *label, int retval", terminated with + NULL. */ +int pcb_hid_message_box(const char *icon, const char *title, const char *label, ...); + #endif Index: trunk/src/hid_dlg.c =================================================================== --- trunk/src/hid_dlg.c (revision 21482) +++ trunk/src/hid_dlg.c (revision 21483) @@ -92,6 +92,40 @@ return call_dialog("messagebox", res, argc, argv); } +int pcb_hid_message_box(const char *icon, const char *title, const char *label, ...) +{ + fgw_arg_t res, argv[128]; + int argc; + va_list ap; + + argv[1].type = FGW_STR; argv[1].val.cstr = icon; + argv[2].type = FGW_STR; argv[2].val.cstr = title; + argv[3].type = FGW_STR; argv[3].val.cstr = label; + argc = 4; + + va_start(ap, label); + for(;argc < 126;) { + argv[argc].type = FGW_STR; + argv[argc].val.cstr = va_arg(ap, const char *); + if (argv[argc].val.cstr == NULL) + break; + argc++; + argv[argc].type = FGW_INT; + argv[argc].val.nat_int = va_arg(ap, int); + argc++; + } + va_end(ap); + + if (pcb_actionv_bin("MessageBox", &res, argc, argv) != 0) + return -1; + + if (fgw_arg_conv(&pcb_fgw, &res, FGW_INT) == 0) + return res.val.nat_int; + + fgw_arg_free(&pcb_fgw, &res); + return -1; +} + static pcb_action_t hid_dlg_action_list[] = { {"PromptFor", pcb_act_PromptFor, pcb_acth_PromptFor, pcb_acts_PromptFor}, {"MessageBox", pcb_act_MessageBox, pcb_acth_MessageBox, pcb_acts_MessageBox} Index: trunk/src/layer.c =================================================================== --- trunk/src/layer.c (revision 21482) +++ trunk/src/layer.c (revision 21483) @@ -655,12 +655,12 @@ } if (new_index == -1 && is_last_top_copper_layer(pcb, old_index)) { - pcb_gui->confirm_dialog("You can't delete the last top-side layer\n", "Ok", NULL); + pcb_hid_message_box("warning", "Layer delete", "You can't delete the last top-side layer\n", "cancel", 0, NULL); return 1; } if (new_index == -1 && is_last_bottom_copper_layer(pcb, old_index)) { - pcb_gui->confirm_dialog("You can't delete the last bottom-side layer\n", "Ok", NULL); + pcb_hid_message_box("warning", "Layer delete", "You can't delete the last bottom-side layer\n", "cancel", 0, NULL); return 1; } Index: trunk/src/object_act.c =================================================================== --- trunk/src/object_act.c (revision 21482) +++ trunk/src/object_act.c (revision 21483) @@ -445,8 +445,9 @@ } } PCB_END_LOOP; - if (number_of_footprints_not_found > 0) - pcb_gui->confirm_dialog("Not all requested footprints were found.\n" "See the message log for details", "Ok", NULL); + if (number_of_footprints_not_found > 0) { + pcb_hid_message_box("warning", "Footprint import", "Not all requested footprints were found.\nSee the message log for details", "ok", 0, NULL); + } return 0; } Index: trunk/src/plug_io.c =================================================================== --- trunk/src/plug_io.c (revision 21482) +++ trunk/src/plug_io.c (revision 21483) @@ -675,16 +675,15 @@ if (Filename && *Filename) { if (!stat(Filename, &buffer) && Confirm) { + const char *all_ok = "all ok"; sprintf(message, _("File '%s' exists, use anyway?"), Filename); if (WasAllButton) *WasAllButton = pcb_false; if (WasCancelButton) *WasCancelButton = pcb_false; - if (AllButton) - response = pcb_gui->confirm_dialog(message, "Cancel", "Ok", AllButton ? "Sequence OK" : 0); - else - response = pcb_gui->confirm_dialog(message, "Cancel", "Ok", "Sequence OK"); - + if (!AllButton) + all_ok = NULL; + response = pcb_hid_message_box("warning", "Overwrite file", message, "cancel", 0, "ok", 1, all_ok, 2, NULL); switch (response) { case 2: if (WasAllButton) Index: trunk/src/undo.c =================================================================== --- trunk/src/undo.c (revision 21482) +++ trunk/src/undo.c (revision 21483) @@ -215,7 +215,7 @@ */ void pcb_undo_clear_list(pcb_bool Force) { - if (pcb_uundo.num_undo && (Force || pcb_gui->confirm_dialog("OK to clear 'undo' buffer?", 0))) { + if (pcb_uundo.num_undo && (Force || pcb_hid_message_box("warning", "clear undo buffer", "Do you reall want to clear 'undo' buffer?", "yes", 1, "no", 0, NULL) == 1)) { uundo_list_clear(&pcb_uundo); pcb_event(PCB_EVENT_UNDO_POST, "i", PCB_UNDO_EV_CLEAR_LIST); }