Added new files resulting from directory restructuring.
[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 <dictionary.h>
30 #include <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 struct _PsppireDict
51 {
52   GObject             parent;
53   struct dictionary *dict;
54
55   /* Cache of variables */
56   struct PsppireVariable **variables;
57
58   gint cache_size;
59 };
60
61 struct _PsppireDictClass
62 {
63   GObjectClass parent_class;
64
65 };
66
67
68 /* -- PsppireDict --- */
69 GType          psppire_dict_get_type (void);
70 PsppireDict*     psppire_dict_new (void);
71 PsppireDict*     psppire_dict_new_from_dict (struct dictionary *d);
72 void           psppire_dict_set_name (PsppireDict* s, gint idx, const gchar *name);
73 void           psppire_dict_delete_var (PsppireDict *s, gint idx);
74
75 /* Return the variable indexed by IDX.
76    returns NULL if IDX is not valid.
77 */
78 struct variable *psppire_dict_get_var(PsppireDict *d, 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
109 G_END_DECLS
110
111 #endif /* __PSPPIRE_DICT_H__ */