1 /* Copyright (c) 2006, Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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.
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.
30 #ifndef __MODEST_HEADER_VIEW_H__
31 #define __MODEST_HEADER_VIEW_H__
33 #include <tny-folder.h>
34 #include <tny-gtk-account-list-model.h>
36 #include <tny-header.h>
37 #include <tny-gtk-header-list-model.h>
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))
49 typedef struct _ModestHeaderView ModestHeaderView;
50 typedef struct _ModestHeaderViewClass ModestHeaderViewClass;
52 struct _ModestHeaderView {
54 /* insert public members, if any */
57 #define MODEST_HEADER_VIEW_COLUMN "header-view-column"
58 #define MODEST_HEADER_VIEW_FLAG_SORT "header-view-flags-sort"
60 typedef enum _ModestHeaderViewColumn {
61 MODEST_HEADER_VIEW_COLUMN_FROM = 0,
62 MODEST_HEADER_VIEW_COLUMN_TO = 1,
63 MODEST_HEADER_VIEW_COLUMN_SUBJECT = 2,
64 MODEST_HEADER_VIEW_COLUMN_SENT_DATE = 3,
65 MODEST_HEADER_VIEW_COLUMN_RECEIVED_DATE = 4,
66 MODEST_HEADER_VIEW_COLUMN_MSGTYPE = 5,
67 MODEST_HEADER_VIEW_COLUMN_ATTACH = 6,
68 MODEST_HEADER_VIEW_COLUMN_SIZE = 7,
69 MODEST_HEADER_VIEW_COLUMN_STATUS = 8,
72 * these two are for compact display on small devices,
73 * with two line display with all relevant headers
75 MODEST_HEADER_VIEW_COLUMN_COMPACT_FLAG = 9, /* priority and attachments */
76 MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_IN = 10, /* incoming mail */
77 MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT = 11,/* outgoing mail */
78 MODEST_HEADER_VIEW_COLUMN_COMPACT_SENT_DATE = 12,
79 MODEST_HEADER_VIEW_COLUMN_COMPACT_RECEIVED_DATE = 13,
81 MODEST_HEADER_VIEW_COLUMN_NUM
83 } ModestHeaderViewColumn;
86 * this can be extended with more style thingies,
87 * to make a small-device specific display
89 typedef enum _ModestHeaderViewStyle {
90 MODEST_HEADER_VIEW_STYLE_DETAILS = 0, /* many columns, single line, col headers visible */
91 MODEST_HEADER_VIEW_STYLE_TWOLINES = 1, /* two-line headers, col headers invisible */
93 MODEST_HEADER_VIEW_STYLE_NUM
94 } ModestHeaderViewStyle;
96 typedef enum _ModestItemType {
97 MODEST_ITEM_TYPE_MESSAGE,
98 MODEST_ITEM_TYPE_FOLDER,
103 struct _ModestHeaderViewClass {
104 GtkTreeViewClass parent_class;
106 void (*header_selected) (ModestHeaderView* self,
110 void (*item_not_found) (ModestHeaderView* self,
114 void (*header_activated) (ModestHeaderView* self,
118 /* msg == NULL implies that the operation is finished, ie.
119 * the progress indictation can be hidden */
120 void (*status_update) (ModestHeaderView* self,
122 gint num, gint total,
127 * modest_header_view_get_type:
129 * get the GType for ModestHeaderView
133 GType modest_header_view_get_type (void) G_GNUC_CONST;
137 * modest_header_view_new:
138 * @folder: a TnyMsgFolder object
139 * @style: a ModestHeaderViewColumn with the style of this listview
140 * ( MODEST_HEADER_VIEW_STYLE_NORMAL or MODEST_HEADER_VIEW_STYLE_COMPACT)
142 * create a new ModestHeaderView instance, based on a folder iface
144 * Returns: a new GtkWidget (a GtkTreeView-subclass)
146 GtkWidget* modest_header_view_new (TnyFolder *folder,
147 ModestHeaderViewStyle style);
150 * modest_header_view_set_folder:
151 * @self: a ModestHeaderView instance
152 * @folder: a TnyFolder object
154 * set the folder for this ModestHeaderView
156 void modest_header_view_set_folder (ModestHeaderView *self,
160 * modest_header_view_get_folder:
161 * @self: a ModestHeaderView instance
163 * get the folder in this ModestHeaderView
165 * Returns: the tny folder instance or NULL if there is none
167 TnyFolder *modest_header_view_get_folder (ModestHeaderView *self);
171 * modest_header_view_set_columns:
172 * @self: a ModestHeaderView instance
173 * @columns: a list of ModestHeaderViewColumn
174 * @type: #TnyFolderType type
176 * set the columns for this ModestHeaderView.
178 * Returns: TRUE if it succeeded, FALSE otherwise
180 gboolean modest_header_view_set_columns (ModestHeaderView *self,
181 const GList *columns,
184 * modest_header_view_get_columns:
185 * @self: a ModestHeaderView instance
187 * get the GtkTreeColumns for this ModestHeaderView. Each one of the
188 * tree columns will have property than can be retrieved
189 * with g_object_get_data MODEST_HEADER_VIEW_COLUMN (#define),
190 * and which contains the corresponding ModestHeaderViewColumn
192 * Returns: newly allocated list of #GtkTreeViewColumns objects, or NULL in case of no columns or error
193 * You must free the list with g_list_free
195 GList* modest_header_view_get_columns (ModestHeaderView *self);
199 * modest_header_view_set_style:
200 * @self: a ModestHeaderView instance
201 * @style: the style for this tree view
203 * set the style for this ModestHeaderView
205 * Returns: TRUE if it succeeded, FALSE otherwise
207 gboolean modest_header_view_set_style (ModestHeaderView *self,
208 ModestHeaderViewStyle style);
211 * modest_header_view_set_folder:
212 * @self: a ModestHeaderView instance
214 * get the style for this ModestHeaderView
216 * Returns: the current style
218 ModestHeaderViewStyle modest_header_view_get_style (ModestHeaderView *self);
221 * modest_header_view_get_selected_headers:
222 * @self: a ModestHeaderView instance
224 * get the list of the currently selected TnyHeader's. The list and
225 * the headers should be freed by the caller
227 * Returns: the list with the currently selected headers
229 TnyList* modest_header_view_get_selected_headers (ModestHeaderView *self);
233 * modest_header_view_is_empty:
234 * @self: a valid ModestHeaderView instance
236 * see if this header view is empty; use this function instead of
237 * using the GtkTreeView parent directly, as 'empty' in this case
238 * may mean that there is one "This is empty"-message, and of course
239 * GtkTreeView then thinks it is *not* empty
241 * Returns: TRUE if the header view is empty, FALSE otherwise
243 gboolean modest_header_view_is_empty (ModestHeaderView *self);
248 * modest_header_view_select_next:
249 * @self: a #ModestHeaderView
251 * Selects the header next to the current selected one
253 void modest_header_view_select_next (ModestHeaderView *self);
256 * modest_header_view_select_prev:
257 * @self: a #ModestHeaderView
259 * Selects the previous header of the current selected one
261 void modest_header_view_select_prev (ModestHeaderView *self);
264 /* PROTECTED method. It's useful when we want to force a given
265 selection to reload a msg. For example if we have selected a header
266 in offline mode, when Modest become online, we want to reload the
267 message automatically without an user click over the header */
269 _modest_header_view_change_selection (GtkTreeSelection *selection,
273 * modest_header_view_get_sort_column_id:
274 * @self: a #ModestHeaderView
275 * @type: #TnyFolderType type
277 * Gets the selected logical columnd id for sorting.
280 modest_header_view_get_sort_column_id (ModestHeaderView *self, TnyFolderType type);
283 * modest_header_view_get_sort_type:
284 * @self: a #ModestHeaderView
285 * @type: #TnyFolderType type
287 * Gets the selected sort type.
290 modest_header_view_get_sort_type (ModestHeaderView *self, TnyFolderType type);
293 * modest_header_view_set_sort_params:
294 * @self: a #ModestHeaderView
295 * @sort_colid: logical column id to sort
296 * @sort_type: #GtkSortType sort type
297 * @type: #TnyFolderType type
299 * Sets the logical columnd id and sort type for sorting operations.
302 modest_header_view_set_sort_params (ModestHeaderView *self, guint sort_colid, GtkSortType sort_type, TnyFolderType type);
305 * modest_header_view_set_sort_params:
306 * @self: a #ModestHeaderView
307 * @sort_colid: logical column id to sort
308 * @sort_type: #GtkSortType sort type
310 * Sorts headers treeview by logical column id, @sort_colid, using a
311 * @sort_type sorting method. In addition, new headder settings will be
312 * stored in @self object.
315 modest_header_view_sort_by_column_id (ModestHeaderView *self,
317 GtkSortType sort_type);
324 #endif /* __MODEST_HEADER_VIEW_H__ */