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