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