1 /* 2 Handle any events in application. 3 Raise events. 4 5 Copyright (C) 2011-2024 6 Free Software Foundation, Inc. 7 8 Written by: 9 Slava Zanko <slavazanko@gmail.com>, 2011. 10 11 This file is part of the Midnight Commander. 12 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. 17 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. 22 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/>. 25 */ 26 27 #include <config.h> 28 29 #include "lib/global.h" 30 #include "lib/event.h" 31 32 #include "internal.h" 33 34 /*** global variables ****************************************************************************/ 35 36 /*** file scope macro definitions ****************************************************************/ 37 38 /*** file scope type declarations ****************************************************************/ 39 40 /*** file scope variables ************************************************************************/ 41 42 /*** file scope functions ************************************************************************/ 43 44 /* --------------------------------------------------------------------------------------------- */ 45 /*** public functions ****************************************************************************/ 46 /* --------------------------------------------------------------------------------------------- */ 47 48 gboolean 49 mc_event_raise (const gchar *event_group_name, const gchar *event_name, gpointer event_data) /* */ 50 { 51 GTree *event_group; 52 GPtrArray *callbacks; 53 guint array_index; 54 55 if (mc_event_grouplist == NULL || event_group_name == NULL || event_name == NULL) 56 return FALSE; 57 58 event_group = mc_event_get_event_group_by_name (event_group_name, FALSE, NULL); 59 if (event_group == NULL) 60 return FALSE; 61 62 callbacks = mc_event_get_event_by_name (event_group, event_name, FALSE, NULL); 63 if (callbacks == NULL) 64 return FALSE; 65 66 for (array_index = callbacks->len; array_index > 0; array_index--) 67 { 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; 71 } 72 return TRUE; 73 } 74 75 /* --------------------------------------------------------------------------------------------- */