diff --git a/lib/widget/dialog.c b/lib/widget/dialog.c index aebd3e210..c191c46a9 100644 --- a/lib/widget/dialog.c +++ b/lib/widget/dialog.c @@ -90,48 +90,6 @@ typedef struct /*** file scope functions ************************************************************************/ /* --------------------------------------------------------------------------------------------- */ -/** - * broadcast a message to all the widgets in a dialog that have - * the options set to flags. If flags is zero, the message is sent - * to all widgets. - */ - -static void -dlg_broadcast_msg_to (WDialog * h, widget_msg_t msg, gboolean reverse, widget_options_t flags) -{ - GList *p, *first; - WGroup *g = GROUP (h); - - if (g->widgets == NULL) - return; - - if (g->current == NULL) - g->current = g->widgets; - - if (reverse) - p = group_get_widget_prev_of (g->current); - else - p = group_get_widget_next_of (g->current); - - first = p; - - do - { - Widget *w = WIDGET (p->data); - - if (reverse) - p = group_get_widget_prev_of (p); - else - p = group_get_widget_next_of (p); - - if ((flags == 0) || ((flags & w->options) != 0)) - send_message (w, NULL, msg, 0, NULL); - } - while (first != p); -} - -/* --------------------------------------------------------------------------------------------- */ - /** * Read histories from the ${XDG_CACHE_HOME}/mc/history file */ @@ -785,15 +743,6 @@ do_refresh (void) } } -/* --------------------------------------------------------------------------------------------- */ -/** broadcast a message to all the widgets in a dialog */ - -void -dlg_broadcast_msg (WDialog * h, widget_msg_t msg) -{ - dlg_broadcast_msg_to (h, msg, FALSE, 0); -} - /* --------------------------------------------------------------------------------------------- */ /** Find the widget with the given callback in the dialog h */ @@ -882,7 +831,7 @@ dlg_draw (WDialog * h) } send_message (h, NULL, MSG_DRAW, 0, NULL); - dlg_broadcast_msg (h, MSG_DRAW); + group_send_broadcast_msg (g, MSG_DRAW); update_cursor (h); } @@ -916,7 +865,7 @@ dlg_init (WDialog * h) dialog_switch_add (h); send_message (h, NULL, MSG_INIT, 0, NULL); - dlg_broadcast_msg (h, MSG_INIT); + group_send_broadcast_msg (g, MSG_INIT); dlg_read_history (h); } diff --git a/lib/widget/dialog.h b/lib/widget/dialog.h index 312cb59ee..4327f4a7c 100644 --- a/lib/widget/dialog.h +++ b/lib/widget/dialog.h @@ -128,8 +128,6 @@ char *dlg_get_title (const WDialog * h, size_t len); void dlg_draw (WDialog * h); -void dlg_broadcast_msg (WDialog * h, widget_msg_t message); - /* Default callback for dialogs */ cb_ret_t dlg_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data); diff --git a/lib/widget/group.c b/lib/widget/group.c index 8c9f3da62..58f257bf1 100644 --- a/lib/widget/group.c +++ b/lib/widget/group.c @@ -100,6 +100,44 @@ group_select_next_or_prev (WGroup * g, gboolean next) } } +/* --------------------------------------------------------------------------------------------- */ +/** + * Send broadcast message to all widgets in the group that have specified options. + * + * @param g WGroup object + * @param msg message sent to widgets + * @param reverse if TRUE, send message in reverse order, FALSE -- in direct one. + * @param options if WOP_DEFAULT, the message is sent to all widgets. Else message is sent to widgets + * that have specified options. + */ + +static void +group_send_broadcast_msg_custom (WGroup * g, widget_msg_t msg, gboolean reverse, + widget_options_t options) +{ + GList *p, *first; + + if (g->widgets == NULL) + return; + + if (g->current == NULL) + g->current = g->widgets; + + p = group_get_next_or_prev_of (g->current, !reverse); + first = p; + + do + { + Widget *w = WIDGET (p->data); + + p = group_get_next_or_prev_of (p, !reverse); + + if (options == WOP_DEFAULT || (options & w->options) != 0) + send_message (w, NULL, msg, 0, NULL); + } + while (first != p); +} + /* --------------------------------------------------------------------------------------------- */ /*** public functions ****************************************************************************/ /* --------------------------------------------------------------------------------------------- */ @@ -310,3 +348,17 @@ group_select_widget_by_id (const WGroup * g, unsigned long id) } /* --------------------------------------------------------------------------------------------- */ +/** + * Send broadcast message to all widgets in the group. + * + * @param g WGroup object + * @param msg message sent to widgets + */ + +void +group_send_broadcast_msg (WGroup * g, widget_msg_t msg) +{ + group_send_broadcast_msg_custom (g, msg, FALSE, WOP_DEFAULT); +} + +/* --------------------------------------------------------------------------------------------- */ diff --git a/lib/widget/group.h b/lib/widget/group.h index 956948702..17f6135c7 100644 --- a/lib/widget/group.h +++ b/lib/widget/group.h @@ -53,6 +53,8 @@ void group_select_prev_widget (WGroup * g); void group_select_widget_by_id (const WGroup * g, unsigned long id); +void group_send_broadcast_msg (WGroup * g, widget_msg_t message); + /* --------------------------------------------------------------------------------------------- */ /*** inline functions ****************************************************************************/ /* --------------------------------------------------------------------------------------------- */ diff --git a/src/filemanager/achown.c b/src/filemanager/achown.c index 4601a72d9..a6f48d9bf 100644 --- a/src/filemanager/achown.c +++ b/src/filemanager/achown.c @@ -688,7 +688,7 @@ advanced_chown_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm ch_flags[i * 3 + parm - 3] = (x_toggle & (1 << parm)) ? '-' : '+'; x_toggle ^= (1 << parm); update_mode (g); - dlg_broadcast_msg (h, MSG_DRAW); + group_send_broadcast_msg (g, MSG_DRAW); break; case XCTRL ('x'): @@ -705,7 +705,7 @@ advanced_chown_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm ch_flags[i * 3 + parm] = (x_toggle & (1 << parm)) ? '-' : '+'; x_toggle ^= (1 << parm); update_mode (g); - dlg_broadcast_msg (h, MSG_DRAW); + group_send_broadcast_msg (g, MSG_DRAW); break; default: