218cae0d764aebd126ae3729db1266fa3b2a5b6b
[pspp-builds.git] / src / ui / gui / psppire-dict.h
1 /* 
2     PSPPIRE --- A Graphical User Interface for PSPP
3     Copyright (C) 2004  Free Software Foundation
4     Written by John Darrington
5
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.
10
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.
15
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
19     02110-1301, USA. */
20
21
22 #ifndef __PSPPIRE_DICT_H__
23 #define __PSPPIRE_DICT_H__
24
25
26 #include <glib-object.h>
27 #include <glib.h>
28
29 #include <data/dictionary.h>
30 #include <data/variable.h>
31
32
33 G_BEGIN_DECLS
34
35
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))
43
44
45
46 /* --- typedefs & structures --- */
47 typedef struct _PsppireDict        PsppireDict;
48 typedef struct _PsppireDictClass PsppireDictClass;
49
50 enum {DICT_TVM_COL_NAME=0, DICT_TVM_COL_VAR, n_DICT_COLS} ;
51
52 struct _PsppireDict
53 {
54   GObject             parent;
55   struct dictionary *dict;
56
57   /* Cache of variables */
58   struct PsppireVariable **variables;
59
60   gint cache_size;
61
62   /* For GtkTreeModelIface */
63   gint stamp;
64 };
65
66 struct _PsppireDictClass
67 {
68   GObjectClass parent_class;
69
70 };
71
72
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);
79
80 /* Return the number of variables in the dictionary */
81 gint psppire_dict_get_var_cnt(const PsppireDict *d);
82
83 /* Return a variable by name.
84    Return NULL if it doesn't exist
85 */
86 struct variable * psppire_dict_lookup_var (const PsppireDict *d, const gchar *name);
87
88 /* Tell the dictionary that one of its variable has changed */
89 void psppire_dict_var_changed(PsppireDict *d, gint idx);
90
91
92 /* Clears the contents of D */
93 void psppire_dict_clear(PsppireDict *d);
94
95 /* Return the IDXth variable */
96
97 struct PsppireVariable * psppire_dict_get_variable(PsppireDict *d, gint idx);
98
99 /* Delete N variables beginning at FIRST */
100 void psppire_dict_delete_variables(PsppireDict *d, gint first, gint n);
101
102 /* Insert a new variable at posn IDX */
103 void psppire_dict_insert_variable(PsppireDict *d, gint idx, const gchar *name);
104
105 gboolean psppire_dict_check_name(const PsppireDict *dict, 
106                               const gchar *name, gboolean report);
107
108 gint psppire_dict_get_next_value_idx (const PsppireDict *dict);
109
110
111 G_END_DECLS
112
113 #endif /* __PSPPIRE_DICT_H__ */