* widget.h (button_new): Remove unused extra argument. Adjust

all dependencies.
This commit is contained in:
Pavel Roskin 2003-09-01 02:07:02 +00:00
parent c27ebffa28
commit 2b9b18150e
17 changed files with 178 additions and 175 deletions

View File

@ -553,7 +553,7 @@ edit_raw_key_query (char *heading, char *query, int cancel)
if (cancel)
add_widget (raw_dlg,
button_new (4, w / 2 - 5, B_CANCEL, NORMAL_BUTTON,
_("Cancel"), 0, 0));
_("Cancel"), 0));
add_widget (raw_dlg, label_new (3 - cancel, 2, query));
add_widget (raw_dlg,
input_new (3 - cancel, w - 5, INPUT_COLOR, 2, "", 0));

View File

@ -1,5 +1,8 @@
2003-08-31 Pavel Roskin <proski@gnu.org>
* widget.h (button_new): Remove unused extra argument. Adjust
all dependencies.
* option.c (check_options): Remove tk field.
* widget.c: Comment fix to get rid of references to Tk.
* wtools.c (real_input_dialog_help): Rename tk_name to histname.

View File

@ -551,7 +551,7 @@ init_chown_advanced (void)
#define XTRACT(i) BY+chown_advanced_but[i].y, BX+chown_advanced_but[i].x, \
chown_advanced_but[i].ret_cmd, chown_advanced_but[i].flags, \
(chown_advanced_but[i].text), 0, 0
(chown_advanced_but[i].text), 0
for (i = 0; i < BUTTONS - 5; i++)
if (!single_set || i < 2)

View File

@ -184,11 +184,11 @@ display_init (int radio_sel, char *init_text, int _check_status,
add_widget (dd,
button_new (4, button_start, B_CANCEL, NORMAL_BUTTON,
cancel_button, 0, 0));
cancel_button, 0));
add_widget (dd,
button_new (3, button_start, B_ENTER, DEFPUSH_BUTTON,
ok_button, 0, 0));
ok_button, 0));
status =
input_new (10, 9, INPUT_COLOR, DISPLAY_X - 14, _status[radio_sel],
@ -272,69 +272,67 @@ sort_box (sortfn *sort_fn, int *reverse, int *case_sensitive)
sortfn *result;
WCheck *c, *case_sense;
char* ok_button = _("&OK");
char* cancel_button = _("&Cancel");
char* reverse_label = _("&Reverse");
char* case_label = _("case sensi&tive");
char* sort_title = _("Sort order");
char *ok_button = _("&OK");
char *cancel_button = _("&Cancel");
char *reverse_label = _("&Reverse");
char *case_label = _("case sensi&tive");
char *sort_title = _("Sort order");
static int i18n_sort_flag = 0, check_pos = 0, button_pos = 0;
static int i18n_sort_flag = 0, check_pos = 0, button_pos = 0;
if (!i18n_sort_flag)
{
int maxlen = 0;
for (i = SORT_TYPES-1; i >= 0; i--)
{
sort_orders_names [i] = _(sort_orders [i].sort_name);
r = strlen (sort_orders_names [i]);
if (r > maxlen)
maxlen = r;
}
check_pos = maxlen + 9;
r = strlen (reverse_label) + 4;
i = strlen (case_label) + 4;
if (i > r)
r = i;
l = strlen (ok_button) + 6;
i = strlen (cancel_button) + 4;
if (i > l)
l = i;
i = check_pos + max(r,l) + 2;
if (i > SORT_X)
SORT_X = i;
i = strlen (sort_title) + 6;
if (i > SORT_X)
SORT_X = i;
button_pos = SORT_X - l - 2;
i18n_sort_flag = 1;
if (!i18n_sort_flag) {
int maxlen = 0;
for (i = SORT_TYPES - 1; i >= 0; i--) {
sort_orders_names[i] = _(sort_orders[i].sort_name);
r = strlen (sort_orders_names[i]);
if (r > maxlen)
maxlen = r;
}
check_pos = maxlen + 9;
r = strlen (reverse_label) + 4;
i = strlen (case_label) + 4;
if (i > r)
r = i;
l = strlen (ok_button) + 6;
i = strlen (cancel_button) + 4;
if (i > l)
l = i;
i = check_pos + max (r, l) + 2;
if (i > SORT_X)
SORT_X = i;
i = strlen (sort_title) + 6;
if (i > SORT_X)
SORT_X = i;
button_pos = SORT_X - l - 2;
i18n_sort_flag = 1;
}
result = 0;
for (i = 0; i < SORT_TYPES; i++)
if ((sortfn *) (sort_orders [i].sort_fn) == sort_fn){
if ((sortfn *) (sort_orders[i].sort_fn) == sort_fn) {
current_mode = i;
break;
}
dd = create_dlg (0, 0, SORT_Y, SORT_X, dialog_colors, NULL,
"[Sort Order...]", sort_title, DLG_CENTER);
add_widget (dd,
button_new (10, button_pos, B_CANCEL, NORMAL_BUTTON, cancel_button,
0, 0));
add_widget (dd,
button_new (10, button_pos, B_CANCEL, NORMAL_BUTTON,
cancel_button, 0));
add_widget (dd,
button_new (9, button_pos, B_ENTER, DEFPUSH_BUTTON, ok_button,
0, 0));
add_widget (dd,
button_new (9, button_pos, B_ENTER, DEFPUSH_BUTTON,
ok_button, 0));
case_sense = check_new (4, check_pos, *case_sensitive, case_label);
add_widget (dd, case_sense);
@ -343,13 +341,13 @@ sort_box (sortfn *sort_fn, int *reverse, int *case_sensitive)
my_radio = radio_new (3, 3, SORT_TYPES, sort_orders_names, 1);
my_radio->sel = my_radio->pos = current_mode;
add_widget (dd, my_radio);
run_dlg (dd);
r = dd->ret_value;
if (r != B_CANCEL){
result = (sortfn *) sort_orders [my_radio->sel].sort_fn;
if (r != B_CANCEL) {
result = (sortfn *) sort_orders[my_radio->sel].sort_fn;
*reverse = c->state & C_BOOL;
*case_sensitive = case_sense->state & C_BOOL;
} else
@ -566,36 +564,37 @@ init_disp_bits_box (void)
char *cpname;
Dlg_head *dbits_dlg;
do_refresh();
do_refresh ();
dbits_dlg = create_dlg( 0, 0, DISPY, DISPX, dialog_colors,
NULL, "[Display bits]", _(" Display bits "), DLG_CENTER);
dbits_dlg =
create_dlg (0, 0, DISPY, DISPX, dialog_colors, NULL,
"[Display bits]", _(" Display bits "), DLG_CENTER);
add_widget( dbits_dlg,
label_new( 3, 4, _("Input / display codepage:"), NULL));
add_widget (dbits_dlg,
label_new (3, 4, _("Input / display codepage:"), NULL));
cpname = (new_display_codepage < 0)
? _("Other 8 bit")
: codepages[ new_display_codepage ].name;
cplabel = label_new( 4, 4, cpname, NULL);
add_widget( dbits_dlg, cplabel );
add_widget( dbits_dlg,
button_new( DISPY - 3, DISPX / 2 + 3, B_CANCEL,
NORMAL_BUTTON, _("&Cancel"), 0, 0, NULL ) );
add_widget( dbits_dlg,
button_new( DISPY - 3, 7, B_ENTER,
NORMAL_BUTTON, _("&OK"), 0, 0, NULL ) );
? _("Other 8 bit")
: codepages[new_display_codepage].name;
cplabel = label_new (4, 4, cpname, NULL);
add_widget (dbits_dlg, cplabel);
inpcheck = check_new( 6, 4, !use_8th_bit_as_meta,
_("F&ull 8 bits input"), NULL );
add_widget( dbits_dlg, inpcheck );
add_widget (dbits_dlg,
button_new (DISPY - 3, DISPX / 2 + 3, B_CANCEL,
NORMAL_BUTTON, _("&Cancel"), 0));
add_widget (dbits_dlg,
button_new (DISPY - 3, 7, B_ENTER, NORMAL_BUTTON, _("&OK"),
0));
inpcheck =
check_new (6, 4, !use_8th_bit_as_meta, _("F&ull 8 bits input"),
NULL);
add_widget (dbits_dlg, inpcheck);
cpname = _("&Select");
add_widget( dbits_dlg,
button_new( 4, DISPX - 8 - strlen(cpname) , B_USER,
NORMAL_BUTTON, cpname,
sel_charset_button, 0, NULL ) );
add_widget (dbits_dlg,
button_new (4, DISPX - 8 - strlen (cpname), B_USER,
NORMAL_BUTTON, cpname, sel_charset_button));
return dbits_dlg;
}
@ -886,7 +885,7 @@ jobs_fill_listbox (void)
}
static int
task_cb (int action, void *ignored)
task_cb (int action)
{
TaskList *tl;
int sig = 0;
@ -928,7 +927,7 @@ static struct
char* name;
int xpos;
int value;
int (*callback)(int, void *);
int (*callback)(int);
}
job_buttons [] =
{
@ -983,7 +982,7 @@ jobs_cmd (void)
add_widget (jobs_dlg, button_new (JOBS_Y-4,
job_buttons [i].xpos, job_buttons [i].value,
NORMAL_BUTTON, job_buttons [i].name,
job_buttons [i].callback, 0));
job_buttons [i].callback));
}
/* Insert all of task information in the list */
@ -1066,9 +1065,9 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain,
in_domain = input_new (3, istart, INPUT_COLOR, ilen, domain, "auth_domain");
add_widget (auth_dlg, in_domain);
add_widget (auth_dlg, button_new (9, b2, B_CANCEL, NORMAL_BUTTON,
buts[1], 0 ,0, "cancel"));
buts[1], 0));
add_widget (auth_dlg, button_new (9, b0, B_ENTER, DEFPUSH_BUTTON,
buts[0], 0, 0, "ok"));
buts[0], 0));
in_password = input_new (7, istart, INPUT_COLOR, ilen, "", "auth_password");
in_password->completion_flags = 0;

View File

@ -205,7 +205,7 @@ init_chmod (void)
BX + chmod_but[i].x,
chmod_but[i].ret_cmd,
chmod_but[i].flags,
_(chmod_but[i].text), 0, 0));
_(chmod_but[i].text), 0));
}
for (i = 0; i < PERMISSIONS; i++) {

View File

@ -167,7 +167,7 @@ init_chown (void)
add_widget (ch_dlg,
button_new (BY + chown_but[i].y, BX + chown_but[i].x,
chown_but[i].ret_cmd, chown_but[i].flags,
_(chown_but[i].text), 0, 0));
_(chown_but[i].text), 0));
/* Add the widgets for the file information */
for (i = 0; i < LABELS; i++) {

View File

@ -221,10 +221,10 @@ file_op_context_create_ui (FileOpContext *ctx, FileOperation op,
add_widget (ui->op_dlg,
button_new (BY - minus, WX - 19 + eta_offset, FILE_ABORT,
NORMAL_BUTTON, _("&Abort"), 0, 0));
NORMAL_BUTTON, _("&Abort"), 0));
add_widget (ui->op_dlg,
button_new (BY - minus, 14 + eta_offset, FILE_SKIP,
NORMAL_BUTTON, _("&Skip"), 0, 0));
NORMAL_BUTTON, _("&Skip"), 0));
add_widget (ui->op_dlg, ui->progress_gauge[2] =
gauge_new (7, FCOPY_GAUGE_X, 0, 100, 0));
@ -549,7 +549,7 @@ static struct {
#define ADD_RD_BUTTON(i)\
add_widget (ui->replace_dlg,\
button_new (rd_widgets [i].ypos, rd_widgets [i].xpos, rd_widgets [i].value,\
NORMAL_BUTTON, rd_widgets [i].text, 0, 0))
NORMAL_BUTTON, rd_widgets [i].text, 0))
#define ADD_RD_LABEL(ui,i,p1,p2)\
g_snprintf (buffer, sizeof (buffer), rd_widgets [i].text, p1, p2);\

View File

@ -226,13 +226,11 @@ find_parameters (char **start_dir, char **pattern, char **content)
DLG_CENTER);
add_widget (find_dlg,
button_new (11, b2, B_CANCEL, NORMAL_BUTTON, buts[2], 0,
0));
button_new (11, b2, B_CANCEL, NORMAL_BUTTON, buts[2], 0));
add_widget (find_dlg,
button_new (11, b1, B_TREE, NORMAL_BUTTON, buts[1], 0, 0));
button_new (11, b1, B_TREE, NORMAL_BUTTON, buts[1], 0));
add_widget (find_dlg,
button_new (11, b0, B_ENTER, DEFPUSH_BUTTON, buts[0], 0,
0));
button_new (11, b0, B_ENTER, DEFPUSH_BUTTON, buts[0], 0));
case_sense = check_new (9, 3, case_sensitive, case_label);
add_widget (find_dlg, case_sense);
@ -725,7 +723,7 @@ find_callback (struct Dlg_head *h, int id, int Msg)
/* Handles the Stop/Start button in the find window */
static int
start_stop (int button, void *extra)
start_stop (int button)
{
running = is_start;
set_idle_proc (find_dlg, running);
@ -739,7 +737,7 @@ start_stop (int button, void *extra)
/* Handle view command, when invoked as a button */
static int
find_do_view_file (int button, void *extra)
find_do_view_file (int button)
{
view_edit_currently_selected_file (0, 0);
return 0;
@ -747,7 +745,7 @@ find_do_view_file (int button, void *extra)
/* Handle edit command, when invoked as a button */
static int
find_do_edit_file (int button, void *extra)
find_do_edit_file (int button)
{
view_edit_currently_selected_file (0, 1);
return 0;
@ -806,27 +804,27 @@ setup_gui (void)
add_widget (find_dlg,
button_new (FIND2_Y - 3, fbuts[7].x, B_VIEW, NORMAL_BUTTON,
fbuts[7].text, find_do_edit_file, find_dlg));
fbuts[7].text, find_do_edit_file));
add_widget (find_dlg,
button_new (FIND2_Y - 3, fbuts[6].x, B_VIEW, NORMAL_BUTTON,
fbuts[6].text, find_do_view_file, find_dlg));
fbuts[6].text, find_do_view_file));
add_widget (find_dlg,
button_new (FIND2_Y - 3, fbuts[5].x, B_PANELIZE,
NORMAL_BUTTON, fbuts[5].text, 0, 0));
NORMAL_BUTTON, fbuts[5].text, 0));
add_widget (find_dlg,
button_new (FIND2_Y - 4, fbuts[4].x, B_CANCEL,
NORMAL_BUTTON, fbuts[4].text, 0, 0));
NORMAL_BUTTON, fbuts[4].text, 0));
stop_button =
button_new (FIND2_Y - 4, fbuts[0].x, B_STOP, NORMAL_BUTTON,
fbuts[0].text, start_stop, find_dlg);
fbuts[0].text, start_stop);
add_widget (find_dlg, stop_button);
add_widget (find_dlg,
button_new (FIND2_Y - 4, fbuts[3].x, B_AGAIN,
NORMAL_BUTTON, fbuts[3].text, 0, 0));
NORMAL_BUTTON, fbuts[3].text, 0));
add_widget (find_dlg,
button_new (FIND2_Y - 4, fbuts[2].x, B_ENTER,
DEFPUSH_BUTTON, fbuts[2].text, 0, 0));
DEFPUSH_BUTTON, fbuts[2].text, 0));
status_label = label_new (FIND2_Y - 6, 4, _("Searching"));
add_widget (find_dlg, status_label);

View File

@ -267,7 +267,7 @@ static void add_name_to_list (char *path)
}
#endif /* !USE_VFS */
static int hotlist_button_callback (int action, void *data)
static int hotlist_button_callback (int action)
{
switch (action) {
case B_MOVE:
@ -417,7 +417,7 @@ static int hotlist_callback (Dlg_head * h, int Par, int Msg)
case '\n':
case KEY_ENTER:
case KEY_RIGHT:
if (hotlist_button_callback (B_ENTER, 0)) {
if (hotlist_button_callback (B_ENTER)) {
h->ret_value = B_ENTER;
dlg_stop (h);
};
@ -425,13 +425,13 @@ static int hotlist_callback (Dlg_head * h, int Par, int Msg)
break;
case KEY_LEFT:
if (hotlist_state.type != LIST_VFSLIST )
return !hotlist_button_callback (B_UP_GROUP, 0);
return !hotlist_button_callback (B_UP_GROUP);
else
return 0;
break;
case KEY_DC:
if (!hotlist_state.moving) {
hotlist_button_callback (B_REMOVE, 0);
hotlist_button_callback (B_REMOVE);
return 1;
}
break;
@ -489,7 +489,7 @@ static int l_call (void *l)
dlg_stop (dlg);
return listbox_finish;
} else {
hotlist_button_callback (B_ENTER, (void *)0);
hotlist_button_callback (B_ENTER);
hotlist_callback (dlg, '\n', DLG_POST_KEY);
return listbox_nothing;
}
@ -500,7 +500,7 @@ static int l_call (void *l)
}
}
hotlist_button_callback (B_UP_GROUP, (void *)0);
hotlist_button_callback (B_UP_GROUP);
hotlist_callback (dlg, 'u', DLG_POST_KEY);
return listbox_nothing;
}
@ -622,7 +622,7 @@ init_hotlist (int list_type)
hotlist_but[i].ret_cmd,
hotlist_but[i].flags,
hotlist_but[i].text,
hotlist_button_callback, 0));
hotlist_button_callback));
}
/* We add the labels.
@ -680,7 +680,7 @@ init_movelist (int list_type, struct hotlist *item)
hotlist_but[i].ret_cmd,
hotlist_but[i].flags,
hotlist_but[i].text,
hotlist_button_callback, 0));
hotlist_button_callback));
}
/* We add the labels. We are interested in the last one,

View File

@ -224,7 +224,7 @@ static void update_split (void)
printw ("%03d", COLS - _first_panel_size);
}
static int b2left_cback (int action, void *data)
static int b2left_cback (int action)
{
if (_equal_split){
/* Turn equal split off */
@ -237,7 +237,7 @@ static int b2left_cback (int action, void *data)
return 0;
}
static int b2right_cback (int action, void *data)
static int b2right_cback (int action)
{
if (_equal_split){
/* Turn equal split off */
@ -250,14 +250,14 @@ static int b2right_cback (int action, void *data)
return 0;
}
static int bplus_cback (int action, void *data)
static int bplus_cback (int action)
{
if (_output_lines < 99)
_output_lines++;
return 0;
}
static int bminus_cback (int action, void *data)
static int bminus_cback (int action)
{
if (_output_lines > 0)
_output_lines--;
@ -437,18 +437,18 @@ static void init_layout (void)
"[Layout]", _("Layout"), DLG_CENTER);
add_widget (layout_dlg,
button_new (BY, b3, B_CANCEL, NORMAL_BUTTON, cancel_button, 0, 0));
button_new (BY, b3, B_CANCEL, NORMAL_BUTTON, cancel_button, 0));
add_widget (layout_dlg,
button_new (BY, b2, B_EXIT, NORMAL_BUTTON, save_button, 0, 0));
button_new (BY, b2, B_EXIT, NORMAL_BUTTON, save_button, 0));
add_widget (layout_dlg,
button_new (BY, b1, B_ENTER, DEFPUSH_BUTTON, ok_button, 0, 0));
button_new (BY, b1, B_ENTER, DEFPUSH_BUTTON, ok_button, 0));
if (console_flag){
add_widget (layout_dlg,
button_new (9, 12 + first_width, B_MINUS, NARROW_BUTTON, "&-",
bminus_cback, 0));
bminus_cback));
add_widget (layout_dlg,
button_new (9, 7 + first_width, B_PLUS, NARROW_BUTTON, "&+",
bplus_cback, 0));
bplus_cback));
}
#define XTRACT(i) *check_options[i].variable, check_options[i].text
@ -470,9 +470,9 @@ static void init_layout (void)
_keybar_visible = keybar_visible;
_message_visible = message_visible;
_xterm_title = xterm_title;
bright_widget = button_new(6, 15, B_2RIGHT, NARROW_BUTTON, "&>", b2right_cback, 0);
bright_widget = button_new(6, 15, B_2RIGHT, NARROW_BUTTON, "&>", b2right_cback);
add_widget (layout_dlg, bright_widget);
bleft_widget = button_new (6, 9, B_2LEFT, NARROW_BUTTON, "&<", b2left_cback, 0);
bleft_widget = button_new (6, 9, B_2LEFT, NARROW_BUTTON, "&<", b2left_cback);
add_widget (layout_dlg, bleft_widget);
check_options [6].widget = check_new (5, 6, XTRACT(6));
old_first_panel_size = -1;

View File

@ -75,7 +75,7 @@ static int learnchanged;
static char* learn_title = N_("Learn keys");
static int learn_button (int action, void *param)
static int learn_button (int action)
{
unsigned char *seq;
Dlg_head *d = message (D_INSERT | 1, _(" Teach me a key "),
@ -263,7 +263,7 @@ init_learn (void)
add_widget (learn_dlg,
button_new (BY + learn_but[i].y, learn_but[i].x,
learn_but[i].ret_cmd, learn_but[i].flags,
_(learn_but[i].text), 0, 0));
_(learn_but[i].text), 0));
x = UX;
y = UY;
@ -281,7 +281,7 @@ init_learn (void)
g_snprintf (buffer, sizeof (buffer), "%-16s", _(key->longname));
add_widget (learn_dlg, learnkeys[i].button = (Widget *)
button_new (y, x, B_USER + i, NARROW_BUTTON, buffer,
learn_button, 0));
learn_button));
add_widget (learn_dlg, learnkeys[i].label = (Widget *)
label_new (y, x + 19, ""));
if (i % 13)

View File

@ -114,13 +114,13 @@ listmode_refresh (Dlg_head * h)
}
static int
bplus_cback (int action, void *data)
bplus_cback (int action)
{
return 0;
}
static int
bminus_cback (int action, void *data)
bminus_cback (int action)
{
return 0;
}
@ -168,10 +168,13 @@ init_listmode (char *oldlistformat)
create_dlg (0, 0, 22, 74, dialog_colors, listmode_callback,
listmode_section, "Listing format edit", DLG_CENTER);
#define XTRACT(i) BY+listmode_but[i].y, BX+listmode_but[i].x, listmode_but[i].ret_cmd, listmode_but[i].flags, listmode_but[i].text, 0, 0, NULL
for (i = 0; i < BUTTONS; i++)
add_widget (listmode_dlg, button_new (XTRACT (i)));
add_widget (listmode_dlg,
button_new (BY + listmode_but[i].y,
BX + listmode_but[i].x,
listmode_but[i].ret_cmd,
listmode_but[i].flags,
listmode_but[i].text, 0));
/* We add the labels. */
for (i = 0; i < LABELS; i++) {
@ -183,10 +186,10 @@ init_listmode (char *oldlistformat)
add_widget (listmode_dlg,
button_new (UY + 13, UX + 37, B_MINUS, NORMAL_BUTTON, "&-",
bminus_cback, 0, NULL));
bminus_cback));
add_widget (listmode_dlg,
button_new (UY + 13, UX + 34, B_PLUS, NORMAL_BUTTON, "&+",
bplus_cback, 0, NULL));
bplus_cback));
radio_itemwidth = radio_new (UY + 9, UX + 22, 3, s_itemwidth, 1, NULL);
add_widget (listmode_dlg, radio_itemwidth);
radio_itemwidth = 0;

View File

@ -201,15 +201,15 @@ init_configure (void)
add_widget (conf_dlg,
button_new (BY, b3, B_CANCEL, NORMAL_BUTTON,
cancel_button, 0, 0));
cancel_button, 0));
add_widget (conf_dlg,
button_new (BY, b2, B_EXIT, NORMAL_BUTTON,
save_button, 0, 0));
save_button, 0));
add_widget (conf_dlg,
button_new (BY, b1, B_ENTER, DEFPUSH_BUTTON,
ok_button, 0, 0));
ok_button, 0));
#define XTRACT(i) *check_options[i].variable, check_options[i].text

View File

@ -164,7 +164,7 @@ init_panelize (void)
BX + panelize_but[i].x,
panelize_but[i].ret_cmd,
panelize_but[i].flags,
panelize_but[i].text, 0, 0));
panelize_but[i].text, 0));
pname =
input_new (UY + 14, UX, INPUT_COLOR, panelize_dlg->cols - 10, "",

View File

@ -71,7 +71,7 @@ button_callback (WButton *b, int Msg, int Par)
break;
if (b->callback)
stop = (*b->callback)(b->action, b->callback_data);
stop = (*b->callback)(b->action);
if (!b->callback || stop){
h->ret_value = b->action;
dlg_stop (h);
@ -204,7 +204,7 @@ button_scan_hotkey(WButton* b)
WButton *
button_new (int y, int x, int action, int flags, char *text,
int (*callback)(int, void *), void *callback_data)
int (*callback)(int))
{
WButton *b = g_new (WButton, 1);
@ -217,7 +217,6 @@ button_new (int y, int x, int action, int flags, char *text,
b->selected = 0;
b->text = g_strdup (text);
b->callback = callback;
b->callback_data = callback_data;
widget_want_hotkey (b->widget, 1);
b->hotkey = 0;
b->hotpos = -1;

View File

@ -20,10 +20,9 @@ typedef struct WButton {
int selected; /* button state */
unsigned int flags; /* button flags */
char *text; /* text of button */
int hotkey; /* hot KEY */
int hotpos; /* offset hot KEY char in text */
int (*callback)(int, void*); /* Callback function */
void *callback_data;
int hotkey; /* hot KEY */
int hotpos; /* offset hot KEY char in text */
int (*callback) (int); /* Callback function */
} WButton;
typedef struct WRadio {
@ -135,7 +134,7 @@ typedef struct {
/* Constructors */
WButton *button_new (int y, int x, int action, int flags, char *text,
int (*callback)(int, void *), void *extra);
int (*callback)(int));
WRadio *radio_new (int y, int x, int count, char **text, int use_hotkey);
WCheck *check_new (int y, int x, int state, char *text);
WInput *input_new (int y, int x, int color, int len, const char *text, char *histname);

View File

@ -80,7 +80,7 @@ Listbox *create_listbox_window (int cols, int lines, char *title, char *help)
add_widget (listbox->dlg,
button_new (lines+3, (cols/2 + 2) - len/2,
B_CANCEL, NORMAL_BUTTON, cancel_string, 0, 0));
B_CANCEL, NORMAL_BUTTON, cancel_string, 0));
add_widget (listbox->dlg, listbox->list);
common_dialog_repaint (listbox->dlg);
return listbox;
@ -110,7 +110,8 @@ Dlg_head *last_query_dlg;
static int sel_pos = 0;
/* Used to ask questions to the user */
int query_dialog (char *header, char *text, int flags, int count, ...)
int
query_dialog (char *header, char *text, int flags, int count, ...)
{
va_list ap;
Dlg_head *query_dlg;
@ -127,18 +128,17 @@ int query_dialog (char *header, char *text, int flags, int count, ...)
query_colors = alarm_colors;
else
query_colors = dialog_colors;
if (header == MSG_ERROR)
header = _("Error");
if (count > 0){
if (count > 0) {
va_start (ap, count);
for (i = 0; i < count; i++)
{
char* cp = va_arg (ap, char *);
win_len += strlen (cp) + 6;
if (strchr (cp, '&') != NULL)
win_len--;
for (i = 0; i < count; i++) {
char *cp = va_arg (ap, char *);
win_len += strlen (cp) + 6;
if (strchr (cp, '&') != NULL)
win_len--;
}
va_end (ap);
}
@ -146,25 +146,26 @@ int query_dialog (char *header, char *text, int flags, int count, ...)
/* count coordinates */
cols = 6 + max (win_len, max (strlen (header), msglen (text, &lines)));
lines += 4 + (count > 0 ? 2 : 0);
xpos = COLS/2 - cols/2;
ypos = LINES/3 - (lines-3)/2;
xpos = COLS / 2 - cols / 2;
ypos = LINES / 3 - (lines - 3) / 2;
/* prepare dialog */
query_dlg = create_dlg (ypos, xpos, lines, cols, query_colors, NULL,
"[QueryBox]", header, DLG_BACKWARD);
query_dlg =
create_dlg (ypos, xpos, lines, cols, query_colors, NULL,
"[QueryBox]", header, DLG_BACKWARD);
if (count > 0){
if (count > 0) {
cols = (cols-win_len-2)/2+2;
cols = (cols - win_len - 2) / 2 + 2;
va_start (ap, count);
for (i = 0; i < count; i++){
for (i = 0; i < count; i++) {
cur_name = va_arg (ap, char *);
xpos = strlen (cur_name)+6;
if (strchr(cur_name, '&') != NULL)
xpos--;
add_widget (query_dlg, button_new
(lines-3, cols, B_USER+i, NORMAL_BUTTON, cur_name,
0, 0));
xpos = strlen (cur_name) + 6;
if (strchr (cur_name, '&') != NULL)
xpos--;
add_widget (query_dlg,
button_new (lines - 3, cols, B_USER + i,
NORMAL_BUTTON, cur_name, 0));
cols += xpos;
if (i == sel_pos)
query_dlg->initfocus = query_dlg->current;
@ -172,21 +173,22 @@ int query_dialog (char *header, char *text, int flags, int count, ...)
va_end (ap);
add_widget (query_dlg, label_new (2, 3, text));
/* run dialog and make result */
run_dlg (query_dlg);
switch (query_dlg->ret_value){
switch (query_dlg->ret_value) {
case B_CANCEL:
break;
default:
result = query_dlg->ret_value-B_USER;
result = query_dlg->ret_value - B_USER;
}
/* free used memory */
destroy_dlg (query_dlg);
} else {
add_widget (query_dlg, label_new (2, 3, text));
add_widget (query_dlg, button_new(0, 0, 0, HIDDEN_BUTTON, "-", 0, 0));
add_widget (query_dlg,
button_new (0, 0, 0, HIDDEN_BUTTON, "-", 0));
last_query_dlg = query_dlg;
}
sel_pos = 0;
@ -316,7 +318,7 @@ quick_dialog_skip (QuickDialog *qd, int nskip)
button_new (ypos, xpos, qw->value,
(qw->value ==
B_ENTER) ? DEFPUSH_BUTTON : NORMAL_BUTTON,
I18N (qw->text), 0, 0);
I18N (qw->text), 0);
break;
/* We use the hotkey pos as the field length */