1 /* This file is part of Clementine. 2 Copyright 2012, 2014, John Maguire <john.maguire@gmail.com> 3 Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com> 4 5 Clementine is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 Clementine is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with Clementine. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef CORE_SIGNALCHECKER_H_ 20 #define CORE_SIGNALCHECKER_H_ 21 22 #include <glib-object.h> 23 24 #include <boost/function_types/function_arity.hpp> 25 #include <boost/typeof/typeof.hpp> 26 27 // Do not call this directly, use CHECKED_GCONNECT instead. 28 gulong CheckedGConnect(gpointer source, const char* signal, GCallback callback, 29 gpointer data, const int callback_param_count); 30 31 #define FUNCTION_ARITY(callback) \ 32 boost::function_types::function_arity<BOOST_TYPEOF(callback)>::value 33 34 #define CHECKED_GCONNECT(source, signal, callback, data) \ 35 CheckedGConnect(source, signal, G_CALLBACK(callback), data, \ 36 FUNCTION_ARITY(callback)) 37 38 #endif // CORE_SIGNALCHECKER_H_ 39