2 PSPPIRE --- A Graphical User Interface for PSPP
3 Copyright (C) 2004 Free Software Foundation
4 Written by John Darrington
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 #ifndef __PSPPIRE_DICT_H__
23 #define __PSPPIRE_DICT_H__
26 #include <glib-object.h>
29 #include <data/dictionary.h>
30 #include <data/variable.h>
36 /* --- type macros --- */
37 #define G_TYPE_PSPPIRE_DICT (psppire_dict_get_type ())
38 #define PSPPIRE_DICT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_PSPPIRE_DICT, PsppireDict))
39 #define PSPPIRE_DICT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G_TYPE_PSPPIRE_DICT, PsppireDictClass))
40 #define G_IS_PSPPIRE_DICT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_PSPPIRE_DICT))
41 #define G_IS_PSPPIRE_DICT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G_TYPE_PSPPIRE_DICT))
42 #define PSPPIRE_DICT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_PSPPIRE_DICT, PsppireDictClass))
46 /* --- typedefs & structures --- */
47 typedef struct _PsppireDict PsppireDict;
48 typedef struct _PsppireDictClass PsppireDictClass;
50 enum {DICT_TVM_COL_NAME=0, DICT_TVM_COL_VAR, n_DICT_COLS} ;
55 struct dictionary *dict;
57 /* Cache of variables */
58 struct PsppireVariable **variables;
62 /* For GtkTreeModelIface */
66 struct _PsppireDictClass
68 GObjectClass parent_class;
73 /* -- PsppireDict --- */
74 GType psppire_dict_get_type (void);
75 PsppireDict* psppire_dict_new (void);
76 PsppireDict* psppire_dict_new_from_dict (struct dictionary *d);
77 void psppire_dict_set_name (PsppireDict* s, gint idx, const gchar *name);
78 void psppire_dict_delete_var (PsppireDict *s, gint idx);
80 /* Return the number of variables in the dictionary */
81 gint psppire_dict_get_var_cnt(const PsppireDict *d);
83 /* Return a variable by name.
84 Return NULL if it doesn't exist
86 struct variable * psppire_dict_lookup_var (const PsppireDict *d, const gchar *name);
88 /* Tell the dictionary that one of its variable has changed */
89 void psppire_dict_var_changed(PsppireDict *d, gint idx);
92 /* Clears the contents of D */
93 void psppire_dict_clear(PsppireDict *d);
95 /* Return the IDXth variable */
97 struct PsppireVariable * psppire_dict_get_variable(PsppireDict *d, gint idx);
99 /* Delete N variables beginning at FIRST */
100 void psppire_dict_delete_variables(PsppireDict *d, gint first, gint n);
102 /* Insert a new variable at posn IDX */
103 void psppire_dict_insert_variable(PsppireDict *d, gint idx, const gchar *name);
105 void psppire_dict_resize_variable(PsppireDict *d,
106 const struct PsppireVariable *pv,
107 gint old_size, gint new_size);
109 gboolean psppire_dict_check_name(const PsppireDict *dict,
110 const gchar *name, gboolean report);
112 gint psppire_dict_get_next_value_idx (const PsppireDict *dict);
117 #endif /* __PSPPIRE_DICT_H__ */