7cdd2bc1cc62fc717ce5cb262949a193f78d6133
[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 <gtk/gtk.h>
34 #include <tny-msg-folder-iface.h>
35 #include <tny-account-tree-model.h>
36 #include <tny-msg-iface.h>
37 #include <tny-msg-header-iface.h>
38 #include <tny-msg-header-list-model.h>
39
40 G_BEGIN_DECLS
41
42 /* convenience macros */
43 #define MODEST_TYPE_HEADER_VIEW             (modest_header_view_get_type())
44 #define MODEST_HEADER_VIEW(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_HEADER_VIEW,ModestHeaderView))
45 #define MODEST_HEADER_VIEW_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_HEADER_VIEW,ModestHeaderViewClass))
46 #define MODEST_IS_HEADER_VIEW(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_HEADER_VIEW))
47 #define MODEST_IS_HEADER_VIEW_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_HEADER_VIEW))
48 #define MODEST_HEADER_VIEW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_HEADER_VIEW,ModestHeaderViewClass))
49
50 typedef struct _ModestHeaderView      ModestHeaderView;
51 typedef struct _ModestHeaderViewClass ModestHeaderViewClass;
52
53 struct _ModestHeaderView {
54          GtkTreeView parent;
55         /* insert public members, if any */
56 };
57
58 struct _ModestHeaderViewClass {
59         GtkTreeViewClass parent_class;
60
61         void (*message_selected) (ModestHeaderView* self,
62                                   TnyMsgIface *msg,
63                                   gpointer user_data);
64
65         /* msg == NULL implies that the operation is finished, ie.
66          * the progress indictation can be hidden */
67         void (*status_update) (ModestHeaderView* self,
68                                const gchar* msg,
69                                gint status,
70                                gpointer user_data);
71 };
72
73
74 enum _ModestHeaderViewColumn {
75         MODEST_HEADER_VIEW_COLUMN_FROM,
76         MODEST_HEADER_VIEW_COLUMN_TO,
77         MODEST_HEADER_VIEW_COLUMN_SUBJECT,
78         MODEST_HEADER_VIEW_COLUMN_SENT_DATE,
79         MODEST_HEADER_VIEW_COLUMN_RECEIVED_DATE,
80         MODEST_HEADER_VIEW_COLUMN_MSGTYPE,
81         MODEST_HEADER_VIEW_COLUMN_ATTACH,
82         MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER,
83
84         MODEST_HEADER_VIEW_COLUMN_NUM
85 };
86 typedef enum _ModestHeaderViewColumn ModestHeaderViewColumn;
87
88
89 enum _ModestHeaderViewStyle {
90         MODEST_HEADER_VIEW_STYLE_NORMAL,
91         MODEST_HEADER_VIEW_STYLE_COMPACT,
92         
93         MODEST_HEADER_VIEW_STYLE_NUM
94 };
95 typedef enum _ModestHeaderViewStyle ModestHeaderViewStyle;
96
97
98 /**
99  * modest_header_view_get_type:
100  * 
101  * get the GType for ModestHeaderView
102  *  
103  * Returns: the GType
104  */
105 GType        modest_header_view_get_type    (void) G_GNUC_CONST;
106
107
108 /**
109  * modest_header_view_new:
110  * @folder: a TnyMsgFolderIface object
111  * @columns: a list of ModestHeaderViewColumn
112  * @style: a ModestHeaderViewColumn with the style of this listview
113  *  (   MODEST_HEADER_VIEW_STYLE_NORMAL or MODEST_HEADER_VIEW_STYLE_COMPACT)
114  * 
115  * create a new ModestHeaderView instance, based on a folder iface
116  *   
117  * Returns: a new GtkWidget (a GtkTreeView-subclass)
118  */
119 GtkWidget*   modest_header_view_new        (TnyMsgFolderIface *folder,
120                                                      GSList *columns,
121                                                      ModestHeaderViewStyle style);
122
123 /**
124  * modest_header_view_set_folder:
125  * @self: a ModestHeaderView instance
126  * @folder: a TnyMsgFolderIface object
127  * 
128  * set the folder for this ModestHeaderView
129  *  
130  * Returns: TRUE if it succeeded, FALSE otherwise
131  */
132 gboolean     modest_header_view_set_folder (ModestHeaderView *self,
133                                                       TnyMsgFolderIface *folder);
134
135
136 /**
137  * modest_header_view_set_columns:
138  * @self: a ModestHeaderView instance
139  * @columns: a list of ModestHeaderViewColumn
140  * 
141  * set the columns for this ModestHeaderView
142  *  
143  * Returns: TRUE if it succeeded, FALSE otherwise
144  */
145 gboolean     modest_header_view_set_columns (ModestHeaderView *self,
146                                                       GSList *columns);
147 /**
148  * modest_header_view_get_columns:
149  * @self: a ModestHeaderView instance
150  * @folder: a TnyMsgFolderIface object
151  * 
152  * get the columns for this ModestHeaderView
153  *  
154  * Returns: list of columms, or NULL in case of no columns or error
155  */
156 const GSList*   modest_header_view_get_columns (ModestHeaderView *self);
157         
158
159 /**
160  * modest_header_view_set_style:
161  * @self: a ModestHeaderView instance
162  * @style: the style for this tree view
163  * 
164  * set the folder for this ModestHeaderView
165  *  
166  * Returns: TRUE if it succeeded, FALSE otherwise
167  */
168 gboolean   modest_header_view_set_style (ModestHeaderView *self,
169                                                   ModestHeaderViewStyle style);
170
171 /**
172  * modest_header_view_set_folder:
173  * @self: a ModestHeaderView instance
174  * @folder: a TnyMsgFolderIface object
175  * 
176  * set the folder for this ModestHeaderView
177  *  
178  * Returns: TRUE if it succeeded, FALSE otherwise
179  */
180 ModestHeaderViewStyle   modest_header_view_get_style (ModestHeaderView *self);
181
182 G_END_DECLS
183
184
185 #endif /* __MODEST_HEADER_VIEW_H__ */
186