2008-10-14 Alejandro Pinheiro <apinheiro@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 typedef enum
82 {
83   HILDON_TOUCH_SELECTOR_SELECTION_MODE_SINGLE,
84   HILDON_TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE
85 } HildonTouchSelectorSelectionMode;
86
87 /* construction */
88 GType
89 hildon_touch_selector_get_type                  (void) G_GNUC_CONST;
90
91 GtkWidget *
92 hildon_touch_selector_new                       (void);
93
94 /* Simple (and recommended) API for one-text-column selectors. */
95 GtkWidget *
96 hildon_touch_selector_new_text                  (void);
97
98 void
99 hildon_touch_selector_append_text               (HildonTouchSelector *selector,
100                                                  const gchar         *text);
101 void
102 hildon_touch_selector_prepend_text              (HildonTouchSelector *selector,
103                                                  const gchar         *text);
104 void
105 hildon_touch_selector_insert_text               (HildonTouchSelector *selector,
106                                                  gint                 position,
107                                                  const gchar         *text);
108
109 /* column related  */
110 HildonTouchSelectorColumn*
111 hildon_touch_selector_append_text_column        (HildonTouchSelector *selector,
112                                                  GtkTreeModel *       model,
113                                                  gboolean             center);
114
115 HildonTouchSelectorColumn*
116 hildon_touch_selector_append_column             (HildonTouchSelector *selector,
117                                                  GtkTreeModel        *model,
118                                                  GtkCellRenderer     *cell_renderer,
119                                                  ...);
120 #ifndef HILDON_DISABLE_DEPRECATED
121 void
122 hildon_touch_selector_set_column_attributes     (HildonTouchSelector *selector,
123                                                  gint                 num_column,
124                                                  GtkCellRenderer     *cell_renderer,
125                                                  ...);
126 #endif
127
128 gboolean
129 hildon_touch_selector_remove_column             (HildonTouchSelector *selector,
130                                                  gint                 column);
131
132 gint
133 hildon_touch_selector_get_num_columns           (HildonTouchSelector *selector);
134
135 void
136 hildon_touch_selector_set_column_selection_mode (HildonTouchSelector              *selector,
137                                                  HildonTouchSelectorSelectionMode  mode);
138
139 HildonTouchSelectorSelectionMode
140 hildon_touch_selector_get_column_selection_mode (HildonTouchSelector *selector);
141
142 HildonTouchSelectorColumn *
143 hildon_touch_selector_get_column                (HildonTouchSelector *selector,
144                                                  gint                 column);
145
146 /* get/set active item */
147 void
148 hildon_touch_selector_set_active                (HildonTouchSelector *selector,
149                                                  gint                 column,
150                                                  gint                 index);
151 gint
152 hildon_touch_selector_get_active                (HildonTouchSelector *selector,
153                                                  gint                 column);
154
155 gboolean
156 hildon_touch_selector_get_selected              (HildonTouchSelector *selector,
157                                                  gint                 column,
158                                                  GtkTreeIter         *iter);
159
160 void
161 hildon_touch_selector_select_iter               (HildonTouchSelector *selector,
162                                                  gint                 column,
163                                                  GtkTreeIter         *iter,
164                                                  gboolean             scroll_to);
165
166 void
167 hildon_touch_selector_unselect_iter             (HildonTouchSelector *selector,
168                                                  gint                 column,
169                                                  GtkTreeIter         *iter);
170
171 GList *
172 hildon_touch_selector_get_selected_rows         (HildonTouchSelector *selector,
173                                                  gint                 column);
174 /* model  */
175 void
176 hildon_touch_selector_set_model                 (HildonTouchSelector *selector,
177                                                  gint                 column,
178                                                  GtkTreeModel        *model);
179 GtkTreeModel *
180 hildon_touch_selector_get_model                 (HildonTouchSelector *selector,
181                                                  gint                 column);
182
183 /* show the current element selected */
184 gchar *
185 hildon_touch_selector_get_current_text          (HildonTouchSelector *selector);
186
187 void
188 hildon_touch_selector_set_print_func            (HildonTouchSelector          *selector,
189                                                  HildonTouchSelectorPrintFunc  func);
190
191 HildonTouchSelectorPrintFunc
192 hildon_touch_selector_get_print_func            (HildonTouchSelector *selector);
193
194 gboolean
195 hildon_touch_selector_has_multiple_selection    (HildonTouchSelector *selector);
196
197 G_END_DECLS
198
199 #endif /* __HILDON_TOUCH_SELECTOR_H__ */