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