1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2006, 2009, 2010, 2011, 2012 Free Software Foundation
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program 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
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #define _(msgid) gettext (msgid)
22 #define N_(msgid) msgid
24 #include <libpspp/i18n.h>
26 #include <gobject/gvaluecollector.h>
28 #include "psppire-var-store.h"
31 #include <data/dictionary.h>
32 #include <data/variable.h>
33 #include <data/format.h>
34 #include <data/missing-values.h>
36 #include "val-labs-dialog.h"
37 #include "missing-val-dialog.h"
38 #include <data/value-labels.h>
40 #include "var-display.h"
45 PSPPIRE_VAR_STORE_DICT
48 static void psppire_var_store_init (PsppireVarStore *var_store);
49 static void psppire_var_store_class_init (PsppireVarStoreClass *class);
50 static void psppire_var_store_finalize (GObject *object);
51 static void psppire_var_store_dispose (GObject *object);
54 static GObjectClass *parent_class = NULL;
57 psppire_var_store_get_type (void)
59 static GType var_store_type = 0;
63 static const GTypeInfo var_store_info =
65 sizeof (PsppireVarStoreClass),
67 NULL, /* base_finalize */
68 (GClassInitFunc) psppire_var_store_class_init,
69 NULL, /* class_finalize */
70 NULL, /* class_data */
71 sizeof (PsppireVarStore),
73 (GInstanceInitFunc) psppire_var_store_init,
76 var_store_type = g_type_register_static (G_TYPE_OBJECT, "PsppireVarStore", &var_store_info, 0);
79 return var_store_type;
83 psppire_var_store_set_property (GObject *object,
88 PsppireVarStore *self = (PsppireVarStore *) object;
92 case PSPPIRE_VAR_STORE_DICT:
93 if ( self->dictionary)
94 g_object_unref (self->dictionary);
95 self->dictionary = g_value_dup_object (value);
99 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
105 psppire_var_store_get_property (GObject *object,
110 PsppireVarStore *self = (PsppireVarStore *) object;
114 case PSPPIRE_VAR_STORE_DICT:
115 g_value_take_object (value, self->dictionary);
119 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
126 psppire_var_store_class_init (PsppireVarStoreClass *class)
128 GObjectClass *object_class;
129 GParamSpec *dict_pspec;
131 parent_class = g_type_class_peek_parent (class);
132 object_class = (GObjectClass*) class;
134 object_class->finalize = psppire_var_store_finalize;
135 object_class->dispose = psppire_var_store_dispose;
136 object_class->set_property = psppire_var_store_set_property;
137 object_class->get_property = psppire_var_store_get_property;
139 dict_pspec = g_param_spec_object ("dictionary",
141 "The PsppireDict represented by this var store",
143 G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
145 g_object_class_install_property (object_class,
146 PSPPIRE_VAR_STORE_DICT,
151 psppire_var_store_init (PsppireVarStore *var_store)
153 var_store->dictionary = NULL;
157 psppire_var_store_get_var (PsppireVarStore *store, glong row)
159 return psppire_dict_get_variable (store->dictionary, row);
163 * psppire_var_store_new:
164 * @dict: The dictionary for this var_store.
167 * Return value: a new #PsppireVarStore
170 psppire_var_store_new (PsppireDict *dict)
172 PsppireVarStore *retval;
174 retval = g_object_new (GTK_TYPE_VAR_STORE, "dictionary", dict, NULL);
176 // psppire_var_store_set_dictionary (retval, dict);
182 psppire_var_store_finalize (GObject *object)
185 (* parent_class->finalize) (object);
189 psppire_var_store_dispose (GObject *object)
191 PsppireVarStore *self = PSPPIRE_VAR_STORE (object);
193 if (self->dictionary)
194 g_object_unref (self->dictionary);
197 (* parent_class->finalize) (object);
201 /* Return the number of variables */
203 psppire_var_store_get_var_cnt (PsppireVarStore *store)
205 return psppire_dict_get_var_cnt (store->dictionary);