mirror of https://github.com/MidnightCommander/mc
Ticket #3566: Split MSG_ACTION into MSG_ACTION and MSG_NOTIFY.
Start step: simplify buttonbar and menu handling. We make WButtonBar send the command directly to the target widget. This lets us simplify the MSG_ACTION case in dialog handlers. The menu handling too is simplified here. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
e213af27a6
commit
6b56cabf6f
|
@ -148,9 +148,12 @@ buttonbar_call (WButtonBar * bb, int i)
|
|||
{
|
||||
cb_ret_t ret = MSG_NOT_HANDLED;
|
||||
Widget *w = WIDGET (bb);
|
||||
Widget *target;
|
||||
|
||||
target = (bb->labels[i].receiver != NULL) ? bb->labels[i].receiver : WIDGET (w->owner);
|
||||
|
||||
if ((bb != NULL) && (bb->labels[i].command != CK_IgnoreKey))
|
||||
ret = send_message (w->owner, w, MSG_ACTION, bb->labels[i].command, bb->labels[i].receiver);
|
||||
ret = send_message (target, w, MSG_ACTION, bb->labels[i].command, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -3406,19 +3406,11 @@ dview_dialog_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
|||
return MSG_HANDLED;
|
||||
|
||||
case MSG_ACTION:
|
||||
/* shortcut */
|
||||
if (sender == NULL)
|
||||
return dview_execute_cmd (NULL, parm);
|
||||
/* message from buttonbar */
|
||||
if (sender == WIDGET (find_buttonbar (h)))
|
||||
{
|
||||
if (data != NULL)
|
||||
return send_message (data, NULL, MSG_ACTION, parm, NULL);
|
||||
/* Handle shortcuts. */
|
||||
|
||||
dview = (WDiff *) find_widget_type (h, dview_callback);
|
||||
return dview_execute_cmd (dview, parm);
|
||||
}
|
||||
return MSG_NOT_HANDLED;
|
||||
/* Note: the buttonbar sends messages directly to the the WDiff, not to
|
||||
* here, which is why we can pass NULL in the following call. */
|
||||
return dview_execute_cmd (NULL, parm);
|
||||
|
||||
case MSG_VALIDATE:
|
||||
dview = (WDiff *) find_widget_type (h, dview_callback);
|
||||
|
|
|
@ -1021,27 +1021,20 @@ edit_dialog_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, v
|
|||
return MSG_HANDLED;
|
||||
|
||||
case MSG_ACTION:
|
||||
/* shortcut */
|
||||
if (sender == NULL)
|
||||
return edit_dialog_command_execute (h, parm);
|
||||
/* message from menu */
|
||||
menubar = find_menubar (h);
|
||||
if (sender == WIDGET (menubar))
|
||||
{
|
||||
if (edit_dialog_command_execute (h, parm) == MSG_HANDLED)
|
||||
return MSG_HANDLED;
|
||||
/* try send command to the current window */
|
||||
return send_message (h->current->data, NULL, MSG_ACTION, parm, NULL);
|
||||
/* Handle shortcuts, menu, and buttonbar. */
|
||||
|
||||
cb_ret_t result;
|
||||
|
||||
result = edit_dialog_command_execute (h, parm);
|
||||
|
||||
/* We forward any commands coming from the menu, and which haven't been
|
||||
handled by the dialog, to the focused WEdit window. */
|
||||
if (result == MSG_NOT_HANDLED && sender == WIDGET (find_menubar (h)))
|
||||
result = send_message (h->current->data, NULL, MSG_ACTION, parm, NULL);
|
||||
|
||||
return result;
|
||||
}
|
||||
/* message from buttonbar */
|
||||
buttonbar = find_buttonbar (h);
|
||||
if (sender == WIDGET (buttonbar))
|
||||
{
|
||||
if (data != NULL)
|
||||
return send_message (data, NULL, MSG_ACTION, parm, NULL);
|
||||
return edit_dialog_command_execute (h, parm);
|
||||
}
|
||||
return MSG_NOT_HANDLED;
|
||||
|
||||
case MSG_KEY:
|
||||
{
|
||||
|
|
|
@ -1566,20 +1566,8 @@ midnight_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void
|
|||
return MSG_HANDLED;
|
||||
|
||||
case MSG_ACTION:
|
||||
/* shortcut */
|
||||
if (sender == NULL)
|
||||
return midnight_execute_cmd (NULL, parm);
|
||||
/* message from menu */
|
||||
if (sender == WIDGET (the_menubar))
|
||||
return midnight_execute_cmd (sender, parm);
|
||||
/* message from buttonbar */
|
||||
if (sender == WIDGET (the_bar))
|
||||
{
|
||||
if (data != NULL)
|
||||
return send_message (data, NULL, MSG_ACTION, parm, NULL);
|
||||
return midnight_execute_cmd (sender, parm);
|
||||
}
|
||||
return MSG_NOT_HANDLED;
|
||||
/* Handle shortcuts, menu, and buttonbar. */
|
||||
return midnight_execute_cmd (sender, parm);
|
||||
|
||||
case MSG_END:
|
||||
panel_deinit ();
|
||||
|
|
13
src/help.c
13
src/help.c
|
@ -966,17 +966,8 @@ help_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *da
|
|||
return help_handle_key (h, parm);
|
||||
|
||||
case MSG_ACTION:
|
||||
/* shortcut */
|
||||
if (sender == NULL)
|
||||
return help_execute_cmd (parm);
|
||||
/* message from buttonbar */
|
||||
if (sender == WIDGET (find_buttonbar (h)))
|
||||
{
|
||||
if (data != NULL)
|
||||
return send_message (data, NULL, MSG_ACTION, parm, NULL);
|
||||
return help_execute_cmd (parm);
|
||||
}
|
||||
return MSG_NOT_HANDLED;
|
||||
/* Handle shortcuts and buttonbar. */
|
||||
return help_execute_cmd (parm);
|
||||
|
||||
default:
|
||||
return dlg_default_callback (w, sender, msg, parm, data);
|
||||
|
|
|
@ -724,19 +724,11 @@ mcview_dialog_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
|||
return MSG_HANDLED;
|
||||
|
||||
case MSG_ACTION:
|
||||
/* shortcut */
|
||||
if (sender == NULL)
|
||||
return mcview_execute_cmd (NULL, parm);
|
||||
/* message from buttonbar */
|
||||
if (sender == WIDGET (find_buttonbar (h)))
|
||||
{
|
||||
if (data != NULL)
|
||||
return send_message (data, NULL, MSG_ACTION, parm, NULL);
|
||||
/* Handle shortcuts. */
|
||||
|
||||
view = (WView *) find_widget_type (h, mcview_callback);
|
||||
return mcview_execute_cmd (view, parm);
|
||||
}
|
||||
return MSG_NOT_HANDLED;
|
||||
/* Note: the buttonbar sends messages directly to the the WView, not to
|
||||
* here, which is why we can pass NULL in the following call. */
|
||||
return mcview_execute_cmd (NULL, parm);
|
||||
|
||||
case MSG_VALIDATE:
|
||||
view = (WView *) find_widget_type (h, mcview_callback);
|
||||
|
|
Loading…
Reference in New Issue