Change license from GPLv2+ to GPLv3+.
[pspp-builds.git] / src / ui / gui / psppire-selector.h
1 /* PSPPIRE - a graphical user interface for PSPP.
2    Copyright (C) 2007  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_SELECTOR_H__
19 #define __PSPPIRE_SELECTOR_H__
20
21
22 #include <glib.h>
23 #include <glib-object.h>
24 #include <gtk/gtkbutton.h>
25 #include <gtk/gtkarrow.h>
26 #include <gtk/gtktreemodel.h>
27 #include <gtk/gtktreemodelfilter.h>
28
29 G_BEGIN_DECLS
30
31 #define PSPPIRE_SELECTOR_TYPE            (psppire_selector_get_type ())
32 #define PSPPIRE_SELECTOR(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), PSPPIRE_SELECTOR_TYPE, PsppireSelector))
33 #define PSPPIRE_SELECTOR_CLASS(class)    (G_TYPE_CHECK_CLASS_CAST ((class), \
34     PSPPIRE_SELECTOR_TYPE, PsppireSelectorClass))
35 #define PSPPIRE_IS_SELECTOR(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
36     PSPPIRE_SELECTOR_TYPE))
37 #define PSPPIRE_IS_SELECTOR_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
38     PSPPIRE_SELECTOR_TYPE))
39
40
41 typedef struct _PsppireSelector       PsppireSelector;
42 typedef struct _PsppireSelectorClass  PsppireSelectorClass;
43
44
45 /* Function for appending selected items to the destination widget */
46 typedef void SelectItemsFunc (GtkTreeIter iter,
47                               GtkWidget *dest,
48                               GtkTreeModel *source_model);
49
50
51 /* Function to determine whether an item in MODEL, pointed to by ITER
52    is currently selected.
53
54    Returns TRUE if the item is currently selected, FALSE otherwise.
55  */
56 typedef gboolean FilterItemsFunc (GtkTreeModel *model,
57                                   GtkTreeIter *iter,
58                                   PsppireSelector *selector);
59
60 enum psppire_selector_dir
61   {
62     PSPPIRE_SELECTOR_SOURCE_TO_DEST,
63     PSPPIRE_SELECTOR_DEST_TO_SOURCE
64   };
65
66
67 struct _PsppireSelector
68 {
69   GtkButton parent;
70
71   /* <private> */
72   GtkWidget *arrow;
73
74   enum psppire_selector_dir direction;
75   GtkWidget *source;
76   GtkWidget *dest;
77
78   /* A flag indicating that the object is in the process of
79      updating its subjects.
80      (not thread safe if two threads access the same object)
81   */
82   gboolean selecting;
83
84   gint orientation;
85
86   GtkTreeModelFilter *filtered_source;
87
88   SelectItemsFunc *select_items;
89   FilterItemsFunc *filter;
90 };
91
92 struct _PsppireSelectorClass
93 {
94   GtkButtonClass parent_class;
95
96   /* This is a hash of Lists of FilterItemsFunc pointers, keyed by address of
97      the source widget */
98   GHashTable *source_hash;
99 };
100
101 GType      psppire_selector_get_type        (void);
102 GtkWidget* psppire_selector_new             (void);
103 void       psppire_selector_set_subjects    (PsppireSelector *,
104                                              GtkWidget *,
105                                              GtkWidget *,
106                                              SelectItemsFunc *,
107                                              FilterItemsFunc * );
108
109 GType psppire_selector_orientation_get_type (void) G_GNUC_CONST;
110
111
112 typedef enum {
113   PSPPIRE_SELECT_SOURCE_BEFORE_DEST,
114   PSPPIRE_SELECT_SOURCE_AFTER_DEST,
115   PSPPIRE_SELECT_SOURCE_ABOVE_DEST,
116   PSPPIRE_SELECT_SOURCE_BELOW_DEST
117 } PsppireSelectorOrientation;
118
119 #define G_TYPE_PSPPIRE_SELECTOR_ORIENTATION \
120   (psppire_selector_orientation_get_type())
121
122
123
124 G_END_DECLS
125
126 #endif /* __PSPPIRE_SELECTOR_H__ */