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