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