mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 12:56:51 +03:00
Added parameter to Wbutton callback to get the message sender easy.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
09b094b153
commit
760b700645
25
src/boxes.c
25
src/boxes.c
@ -558,10 +558,11 @@ static WLabel *cplabel;
|
||||
static WCheck *inpcheck;
|
||||
|
||||
static int
|
||||
sel_charset_button (int action)
|
||||
sel_charset_button (WButton *button, int action)
|
||||
{
|
||||
int new_dcp;
|
||||
|
||||
(void) button;
|
||||
(void) action;
|
||||
|
||||
new_dcp = select_charset (-1, -1, new_display_codepage, TRUE);
|
||||
@ -890,12 +891,14 @@ jobs_fill_listbox (void)
|
||||
}
|
||||
|
||||
static int
|
||||
task_cb (int action)
|
||||
task_cb (WButton *button, int action)
|
||||
{
|
||||
TaskList *tl;
|
||||
int sig = 0;
|
||||
|
||||
if (!bg_list->list)
|
||||
(void) button;
|
||||
|
||||
if (bg_list->list == NULL)
|
||||
return 0;
|
||||
|
||||
/* Get this instance information */
|
||||
@ -937,18 +940,16 @@ static struct
|
||||
const char *name;
|
||||
int xpos;
|
||||
int value;
|
||||
int (*callback) (int);
|
||||
bcback callback;
|
||||
}
|
||||
job_buttons[] =
|
||||
{
|
||||
{
|
||||
N_("&Stop"), 3, B_STOP, task_cb},
|
||||
{
|
||||
N_("&Resume"), 12, B_RESUME, task_cb},
|
||||
{
|
||||
N_("&Kill"), 23, B_KILL, task_cb},
|
||||
{
|
||||
N_("&OK"), 35, B_CANCEL, NULL}
|
||||
/* *INDENT-OFF* */
|
||||
{ N_("&Stop"), 3, B_STOP, task_cb },
|
||||
{ N_("&Resume"), 12, B_RESUME, task_cb },
|
||||
{ N_("&Kill"), 23, B_KILL, task_cb },
|
||||
{ N_("&OK"), 35, B_CANCEL, NULL }
|
||||
/* *INDENT-ON* */
|
||||
};
|
||||
|
||||
void
|
||||
|
17
src/find.c
17
src/find.c
@ -1142,9 +1142,10 @@ find_callback (struct Dlg_head *h, Widget * sender, dlg_msg_t msg, int parm, voi
|
||||
|
||||
/* Handles the Stop/Start button in the find window */
|
||||
static int
|
||||
start_stop (int button)
|
||||
start_stop (WButton *button, int action)
|
||||
{
|
||||
(void) button;
|
||||
(void) action;
|
||||
|
||||
running = is_start;
|
||||
set_idle_proc (find_dlg, running);
|
||||
@ -1158,9 +1159,10 @@ start_stop (int button)
|
||||
|
||||
/* Handle view command, when invoked as a button */
|
||||
static int
|
||||
find_do_view_file (int button)
|
||||
find_do_view_file (WButton *button, int action)
|
||||
{
|
||||
(void) button;
|
||||
(void) action;
|
||||
|
||||
view_edit_currently_selected_file (0, 0);
|
||||
return 0;
|
||||
@ -1168,9 +1170,10 @@ find_do_view_file (int button)
|
||||
|
||||
/* Handle edit command, when invoked as a button */
|
||||
static int
|
||||
find_do_edit_file (int button)
|
||||
find_do_edit_file (WButton *button, int action)
|
||||
{
|
||||
(void) button;
|
||||
(void) action;
|
||||
|
||||
view_edit_currently_selected_file (0, 1);
|
||||
return 0;
|
||||
@ -1236,17 +1239,17 @@ setup_gui (void)
|
||||
button_new (FIND2_Y - 3, fbuts[6].x, B_VIEW, NORMAL_BUTTON,
|
||||
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));
|
||||
button_new (FIND2_Y - 3, fbuts[5].x, B_PANELIZE, NORMAL_BUTTON, fbuts[5].text, NULL));
|
||||
|
||||
add_widget (find_dlg,
|
||||
button_new (FIND2_Y - 4, fbuts[4].x, B_CANCEL, NORMAL_BUTTON, fbuts[4].text, 0));
|
||||
button_new (FIND2_Y - 4, fbuts[4].x, B_CANCEL, NORMAL_BUTTON, fbuts[4].text, NULL));
|
||||
stop_button =
|
||||
button_new (FIND2_Y - 4, fbuts[0].x, B_STOP, NORMAL_BUTTON, 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));
|
||||
button_new (FIND2_Y - 4, fbuts[3].x, B_AGAIN, NORMAL_BUTTON, fbuts[3].text, NULL));
|
||||
add_widget (find_dlg,
|
||||
button_new (FIND2_Y - 4, fbuts[2].x, B_ENTER, DEFPUSH_BUTTON, fbuts[2].text, 0));
|
||||
button_new (FIND2_Y - 4, fbuts[2].x, B_ENTER, DEFPUSH_BUTTON, fbuts[2].text, NULL));
|
||||
|
||||
status_label = label_new (FIND2_Y - 7, 4, _("Searching"));
|
||||
add_widget (find_dlg, status_label);
|
||||
|
@ -306,8 +306,10 @@ add_name_to_list (const char *path)
|
||||
#endif /* !ENABLE_VFS */
|
||||
|
||||
static int
|
||||
hotlist_button_callback (int action)
|
||||
hotlist_button_callback (WButton *button, int action)
|
||||
{
|
||||
(void) button;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case B_MOVE:
|
||||
@ -463,7 +465,7 @@ hotlist_handle_key (Dlg_head * h, int key)
|
||||
case '\n':
|
||||
case KEY_ENTER:
|
||||
case KEY_RIGHT:
|
||||
if (hotlist_button_callback (B_ENTER))
|
||||
if (hotlist_button_callback (NULL, B_ENTER))
|
||||
{
|
||||
h->ret_value = B_ENTER;
|
||||
dlg_stop (h);
|
||||
@ -472,7 +474,7 @@ hotlist_handle_key (Dlg_head * h, int key)
|
||||
|
||||
case KEY_LEFT:
|
||||
if (hotlist_state.type != LIST_VFSLIST)
|
||||
return !hotlist_button_callback (B_UP_GROUP);
|
||||
return !hotlist_button_callback (NULL, B_UP_GROUP);
|
||||
else
|
||||
return MSG_NOT_HANDLED;
|
||||
|
||||
@ -481,7 +483,7 @@ hotlist_handle_key (Dlg_head * h, int key)
|
||||
return MSG_NOT_HANDLED;
|
||||
else
|
||||
{
|
||||
hotlist_button_callback (B_REMOVE);
|
||||
hotlist_button_callback (NULL, B_REMOVE);
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
@ -574,7 +576,7 @@ l_call (WListbox * list)
|
||||
}
|
||||
else
|
||||
{
|
||||
hotlist_button_callback (B_ENTER);
|
||||
hotlist_button_callback (NULL, B_ENTER);
|
||||
hotlist_callback (dlg, NULL, DLG_POST_KEY, '\n', NULL);
|
||||
return LISTBOX_CONT;
|
||||
}
|
||||
@ -587,7 +589,7 @@ l_call (WListbox * list)
|
||||
}
|
||||
}
|
||||
|
||||
hotlist_button_callback (B_UP_GROUP);
|
||||
hotlist_button_callback (NULL, B_UP_GROUP);
|
||||
hotlist_callback (dlg, NULL, DLG_POST_KEY, 'u', NULL);
|
||||
return LISTBOX_CONT;
|
||||
}
|
||||
|
12
src/layout.c
12
src/layout.c
@ -243,8 +243,9 @@ update_split (void)
|
||||
}
|
||||
|
||||
static int
|
||||
b2left_cback (int action)
|
||||
b2left_cback (WButton *button, int action)
|
||||
{
|
||||
(void) button;
|
||||
(void) action;
|
||||
|
||||
if (_equal_split)
|
||||
@ -260,8 +261,9 @@ b2left_cback (int action)
|
||||
}
|
||||
|
||||
static int
|
||||
b2right_cback (int action)
|
||||
b2right_cback (WButton *button, int action)
|
||||
{
|
||||
(void) button;
|
||||
(void) action;
|
||||
|
||||
if (_equal_split)
|
||||
@ -277,8 +279,9 @@ b2right_cback (int action)
|
||||
}
|
||||
|
||||
static int
|
||||
bplus_cback (int action)
|
||||
bplus_cback (WButton *button, int action)
|
||||
{
|
||||
(void) button;
|
||||
(void) action;
|
||||
|
||||
if (_output_lines < 99)
|
||||
@ -287,8 +290,9 @@ bplus_cback (int action)
|
||||
}
|
||||
|
||||
static int
|
||||
bminus_cback (int action)
|
||||
bminus_cback (WButton *button, int action)
|
||||
{
|
||||
(void) button;
|
||||
(void) action;
|
||||
|
||||
if (_output_lines > 0)
|
||||
|
10
src/learn.c
10
src/learn.c
@ -63,8 +63,10 @@ static struct {
|
||||
int ret_cmd, flags, y, x;
|
||||
const char *text;
|
||||
} learn_but[BUTTONS] = {
|
||||
/* *INDENT-OFF */
|
||||
{ B_CANCEL, NORMAL_BUTTON, 0, 39, N_("&Cancel") },
|
||||
{ B_ENTER, DEFPUSH_BUTTON, 0, 25, N_("&Save") }
|
||||
/* *INDENT-ON */
|
||||
};
|
||||
|
||||
static Dlg_head *learn_dlg;
|
||||
@ -81,10 +83,14 @@ static int learnchanged;
|
||||
static const char* learn_title = N_("Learn keys");
|
||||
|
||||
|
||||
static int learn_button (int action)
|
||||
static int learn_button (WButton *button, int action)
|
||||
{
|
||||
Dlg_head *d;
|
||||
char *seq;
|
||||
Dlg_head *d = create_message (D_ERROR, _("Teach me a key"),
|
||||
|
||||
(void) button;
|
||||
|
||||
d = create_message (D_ERROR, _("Teach me a key"),
|
||||
_("Please press the %s\n"
|
||||
"and then wait until this message disappears.\n\n"
|
||||
"Then, press it again to see if OK appears\n"
|
||||
|
@ -224,7 +224,7 @@ button_callback (Widget * w, widget_msg_t msg, int parm)
|
||||
return MSG_NOT_HANDLED;
|
||||
|
||||
if (b->callback)
|
||||
stop = (*b->callback) (b->action);
|
||||
stop = (*b->callback) (b, b->action);
|
||||
if (!b->callback || stop)
|
||||
{
|
||||
h->ret_value = b->action;
|
||||
|
@ -30,7 +30,8 @@ typedef enum {
|
||||
/* widget variable of type Widget. We abuse this fact everywhere */
|
||||
|
||||
/* button callback */
|
||||
typedef int (*bcback) (int);
|
||||
struct WButton;
|
||||
typedef int (*bcback) (struct WButton *button, int action);
|
||||
|
||||
/* structure for label (caption) with hotkey, if original text does not contain
|
||||
* hotkey, only start is valid and is equal to original text
|
||||
|
Loading…
Reference in New Issue
Block a user