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
                                                 gpointer user_data);
57
58
struct                                          _HildonTouchSelector
59
{
60
  GtkVBox parent_instance;
61
62
  /*< private > */
63
  HildonTouchSelectorPrivate *priv;
64
};
65
66
struct                                          _HildonTouchSelectorClass
67
{
68
  GtkVBoxClass parent_class;
69
70
  /* signals */
71
  void (*changed)                               (HildonTouchSelector *selector,
72
                                                 gint column);
73
74
  /* virtual methods */
75
  void (*set_model)                             (HildonTouchSelector *selector,
76
                                                 gint column,
77
                                                 GtkTreeModel *model);
78
79
  gboolean (*has_multiple_selection)            (HildonTouchSelector *selector);
80
};
81
82
/**
83
 * HildonTouchSelectorSelectionMode:
84
 * @HILDON_TOUCH_SELECTOR_SELECTION_MODE_SINGLE: Users can select one item
85
 * @HILDON_TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE: Users can select one to many items
86
 *
87
 * Describes the selection mode of a #HildonTouchSelector.
88
 **/
89
typedef enum
90
{
91
  HILDON_TOUCH_SELECTOR_SELECTION_MODE_SINGLE,
92
  HILDON_TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE
93
} HildonTouchSelectorSelectionMode;
94
95
/* construction */
96
GType
97
hildon_touch_selector_get_type                  (void) G_GNUC_CONST;
98
99
GtkWidget *
100
hildon_touch_selector_new                       (void);
101
102
/* Simple (and recommended) API for one-text-column selectors. */
103
GtkWidget *
104
hildon_touch_selector_new_text                  (void);
105
106
void
107
hildon_touch_selector_append_text               (HildonTouchSelector *selector,
108
                                                 const gchar         *text);
109
void
110
hildon_touch_selector_prepend_text              (HildonTouchSelector *selector,
111
                                                 const gchar         *text);
112
void
113
hildon_touch_selector_insert_text               (HildonTouchSelector *selector,
114
                                                 gint                 position,
115
                                                 const gchar         *text);
116
117
/* column related  */
118
HildonTouchSelectorColumn*
119
hildon_touch_selector_append_text_column        (HildonTouchSelector *selector,
120
                                                 GtkTreeModel *       model,
121
                                                 gboolean             center);
122
123
HildonTouchSelectorColumn*
124
hildon_touch_selector_append_column             (HildonTouchSelector *selector,
125
                                                 GtkTreeModel        *model,
126
                                                 GtkCellRenderer     *cell_renderer,
127
                                                 ...);
128
#ifndef HILDON_DISABLE_DEPRECATED
129
void
130
hildon_touch_selector_set_column_attributes     (HildonTouchSelector *selector,
131
                                                 gint                 num_column,
132
                                                 GtkCellRenderer     *cell_renderer,
133
                                                 ...);
134
#endif
135
136
gboolean
137
hildon_touch_selector_remove_column             (HildonTouchSelector *selector,
138
                                                 gint                 column);
139
140
gint
141
hildon_touch_selector_get_num_columns           (HildonTouchSelector *selector);
142
143
void
144
hildon_touch_selector_set_column_selection_mode (HildonTouchSelector              *selector,
145
                                                 HildonTouchSelectorSelectionMode  mode);
146
147
HildonTouchSelectorSelectionMode
148
hildon_touch_selector_get_column_selection_mode (HildonTouchSelector *selector);
149
150
HildonTouchSelectorColumn *
151
hildon_touch_selector_get_column                (HildonTouchSelector *selector,
152
                                                 gint                 column);
153
154
/* get/set active item */
155
void
156
hildon_touch_selector_set_active                (HildonTouchSelector *selector,
157
                                                 gint                 column,
158
                                                 gint                 index);
159
gint
160
hildon_touch_selector_get_active                (HildonTouchSelector *selector,
161
                                                 gint                 column);
162
163
gboolean
164
hildon_touch_selector_get_selected              (HildonTouchSelector *selector,
165
                                                 gint                 column,
166
                                                 GtkTreeIter         *iter);
167
168
void
169
hildon_touch_selector_select_iter               (HildonTouchSelector *selector,
170
                                                 gint                 column,
171
                                                 GtkTreeIter         *iter,
172
                                                 gboolean             scroll_to);
173
174
void
175
hildon_touch_selector_unselect_iter             (HildonTouchSelector *selector,
176
                                                 gint                 column,
177
                                                 GtkTreeIter         *iter);
178
179
void
180
hildon_touch_selector_unselect_all              (HildonTouchSelector * selector,
181
                                                 gint                  column);
182
183
GList *
184
hildon_touch_selector_get_selected_rows         (HildonTouchSelector *selector,
185
                                                 gint                 column);
186
/* model  */
187
void
188
hildon_touch_selector_set_model                 (HildonTouchSelector *selector,
189
                                                 gint                 column,
190
                                                 GtkTreeModel        *model);
191
GtkTreeModel *
192
hildon_touch_selector_get_model                 (HildonTouchSelector *selector,
193
                                                 gint                 column);
194
195
/* show the current element selected */
196
gchar *
197
hildon_touch_selector_get_current_text          (HildonTouchSelector *selector);
198
199
void
200
hildon_touch_selector_set_print_func            (HildonTouchSelector          *selector,
201
                                                 HildonTouchSelectorPrintFunc  func);
202
203
void
204
hildon_touch_selector_set_print_func_full       (HildonTouchSelector          *selector,
205
                                                 HildonTouchSelectorPrintFunc  func,
206
                                                 gpointer                      user_data,
207
                                                 GDestroyNotify                destroy_func);
208
209
HildonTouchSelectorPrintFunc
210
hildon_touch_selector_get_print_func            (HildonTouchSelector *selector);
211
212
gboolean
213
hildon_touch_selector_has_multiple_selection    (HildonTouchSelector *selector);
214
215
void
216
hildon_touch_selector_center_on_selected        (HildonTouchSelector *selector);
217
218
void
219
hildon_touch_selector_center_on_index           (HildonTouchSelector *selector,
220
                                                 gint column,
221
                                                 gint index);
222
void
223
hildon_touch_selector_optimal_size_request      (HildonTouchSelector *selector,
224
                                                 GtkRequisition *requisition);
225
226
HildonUIMode
227
hildon_touch_selector_get_hildon_ui_mode        (HildonTouchSelector *selector);
228
229
gboolean
230
hildon_touch_selector_set_hildon_ui_mode        (HildonTouchSelector *selector,
231
                                                 HildonUIMode         mode);
232
GtkTreePath*
233
hildon_touch_selector_get_last_activated_row    (HildonTouchSelector *selector,
234
                                                 gint                 column);
235
void
236
hildon_touch_selector_set_live_search           (HildonTouchSelector *selector,
237
                                                 gboolean live_search);
238
239
gboolean
240
hildon_touch_selector_get_live_search           (HildonTouchSelector *selector);
241
242
G_END_DECLS
243
244
#endif /* __HILDON_TOUCH_SELECTOR_H__ */