#define MAXBUF 200
#define MAXFORMAT 20
+#define BUTTONS 4
/* globals -- ick */
static int buttonHeight = 1;
+static const char * buttonText[BUTTONS];
int max (int a, int b)
{
static newtComponent (*makeButton)(int left, int right, const char * text) =
newtCompactButton;
+static const char * getButtonText(int button) {
+ const char * text;
+ if (button < 0 || button >= BUTTONS)
+ return NULL;
+
+ text = buttonText[button];
+ if (text)
+ return text;
+
+ switch (button) {
+ case 0: text = "Ok";
+ break;
+ case 1: text = "Cancel";
+ break;
+ case 2: text = "Yes";
+ break;
+ case 3: text = "No";
+ break;
+ default:
+ return NULL;
+ }
+ return dgettext(PACKAGE, text);
+}
+
static void addButtons(int height, int width, newtComponent form,
newtComponent * okay, newtComponent * cancel,
int flags) {
// FIXME: DO SOMETHING ABOUT THE HARD-CODED CONSTANTS
if (flags & FLAG_NOCANCEL) {
*okay = makeButton((width - 8) / 2, height - buttonHeight - 1,
- dgettext(PACKAGE, "Ok"));
+ getButtonText(BUTTON_OK));
*cancel = NULL;
newtFormAddComponent(form, *okay);
} else {
*okay = makeButton((width - 18) / 3, height - buttonHeight - 1,
- dgettext(PACKAGE,"Ok"));
+ getButtonText(BUTTON_OK));
*cancel = makeButton(((width - 18) / 3) * 2 + 9,
height - buttonHeight - 1,
- dgettext(PACKAGE,"Cancel"));
+ getButtonText(BUTTON_CANCEL));
newtFormAddComponents(form, *okay, *cancel, NULL);
}
}
case MSGBOX_MSG:
// FIXME Do something about the hard-coded constants
yes = makeButton((width - 8) / 2, height - 1 - buttonHeight,
- dgettext(PACKAGE,"Ok"));
+ getButtonText(BUTTON_OK));
newtFormAddComponent(form, yes);
break;
default:
yes = makeButton((width - 16) / 3, height - 1 - buttonHeight,
- dgettext(PACKAGE,"Yes"));
+ getButtonText(BUTTON_YES));
no = makeButton(((width - 16) / 3) * 2 + 9, height - 1 - buttonHeight,
- dgettext(PACKAGE,"No"));
+ getButtonText(BUTTON_NO));
newtFormAddComponents(form, yes, no, NULL);
if (flags & FLAG_DEFAULT_NO)
makeButton = newtCompactButton;
}
}
+
+void setButtonText(const char * text, int button) {
+ if (button < 0 || button >= BUTTONS)
+ return;
+ buttonText[button] = text;
+}
"\t--default-item <string> set default string\n"
"\t--fb use full buttons\n"
"\t--nocancel no cancel button\n"
+ "\t--yes-button <text> set text of yes button\n"
+ "\t--no-button <text> set text of no button\n"
+ "\t--ok-button <text> set text of ok button\n"
+ "\t--cancel-button <text> set text of cancel button\n"
"\t--noitem display tags only\n"
"\t--separate-output <fd> output one line at a time\n"
"\t--output-fd <fd> output to fd, not stdout\n"
char * title = NULL;
char *default_item = NULL;
char * backtitle = NULL;
+ char * yes_button = NULL;
+ char * no_button = NULL;
+ char * ok_button = NULL;
+ char * cancel_button = NULL;
int help = 0, version = 0;
struct poptOption optionsTable[] = {
{ "backtitle", '\0', POPT_ARG_STRING, &backtitle, 0 },
{ "yesno", '\0', 0, 0, OPT_YESNO },
{ "passwordbox", '\0', 0, 0, OPT_PASSWORDBOX },
{ "output-fd", '\0', POPT_ARG_INT, &outputfd, 0 },
+ { "yes-button", '\0', POPT_ARG_STRING, &yes_button, 0},
+ { "no-button", '\0', POPT_ARG_STRING, &no_button, 0},
+ { "ok-button", '\0', POPT_ARG_STRING, &ok_button, 0},
+ { "cancel-button", '\0', POPT_ARG_STRING, &cancel_button, 0},
{ "help", 'h', 0, &help, 0, NULL, NULL },
{ "version", 'v', 0, &version, 0, NULL, NULL },
{ 0, 0, 0, 0, 0 }
if (backtitle)
newtDrawRootText(0, 0, backtitle);
+ if (ok_button)
+ setButtonText(ok_button, BUTTON_OK);
+ if (cancel_button)
+ setButtonText(cancel_button, BUTTON_CANCEL);
+ if (yes_button)
+ setButtonText(yes_button, BUTTON_YES);
+ if (no_button)
+ setButtonText(no_button, BUTTON_NO);
+
if (noCancel) flags |= FLAG_NOCANCEL;
if (noItem) flags |= FLAG_NOITEM;
if (noTags) flags |= FLAG_NOTAGS;