2008-08-04 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
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
60 typedef enum
61 {
62   HILDON_TOUCH_SELECTOR_SELECTION_MODE_SINGLE,
63   HILDON_TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE
64 } HildonTouchSelectorSelectionMode;
65
66 /* construction */
67 GType      hildon_touch_selector_get_type (void) G_GNUC_CONST;
68 GtkWidget *hildon_touch_selector_new      (void);
69
70 /* Simple (and recommended) API for one-text-column selectors. */
71 GtkWidget *hildon_touch_selector_new_text (void);
72
73 void hildon_touch_selector_append_text    (HildonTouchSelector * selector,
74                                           const gchar * text);
75 void hildon_touch_selector_prepend_text   (HildonTouchSelector * selector,
76                                           const gchar * text);
77 void hildon_touch_selector_insert_text    (HildonTouchSelector * selector,
78                                           gint position, const gchar * text);
79
80 /* column related  */
81 gboolean hildon_touch_selector_append_text_column     (HildonTouchSelector * selector,
82                                                        GtkTreeModel * model);
83
84 gboolean hildon_touch_selector_append_column          (HildonTouchSelector * selector,
85                                                        GtkTreeModel * model,
86                                                        GtkCellRenderer * cell_renderer,
87                                                        ...);
88
89 void hildon_touch_selector_set_column_attributes      (HildonTouchSelector * selector,
90                                                        gint column,
91                                                        GtkCellRenderer * cell_renderer,
92                                                        ...);
93
94 gboolean hildon_touch_selector_remove_column          (HildonTouchSelector * selector,
95                                                        gint column);
96
97 gint hildon_touch_selector_get_num_columns            (HildonTouchSelector * selector);
98
99 void hildon_touch_selector_set_column_selection_mode  (HildonTouchSelector * selector,
100                                                        HildonTouchSelectorSelectionMode mode);
101
102 HildonTouchSelectorSelectionMode
103 hildon_touch_selector_get_column_selection_mode       (HildonTouchSelector * selector);
104
105 /* get/set active item */
106 gboolean hildon_touch_selector_get_active_iter  (HildonTouchSelector * selector,
107                                                  gint column,
108                                                  GtkTreeIter * iter);
109 void hildon_touch_selector_set_active_iter      (HildonTouchSelector * selector,
110                                                  gint column,
111                                                  GtkTreeIter * iter,
112                                                  gboolean scroll_to);
113 GList *hildon_touch_selector_get_selected_rows  (HildonTouchSelector * selector,
114                                                  gint column);
115 /* model  */
116 void hildon_touch_selector_set_model            (HildonTouchSelector * selector,
117                                                  gint column, GtkTreeModel * model);
118 GtkTreeModel *hildon_touch_selector_get_model   (HildonTouchSelector * selector,
119                                                  gint column);
120
121 /* show the current element selected */
122 gchar *hildon_touch_selector_get_current_text (HildonTouchSelector * selector);
123
124 void hildon_touch_selector_set_print_func     (HildonTouchSelector * selector,
125                                                HildonTouchSelectorPrintFunc func);
126
127 HildonTouchSelectorPrintFunc
128 hildon_touch_selector_get_print_func          (HildonTouchSelector * selector);
129
130 G_END_DECLS
131
132 #endif /* __HILDON_TOUCH_SELECTOR_H__ */