2 Copyright (C) 2001-2006, William Joseph.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #if !defined( INCLUDED_GTKUTIL_CLOSURE_H )
23 #define INCLUDED_GTKUTIL_CLOSURE_H
25 #include <glib-object.h>
26 #include "generic/callback.h"
28 inline void closure_destroy( gpointer data, GClosure* closure ){
29 delete reinterpret_cast<Callback<void()>*>( data );
32 inline GClosure* create_cclosure( GCallback func, const Callback<void()>& callback ){
33 return g_cclosure_new( func, new Callback<void()>( callback ), closure_destroy );
36 inline GValue GValue_default(){
42 inline gint object_get_int_property( GObject* object, const char* property ){
43 GValue gvalue = GValue_default();
44 g_value_init( &gvalue, G_TYPE_INT );
45 g_object_get_property( object, property, &gvalue );
46 return g_value_get_int( &gvalue );
49 inline void object_set_int_property( GObject* object, const char* property, gint value ){
50 GValue gvalue = GValue_default();
51 g_value_init( &gvalue, G_TYPE_INT );
52 g_value_set_int( &gvalue, value );
53 g_object_set_property( object, property, &gvalue );
56 inline gboolean object_get_boolean_property( GObject* object, const char* property ){
57 GValue gvalue = GValue_default();
58 g_value_init( &gvalue, G_TYPE_BOOLEAN );
59 g_object_get_property( object, property, &gvalue );
60 return g_value_get_boolean( &gvalue );
63 inline void object_set_boolean_property( GObject* object, const char* property, gboolean value ){
64 GValue gvalue = GValue_default();
65 g_value_init( &gvalue, G_TYPE_BOOLEAN );
66 g_value_set_boolean( &gvalue, value );
67 g_object_set_property( object, property, &gvalue );