Merge branch '3760_wedit_over_buttonbar'
[midnight-commander.git] / lib / event / raise.c
blob2bbe37ec8b7264a0d6697f4c05a5581716dad4a5
1 /*
2 Handle any events in application.
3 Raise events.
5 Copyright (C) 2011-2017
6 Free Software Foundation, Inc.
8 Written by:
9 Slava Zanko <slavazanko@gmail.com>, 2011.
11 This file is part of the Midnight Commander.
13 The Midnight Commander is free software: you can redistribute it
14 and/or modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation, either version 3 of the License,
16 or (at your option) any later version.
18 The Midnight Commander is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #include <config.h>
29 #include "lib/global.h"
30 #include "lib/event.h"
32 #include "internal.h"
34 /*** global variables ****************************************************************************/
36 /*** file scope macro definitions ****************************************************************/
38 /*** file scope type declarations ****************************************************************/
40 /*** file scope variables ************************************************************************/
42 /*** file scope functions ************************************************************************/
44 /* --------------------------------------------------------------------------------------------- */
45 /*** public functions ****************************************************************************/
46 /* --------------------------------------------------------------------------------------------- */
48 gboolean
49 mc_event_raise (const gchar * event_group_name, const gchar * event_name, gpointer event_data)
51 GTree *event_group;
52 GPtrArray *callbacks;
53 guint array_index;
55 if (mc_event_grouplist == NULL || event_group_name == NULL || event_name == NULL)
56 return FALSE;
58 event_group = mc_event_get_event_group_by_name (event_group_name, FALSE, NULL);
59 if (event_group == NULL)
60 return FALSE;
62 callbacks = mc_event_get_event_by_name (event_group, event_name, FALSE, NULL);
63 if (callbacks == NULL)
64 return FALSE;
66 for (array_index = callbacks->len; array_index > 0; array_index--)
68 mc_event_callback_t *cb = g_ptr_array_index (callbacks, array_index - 1);
69 if (!(*cb->callback) (event_group_name, event_name, cb->init_data, event_data))
70 break;
72 return TRUE;
75 /* --------------------------------------------------------------------------------------------- */