Added parameter to Wbutton callback to get the message sender easy.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2010-06-30 12:25:16 +04:00
parent 09b094b153
commit 760b700645
7 changed files with 50 additions and 33 deletions

View File

@ -558,10 +558,11 @@ static WLabel *cplabel;
static WCheck *inpcheck; static WCheck *inpcheck;
static int static int
sel_charset_button (int action) sel_charset_button (WButton *button, int action)
{ {
int new_dcp; int new_dcp;
(void) button;
(void) action; (void) action;
new_dcp = select_charset (-1, -1, new_display_codepage, TRUE); new_dcp = select_charset (-1, -1, new_display_codepage, TRUE);
@ -890,12 +891,14 @@ jobs_fill_listbox (void)
} }
static int static int
task_cb (int action) task_cb (WButton *button, int action)
{ {
TaskList *tl; TaskList *tl;
int sig = 0; int sig = 0;
if (!bg_list->list) (void) button;
if (bg_list->list == NULL)
return 0; return 0;
/* Get this instance information */ /* Get this instance information */
@ -937,18 +940,16 @@ static struct
const char *name; const char *name;
int xpos; int xpos;
int value; int value;
int (*callback) (int); bcback callback;
} }
job_buttons[] = job_buttons[] =
{ {
{ /* *INDENT-OFF* */
N_("&Stop"), 3, B_STOP, task_cb}, { N_("&Stop"), 3, B_STOP, task_cb },
{ { N_("&Resume"), 12, B_RESUME, task_cb },
N_("&Resume"), 12, B_RESUME, task_cb}, { N_("&Kill"), 23, B_KILL, task_cb },
{ { N_("&OK"), 35, B_CANCEL, NULL }
N_("&Kill"), 23, B_KILL, task_cb}, /* *INDENT-ON* */
{
N_("&OK"), 35, B_CANCEL, NULL}
}; };
void void

View File

@ -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 */ /* Handles the Stop/Start button in the find window */
static int static int
start_stop (int button) start_stop (WButton *button, int action)
{ {
(void) button; (void) button;
(void) action;
running = is_start; running = is_start;
set_idle_proc (find_dlg, running); set_idle_proc (find_dlg, running);
@ -1158,9 +1159,10 @@ start_stop (int button)
/* Handle view command, when invoked as a button */ /* Handle view command, when invoked as a button */
static int static int
find_do_view_file (int button) find_do_view_file (WButton *button, int action)
{ {
(void) button; (void) button;
(void) action;
view_edit_currently_selected_file (0, 0); view_edit_currently_selected_file (0, 0);
return 0; return 0;
@ -1168,9 +1170,10 @@ find_do_view_file (int button)
/* Handle edit command, when invoked as a button */ /* Handle edit command, when invoked as a button */
static int static int
find_do_edit_file (int button) find_do_edit_file (WButton *button, int action)
{ {
(void) button; (void) button;
(void) action;
view_edit_currently_selected_file (0, 1); view_edit_currently_selected_file (0, 1);
return 0; return 0;
@ -1236,17 +1239,17 @@ setup_gui (void)
button_new (FIND2_Y - 3, fbuts[6].x, B_VIEW, NORMAL_BUTTON, button_new (FIND2_Y - 3, fbuts[6].x, B_VIEW, NORMAL_BUTTON,
fbuts[6].text, find_do_view_file)); fbuts[6].text, find_do_view_file));
add_widget (find_dlg, 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, 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 = stop_button =
button_new (FIND2_Y - 4, fbuts[0].x, B_STOP, NORMAL_BUTTON, fbuts[0].text, start_stop); 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, stop_button);
add_widget (find_dlg, 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, 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")); status_label = label_new (FIND2_Y - 7, 4, _("Searching"));
add_widget (find_dlg, status_label); add_widget (find_dlg, status_label);

View File

@ -306,8 +306,10 @@ add_name_to_list (const char *path)
#endif /* !ENABLE_VFS */ #endif /* !ENABLE_VFS */
static int static int
hotlist_button_callback (int action) hotlist_button_callback (WButton *button, int action)
{ {
(void) button;
switch (action) switch (action)
{ {
case B_MOVE: case B_MOVE:
@ -463,7 +465,7 @@ hotlist_handle_key (Dlg_head * h, int key)
case '\n': case '\n':
case KEY_ENTER: case KEY_ENTER:
case KEY_RIGHT: case KEY_RIGHT:
if (hotlist_button_callback (B_ENTER)) if (hotlist_button_callback (NULL, B_ENTER))
{ {
h->ret_value = B_ENTER; h->ret_value = B_ENTER;
dlg_stop (h); dlg_stop (h);
@ -472,7 +474,7 @@ hotlist_handle_key (Dlg_head * h, int key)
case KEY_LEFT: case KEY_LEFT:
if (hotlist_state.type != LIST_VFSLIST) if (hotlist_state.type != LIST_VFSLIST)
return !hotlist_button_callback (B_UP_GROUP); return !hotlist_button_callback (NULL, B_UP_GROUP);
else else
return MSG_NOT_HANDLED; return MSG_NOT_HANDLED;
@ -481,7 +483,7 @@ hotlist_handle_key (Dlg_head * h, int key)
return MSG_NOT_HANDLED; return MSG_NOT_HANDLED;
else else
{ {
hotlist_button_callback (B_REMOVE); hotlist_button_callback (NULL, B_REMOVE);
return MSG_HANDLED; return MSG_HANDLED;
} }
@ -574,7 +576,7 @@ l_call (WListbox * list)
} }
else else
{ {
hotlist_button_callback (B_ENTER); hotlist_button_callback (NULL, B_ENTER);
hotlist_callback (dlg, NULL, DLG_POST_KEY, '\n', NULL); hotlist_callback (dlg, NULL, DLG_POST_KEY, '\n', NULL);
return LISTBOX_CONT; 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); hotlist_callback (dlg, NULL, DLG_POST_KEY, 'u', NULL);
return LISTBOX_CONT; return LISTBOX_CONT;
} }

View File

@ -243,8 +243,9 @@ update_split (void)
} }
static int static int
b2left_cback (int action) b2left_cback (WButton *button, int action)
{ {
(void) button;
(void) action; (void) action;
if (_equal_split) if (_equal_split)
@ -260,8 +261,9 @@ b2left_cback (int action)
} }
static int static int
b2right_cback (int action) b2right_cback (WButton *button, int action)
{ {
(void) button;
(void) action; (void) action;
if (_equal_split) if (_equal_split)
@ -277,8 +279,9 @@ b2right_cback (int action)
} }
static int static int
bplus_cback (int action) bplus_cback (WButton *button, int action)
{ {
(void) button;
(void) action; (void) action;
if (_output_lines < 99) if (_output_lines < 99)
@ -287,8 +290,9 @@ bplus_cback (int action)
} }
static int static int
bminus_cback (int action) bminus_cback (WButton *button, int action)
{ {
(void) button;
(void) action; (void) action;
if (_output_lines > 0) if (_output_lines > 0)

View File

@ -63,8 +63,10 @@ static struct {
int ret_cmd, flags, y, x; int ret_cmd, flags, y, x;
const char *text; const char *text;
} learn_but[BUTTONS] = { } learn_but[BUTTONS] = {
/* *INDENT-OFF */
{ B_CANCEL, NORMAL_BUTTON, 0, 39, N_("&Cancel") }, { B_CANCEL, NORMAL_BUTTON, 0, 39, N_("&Cancel") },
{ B_ENTER, DEFPUSH_BUTTON, 0, 25, N_("&Save") } { B_ENTER, DEFPUSH_BUTTON, 0, 25, N_("&Save") }
/* *INDENT-ON */
}; };
static Dlg_head *learn_dlg; static Dlg_head *learn_dlg;
@ -81,10 +83,14 @@ static int learnchanged;
static const char* learn_title = N_("Learn keys"); 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; 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" _("Please press the %s\n"
"and then wait until this message disappears.\n\n" "and then wait until this message disappears.\n\n"
"Then, press it again to see if OK appears\n" "Then, press it again to see if OK appears\n"

View File

@ -224,7 +224,7 @@ button_callback (Widget * w, widget_msg_t msg, int parm)
return MSG_NOT_HANDLED; return MSG_NOT_HANDLED;
if (b->callback) if (b->callback)
stop = (*b->callback) (b->action); stop = (*b->callback) (b, b->action);
if (!b->callback || stop) if (!b->callback || stop)
{ {
h->ret_value = b->action; h->ret_value = b->action;

View File

@ -30,7 +30,8 @@ typedef enum {
/* widget variable of type Widget. We abuse this fact everywhere */ /* widget variable of type Widget. We abuse this fact everywhere */
/* button callback */ /* 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 /* structure for label (caption) with hotkey, if original text does not contain
* hotkey, only start is valid and is equal to original text * hotkey, only start is valid and is equal to original text