* listen to updates in the account store, and refresh
[modest] / src / modest-tny-header-tree-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
31 /* modest-tny-header-tree-view.h */
32
33 #ifndef __MODEST_TNY_HEADER_TREE_VIEW_H__
34 #define __MODEST_TNY_HEADER_TREE_VIEW_H__
35
36 #include <gtk/gtk.h>
37 #include <tny-msg-folder-iface.h>
38 #include <tny-account-tree-model.h>
39 #include <tny-msg-iface.h>
40 #include <tny-msg-header-iface.h>
41 #include <tny-msg-header-list-model.h>
42
43 G_BEGIN_DECLS
44
45 /* convenience macros */
46 #define MODEST_TYPE_TNY_HEADER_TREE_VIEW             (modest_tny_header_tree_view_get_type())
47 #define MODEST_TNY_HEADER_TREE_VIEW(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_TNY_HEADER_TREE_VIEW,ModestTnyHeaderTreeView))
48 #define MODEST_TNY_HEADER_TREE_VIEW_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_TNY_HEADER_TREE_VIEW,ModestTnyHeaderTreeViewClass))
49 #define MODEST_IS_TNY_HEADER_TREE_VIEW(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_TNY_HEADER_TREE_VIEW))
50 #define MODEST_IS_TNY_HEADER_TREE_VIEW_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_TNY_HEADER_TREE_VIEW))
51 #define MODEST_TNY_HEADER_TREE_VIEW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_TNY_HEADER_TREE_VIEW,ModestTnyHeaderTreeViewClass))
52
53 typedef struct _ModestTnyHeaderTreeView      ModestTnyHeaderTreeView;
54 typedef struct _ModestTnyHeaderTreeViewClass ModestTnyHeaderTreeViewClass;
55
56 struct _ModestTnyHeaderTreeView {
57          GtkTreeView parent;
58         /* insert public members, if any */
59 };
60
61 struct _ModestTnyHeaderTreeViewClass {
62         GtkTreeViewClass parent_class;
63
64         void (*message_selected) (ModestTnyHeaderTreeView* self,
65                                   TnyMsgIface *msg,
66                                   gpointer user_data);
67
68         /* msg == NULL implies that the operation is finished, ie.
69          * the progress indictation can be hidden */
70         void (*status_update) (ModestTnyHeaderTreeView* self,
71                                const gchar* msg,
72                                gint status,
73                                gpointer user_data);
74 };
75
76
77 enum {
78         MODEST_TNY_HEADER_TREE_VIEW_COLUMN_FROM,
79         MODEST_TNY_HEADER_TREE_VIEW_COLUMN_TO,
80         MODEST_TNY_HEADER_TREE_VIEW_COLUMN_SUBJECT,
81         MODEST_TNY_HEADER_TREE_VIEW_COLUMN_SENT_DATE,
82         MODEST_TNY_HEADER_TREE_VIEW_COLUMN_RECEIVED_DATE,
83         MODEST_TNY_HEADER_TREE_VIEW_COLUMN_MSGTYPE,
84         MODEST_TNY_HEADER_TREE_VIEW_COLUMN_ATTACH,
85         MODEST_TNY_HEADER_TREE_VIEW_COLUMN_COMPACT_HEADER,
86
87         MODEST_TNY_HEADER_TREE_VIEW_COLUMN_NUM
88 };
89 typedef guint ModestTnyHeaderTreeViewColumn;
90
91 enum {
92         MODEST_TNY_HEADER_TREE_VIEW_STYLE_NORMAL,
93         MODEST_TNY_HEADER_TREE_VIEW_STYLE_COMPACT,
94         
95         MODEST_TNY_HEADER_TREE_VIEW_STYLE_NUM
96 };
97 typedef guint ModestTnyHeaderTreeViewStyle;
98
99
100
101 /**
102  * modest_tny_header_tree_view_get_type:
103  * 
104  * get the GType for ModestTnyHeaderTreeView
105  *  
106  * Returns: the GType
107  */
108 GType        modest_tny_header_tree_view_get_type    (void) G_GNUC_CONST;
109
110
111 /**
112  * modest_tny_header_tree_view_new:
113  * @folder: a TnyMsgFolderIface object
114  * @columns: a list of ModestTnyHeaderTreeViewColumn
115  * @style: a ModestTnyHeaderTreeViewColumn with the style of this listview
116  *  (   MODEST_TNY_HEADER_TREE_VIEW_STYLE_NORMAL or MODEST_TNY_HEADER_TREE_VIEW_STYLE_COMPACT)
117  * 
118  * create a new ModestTnyHeaderTreeView instance, based on a folder iface
119  *   
120  * Returns: a new GtkWidget (a GtkTreeView-subclass)
121  */
122 GtkWidget*   modest_tny_header_tree_view_new        (TnyMsgFolderIface *folder,
123                                                      GSList *columns,
124                                                      ModestTnyHeaderTreeViewStyle style);
125
126 /**
127  * modest_tny_header_tree_view_set_folder:
128  * @self: a ModestTnyHeaderTreeView instance
129  * @folder: a TnyMsgFolderIface object
130  * 
131  * set the folder for this ModestTnyHeaderTreeView
132  *  
133  * Returns: TRUE if it succeeded, FALSE otherwise
134  */
135 gboolean     modest_tny_header_tree_view_set_folder (ModestTnyHeaderTreeView *self,
136                                                       TnyMsgFolderIface *folder);
137
138
139 /**
140  * modest_tny_header_tree_view_set_columns:
141  * @self: a ModestTnyHeaderTreeView instance
142  * @columns: a list of ModestTnyHeaderTreeViewColumn
143  * 
144  * set the columns for this ModestTnyHeaderTreeView
145  *  
146  * Returns: TRUE if it succeeded, FALSE otherwise
147  */
148 gboolean     modest_tny_header_tree_view_set_columns (ModestTnyHeaderTreeView *self,
149                                                       GSList *columns);
150 /**
151  * modest_tny_header_tree_view_get_columns:
152  * @self: a ModestTnyHeaderTreeView instance
153  * @folder: a TnyMsgFolderIface object
154  * 
155  * get the columns for this ModestTnyHeaderTreeView
156  *  
157  * Returns: list of columms, or NULL in case of no columns or error
158  */
159 const GSList*   modest_tny_header_tree_view_get_columns (ModestTnyHeaderTreeView *self);
160         
161
162 /**
163  * modest_tny_header_tree_view_set_style:
164  * @self: a ModestTnyHeaderTreeView instance
165  * @style: the style for this tree view
166  * 
167  * set the folder for this ModestTnyHeaderTreeView
168  *  
169  * Returns: TRUE if it succeeded, FALSE otherwise
170  */
171 gboolean   modest_tny_header_tree_view_set_style (ModestTnyHeaderTreeView *self,
172                                                   ModestTnyHeaderTreeViewStyle style);
173
174 /**
175  * modest_tny_header_tree_view_set_folder:
176  * @self: a ModestTnyHeaderTreeView instance
177  * @folder: a TnyMsgFolderIface object
178  * 
179  * set the folder for this ModestTnyHeaderTreeView
180  *  
181  * Returns: TRUE if it succeeded, FALSE otherwise
182  */
183 ModestTnyHeaderTreeViewStyle   modest_tny_header_tree_view_get_style (ModestTnyHeaderTreeView *self);
184
185 G_END_DECLS
186
187
188
189
190
191 #endif /* __MODEST_TNY_HEADER_TREE_VIEW_H__ */
192