b6b1bc88283303979f76e198e295d5e8374ebe46
[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
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18     02110-1301, USA. */
19
20
21 #ifndef __PSPPIRE_DICT_H__
22 #define __PSPPIRE_DICT_H__
23
24
25 #include <glib-object.h>
26 #include <glib.h>
27
28 #include <data/dictionary.h>
29 #include <data/variable.h>
30
31
32 G_BEGIN_DECLS
33
34
35 /* --- type macros --- */
36 #define G_TYPE_PSPPIRE_DICT              (psppire_dict_get_type ())
37 #define PSPPIRE_DICT(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_PSPPIRE_DICT, PsppireDict))
38 #define PSPPIRE_DICT_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), G_TYPE_PSPPIRE_DICT, PsppireDictClass))
39 #define G_IS_PSPPIRE_DICT(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_PSPPIRE_DICT))
40 #define G_IS_PSPPIRE_DICT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), G_TYPE_PSPPIRE_DICT))
41 #define PSPPIRE_DICT_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_PSPPIRE_DICT, PsppireDictClass))
42
43
44
45 /* --- typedefs & structures --- */
46 typedef struct _PsppireDict        PsppireDict;
47 typedef struct _PsppireDictClass PsppireDictClass;
48
49 enum {DICT_TVM_COL_NAME=0, DICT_TVM_COL_VAR, n_DICT_COLS} ;
50
51 struct _PsppireDict
52 {
53   GObject             parent;
54   struct dictionary *dict;
55
56   /* For GtkTreeModelIface */
57   gint stamp;
58 };
59
60 struct _PsppireDictClass
61 {
62   GObjectClass parent_class;
63
64 };
65
66
67 /* -- PsppireDict --- */
68 GType          psppire_dict_get_type (void);
69 PsppireDict*     psppire_dict_new_from_dict (struct dictionary *d);
70 void           psppire_dict_set_name (PsppireDict* s, gint idx, const gchar *name);
71 void           psppire_dict_delete_var (PsppireDict *s, gint idx);
72
73 /* Return the number of variables in the dictionary */
74 gint psppire_dict_get_var_cnt (const PsppireDict *d);
75
76 /* Return a variable by name.
77    Return NULL if it doesn't exist
78 */
79 struct variable * psppire_dict_lookup_var (const PsppireDict *d, const gchar *name);
80
81 /* Clears the contents of D */
82 void psppire_dict_clear (PsppireDict *d);
83
84 /* Return the IDXth variable */
85 struct variable * psppire_dict_get_variable (PsppireDict *d, gint idx);
86
87 /* Delete N variables beginning at FIRST */
88 void psppire_dict_delete_variables (PsppireDict *d, gint first, gint n);
89
90 /* Insert a new variable at posn IDX */
91 void psppire_dict_insert_variable (PsppireDict *d, gint idx, const gchar *name);
92
93 void psppire_dict_resize_variable (PsppireDict *,
94                                   const struct variable *,
95                                   gint, gint );
96
97 gboolean psppire_dict_check_name (const PsppireDict *dict,
98                               const gchar *name, gboolean report);
99
100 gint psppire_dict_get_next_value_idx (const PsppireDict *dict);
101
102 void psppire_dict_rename_var (PsppireDict *dict, struct variable *v,
103                               const gchar *text);
104
105 void psppire_dict_replace_dictionary (PsppireDict *, struct dictionary *);
106
107
108 G_END_DECLS
109
110 #endif /* __PSPPIRE_DICT_H__ */