Refactor hildon_window_add_toolbar to have implementation through Modest API
[modest] / src / widgets / modest-window.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_WINDOW_H__
31 #define __MODEST_WINDOW_H__
32
33 #include <glib-object.h>
34 #include <tny-account-store.h>
35
36 G_BEGIN_DECLS
37
38 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif /*HAVE_CONFIG_H*/
41
42 #include <gtk/gtk.h>
43  
44 /* 
45  * admittedly, the ifdefs for gtk and maemo are rather ugly; still
46  * this way is probably the easiest to maintain
47  */
48 #ifdef MODEST_TOOLKIT_GTK
49 typedef GtkWindow      ModestWindowParent;
50 typedef GtkWindowClass ModestWindowParentClass;
51 #else
52 #ifdef MODEST_TOOLKIT_HILDON2
53 #include <hildon/hildon-stackable-window.h>
54 typedef HildonStackableWindow      ModestWindowParent;
55 typedef HildonStackableWindowClass ModestWindowParentClass;
56 #else
57 #include <hildon/hildon-window.h>
58 typedef HildonWindow      ModestWindowParent;
59 typedef HildonWindowClass ModestWindowParentClass;
60 #endif
61
62 #ifndef GTK_STOCK_FULLSCREEN
63 #define GTK_STOCK_FULLSCREEN ""
64 #endif /*GTK_STOCK_FULLSCREEN*/
65
66 #endif /*!MODEST_TOOLKIT_GTK */
67
68 /* Dimmed state variables */
69 typedef struct _DimmedState {   
70         guint    n_selected;
71         guint    already_opened_msg;
72         gboolean any_marked_as_deleted;
73         gboolean all_marked_as_deleted;
74         gboolean any_marked_as_seen;
75         gboolean all_marked_as_seen;
76         gboolean any_marked_as_cached;
77         gboolean all_marked_as_cached;
78         gboolean any_has_attachments;
79         gboolean all_has_attachments;
80         gboolean sent_in_progress;
81         gboolean all_selected;
82 } DimmedState;
83
84 /* convenience macros */
85 #define MODEST_TYPE_WINDOW             (modest_window_get_type())
86 #define MODEST_WINDOW(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_WINDOW,ModestWindow))
87 #define MODEST_WINDOW_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_WINDOW,GObject))
88 #define MODEST_IS_WINDOW(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_WINDOW))
89 #define MODEST_IS_WINDOW_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_WINDOW))
90 #define MODEST_WINDOW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_WINDOW,ModestWindowClass))
91
92 typedef struct _ModestWindow      ModestWindow;
93 typedef struct _ModestWindowClass ModestWindowClass;
94
95 struct _ModestWindow {
96          ModestWindowParent parent;
97 };
98
99 struct _ModestWindowClass {
100         ModestWindowParentClass parent_class;
101
102         /* virtual methods */
103         void (*set_zoom_func) (ModestWindow *self, gdouble zoom);
104         gdouble (*get_zoom_func) (ModestWindow *self);
105         gboolean (*zoom_plus_func) (ModestWindow *self);
106         gboolean (*zoom_minus_func) (ModestWindow *self);
107         void (*show_toolbar_func) (ModestWindow *self, gboolean show_toolbar);
108         void (*save_state_func) (ModestWindow *self);
109         void (*disconnect_signals_func) (ModestWindow *self);
110         void (*show_progress_func) (ModestWindow *self, gboolean show);
111         void (*add_toolbar_func) (ModestWindow *self, GtkToolbar *toolbar);
112 };
113
114 /**
115  * modest_window_get_type:
116  *
117  * get the #GType for #ModestWindow
118  * 
119  * Returns: the type
120  */     
121 GType        modest_window_get_type    (void) G_GNUC_CONST;
122
123
124 /**
125  * modest_window_get_active_account:
126  * @self: a modest window instance
127  * 
128  * get the name of the active account
129  * 
130  * Returns: the active account name as a constant string
131  */     
132 const gchar* modest_window_get_active_account (ModestWindow *self);
133
134
135
136 /**
137  * modest_window_set_active_account:
138  * @self: a modest window instance
139  * @active_account: a new active account name for this window
140  * 
141  * set the active account for this window.
142  * NOTE: this must be a valid, non-pseudo account.
143  * 
144  */     
145 void modest_window_set_active_account (ModestWindow *self, const gchar *active_account);
146
147 /**
148  * modest_window_get_active_mailbox:
149  * @self: a modest window instance
150  * 
151  * get the name of the active mailbox
152  * 
153  * Returns: the active mailbox as a constant string
154  */     
155 const gchar* modest_window_get_active_mailbox (ModestWindow *self);
156
157
158
159 /**
160  * modest_window_set_active_account:
161  * @self: a modest window instance
162  * @active_mailbox: a new active mailbox name for this window
163  * 
164  * set the active mailbox for this window.
165  * 
166  */     
167 void modest_window_set_active_mailbox (ModestWindow *self, const gchar *active_mailbox);
168
169 /**
170  * modest_window_set_zoom:
171  * @window: a #ModestWindow instance
172  * @zoom: the zoom level (1.0 is no zoom)
173  *
174  * sets the zoom level of the window
175  */
176 void            modest_window_set_zoom    (ModestWindow *window,
177                                            gdouble value);
178
179 /**
180  * modest_window_get_zoom:
181  * @window: a #ModestWindow instance
182  *
183  * gets the zoom of the window
184  *
185  * Returns: the current zoom value (1.0 is no zoom)
186  */
187 gdouble         modest_window_get_zoom    (ModestWindow *window);
188
189 /**
190  * modest_window_zoom_plus:
191  * @window: a #ModestWindow
192  *
193  * increases one level the zoom.
194  *
195  * Returns: %TRUE if successful, %FALSE if increasing zoom is not available
196  */
197 gboolean modest_window_zoom_plus (ModestWindow *window);
198
199 /**
200  * modest_window_zoom_minus:
201  * @window: a #ModestWindow
202  *
203  * decreases one level the zoom.
204  *
205  * Returns: %TRUE if successful, %FALSE if increasing zoom is not available
206  */
207 gboolean modest_window_zoom_minus (ModestWindow *window);
208
209
210 /**
211  * modest_window_show_toolbar:
212  * @window: 
213  * @view_toolbar: whether or not the toolbar should be shown
214  * 
215  * shows/hides the window toolbar
216  **/
217 void     modest_window_show_toolbar (ModestWindow *window, 
218                                      gboolean show_toolbar);
219                                      
220 /**
221  * modest_window_save_state:
222  * @window: 
223  * 
224  * Ask the window to save its settings for loading again later.
225  * This actually invokes the save_setting_func vfunc, which 
226  * derived windows should implement.
227  **/
228 void     modest_window_save_state (ModestWindow *window);
229
230
231 /**
232  * modest_window_set_dimming_state:
233  * @window: a #ModestWindow instance object
234  * @state: the #DimmedState state at specific time 
235  * 
236  * Set basic dimming variables from selected headers at
237  * specific moment.
238  **/
239 void
240 modest_window_set_dimming_state (ModestWindow *window,
241                                  DimmedState *state);
242
243 /**
244  * modest_window_set_dimming_state:
245  * @window: a #ModestWindow instance object
246  * 
247  * Set basic dimming variables from selected headers at
248  * specific moment.
249  * 
250  * @Returns: a  #DimmedState state saved previously. 
251  **/
252 const DimmedState *
253 modest_window_get_dimming_state (ModestWindow *window);
254                                 
255
256 /**
257  * modest_window_get_action:
258  * @window: a #ModestWindow instance object
259  * @action_path: the full path of required action.
260  * 
261  * Get an action from ui manager, using @action_path parameter,
262  * which represent the full path to the required action into UIManager 
263  * xml definition.
264  **/
265 GtkAction * modest_window_get_action (ModestWindow *window, const gchar *action_path); 
266
267 /**
268  * modest_window_get_action_widget:
269  * @window: a #ModestWindow instance object
270  * @action_path: the full path of required action.
271  * 
272  * Get action widget from ui manager, using @action_path parameter,
273  * which represent the full path to the required action into UIManager 
274  * xml definition.
275  **/
276 GtkWidget *modest_window_get_action_widget (ModestWindow *window, 
277                                             const gchar *action_path);
278
279 /**
280  * modest_window_check_dimming_rules:
281  * @self: a #ModestWindow instance object
282  * 
283  * Calls UI Dimming Manager of @self window to check all dimming rules.
284  * 
285  **/
286 void modest_window_check_dimming_rules (ModestWindow *self);
287
288 /**
289  * modest_window_check_dimming_rules:
290  * @self: a #ModestWindow instance object
291  * @group: a #ModestWindow instance object
292  * 
293  * Calls UI Dimming Manager of @self window to check @group_name specific
294  * dimming rules.
295  * 
296  **/
297 void modest_window_check_dimming_rules_group (ModestWindow *self,
298                                               const gchar *group_name);
299
300
301 /**
302  * modest_window_enable_dimming:
303  * @self: a #ModestWindow instance object
304  * 
305  * Enables UI dimming rules checking.
306  *
307  **/
308 void modest_window_enable_dimming (ModestWindow *self);
309
310
311 /**
312  * modest_window_disable_dimming:
313  * @self: a #ModestWindow instance object
314  * 
315  * Disables UI dimming rules checking.
316  *
317  **/
318 void modest_window_disable_dimming (ModestWindow *self);
319
320
321 void modest_window_disconnect_signals (ModestWindow *self);
322
323 void modest_window_show_progress (ModestWindow *self, gboolean show_progress);
324
325 void modest_window_add_toolbar (ModestWindow *self, GtkToolbar *toolbar);
326
327
328 G_END_DECLS
329
330 #endif /* __MODEST_WINDOW_H__ */