* src/modest-tny-store-actions.h
[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-folder.h>
35 #include <tny-gtk-account-tree-model.h>
36 #include <tny-msg.h>
37 #include <tny-header.h>
38 #include <tny-gtk-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 typedef enum _ModestItemType ModestItemType;
59
60 struct _ModestHeaderViewClass {
61         GtkTreeViewClass parent_class;
62
63         void (*message_selected) (ModestHeaderView* self,
64                                   TnyMsg *msg,
65                                   gpointer user_data);
66
67         void (*item_not_found) (ModestHeaderView* self,
68                                 ModestItemType type,
69                                 gpointer user_data);
70         
71         /* msg == NULL implies that the operation is finished, ie.
72          * the progress indictation can be hidden */
73         void (*status_update) (ModestHeaderView* self,
74                                const gchar* msg,
75                                gint status,
76                                gpointer user_data);
77 };
78
79
80 enum _ModestHeaderViewColumn {
81         MODEST_HEADER_VIEW_COLUMN_FROM,
82         MODEST_HEADER_VIEW_COLUMN_TO,
83         MODEST_HEADER_VIEW_COLUMN_SUBJECT,
84         MODEST_HEADER_VIEW_COLUMN_SENT_DATE,
85         MODEST_HEADER_VIEW_COLUMN_RECEIVED_DATE,
86         MODEST_HEADER_VIEW_COLUMN_MSGTYPE,
87         MODEST_HEADER_VIEW_COLUMN_ATTACH,
88         MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER,
89
90         MODEST_HEADER_VIEW_COLUMN_NUM
91 };
92 typedef enum _ModestHeaderViewColumn ModestHeaderViewColumn;
93
94 enum _ModestHeaderViewStyle {
95         MODEST_HEADER_VIEW_STYLE_NORMAL,
96         MODEST_HEADER_VIEW_STYLE_COMPACT,
97         MODEST_HEADER_VIEW_STYLE_NUM
98 };
99 typedef enum _ModestHeaderViewStyle ModestHeaderViewStyle;
100
101 enum _ModestItemType {
102         MODEST_ITEM_TYPE_MESSAGE,
103         MODEST_ITEM_TYPE_FOLDER,
104         MODEST_ITEM_TYPE_NUM
105 };
106
107
108 /**
109  * modest_header_view_get_type:
110  * 
111  * get the GType for ModestHeaderView
112  *  
113  * Returns: the GType
114  */
115 GType        modest_header_view_get_type    (void) G_GNUC_CONST;
116
117
118 /**
119  * modest_header_view_new:
120  * @folder: a TnyMsgFolder object
121  * @columns: a list of ModestHeaderViewColumn
122  * @style: a ModestHeaderViewColumn with the style of this listview
123  *  (   MODEST_HEADER_VIEW_STYLE_NORMAL or MODEST_HEADER_VIEW_STYLE_COMPACT)
124  * 
125  * create a new ModestHeaderView instance, based on a folder iface
126  *   
127  * Returns: a new GtkWidget (a GtkTreeView-subclass)
128  */
129 GtkWidget*   modest_header_view_new        (TnyFolder *folder,
130                                             GSList *columns,
131                                             ModestHeaderViewStyle style);
132
133 /**
134  * modest_header_view_set_folder:
135  * @self: a ModestHeaderView instance
136  * @folder: a TnyFolder object
137  * 
138  * set the folder for this ModestHeaderView
139  *  
140  * Returns: TRUE if it succeeded, FALSE otherwise
141  */
142 gboolean     modest_header_view_set_folder (ModestHeaderView *self,
143                                             TnyFolder *folder);
144
145
146 /**
147  * modest_header_view_set_columns:
148  * @self: a ModestHeaderView instance
149  * @columns: a list of ModestHeaderViewColumn
150  * 
151  * set the columns for this ModestHeaderView
152  *  
153  * Returns: TRUE if it succeeded, FALSE otherwise
154  */
155 gboolean     modest_header_view_set_columns (ModestHeaderView *self,
156                                              GSList *columns);
157 /**
158  * modest_header_view_get_columns:
159  * @self: a ModestHeaderView instance
160  * @folder: a TnyFolder object
161  * 
162  * get the columns for this ModestHeaderView
163  *  
164  * Returns: list of columms, or NULL in case of no columns or error
165  */
166 const GSList*   modest_header_view_get_columns (ModestHeaderView *self);
167         
168
169 /**
170  * modest_header_view_set_style:
171  * @self: a ModestHeaderView instance
172  * @style: the style for this tree view
173  * 
174  * set the style this ModestHeaderView
175  *  
176  * Returns: TRUE if it succeeded, FALSE otherwise
177  */
178 gboolean   modest_header_view_set_style (ModestHeaderView *self,
179                                          ModestHeaderViewStyle style);
180
181 /**
182  * modest_header_view_set_folder:
183  * @self: a ModestHeaderView instance
184  * 
185  * get the style for this ModestHeaderView
186  *  
187  * Returns: the current style
188  */
189 ModestHeaderViewStyle   modest_header_view_get_style (ModestHeaderView *self);
190
191 TnyList* modest_header_view_get_selected_headers (ModestHeaderView *self);
192
193 G_END_DECLS
194
195
196 #endif /* __MODEST_HEADER_VIEW_H__ */
197