Change license from GPLv2+ to GPLv3+.
[pspp-builds.git] / src / ui / gui / psppire-dict.h
1 /* PSPPIRE - a graphical user interface for PSPP.
2    Copyright (C) 2004  Free Software Foundation
3
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.
8
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.
13
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/>. */
16
17
18 #ifndef __PSPPIRE_DICT_H__
19 #define __PSPPIRE_DICT_H__
20
21
22 #include <glib-object.h>
23 #include <glib.h>
24
25 #include <data/dictionary.h>
26 #include <data/variable.h>
27
28
29 G_BEGIN_DECLS
30
31
32 /* --- type macros --- */
33 #define G_TYPE_PSPPIRE_DICT              (psppire_dict_get_type ())
34 #define PSPPIRE_DICT(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_PSPPIRE_DICT, PsppireDict))
35 #define PSPPIRE_DICT_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), G_TYPE_PSPPIRE_DICT, PsppireDictClass))
36 #define PSPPIRE_IS_DICT(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_PSPPIRE_DICT))
37 #define PSPPIRE_IS_DICT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), G_TYPE_PSPPIRE_DICT))
38 #define PSPPIRE_DICT_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_PSPPIRE_DICT, PsppireDictClass))
39
40
41
42 /* --- typedefs & structures --- */
43 typedef struct _PsppireDict        PsppireDict;
44 typedef struct _PsppireDictClass PsppireDictClass;
45
46 enum {DICT_TVM_COL_NAME=0, DICT_TVM_COL_VAR, n_DICT_COLS} ;
47
48 struct _PsppireDict
49 {
50   GObject             parent;
51   struct dictionary *dict;
52
53   /* For GtkTreeModelIface */
54   gint stamp;
55 };
56
57 struct _PsppireDictClass
58 {
59   GObjectClass parent_class;
60
61 };
62
63
64 /* -- PsppireDict --- */
65 GType          psppire_dict_get_type (void);
66 PsppireDict*   psppire_dict_new_from_dict (struct dictionary *d);
67 gboolean       psppire_dict_set_name (PsppireDict* s, gint idx, const gchar *name);
68 void           psppire_dict_delete_var (PsppireDict *s, gint idx);
69
70 /* Return the number of variables in the dictionary */
71 gint psppire_dict_get_var_cnt (const PsppireDict *d);
72
73 /* Return a variable by name.
74    Return NULL if it doesn't exist
75 */
76 struct variable * psppire_dict_lookup_var (const PsppireDict *d, const gchar *name);
77
78 /* Clears the contents of D */
79 void psppire_dict_clear (PsppireDict *d);
80
81 /* Return the IDXth variable */
82 struct variable * psppire_dict_get_variable (const PsppireDict *d, gint idx);
83
84 /* Delete N variables beginning at FIRST */
85 void psppire_dict_delete_variables (PsppireDict *d, gint first, gint n);
86
87 /* Insert a new variable at posn IDX */
88 void psppire_dict_insert_variable (PsppireDict *d, gint idx, const gchar *name);
89
90 void psppire_dict_resize_variable (PsppireDict *,
91                                   const struct variable *,
92                                   gint, gint );
93
94 gboolean psppire_dict_check_name (const PsppireDict *dict,
95                               const gchar *name, gboolean report);
96
97 gint psppire_dict_get_next_value_idx (const PsppireDict *dict);
98
99 gboolean psppire_dict_rename_var (PsppireDict *dict, struct variable *v,
100                               const gchar *text);
101
102 void psppire_dict_replace_dictionary (PsppireDict *, struct dictionary *);
103
104 struct variable * psppire_dict_get_weight_variable (const PsppireDict *);
105
106
107 G_END_DECLS
108
109 #endif /* __PSPPIRE_DICT_H__ */