* make it compile again with latest Tinymail; does not work yet though.
[modest] / src / modest-widget-factory.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_WIDGET_FACTORY_H__
31 #define __MODEST_WIDGET_FACTORY_H__
32
33 #include <glib-object.h>
34 #include <glib/gi18n.h>
35 #include <modest-account-mgr.h>
36 #include <modest-tny-account-store.h>
37
38 #include <widgets/modest-header-view.h>
39 #include <widgets/modest-folder-view.h>
40 #include <widgets/modest-msg-view.h>
41 #include <widgets/modest-account-view.h>
42 #include <widgets/modest-toolbar.h>
43 #include <widgets/modest-combo-box.h>
44
45 G_BEGIN_DECLS
46
47 /* convenience macros */
48 #define MODEST_TYPE_WIDGET_FACTORY             (modest_widget_factory_get_type())
49 #define MODEST_WIDGET_FACTORY(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_WIDGET_FACTORY,ModestWidgetFactory))
50 #define MODEST_WIDGET_FACTORY_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_WIDGET_FACTORY,GObject))
51 #define MODEST_IS_WIDGET_FACTORY(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_WIDGET_FACTORY))
52 #define MODEST_IS_WIDGET_FACTORY_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_WIDGET_FACTORY))
53 #define MODEST_WIDGET_FACTORY_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_WIDGET_FACTORY,ModestWidgetFactoryClass))
54
55 typedef struct _ModestWidgetFactory      ModestWidgetFactory;
56 typedef struct _ModestWidgetFactoryClass ModestWidgetFactoryClass;
57
58 struct _ModestWidgetFactory {
59          GObject parent;
60         /* insert public members, if any */
61 };
62
63 struct _ModestWidgetFactoryClass {
64         GObjectClass parent_class;
65         /* insert signal callback declarations, eg. */
66         /* void (* my_event) (ModestWidgetFactory* obj); */
67 };
68
69
70 enum _ModestComboBoxType {
71         MODEST_COMBO_BOX_TYPE_STORE_PROTOS,
72         MODEST_COMBO_BOX_TYPE_TRANSPORT_PROTOS,
73         MODEST_COMBO_BOX_TYPE_SECURITY_PROTOS,
74         MODEST_COMBO_BOX_TYPE_AUTH_PROTOS,
75         MODEST_COMBO_BOX_TYPE_TRANSPORTS
76 };
77 typedef enum _ModestComboBoxType ModestComboBoxType;
78
79
80 /**
81  * modest_widget_factory_get_type
82  *
83  * get the GType for ModestWidgetFactory
84  *
85  * Returns: the GType
86  */
87 GType        modest_widget_factory_get_type    (void) G_GNUC_CONST;
88
89
90 /**
91  * modest_widget_factory_new
92  * @conf: a modest conf instance
93  * @acc_store: a modest account store instance
94  * @acc_mgr: a modest account mgr instance
95  *
96  * instantiates a ModestWidgetFactory
97  *
98  * Returns: a new ModestWidgetFactory, or NULL in case of error
99  */
100 ModestWidgetFactory*      modest_widget_factory_new   (ModestConf *conf,
101                                                        ModestTnyAccountStore *acc_store,
102                                                        ModestAccountMgr *account_mgr);
103 /**
104  * modest_widget_factory_get_folder_view
105  * @self: a ModestWidgetFactory instance
106  * 
107  * return the folder tree widget (ie. the widget with the list of folders);
108  *
109  * This factory will always return the
110  * same widget, and takes care of its lifetime - users should *not* destroy it.
111  *
112  * Returns: a folder tree view, or NULL in case of error
113  */
114 ModestFolderView*    modest_widget_factory_get_folder_view (ModestWidgetFactory *self);
115
116
117 /**
118  * modest_widget_factory_get_header_view
119  * @self: a ModestWidgetFactory instance
120  * 
121  * return the header tree widget (ie. the widget with the list of headers);
122  *
123  * This factory will always return the
124  * same widget, and takes care of its lifetime - users should *not* destroy it.
125  *
126  * Returns: a header tree view, or NULL in case of error
127  */
128 ModestHeaderView*    modest_widget_factory_get_header_view (ModestWidgetFactory *self);
129
130
131 /**
132  * modest_widget_factory_get_msg_preview
133  * @self: a ModestWidgetFactory instance
134  * 
135  * return the message preview widget (ie. the widget with shows the currently selected message);
136  *
137  * This factory will always return the
138  * same widget, and takes care of its lifetime - users should *not* destroy it.
139  *
140  * Returns: a header tree view, or NULL in case of error
141  */
142 ModestMsgView*           modest_widget_factory_get_msg_preview (ModestWidgetFactory *self);
143
144
145 /**
146  * modest_widget_factory_get_account_view
147  * @self: a ModestWidgetFactory instance
148  * 
149  * return an account view widget (ie. the widget that shows a list of accounts)
150  *
151  * This factory will always return the
152  * same widget, and takes care of its lifetime - users should *not* destroy it.
153  *
154  * Returns: the account view, or NULL in case of error
155  */
156 ModestAccountView*    modest_widget_factory_get_account_view (ModestWidgetFactory *self);
157
158
159 /**
160  * modest_widget_factory_get_progress_bar
161  * @self: a ModestWidgetFactory instance
162  * 
163  * return an progress bar widget 
164  * if the widget factory was created with 'auto_connect', then this progress bar
165  * will automatically update for changes in the other widgets
166  * NOTE the naming inconsistency: GtkProgressBar vs GtkStatusbar 
167  * 
168  * This factory will always return the
169  * same widget, and takes care of its lifetime - users should *not* destroy it.
170  *
171  * Returns: the progress bar widget
172  */
173 GtkWidget*       modest_widget_factory_get_progress_bar (ModestWidgetFactory *self);
174
175
176
177 /**
178  * modest_widget_factory_get_status_bar
179  * @self: a ModestWidgetFactory instance
180  * 
181  * return an status bar widget 
182  * if the widget factory was created with 'auto_connect', then this status bar
183  * will automatically update for changes in the other widgets
184  * NOTE the naming inconsistency: GtkProgressBar vs GtkStatusbar 
185  * 
186  * This factory will always return the
187  * same widget, and takes care of its lifetime - users should *not* destroy it.
188  *
189  * Returns: the status bar widget
190  */
191 GtkWidget*     modest_widget_factory_get_status_bar (ModestWidgetFactory *self);
192
193 /**
194  * modest_widget_factory_get_store
195  * @self: a ModestWidgetFactory instance
196  * @type: the type of items we want a combo box for
197  * 
198  * return a combobox with with the given items
199  *  
200  * Returns: the combo box
201  */
202 GtkWidget*     modest_widget_factory_get_combo_box (ModestWidgetFactory *self,
203                                                     ModestComboBoxType type);
204
205
206 /**
207  * modest_widget_factory_get_online_combo
208  * @self: a ModestWidgetFactory instance
209  * 
210  * return a toggle which with one can see whether online/offline mode is active.
211  * In case of auto-connect, this will automatically be sync'd with the
212  * account_store / device
213  *  
214  * Returns: the combo box
215  */
216 GtkWidget*  modest_widget_factory_get_online_toggle (ModestWidgetFactory *self);
217
218
219
220
221 /**
222  * modest_widget_factory_get_folder_info_label
223  * @self: a ModestWidgetFactory instance
224  * 
225  * return a label with the number of items, unread items in the current folder
226  *  
227  * Returns: the label
228  */
229 GtkWidget* modest_widget_factory_get_folder_info_label (ModestWidgetFactory *self);
230
231
232 /**
233  * modest_widget_factory_get_main_toolbar
234  * @self: a ModestWidgetFactory instance
235  * @items: a list of ModestToolbarButtons (button_ids)
236  *
237  * returns the main toolbar widget; their enabled/disabled state synchronized with
238  * the other widgets. Note that after the first calling, this function will
239  * always return the same toolbar, regardless of the items
240  *  
241  * Returns: the toolbar
242  */
243 ModestToolbar *modest_widget_factory_get_main_toolbar (ModestWidgetFactory *self, 
244                                                        GSList *items);
245
246 /**
247  * modest_widget_factory_get_edit_toolbar
248  * @self: a ModestWidgetFactory instance
249  * @items: a list of ModestToolbarButtons (button_ids)
250  *
251  * returns the toolbar widget for edit windows; the enabled/disabled
252  * state synchronized with the other widgets.
253  *  
254  * Returns: the toolbar
255  */
256 ModestToolbar *modest_widget_factory_get_edit_toolbar (ModestWidgetFactory *self, 
257                                                        GSList *items);
258
259
260 G_END_DECLS
261
262 #endif /* __MODEST_WIDGET_FACTORY_H__ */
263