2 * Copyright 1999-2001 Adrian E. Feiguin <feiguin@ifir.edu.ar>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
24 #include "gtkextrafeatures.h"
25 #include <gobject/gvaluecollector.h>
27 const guint gtkextra_major_version = GTKEXTRA_MAJOR_VERSION;
28 const guint gtkextra_minor_version = GTKEXTRA_MINOR_VERSION;
29 const guint gtkextra_micro_version = GTKEXTRA_MICRO_VERSION;
30 const guint gtkextra_binary_age = GTKEXTRA_BINARY_AGE;
31 const guint gtkextra_interface_age = GTKEXTRA_INTERFACE_AGE;
34 gtkextra_check_version (guint required_major,
38 if (required_major > GTKEXTRA_MAJOR_VERSION)
39 return "GtkExtra version too old (major mismatch)";
40 if (required_major < GTKEXTRA_MAJOR_VERSION)
41 return "GtkExtra version too new (major mismatch)";
42 if (required_minor > GTKEXTRA_MINOR_VERSION)
43 return "GtkExtra version too old (minor mismatch)";
44 if (required_minor < GTKEXTRA_MINOR_VERSION)
45 return "GtkExtra version too new (minor mismatch)";
46 if (required_micro < GTKEXTRA_MICRO_VERSION - GTKEXTRA_BINARY_AGE)
47 return "GtkExtra version too new (micro mismatch)";
48 if (required_micro > GTKEXTRA_MICRO_VERSION)
49 return "GtkExtra version too old (micro mismatch)";
55 _gtkextra_signal_test(GtkObject *object, guint signal_id, gint arg1, gint arg2, gboolean *default_ret)
59 GValue instance_and_param[3] = { { 0, }, {0, }, {0, } };
61 g_value_init(instance_and_param + 0, GTK_OBJECT_TYPE(object));
62 g_value_set_instance(instance_and_param + 0, G_OBJECT(object));
64 g_value_init(instance_and_param + 1, G_TYPE_INT);
65 g_value_set_int(instance_and_param + 1, arg1);
67 g_value_init(instance_and_param + 2, G_TYPE_INT);
68 g_value_set_int(instance_and_param + 2, arg2);
70 g_value_init(&ret, G_TYPE_BOOLEAN);
71 g_value_set_boolean(&ret, *default_ret);
73 g_signal_emitv(instance_and_param, signal_id, 0, &ret);
74 *default_ret = g_value_get_boolean(&ret);
76 g_value_unset(instance_and_param + 0);
77 g_value_unset(instance_and_param + 1);
78 g_value_unset(instance_and_param + 2);
83 _gtkextra_signal_emit(GtkObject *object, guint signal_id, ...)
87 GValue instance_and_params [10] = { {0, }, };
93 va_start (var_args, signal_id);
95 g_value_init(instance_and_params + 0, GTK_OBJECT_TYPE(object));
96 g_value_set_instance (instance_and_params + 0, G_OBJECT(object));
98 g_signal_query(signal_id, &query);
100 for (i = 0; i < query.n_params; i++)
102 gboolean static_scope = query.param_types[i]&~G_SIGNAL_TYPE_STATIC_SCOPE;
103 g_value_init(instance_and_params + i + 1, query.param_types[i]);
106 G_VALUE_COLLECT (instance_and_params + i + 1,
108 static_scope ? G_VALUE_NOCOPY_CONTENTS : 0,
113 g_warning ("%s: %s", G_STRLOC, error);
116 g_value_unset (instance_and_params + i);
125 g_value_init(&ret, query.return_type);
126 result = va_arg(var_args,gboolean *);
127 g_value_set_boolean(&ret, *result);
128 g_signal_emitv(instance_and_params, signal_id, 0, &ret);
129 *result = g_value_get_boolean(&ret);
130 g_value_unset (&ret);
132 for (i = 0; i < query.n_params; i++)
133 g_value_unset (instance_and_params + 1 + i);
134 g_value_unset (instance_and_params + 0);