]> de.git.xonotic.org Git - voretournament/voretournament.git/blob - misc/mediasource/extra/netradiant-src/libs/gtkutil/closure.h
Rename the compiled fteqcc to fteqcc-win32 (as that's what it is)
[voretournament/voretournament.git] / misc / mediasource / extra / netradiant-src / libs / gtkutil / closure.h
1 /*
2 Copyright (C) 2001-2006, William Joseph.
3 All Rights Reserved.
4
5 This file is part of GtkRadiant.
6
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.
11
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.
16
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
20 */
21
22 #if !defined(INCLUDED_GTKUTIL_CLOSURE_H)
23 #define INCLUDED_GTKUTIL_CLOSURE_H
24
25 #include <glib-object.h>
26 #include "generic/callback.h"
27
28 inline void closure_destroy(gpointer data, GClosure* closure)
29 {
30   delete reinterpret_cast<Callback*>(data);
31 }
32
33 inline GClosure* create_cclosure(GCallback func, const Callback& callback)
34 {
35   return g_cclosure_new(func, new Callback(callback), closure_destroy);
36 }
37
38 inline GValue GValue_default()
39 {
40   GValue value;
41   value.g_type = 0;
42   return value;
43 }
44
45 inline gint object_get_int_property(GObject* object, const char* property)
46 {
47   GValue gvalue = GValue_default();
48   g_value_init(&gvalue, G_TYPE_INT);
49   g_object_get_property(object, property, &gvalue);
50   return g_value_get_int(&gvalue);
51 }
52
53 inline void object_set_int_property(GObject* object, const char* property, gint value)
54 {
55   GValue gvalue = GValue_default();
56   g_value_init(&gvalue, G_TYPE_INT);
57   g_value_set_int(&gvalue, value);
58   g_object_set_property(object, property, &gvalue);
59 }
60
61 inline gboolean object_get_boolean_property(GObject* object, const char* property)
62 {
63   GValue gvalue = GValue_default();
64   g_value_init(&gvalue, G_TYPE_BOOLEAN);
65   g_object_get_property(object, property, &gvalue);
66   return g_value_get_boolean(&gvalue);
67 }
68
69 inline void object_set_boolean_property(GObject* object, const char* property, gboolean value)
70 {
71   GValue gvalue = GValue_default();
72   g_value_init(&gvalue, G_TYPE_BOOLEAN);
73   g_value_set_boolean(&gvalue, value);
74   g_object_set_property(object, property, &gvalue);
75 }
76
77 #endif