ba38631d22dadbce0c10fcba79ca65609e08ee3b
[pspp-builds.git] / src / ui / gui / psppire-acr.h
1 /* PSPPIRE - a graphical user interface for PSPP.
2    Copyright (C) 2007 Free Software Foundation, Inc.
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_ACR_H__
19 #define __PSPPIRE_ACR_H__
20
21 /*
22   This widget is a GtkBox which looks roughly like:
23
24   +-----------------------------+
25   |+------------+  +----------+ |
26   ||   Add      |  |          | |
27   |+------------+  |          | |
28   |                |          | |
29   |+------------+  |          | |
30   ||   Edit     |  |          | |
31   |+------------+  |          | |
32   |                |          | |
33   |+------------+  |          | |
34   ||  Remove    |  |          | |
35   |+------------+  +----------+ |
36   +-----------------------------+
37
38   It interacts with an external widget, such as a GtkEntry.
39   It maintains a list of items controlled by the three buttons.
40   This implementation deals only with g_double values.
41  */
42
43
44 #include <glib.h>
45 #include <glib-object.h>
46 #include <gtk/gtkhbox.h>
47 #include <gtk/gtkentry.h>
48 #include <gtk/gtktreeselection.h>
49
50
51 G_BEGIN_DECLS
52
53 #define PSPPIRE_ACR_TYPE            (psppire_acr_get_type ())
54 #define PSPPIRE_ACR(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), PSPPIRE_ACR_TYPE, PsppireAcr))
55 #define PSPPIRE_ACR_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), PSPPIRE_ACR_TYPE, PsppireAcrClass))
56 #define PSPPIRE_IS_ACR(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_ACR_TYPE))
57 #define PSPPIRE_IS_ACR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_ACR_TYPE))
58
59
60 typedef struct _PsppireAcr       PsppireAcr;
61 typedef struct _PsppireAcrClass  PsppireAcrClass;
62
63 typedef gboolean (*GetValueFunc) (gint, GValue *, gpointer);
64 typedef gboolean (*EnabledFunc) (gpointer);
65 typedef void (*UpdateCallbackFunc) (gpointer);
66
67 struct _PsppireAcr
68 {
69   GtkHBox parent;
70
71
72   GtkListStore *list_store;
73
74   GtkTreeView *tv;
75   GtkTreeSelection *selection;
76
77   /* The buttons */
78   GtkWidget *add_button;
79   GtkWidget *change_button;
80   GtkWidget *remove_button;
81
82   GetValueFunc get_value;
83   gpointer get_value_data;
84
85   EnabledFunc enabled;
86   gpointer enabled_data;
87
88   UpdateCallbackFunc update;
89   gpointer update_data;
90 };
91
92
93 struct _PsppireAcrClass
94 {
95   GtkHBoxClass parent_class;
96 };
97
98
99
100 GType       psppire_acr_get_type        (void);
101 GtkWidget*  psppire_acr_new             (void);
102
103 void        psppire_acr_set_model       (PsppireAcr *, GtkListStore *);
104 void        psppire_acr_set_get_value_func (PsppireAcr *, GetValueFunc,
105                                             gpointer);
106
107 void        psppire_acr_set_enable_func (PsppireAcr *, EnabledFunc, gpointer);
108
109 void        psppire_acr_set_enabled (PsppireAcr *, gboolean);
110 void        psppire_acr_set_entry  (PsppireAcr *, GtkEntry *);
111
112
113
114 G_END_DECLS
115
116 #endif /* __PSPPIRE_ACR_H__ */