* Cleaned some header files, deleting unused includes
[modest] / src / widgets / modest-header-view.h
1 /* Copyright (c) 2006, Nokia Corporation
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  *   notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  *   notice, this list of conditions and the following disclaimer in the
12  *   documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Nokia Corporation nor the names of its
14  *   contributors may be used to endorse or promote products derived from
15  *   this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #ifndef __MODEST_HEADER_VIEW_H__
31 #define __MODEST_HEADER_VIEW_H__
32
33 #include <tny-folder.h>
34 #include <tny-gtk-account-list-model.h>
35 #include <tny-msg.h>
36 #include <tny-header.h>
37 #include <tny-gtk-header-list-model.h>
38
39 G_BEGIN_DECLS
40
41 /* convenience macros */
42 #define MODEST_TYPE_HEADER_VIEW             (modest_header_view_get_type())
43 #define MODEST_HEADER_VIEW(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_HEADER_VIEW,ModestHeaderView))
44 #define MODEST_HEADER_VIEW_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_HEADER_VIEW,ModestHeaderViewClass))
45 #define MODEST_IS_HEADER_VIEW(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_HEADER_VIEW))
46 #define MODEST_IS_HEADER_VIEW_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_HEADER_VIEW))
47 #define MODEST_HEADER_VIEW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_HEADER_VIEW,ModestHeaderViewClass))
48
49 typedef struct _ModestHeaderView      ModestHeaderView;
50 typedef struct _ModestHeaderViewClass ModestHeaderViewClass;
51
52 struct _ModestHeaderView {
53          GtkTreeView parent;
54         /* insert public members, if any */
55 };
56
57 #define MODEST_HEADER_VIEW_COLUMN    "header-view-column"
58
59 typedef enum _ModestHeaderViewColumn {
60         MODEST_HEADER_VIEW_COLUMN_FROM            = 0,
61         MODEST_HEADER_VIEW_COLUMN_TO,
62         MODEST_HEADER_VIEW_COLUMN_SUBJECT,
63         MODEST_HEADER_VIEW_COLUMN_SENT_DATE,
64         MODEST_HEADER_VIEW_COLUMN_RECEIVED_DATE,
65         MODEST_HEADER_VIEW_COLUMN_MSGTYPE,
66         MODEST_HEADER_VIEW_COLUMN_ATTACH,
67
68         /*
69          * these two are for compact display on small devices,
70          * with two line display with all relevant headers
71          */
72         MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_IN,  /* incoming mail */
73         MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT, /* outgoing mail */
74         
75         MODEST_HEADER_VIEW_COLUMN_NUM
76
77 } ModestHeaderViewColumn;
78
79 /*
80  * this can be extended with more style thingies,
81  * to make a small-device specific display
82  */
83 typedef enum _ModestHeaderViewStyle {
84         MODEST_HEADER_VIEW_STYLE_SHOW_HEADERS = 0x01,
85         MODEST_HEADER_VIEW_STYLE_NORMAL = 0x02,
86 } ModestHeaderViewStyle;
87
88 typedef enum _ModestItemType {
89         MODEST_ITEM_TYPE_MESSAGE,
90         MODEST_ITEM_TYPE_FOLDER,
91         MODEST_ITEM_TYPE_NUM
92 } ModestItemType;
93
94
95 typedef enum _ModestHeaderViewState {
96         MODEST_HEADER_VIEW_STATE_IS_EMPTY               = 0x01,
97         MODEST_HEADER_VIEW_STATE_HAS_CURSOR             = 0x02,
98         MODEST_HEADER_VIEW_STATE_HAS_SELECTION          = 0x04,
99         MODEST_HEADER_VIEW_STATE_HAS_MULTIPLE_SELECTION = 0x08,
100         MODEST_HEADER_VIEW_STATE_AT_FIRST_ITEM          = 0x0f,
101         MODEST_HEADER_VIEW_STATE_AT_LAST_ITEM           = 0x10
102 } ModestHeaderViewState;
103
104 struct _ModestHeaderViewClass {
105         GtkTreeViewClass parent_class;
106
107         void (*header_selected) (ModestHeaderView* self,
108                                  TnyHeader *header,
109                                  gpointer user_data);
110
111         void (*item_not_found) (ModestHeaderView* self,
112                                 ModestItemType type,
113                                 gpointer user_data);
114         
115         /* msg == NULL implies that the operation is finished, ie.
116          * the progress indictation can be hidden */
117         void (*status_update) (ModestHeaderView* self,
118                                const gchar* msg,
119                                gint num, gint total,
120                                gpointer user_data);
121 };
122
123 /**
124  * modest_header_view_get_type:
125  * 
126  * get the GType for ModestHeaderView
127  *  
128  * Returns: the GType
129  */
130 GType        modest_header_view_get_type    (void) G_GNUC_CONST;
131
132
133 /**
134  * modest_header_view_new:
135  * @folder: a TnyMsgFolder object
136  * @columns: a list of ModestHeaderViewColumn
137  * @style: a ModestHeaderViewColumn with the style of this listview
138  *  (   MODEST_HEADER_VIEW_STYLE_NORMAL or MODEST_HEADER_VIEW_STYLE_COMPACT)
139  * 
140  * create a new ModestHeaderView instance, based on a folder iface
141  *   
142  * Returns: a new GtkWidget (a GtkTreeView-subclass)
143  */
144 GtkWidget*   modest_header_view_new        (TnyFolder *folder,
145                                             const GList *columns,
146                                             ModestHeaderViewStyle style);
147
148 /**
149  * modest_header_view_set_folder:
150  * @self: a ModestHeaderView instance
151  * @folder: a TnyFolder object
152  * 
153  * set the folder for this ModestHeaderView
154  *  
155  * Returns: TRUE if it succeeded, FALSE otherwise
156  */
157 gboolean     modest_header_view_set_folder (ModestHeaderView *self,
158                                             TnyFolder *folder);
159
160
161
162
163 /**
164  * modest_header_view_get_folder:
165  * @self: a ModestHeaderView instance
166  * 
167  * get the folder in this ModestHeaderView
168  *  
169  * Returns: the tny folder instance or NULL if there is none
170  */
171 TnyFolder *modest_header_view_get_folder (ModestHeaderView *self);
172
173
174 /**
175  * modest_header_view_set_columns:
176  * @self: a ModestHeaderView instance
177  * @columns: a list of ModestHeaderViewColumn
178  * 
179  * set the columns for this ModestHeaderView.
180  *  
181  * Returns: TRUE if it succeeded, FALSE otherwise
182  */
183 gboolean modest_header_view_set_columns (ModestHeaderView *self,
184                                          const GList *columns);
185 /**
186  * modest_header_view_get_columns:
187  * @self: a ModestHeaderView instance
188  * 
189  * get the GtkTreeColumns for this ModestHeaderView. Each one of the
190  * tree columns will have property  than can be retrieved
191  * with g_object_get_data MODEST_HEADER_VIEW_COLUMN (#define),
192  * and which contains the corresponding ModestHeaderViewColumn
193  *  
194  * Returns: newly allocated list of column ids, or NULL in case of no columns or error
195  * You must free the list with g_list_free
196  */
197 GList*  modest_header_view_get_columns (ModestHeaderView *self);
198         
199
200
201 /**
202  * modest_header_view_get_state
203  * @self: a ModestHeaderView instance
204  * 
205  * get the state for this header view; see the ModestHeaderViewState enum
206  * for possible values.
207  * 
208  * Returns: the state for this header view
209  */
210 ModestHeaderViewState modest_header_view_get_state (ModestHeaderView *self);
211
212
213
214 /**
215  * modest_header_view_set_style:
216  * @self: a ModestHeaderView instance
217  * @style: the style for this tree view
218  * 
219  * set the style for this ModestHeaderView
220  *  
221  * Returns: TRUE if it succeeded, FALSE otherwise
222  */
223 gboolean   modest_header_view_set_style (ModestHeaderView *self,
224                                          ModestHeaderViewStyle style);
225
226 /**
227  * modest_header_view_set_folder:
228  * @self: a ModestHeaderView instance
229  * 
230  * get the style for this ModestHeaderView
231  *  
232  * Returns: the current style
233  */
234 ModestHeaderViewStyle   modest_header_view_get_style (ModestHeaderView *self);
235
236
237
238 /**
239  * modest_header_view_get_selected_headers:
240  * @self: a ModestHeaderView instance
241  * 
242  * get the list of the currently selected TnyHeader's
243  *  
244  * Returns: the list with the currently selected headers
245  */
246 TnyList* modest_header_view_get_selected_headers (ModestHeaderView *self);
247
248
249 /**
250  * modest_header_view_select_next:
251  * @self: a #ModestHeaderView
252  * 
253  * Selects the header next to the current selected one
254  **/
255 void     modest_header_view_select_next          (ModestHeaderView *self);
256
257 G_END_DECLS
258
259
260 #endif /* __MODEST_HEADER_VIEW_H__ */
261