Fixed bug reporting the significance of paired value t-test.
[pspp-builds.git] / lib / gtksheet / gtkextra.c
1 /* gtkextra
2  * Copyright 1999-2001 Adrian E. Feiguin <feiguin@ifir.edu.ar>
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 #include <config.h>
21
22 #include <string.h>
23 #include <gtk/gtk.h>
24 #include "gtkextrafeatures.h"
25 #include <gobject/gvaluecollector.h>
26
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;
32
33 gchar *
34 gtkextra_check_version (guint required_major,
35                         guint required_minor,
36                         guint required_micro)
37 {
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)";
50   return NULL;
51 }
52
53 /*
54 void
55 _gtkextra_signal_test(GtkObject *object, guint signal_id, gint arg1, gint arg2, gboolean *default_ret)
56 {
57   gboolean result;
58   GValue ret = { 0, };
59   GValue instance_and_param[3] = { { 0, }, {0, }, {0, } };
60
61   g_value_init(instance_and_param + 0, GTK_OBJECT_TYPE(object));
62   g_value_set_instance(instance_and_param + 0, G_OBJECT(object));
63
64   g_value_init(instance_and_param + 1, G_TYPE_INT);
65   g_value_set_int(instance_and_param + 1, arg1);
66
67   g_value_init(instance_and_param + 2, G_TYPE_INT);
68   g_value_set_int(instance_and_param + 2, arg2);
69
70   g_value_init(&ret, G_TYPE_BOOLEAN);
71   g_value_set_boolean(&ret, *default_ret);
72
73   g_signal_emitv(instance_and_param, signal_id, 0, &ret);
74   *default_ret = g_value_get_boolean(&ret);
75
76   g_value_unset(instance_and_param + 0);
77   g_value_unset(instance_and_param + 1);
78   g_value_unset(instance_and_param + 2);
79 }
80 */
81
82 void
83 _gtkextra_signal_emit(GtkObject *object, guint signal_id, ...)
84 {
85   gboolean *result;
86   GValue ret = { 0, };
87   GValue instance_and_params [10] = { {0, }, };
88   va_list var_args;
89   GSignalQuery query;
90   gchar *error;
91   int i;
92
93   va_start (var_args, signal_id);
94
95   g_value_init(instance_and_params + 0, GTK_OBJECT_TYPE(object));
96   g_value_set_instance (instance_and_params + 0, G_OBJECT(object));
97
98   g_signal_query(signal_id, &query);
99
100   for (i = 0; i < query.n_params; i++)
101     {
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]);
104
105
106       G_VALUE_COLLECT (instance_and_params + i + 1,
107                        var_args,
108                        static_scope ? G_VALUE_NOCOPY_CONTENTS : 0,
109                        &error);
110
111       if (error)
112         {
113           g_warning ("%s: %s", G_STRLOC, error);
114           g_free (error);
115           while (i-- > 0)
116             g_value_unset (instance_and_params + i);
117
118           va_end (var_args);
119           return;
120         }
121
122
123     }
124
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);
131
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);
135
136   va_end (var_args);
137 }