Added method find_registered_message_uid in window mgr.
[modest] / src / widgets / modest-window-mgr.h
1 /* Copyright (c) 2006,2007 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_MGR_H__
31 #define __MODEST_WINDOW_MGR_H__
32
33 #include <glib-object.h>
34 #include "modest-window.h"
35
36 G_BEGIN_DECLS
37
38 /* convenience macros */
39 #define MODEST_TYPE_WINDOW_MGR             (modest_window_mgr_get_type())
40 #define MODEST_WINDOW_MGR(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_WINDOW_MGR,ModestWindowMgr))
41 #define MODEST_WINDOW_MGR_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_WINDOW_MGR,ModestWindowMgrClass))
42 #define MODEST_IS_WINDOW_MGR(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_WINDOW_MGR))
43 #define MODEST_IS_WINDOW_MGR_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_WINDOW_MGR))
44 #define MODEST_WINDOW_MGR_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_WINDOW_MGR,ModestWindowMgrClass))
45
46 typedef struct _ModestWindowMgr      ModestWindowMgr;
47 typedef struct _ModestWindowMgrClass ModestWindowMgrClass;
48
49 struct _ModestWindowMgr {
50          GObject parent;
51 };
52
53 struct _ModestWindowMgrClass {
54         GObjectClass parent_class;
55
56         /* Virtuals */
57         gboolean              (*register_window)                (ModestWindowMgr *self,
58                                                                  ModestWindow *window,
59                                                                  ModestWindow *parent);
60         void                  (*unregister_window)              (ModestWindowMgr *self,
61                                                                  ModestWindow *window);
62         void                  (*set_fullscreen_mode)            (ModestWindowMgr *self,
63                                                                  gboolean on);
64         gboolean              (*get_fullscreen_mode)            (ModestWindowMgr *self);
65         void                  (*show_toolbars)                  (ModestWindowMgr *self,
66                                                                  GType window_type,
67                                                                  gboolean show_toolbars,
68                                                                  gboolean fullscreen);
69         ModestWindow *        (*get_main_window)                (ModestWindowMgr *self,
70                                                                  gboolean show);
71         gboolean              (*close_all_windows)              (ModestWindowMgr *self);
72         GtkWindow *           (*get_modal)                      (ModestWindowMgr *self);
73         void                  (*set_modal)                      (ModestWindowMgr *self,
74                                                                  GtkWindow *window,
75                                                                  GtkWindow *parent);
76         gboolean              (*find_registered_header)         (ModestWindowMgr *self,
77                                                                  TnyHeader *header,
78                                                                  ModestWindow **win);
79         gboolean              (*find_registered_message_uid)    (ModestWindowMgr *self,
80                                                                  const gchar *msg_uid,
81                                                                  ModestWindow **win);
82         GList *               (*get_window_list)                (ModestWindowMgr *self);
83         ModestWindow *        (*show_initial_window)            (ModestWindowMgr *self);
84         ModestWindow *        (*get_current_top)                (ModestWindowMgr *self);
85         gboolean              (*screen_is_on)                   (ModestWindowMgr *self);
86         /* Signals */
87         void (*window_list_empty) (ModestWindowMgr *self);
88         void (*progress_list_changed) (ModestWindowMgr *self);
89 };
90
91
92 /* member functions */
93 GType        modest_window_mgr_get_type    (void) G_GNUC_CONST;
94
95 /* typical parameter-less _new function */
96 ModestWindowMgr*    modest_window_mgr_new         (void);
97
98
99 /**
100  * modest_window_mgr_register_window:
101  * @self: the #ModestWindowMgr
102  * @window: a #ModestWindow
103  * 
104  * Registers a new window in the window manager. The window manager
105  * will keep a reference.
106  **/
107 gboolean           modest_window_mgr_register_window       (ModestWindowMgr *self, 
108                                                             ModestWindow *window,
109                                                             ModestWindow *parent);
110
111 /**
112  * modest_window_mgr_unregister_window:
113  * @self: the #ModestWindowMgr
114  * @window: a #ModestWindow
115  * 
116  * Unregisters a given window from the window manager. The window
117  * manager will free its reference to it.
118  **/
119 void           modest_window_mgr_unregister_window     (ModestWindowMgr *self, 
120                                                         ModestWindow *window);
121
122 /**
123  * modest_window_mgr_register_banner:
124  * @self: a #ModestWindowMgr
125  *
126  * Increase the count of pending banners in the window manager
127  */
128 void           modest_window_mgr_register_banner (ModestWindowMgr *self);
129
130 /**
131  * modest_window_mgr_unregister_banner:
132  * @self: a #ModestWindowMgr
133  *
134  * Decrease the count of pending banners in the window manager
135  */
136 void           modest_window_mgr_unregister_banner (ModestWindowMgr *self);
137
138 /**
139  * modest_window_mgr_set_fullscreen_mode:
140  * @self: a #ModestWindowMgr
141  * @on: a #gboolean
142  * 
143  * sets/unsets the application windows in fullscreen mode
144  **/
145 void           modest_window_mgr_set_fullscreen_mode   (ModestWindowMgr *self,
146                                                         gboolean on);
147
148 /**
149  * modest_window_mgr_get_fullscreen_mode:
150  * @self: a #ModestWindowMgr
151  * 
152  * gets the application current fullscreen mode
153  *
154  * Return value: TRUE is the application is in fullscrenn mode,
155  * otherwise FALSE
156  **/
157 gboolean       modest_window_mgr_get_fullscreen_mode   (ModestWindowMgr *self);
158
159
160 /**
161  * modest_window_mgr_show_toolbars:
162  * @self: a #ModestWindowMgr
163  * @window_type: apply the show toolbars command only to the windows of this type
164  * @show_toolbar: whether or not the toolbars should be shown
165  * @fullscreen: TRUE/FALSE for show/hide in fullscreen mode, otherwise
166  * it applies to normal mode
167  * 
168  * shows or hides the toolbars of the registered windows. Note that if
169  * the #fullscreen attribute is TRUE and the application is in normal
170  * mode, you will not see the changes until the application switches
171  * to fullscreen mode and viceversa
172  **/
173 void           modest_window_mgr_show_toolbars         (ModestWindowMgr *self,
174                                                         GType window_type,
175                                                         gboolean show_toolbars,
176                                                         gboolean fullscreen);
177 /**
178  * modest_window_mgr_get_main_window:
179  * @self: a #ModestWindowMgr
180  * @show: if TRUE, create the main window and show it if it was not existing.
181  *
182  * get the main window, and depending on @create, create one if it does not exist yet
183  *
184  * Returns: the main window or NULL in case of error, or the main-window
185  * did not yet exist
186  **/
187 ModestWindow*  modest_window_mgr_get_main_window       (ModestWindowMgr *self,
188                                                         gboolean show);
189
190 /**
191  * modest_window_mgr_set_main_window:
192  * @self: a #ModestWindowMgr
193  * @main_win: a #ModestMainWindow
194  */
195 void modest_window_mgr_set_main_window (ModestWindowMgr *self, ModestWindow *main_win);
196
197
198 /**
199  * modest_window_mgr_main_window_exists:
200  * @self: a #ModestWindowMgr
201  *
202  * do we have a main window?
203  *
204  * Returns: TRUE if there's a main window, FALSE otherwise
205  **/
206 gboolean  modest_window_mgr_main_window_exists       (ModestWindowMgr *self);
207
208
209
210 /**
211  * modest_window_mgr_get_modal:
212  * @self: a #ModestWindowMgr
213  *
214  * get the modal window; if it's NULL, there's no active modal window
215  *
216  * Returns: the modal window or NULL
217  **/
218 GtkWindow*    modest_window_mgr_get_modal  (ModestWindowMgr *self);
219
220
221 /**
222  * modest_window_mgr_get_easysetup_dialog:
223  * @self: a #ModestWindowMgr
224  *
225  * set the modal dialog; set it to NULL after destroying the dialog
226  *
227  **/
228 void          modest_window_mgr_set_modal  (ModestWindowMgr *self,
229                                             GtkWindow *window,
230                                             GtkWindow *parent);
231
232 /**
233  * modest_window_mgr_prevent_hibernation_while_window_is_shown:
234  * @self: a #ModestWindowMgr
235  * @window: The window that should prevent hibernation while it is shown.
236  * 
237  * Call this if hibernation should not be allowed because 
238  * windows are open whose state cannot sensible be saved, such as Account 
239  * Settings dialogs.
240  * This causes modest_window_mgr_get_hibernation_is_prevented() to return TRUE 
241  * until all such windows have been closed. That means, until the windows have 
242  * been hidden - window destruction or other memory management is not relevant.
243  **/
244 void modest_window_mgr_prevent_hibernation_while_window_is_shown (ModestWindowMgr *self, 
245         GtkWindow *window);
246
247
248
249 /**
250  * modest_window_mgr_register_help_id
251  * @self: a #ModestWindowMgr
252  * @win: some window
253  * @help_id: the help_id for this window
254  * 
255  * register a help id for a window
256  **/
257 void
258 modest_window_mgr_register_help_id (ModestWindowMgr *self, GtkWindow *win, const gchar* help_id);
259
260
261 /**
262  * modest_window_mgr_get_help_id:
263  * @self: a #ModestWindowMgr
264  * @win: some window
265  * 
266  * get the help id for a window; if the window is the main-window and some folder is
267  * selected, it will return the proper help_id for that
268  *
269  * Returns: a help _id
270  **/
271 const gchar*
272 modest_window_mgr_get_help_id (ModestWindowMgr *self, GtkWindow *win);
273
274
275
276 /**
277  * modest_window_mgr_find_registered_header
278  * @self: a #ModestWindowMgr
279  * @header: a valid #TnyHeader
280  * 
281  * search for the given uid in both the list of preregistered uids and in the window list;
282  * if it's available in the window list, fill the *win out-param
283  *
284  * returns TRUE if found, FALSE otherwise
285  **/
286 gboolean modest_window_mgr_find_registered_header (ModestWindowMgr *self,  TnyHeader *header,
287                                                ModestWindow **win);
288
289
290 /**
291  * modest_window_mgr_find_registered_header
292  * @self: a #ModestWindowMgr
293  * @msg_uid: a message uid
294  * 
295  * search for the given uid in both the list of preregistered uids and in the window list;
296  * if it's available in the window list, fill the *win out-param
297  *
298  * returns TRUE if found, FALSE otherwise
299  **/
300 gboolean modest_window_mgr_find_registered_message_uid (ModestWindowMgr *self,  const gchar *msg_uid,
301                                                         ModestWindow **win);
302
303 /**
304  * modest_window_mgr_get_window_list:
305  * @self: a #ModestWindowMgr
306  *
307  * get the list of windows registered in window mgr.
308  *
309  * Returns: a #GList, that caller should free
310  */
311 GList *modest_window_mgr_get_window_list (ModestWindowMgr *self);
312
313 /**
314  * modest_window_mgr_close_all_windows
315  * @self: a #ModestWindowMgr
316  * 
317  * Close all registered windows. If failed (for example because
318  * one confirmation dialog rejected the operation), return %FALSE
319  **/
320 gboolean modest_window_mgr_close_all_windows (ModestWindowMgr *self);
321
322 /**
323  * modest_window_mgr_register_header
324  * @self: a #ModestWindowMgr
325  * @header: a valid #TnyHeader
326  * @alt_uid: alternative uid in case @header does not provide one
327  * 
328  * register the uid, even before the window is created. thus, we know when
329  * some window creation might already be underway. the uid will automatically be
330  * removed when the window itself will registered
331  * 
332  **/
333 void  modest_window_mgr_register_header   (ModestWindowMgr *self,  TnyHeader *header, const gchar *alt_uid);
334         
335
336 /**
337  * modest_window_mgr_unregister_header
338  * @self: a #ModestWindowMgr
339  * @header: a valid #TnyHeader
340  * 
341  * unregister the uid. We could need to do that if there is any error
342  * retrieving a message. In that case the window will not be
343  * registered and thus the header will not be removed, so we must do
344  * it manually
345  **/
346 void  modest_window_mgr_unregister_header (ModestWindowMgr *self,  TnyHeader *header);
347
348 /**
349  * modest_window_mgr_get_hibernation_is_prevented:
350  * @self: a #ModestWindowMgr
351  * @result: Whether any windows are currently preventing hibernation.
352  * 
353  * Use this to discover whether hibernation should not be allowed because 
354  * windows are open whose state cannot sensible be saved, such as Account 
355  * Settings dialogs. This function will return true after someone has called 
356  * modest_window_mgr_prevent_hibernation_while_window_is_shown() and before 
357  * that window has been closed.
358  **/
359 gboolean modest_window_mgr_get_hibernation_is_prevented (ModestWindowMgr *self);
360
361 /**
362  * modest_window_mgr_save_state_for_all_windows:
363  * @self: a #ModestWindowMgr
364  * 
365  * Save any state for all windows. For instance, call this before allowing 
366  * application hibernation.
367  **/
368 void modest_window_mgr_save_state_for_all_windows (ModestWindowMgr *self);
369
370 /**
371  * modest_window_mgr_get_num_windows:
372  * @self: a #ModestWindowMgr
373  * 
374  * Gets the number of already registered windows, and pending banners
375  *
376  * Returns: the number of already registered windows, and pending banners
377  **/
378 guint modest_window_mgr_get_num_windows (ModestWindowMgr *self);
379
380 /**
381  * modest_window_mgr_get_msg_view_window:
382  * @self: a #ModestWindowMgr
383  *
384  * obtain a cached #ModestMsgViewWindow if available, or construct a new
385  * one.
386  *
387  * Returns: a #ModestMsgViewWindow
388  */
389 GtkWidget *   modest_window_mgr_get_msg_view_window (ModestWindowMgr *self);
390
391 /**
392  * modest_window_mgr_get_msg_edit_window:
393  * @self: a #ModestWindowMgr
394  *
395  * obtain a cached #ModestMsgEditWindow if available, or construct a new
396  * one.
397  *
398  * Returns: a #ModestMsgEditWindow
399  */
400 GtkWidget *   modest_window_mgr_get_msg_edit_window (ModestWindowMgr *self);
401
402 /**
403  * modest_window_mgr_show_initial_window:
404  * @self: a #ModestWindowMgr
405  *
406  * This function determines which is the window that should be
407  * initially launched. After that it shows that window. If there is no
408  * account available this function also launches the account setup
409  * wizard.
410  *
411  * Returns: the initial window. NULL if something goes wrong
412  **/
413 ModestWindow* modest_window_mgr_show_initial_window (ModestWindowMgr *self);
414
415 /**
416  * modest_window_mgr_get_current_top:
417  * @self: a #ModestWindowMgr
418  * 
419  * this function returns the ModestWindow that is currently on top of all the others
420  * 
421  * Returns: the topmost #ModestWindow
422  **/
423 ModestWindow* modest_window_mgr_get_current_top (ModestWindowMgr *self);
424
425 /**
426  * modest_window_mgr_screen_is_on:
427  * @self: a #ModestWindowMgr
428  *
429  * this function returns if device display is on or not
430  *
431  * Returns: %TRUE if screen is on, %FALSE if not
432  */
433 gboolean modest_window_mgr_screen_is_on (ModestWindowMgr *self);
434
435 /**
436  * modest_window_mgr_get_progress_operations:
437  * @self: a #ModestWindowMgr
438  *
439  * get a list of operations in progress
440  *
441  * Returns: a newly allocated #TnyList
442  */
443 TnyList *modest_window_mgr_get_progress_operations (ModestWindowMgr *self);
444
445 /**
446  * modest_window_mgr_has_progress_operation:
447  * @self: a #ModestWindowMgr
448  *
449  * is there are send/receive or receive operations in progress for any account.
450  *
451  * Returns: %TRUE if receive progress operations are in progress.
452  */
453 gboolean modest_window_mgr_has_progress_operation (ModestWindowMgr *self);
454
455 /**
456  * modest_window_mgr_has_progress_operation_on_account:
457  * @self: a #ModestWindowMgr
458  * @account_name: a string
459  *
460  * is there are send/receive or receive operations in progress for @account_name.
461  *
462  * Returns: %TRUE if receive progress operations are in progress.
463  */
464 gboolean modest_window_mgr_has_progress_operation_on_account (ModestWindowMgr *self,
465                                                               const gchar *account_name);
466
467 G_END_DECLS
468
469 #endif /* __MODEST_WINDOW_MGR_H__ */