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