90eeb50517d90a548bf735847175bdcac6882f1a
[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
26 G_BEGIN_DECLS
27
28 #define HILDON_TYPE_TOUCH_SELECTOR             (hildon_touch_selector_get_type ())
29 #define HILDON_TOUCH_SELECTOR(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), HILDON_TYPE_TOUCH_SELECTOR, HildonTouchSelector))
30 #define HILDON_TOUCH_SELECTOR_CLASS(vtable)    (G_TYPE_CHECK_CLASS_CAST ((vtable), HILDON_TYPE_TOUCH_SELECTOR, HildonTouchSelectorClass))
31 #define HILDON_IS_TOUCH_SELECTOR(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HILDON_TYPE_TOUCH_SELECTOR))
32 #define HILDON_IS_TOUCH_SELECTOR_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), HILDON_TYPE_TOUCH_SELECTOR))
33 #define HILDON_TOUCH_SELECTOR_GET_CLASS(inst)  (G_TYPE_INSTANCE_GET_CLASS ((inst), HILDON_TYPE_TOUCH_SELECTOR, HildonTouchSelectorClass))
34
35 typedef struct _HildonTouchSelector HildonTouchSelector;
36 typedef struct _HildonTouchSelectorClass HildonTouchSelectorClass;
37 typedef struct _HildonTouchSelectorPrivate HildonTouchSelectorPrivate;
38
39 typedef gchar *(*HildonTouchSelectorPrintFunc) (HildonTouchSelector * selector);
40
41 struct _HildonTouchSelector
42 {
43   GtkHBox parent_instance;
44
45   /*< private > */
46   HildonTouchSelectorPrivate *priv;
47 };
48
49 struct _HildonTouchSelectorClass
50 {
51   GtkHBoxClass parent_class;
52
53   /* signals */
54   void (*changed) (HildonTouchSelector * selector, gint column);
55
56   /* virtual methods */
57   void (*set_model) (HildonTouchSelector *selector, gint column, GtkTreeModel *model);
58
59   gboolean (*has_multiple_selection) (HildonTouchSelector *selector);
60 };
61
62 typedef enum
63 {
64   HILDON_TOUCH_SELECTOR_SELECTION_MODE_SINGLE,
65   HILDON_TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE
66 } HildonTouchSelectorSelectionMode;
67
68 /* construction */
69 GType      hildon_touch_selector_get_type (void) G_GNUC_CONST;
70 GtkWidget *hildon_touch_selector_new      (void);
71
72 /* Simple (and recommended) API for one-text-column selectors. */
73 GtkWidget *hildon_touch_selector_new_text (void);
74
75 void hildon_touch_selector_append_text    (HildonTouchSelector * selector,
76                                           const gchar * text);
77 void hildon_touch_selector_prepend_text   (HildonTouchSelector * selector,
78                                           const gchar * text);
79 void hildon_touch_selector_insert_text    (HildonTouchSelector * selector,
80                                           gint position, const gchar * text);
81
82 /* column related  */
83 gboolean hildon_touch_selector_append_text_column     (HildonTouchSelector * selector,
84                                                        GtkTreeModel * model, gboolean center);
85
86 gboolean hildon_touch_selector_append_column          (HildonTouchSelector * selector,
87                                                        GtkTreeModel * model,
88                                                        GtkCellRenderer * cell_renderer,
89                                                        ...);
90
91 void hildon_touch_selector_set_column_attributes      (HildonTouchSelector * selector,
92                                                        gint num_column,
93                                                        GtkCellRenderer * cell_renderer,
94                                                        ...);
95
96 gboolean hildon_touch_selector_remove_column          (HildonTouchSelector * selector,
97                                                        gint column);
98
99 gint hildon_touch_selector_get_num_columns            (HildonTouchSelector * selector);
100
101 void hildon_touch_selector_set_column_selection_mode  (HildonTouchSelector * selector,
102                                                        HildonTouchSelectorSelectionMode mode);
103
104 HildonTouchSelectorSelectionMode
105 hildon_touch_selector_get_column_selection_mode       (HildonTouchSelector * selector);
106
107 /* get/set active item */
108 void hildon_touch_selector_set_active           (HildonTouchSelector *selector,
109                                                  gint column,
110                                                  gint index);
111 gint hildon_touch_selector_get_active           (HildonTouchSelector * selector,
112                                                  gint column);
113 gboolean hildon_touch_selector_get_selected     (HildonTouchSelector * selector,
114                                                  gint column,
115                                                  GtkTreeIter * iter);
116 void hildon_touch_selector_select_iter          (HildonTouchSelector * selector,
117                                                  gint column,
118                                                  GtkTreeIter * iter,
119                                                  gboolean scroll_to);
120 void hildon_touch_selector_unselect_iter        (HildonTouchSelector * selector,
121                                                  gint column,
122                                                  GtkTreeIter * iter);
123 GList *hildon_touch_selector_get_selected_rows  (HildonTouchSelector * selector,
124                                                  gint column);
125 /* model  */
126 void hildon_touch_selector_set_model            (HildonTouchSelector * selector,
127                                                  gint column, GtkTreeModel * model);
128 GtkTreeModel *hildon_touch_selector_get_model   (HildonTouchSelector * selector,
129                                                  gint column);
130
131 /* show the current element selected */
132 gchar *hildon_touch_selector_get_current_text (HildonTouchSelector * selector);
133
134 void hildon_touch_selector_set_print_func     (HildonTouchSelector * selector,
135                                                HildonTouchSelectorPrintFunc func);
136
137 HildonTouchSelectorPrintFunc
138 hildon_touch_selector_get_print_func          (HildonTouchSelector * selector);
139
140 gboolean
141 hildon_touch_selector_has_multiple_selection (HildonTouchSelector * selector);
142
143 G_END_DECLS
144
145 #endif /* __HILDON_TOUCH_SELECTOR_H__ */