* improvements in display of address, refactored some code
[modest] / src / modest-window-mgr.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
31 /* modest-window-mgr.h */
32
33 #ifndef __MODEST_WINDOW_MGR_H__
34 #define __MODEST_WINDOW_MGR_H__
35
36 #include <glib-object.h>
37 /* other include files */
38
39 G_BEGIN_DECLS
40
41 /* convenience macros */
42 #define MODEST_TYPE_WINDOW_MGR             (modest_window_mgr_get_type())
43 #define MODEST_WINDOW_MGR(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_WINDOW_MGR,ModestWindowMgr))
44 #define MODEST_WINDOW_MGR_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_WINDOW_MGR,GObject))
45 #define MODEST_IS_WINDOW_MGR(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_WINDOW_MGR))
46 #define MODEST_IS_WINDOW_MGR_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_WINDOW_MGR))
47 #define MODEST_WINDOW_MGR_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_WINDOW_MGR,ModestWindowMgrClass))
48
49 enum {
50         MODEST_MAIN_WINDOW,        /* the main window */
51         MODEST_EDIT_WINDOW,        /* a window to edit a mail */
52         MODEST_ACCOUNT_WINDOW,     /* a window to edit account information */
53         MODEST_VIEW_WINDOW         /* a window to view mails */
54 };
55 typedef guint ModestWindowType;
56
57
58 typedef struct _ModestOpenWindow ModestOpenWindow;
59 struct _ModestOpenWindow {
60         GObject          *win;
61         ModestWindowType type;
62         guint            id;
63 };
64
65
66 typedef struct _ModestWindowMgr      ModestWindowMgr;
67 typedef struct _ModestWindowMgrClass ModestWindowMgrClass;
68
69 struct _ModestWindowMgr {
70         GObject parent;
71 };
72
73 struct _ModestWindowMgrClass {
74         GObjectClass parent_class;
75         
76         void (* last_window_closed) (ModestWindowMgr* obj);
77 };
78
79 /* member functions */
80 GType        modest_window_mgr_get_type    (void) G_GNUC_CONST;
81
82 /**
83  * modest_window_mgr_new:
84  *
85  * creates a new ModestWindowMgr instance
86  *
87  * Returns: a new ModestWindowMgr, or NULL in case of error
88  */
89 GObject*    modest_window_mgr_new         (void);
90
91 /**
92  * modest_window_mgr_register:
93  * @self: a ModestWindowMgr instance
94  * @win: the GObject of the window to register
95  * @type: ModestWindowType of the window to register
96  * @window_id: a guint window_id of the window
97  *
98  * register a window with the ModestWindowMgr instance *self
99  *
100  * Returns: TRUE on success, else FALSE
101  */
102 gboolean    modest_window_mgr_register   (ModestWindowMgr *self, GObject *win,
103                                           ModestWindowType type, guint window_id);
104
105 /**
106  * modest_window_mgr_unregister:
107  * @self: a ModestWindowMgr instance
108  * @win: the GObject of the window to register
109  *
110  * unregister a window from the ModestWindowMgr instance *self
111  *
112  * Returns: TRUE on success, else FALSE
113  */
114 gboolean    modest_window_mgr_unregister (ModestWindowMgr *self, GObject *win);
115
116 /**
117  * modest_window_mgr_find_by_type:
118  * @self: a ModestWindowMgr instance
119  * @type: the ModestWindowType to search for
120  *
121  * search for a window of type 'type' in the ModestWindowMgr instance *self
122  *
123  * Returns: the GObject of the window, else NULL
124  */
125 GObject*    modest_window_mgr_find_by_type (ModestWindowMgr *self, ModestWindowType type);
126
127 /**
128  * modest_window_mgr_find_by_id:
129  * @self: a ModestWindowMgr instance
130  * @window_id: the ModestWindowType to search for
131  *
132  * search for a window with a specific 'window_id' in the ModestWindowMgr instance *self
133  *
134  * Returns: the GObject of the window, else NULL
135  */
136 GObject*    modest_window_mgr_find_by_id (ModestWindowMgr *self, gint window_id);
137
138 G_END_DECLS
139
140 #endif /* __MODEST_WINDOW_MGR_H__ */
141