e7acb1e04640d421c5d939e9bce1f894e0cef6f6
[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   /* For GtkTreeModelIface */
58   gint stamp;
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 number of variables in the dictionary */
76 gint psppire_dict_get_var_cnt(const PsppireDict *d);
77
78 /* Return a variable by name.
79    Return NULL if it doesn't exist
80 */
81 struct variable * psppire_dict_lookup_var (const PsppireDict *d, const gchar *name);
82
83 /* Tell the dictionary that one of its variable has changed */
84 void psppire_dict_var_changed(PsppireDict *d, gint idx);
85
86
87 /* Clears the contents of D */
88 void psppire_dict_clear(PsppireDict *d);
89
90 /* Return the IDXth variable */
91
92 struct variable * psppire_dict_get_variable (PsppireDict *d, gint idx);
93
94 /* Delete N variables beginning at FIRST */
95 void psppire_dict_delete_variables(PsppireDict *d, gint first, gint n);
96
97 /* Insert a new variable at posn IDX */
98 void psppire_dict_insert_variable(PsppireDict *d, gint idx, const gchar *name);
99
100 void psppire_dict_resize_variable(PsppireDict *, 
101                                   const struct variable *,
102                                   gint, gint );
103
104 gboolean psppire_dict_check_name(const PsppireDict *dict, 
105                               const gchar *name, gboolean report);
106
107 gint psppire_dict_get_next_value_idx (const PsppireDict *dict);
108
109 void psppire_dict_rename_var (PsppireDict *dict, struct variable *v,
110                               const gchar *text);
111
112
113 G_END_DECLS
114
115 #endif /* __PSPPIRE_DICT_H__ */