2009-01-13 Claudio Saavedra <csaavedra@igalia.com>
[hildon] / src / hildon-touch-selector.h
1 /*
2  * This file is a part of hildon
3  *
4  * Copyright (C) 2005, 2008 Nokia Corporation.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version. or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20
21 #ifndef                                         __HILDON_TOUCH_SELECTOR_H__
22 #define                                         __HILDON_TOUCH_SELECTOR_H__
23
24 #include                                        <gtk/gtk.h>
25 #include                                        "hildon-touch-selector-column.h"
26
27 G_BEGIN_DECLS
28
29 #define                                         HILDON_TYPE_TOUCH_SELECTOR \
30                                                 (hildon_touch_selector_get_type ())
31
32 #define                                         HILDON_TOUCH_SELECTOR(obj) \
33                                                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
34                                                 HILDON_TYPE_TOUCH_SELECTOR, HildonTouchSelector))
35
36 #define                                         HILDON_TOUCH_SELECTOR_CLASS(vtable) \
37                                                 (G_TYPE_CHECK_CLASS_CAST ((vtable), \
38                                                 HILDON_TYPE_TOUCH_SELECTOR, HildonTouchSelectorClass))
39
40 #define                                         HILDON_IS_TOUCH_SELECTOR(obj) \
41                                                 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
42                                                 HILDON_TYPE_TOUCH_SELECTOR))
43
44 #define                                         HILDON_IS_TOUCH_SELECTOR_CLASS(vtable) \
45                                                 (G_TYPE_CHECK_CLASS_TYPE ((vtable), HILDON_TYPE_TOUCH_SELECTOR))
46
47 #define                                         HILDON_TOUCH_SELECTOR_GET_CLASS(inst) \
48                                                 (G_TYPE_INSTANCE_GET_CLASS ((inst), \
49                                                 HILDON_TYPE_TOUCH_SELECTOR, HildonTouchSelectorClass))
50
51 typedef struct                                  _HildonTouchSelector HildonTouchSelector;
52 typedef struct                                  _HildonTouchSelectorClass HildonTouchSelectorClass;
53 typedef struct                                  _HildonTouchSelectorPrivate HildonTouchSelectorPrivate;
54
55 typedef gchar *(*HildonTouchSelectorPrintFunc)  (HildonTouchSelector * selector);
56
57 struct                                          _HildonTouchSelector
58 {
59   GtkVBox parent_instance;
60
61   /*< private > */
62   HildonTouchSelectorPrivate *priv;
63 };
64
65 struct                                          _HildonTouchSelectorClass
66 {
67   GtkVBoxClass parent_class;
68
69   /* signals */
70   void (*changed)                               (HildonTouchSelector *selector,
71                                                  gint column);
72
73   /* virtual methods */
74   void (*set_model)                             (HildonTouchSelector *selector,
75                                                  gint column,
76                                                  GtkTreeModel *model);
77
78   gboolean (*has_multiple_selection)            (HildonTouchSelector *selector);
79 };
80
81 /**
82  * HildonTouchSelectorSelectionMode:
83  * @HILDON_TOUCH_SELECTOR_SELECTION_MODE_SINGLE: Users can select one item
84  * @HILDON_TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE: Users can select one to many items
85  *
86  * Describes the selection mode of a #HildonTouchSelector.
87  **/
88 typedef enum
89 {
90   HILDON_TOUCH_SELECTOR_SELECTION_MODE_SINGLE,
91   HILDON_TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE
92 } HildonTouchSelectorSelectionMode;
93
94 /* construction */
95 GType
96 hildon_touch_selector_get_type                  (void) G_GNUC_CONST;
97
98 GtkWidget *
99 hildon_touch_selector_new                       (void);
100
101 /* Simple (and recommended) API for one-text-column selectors. */
102 GtkWidget *
103 hildon_touch_selector_new_text                  (void);
104
105 void
106 hildon_touch_selector_append_text               (HildonTouchSelector *selector,
107                                                  const gchar         *text);
108 void
109 hildon_touch_selector_prepend_text              (HildonTouchSelector *selector,
110                                                  const gchar         *text);
111 void
112 hildon_touch_selector_insert_text               (HildonTouchSelector *selector,
113                                                  gint                 position,
114                                                  const gchar         *text);
115
116 /* column related  */
117 HildonTouchSelectorColumn*
118 hildon_touch_selector_append_text_column        (HildonTouchSelector *selector,
119                                                  GtkTreeModel *       model,
120                                                  gboolean             center);
121
122 HildonTouchSelectorColumn*
123 hildon_touch_selector_append_column             (HildonTouchSelector *selector,
124                                                  GtkTreeModel        *model,
125                                                  GtkCellRenderer     *cell_renderer,
126                                                  ...);
127 #ifndef HILDON_DISABLE_DEPRECATED
128 void
129 hildon_touch_selector_set_column_attributes     (HildonTouchSelector *selector,
130                                                  gint                 num_column,
131                                                  GtkCellRenderer     *cell_renderer,
132                                                  ...);
133 #endif
134
135 gboolean
136 hildon_touch_selector_remove_column             (HildonTouchSelector *selector,
137                                                  gint                 column);
138
139 gint
140 hildon_touch_selector_get_num_columns           (HildonTouchSelector *selector);
141
142 void
143 hildon_touch_selector_set_column_selection_mode (HildonTouchSelector              *selector,
144                                                  HildonTouchSelectorSelectionMode  mode);
145
146 HildonTouchSelectorSelectionMode
147 hildon_touch_selector_get_column_selection_mode (HildonTouchSelector *selector);
148
149 HildonTouchSelectorColumn *
150 hildon_touch_selector_get_column                (HildonTouchSelector *selector,
151                                                  gint                 column);
152
153 /* get/set active item */
154 void
155 hildon_touch_selector_set_active                (HildonTouchSelector *selector,
156                                                  gint                 column,
157                                                  gint                 index);
158 gint
159 hildon_touch_selector_get_active                (HildonTouchSelector *selector,
160                                                  gint                 column);
161
162 gboolean
163 hildon_touch_selector_get_selected              (HildonTouchSelector *selector,
164                                                  gint                 column,
165                                                  GtkTreeIter         *iter);
166
167 void
168 hildon_touch_selector_select_iter               (HildonTouchSelector *selector,
169                                                  gint                 column,
170                                                  GtkTreeIter         *iter,
171                                                  gboolean             scroll_to);
172
173 void
174 hildon_touch_selector_unselect_iter             (HildonTouchSelector *selector,
175                                                  gint                 column,
176                                                  GtkTreeIter         *iter);
177
178 GList *
179 hildon_touch_selector_get_selected_rows         (HildonTouchSelector *selector,
180                                                  gint                 column);
181 /* model  */
182 void
183 hildon_touch_selector_set_model                 (HildonTouchSelector *selector,
184                                                  gint                 column,
185                                                  GtkTreeModel        *model);
186 GtkTreeModel *
187 hildon_touch_selector_get_model                 (HildonTouchSelector *selector,
188                                                  gint                 column);
189
190 /* show the current element selected */
191 gchar *
192 hildon_touch_selector_get_current_text          (HildonTouchSelector *selector);
193
194 void
195 hildon_touch_selector_set_print_func            (HildonTouchSelector          *selector,
196                                                  HildonTouchSelectorPrintFunc  func);
197
198 HildonTouchSelectorPrintFunc
199 hildon_touch_selector_get_print_func            (HildonTouchSelector *selector);
200
201 gboolean
202 hildon_touch_selector_has_multiple_selection    (HildonTouchSelector *selector);
203
204 G_END_DECLS
205
206 #endif /* __HILDON_TOUCH_SELECTOR_H__ */