Avoid wait on taking screenshot. Now it shouldn't be required.
[modest] / src / hildon2 / modest-mailboxes-window.c
1 /* Copyright (c) 2009, 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 #include <modest-mailboxes-window.h>
31 #include <hildon/hildon-pannable-area.h>
32 #include <modest-window-mgr.h>
33 #include <modest-signal-mgr.h>
34 #include <modest-runtime.h>
35 #include <modest-platform.h>
36 #include <modest-maemo-utils.h>
37 #include <modest-icon-names.h>
38 #include <modest-ui-constants.h>
39 #include <modest-account-mgr.h>
40 #include <modest-account-mgr-helpers.h>
41 #include <modest-defs.h>
42 #include <modest-ui-actions.h>
43 #include <modest-window.h>
44 #include <hildon/hildon-program.h>
45 #include <hildon/hildon-banner.h>
46 #include <hildon/hildon-button.h>
47 #include <tny-account-store-view.h>
48 #include <modest-header-window.h>
49 #include <modest-ui-dimming-rules.h>
50 #include <modest-ui-dimming-manager.h>
51 #include <modest-window-priv.h>
52 #include "modest-text-utils.h"
53 #include "modest-tny-account.h"
54 #include <modest-folder-window.h>
55
56 /* 'private'/'protected' functions */
57 static void modest_mailboxes_window_class_init  (ModestMailboxesWindowClass *klass);
58 static void modest_mailboxes_window_init        (ModestMailboxesWindow *obj);
59 static void modest_mailboxes_window_finalize    (GObject *obj);
60
61 static void connect_signals (ModestMailboxesWindow *self);
62 static void modest_mailboxes_window_disconnect_signals (ModestWindow *self);
63
64 static void on_mailbox_activated (ModestFolderView *mailboxes_view,
65                                   TnyFolder *folder,
66                                   gpointer userdata);
67 static void on_progress_list_changed (ModestWindowMgr *mgr,
68                                       ModestMailboxesWindow *self);
69 static gboolean on_map_event (GtkWidget *widget,
70                               GdkEvent *event,
71                               gpointer userdata);
72 static void update_progress_hint (ModestMailboxesWindow *self);
73 static void on_queue_changed    (ModestMailOperationQueue *queue,
74                                  ModestMailOperation *mail_op,
75                                  ModestMailOperationQueueNotification type,
76                                  ModestMailboxesWindow *self);
77 static void on_activity_changed (ModestFolderView *view,
78                                  gboolean activity,
79                                  ModestMailboxesWindow *folder_window);
80 static gboolean on_key_press(GtkWidget *widget,
81                                 GdkEventKey *event,
82                                 gpointer user_data);
83
84 typedef struct _ModestMailboxesWindowPrivate ModestMailboxesWindowPrivate;
85 struct _ModestMailboxesWindowPrivate {
86
87         GtkWidget *folder_view;
88         GtkWidget *top_vbox;
89         GtkWidget *new_message_button;
90
91         /* signals */
92         GSList *sighandlers;
93
94         gchar *current_store_account;
95         gboolean progress_hint;
96         guint queue_change_handler;
97 };
98 #define MODEST_MAILBOXES_WINDOW_GET_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE((o), \
99                                                                           MODEST_TYPE_MAILBOXES_WINDOW, \
100                                                                           ModestMailboxesWindowPrivate))
101
102 /* globals */
103 static GtkWindowClass *parent_class = NULL;
104
105 /************************************************************************/
106
107 GType
108 modest_mailboxes_window_get_type (void)
109 {
110         static GType my_type = 0;
111         if (!my_type) {
112                 static const GTypeInfo my_info = {
113                         sizeof(ModestMailboxesWindowClass),
114                         NULL,           /* base init */
115                         NULL,           /* base finalize */
116                         (GClassInitFunc) modest_mailboxes_window_class_init,
117                         NULL,           /* class finalize */
118                         NULL,           /* class data */
119                         sizeof(ModestMailboxesWindow),
120                         1,              /* n_preallocs */
121                         (GInstanceInitFunc) modest_mailboxes_window_init,
122                         NULL
123                 };
124                 my_type = g_type_register_static (MODEST_TYPE_HILDON2_WINDOW,
125                                                   "ModestMailboxesWindow",
126                                                   &my_info, 0);
127         }
128         return my_type;
129 }
130
131 static void
132 modest_mailboxes_window_class_init (ModestMailboxesWindowClass *klass)
133 {
134         GObjectClass *gobject_class;
135         gobject_class = (GObjectClass*) klass;
136         ModestWindowClass *modest_window_class = (ModestWindowClass *) klass;
137
138         parent_class            = g_type_class_peek_parent (klass);
139         gobject_class->finalize = modest_mailboxes_window_finalize;
140
141         g_type_class_add_private (gobject_class, sizeof(ModestMailboxesWindowPrivate));
142         
143         modest_window_class->disconnect_signals_func = modest_mailboxes_window_disconnect_signals;
144 }
145
146 static void
147 modest_mailboxes_window_init (ModestMailboxesWindow *obj)
148 {
149         ModestMailboxesWindowPrivate *priv;
150
151         priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE(obj);
152
153         priv->sighandlers = NULL;
154         
155         priv->folder_view = NULL;
156
157         priv->top_vbox = NULL;
158
159         priv->current_store_account = NULL;
160         priv->progress_hint = FALSE;
161         priv->queue_change_handler = 0;
162 }
163
164 static void
165 modest_mailboxes_window_finalize (GObject *obj)
166 {
167         ModestMailboxesWindowPrivate *priv;
168
169         priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE(obj);
170
171         if (priv->current_store_account) {
172                 g_free (priv->current_store_account);
173                 priv->current_store_account = NULL;
174         }
175
176         /* Sanity check: shouldn't be needed, the window mgr should
177            call this function before */
178         modest_mailboxes_window_disconnect_signals (MODEST_WINDOW (obj));       
179
180         G_OBJECT_CLASS(parent_class)->finalize (obj);
181 }
182
183 static void
184 modest_mailboxes_window_disconnect_signals (ModestWindow *self)
185 {
186         ModestMailboxesWindowPrivate *priv;
187         priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE(self);
188
189         if (g_signal_handler_is_connected (G_OBJECT (modest_runtime_get_mail_operation_queue ()), 
190                                            priv->queue_change_handler))
191                 g_signal_handler_disconnect (G_OBJECT (modest_runtime_get_mail_operation_queue ()), 
192                                              priv->queue_change_handler);
193
194         modest_signal_mgr_disconnect_all_and_destroy (priv->sighandlers);
195         priv->sighandlers = NULL;
196 }
197
198 static void
199 on_visible_account_changed (ModestFolderView *mailboxes_view,
200                             const gchar *account_id,
201                             gpointer user_data)
202 {
203         if (account_id) {
204                 TnyAccount *acc = 
205                         modest_tny_account_store_get_tny_account_by (modest_runtime_get_account_store(),
206                                                                      MODEST_TNY_ACCOUNT_STORE_QUERY_ID,
207                                                                      account_id);
208                 if (acc) {
209                         const gchar *name;
210                         gchar *title = NULL;
211
212                         name = modest_tny_account_get_parent_modest_account_name_for_server_account (acc);
213                         title = modest_account_mgr_get_display_name (modest_runtime_get_account_mgr(),
214                                                                      name);
215                         if (title) {
216                                 gtk_window_set_title (GTK_WINDOW (user_data), title);
217                                 g_free (title);
218                         } else {
219                                 gtk_window_set_title (GTK_WINDOW (user_data), _("mcen_ap_name"));
220                         }
221                         g_object_unref (acc);
222                 }
223         } else {
224                 gtk_window_set_title (GTK_WINDOW (user_data), _("mcen_ap_name"));
225         }
226 }
227
228 static void
229 connect_signals (ModestMailboxesWindow *self)
230 {
231         ModestMailboxesWindowPrivate *priv;
232
233         priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE(self);
234
235         /* mailboxes view */
236         priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers, 
237                                                        G_OBJECT (priv->folder_view), "folder-activated", 
238                                                        G_CALLBACK (on_mailbox_activated), self);
239
240         priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
241                                                        G_OBJECT (modest_runtime_get_window_mgr ()),
242                                                        "progress-list-changed",
243                                                        G_CALLBACK (on_progress_list_changed), self);
244
245         priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
246                                                        G_OBJECT (priv->folder_view),
247                                                        "activity-changed",
248                                                        G_CALLBACK (on_activity_changed), self);
249
250         priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
251                                                        G_OBJECT (priv->folder_view),
252                                                        "visible-account-changed",
253                                                        G_CALLBACK (on_visible_account_changed), self);
254
255         priv->sighandlers = 
256                 modest_signal_mgr_connect (priv->sighandlers,
257                                            G_OBJECT (priv->new_message_button),
258                                            "clicked",
259                                            G_CALLBACK (modest_ui_actions_on_new_msg), self);
260
261         /* connect window keys -> priv->folder_view scroll here? */
262         g_signal_connect(G_OBJECT(self), "key-press-event",
263                         G_CALLBACK(on_key_press), self);
264 }
265
266 ModestWindow *
267 modest_mailboxes_window_new (const gchar *account)
268 {
269         ModestMailboxesWindow *self = NULL;     
270         ModestMailboxesWindowPrivate *priv = NULL;
271         HildonProgram *app;
272         GdkPixbuf *window_icon;
273         GtkWidget *pannable;
274         GtkWidget *action_area_box;
275         GdkPixbuf *new_message_pixbuf;
276         guint accel_key;
277         GdkModifierType accel_mods;
278         GtkAccelGroup *accel_group;
279         GtkWidget *top_alignment;
280         
281         self  = MODEST_MAILBOXES_WINDOW(g_object_new(MODEST_TYPE_MAILBOXES_WINDOW, NULL));
282         priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE(self);
283
284         pannable = hildon_pannable_area_new ();
285         priv->queue_change_handler =
286                 g_signal_connect (G_OBJECT (modest_runtime_get_mail_operation_queue ()),
287                                   "queue-changed",
288                                   G_CALLBACK (on_queue_changed),
289                                   self);
290
291         priv->folder_view  = modest_platform_create_folder_view (NULL);
292         modest_folder_view_set_cell_style (MODEST_FOLDER_VIEW (priv->folder_view),
293                                            MODEST_FOLDER_VIEW_CELL_STYLE_COMPACT);
294         modest_folder_view_set_filter (MODEST_FOLDER_VIEW (priv->folder_view), 
295                                        MODEST_FOLDER_VIEW_FILTER_HIDE_ACCOUNTS);
296
297         action_area_box = hildon_tree_view_get_action_area_box (GTK_TREE_VIEW (priv->folder_view));
298         priv->new_message_button = hildon_button_new (0, HILDON_BUTTON_ARRANGEMENT_HORIZONTAL);
299
300         hildon_button_set_title (HILDON_BUTTON (priv->new_message_button), _("mcen_ti_new_message"));
301         new_message_pixbuf = modest_platform_get_icon ("general_add", MODEST_ICON_SIZE_BIG);
302         hildon_button_set_image (HILDON_BUTTON (priv->new_message_button), gtk_image_new_from_pixbuf (new_message_pixbuf));
303         g_object_unref (new_message_pixbuf);
304
305         gtk_box_pack_start (GTK_BOX (action_area_box), priv->new_message_button, TRUE, TRUE, 0);
306         gtk_widget_show_all (priv->new_message_button);
307         hildon_tree_view_set_action_area_visible (GTK_TREE_VIEW (priv->folder_view), TRUE);
308         
309         /* Set account store */
310         tny_account_store_view_set_account_store (TNY_ACCOUNT_STORE_VIEW (priv->folder_view),
311                                                   TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()));
312
313         priv->top_vbox = gtk_vbox_new (0, FALSE);
314         top_alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
315         gtk_alignment_set_padding (GTK_ALIGNMENT (top_alignment), 
316                                    0, 0, 
317                                    MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE);
318
319         gtk_container_add (GTK_CONTAINER (pannable), priv->folder_view);
320         gtk_box_pack_end (GTK_BOX (priv->top_vbox), pannable, TRUE, TRUE, 0);
321         gtk_container_add (GTK_CONTAINER (top_alignment), priv->top_vbox);
322         gtk_container_add (GTK_CONTAINER (self), top_alignment);
323
324         gtk_widget_show (priv->folder_view);
325         gtk_widget_show (pannable);
326         gtk_widget_show (top_alignment);
327         gtk_widget_show (priv->top_vbox);
328
329         connect_signals (MODEST_MAILBOXES_WINDOW (self));
330
331         /* Get device name */
332         modest_maemo_utils_get_device_name ();
333
334         app = hildon_program_get_instance ();
335         hildon_program_add_window (app, HILDON_WINDOW (self));
336         
337         /* Set window icon */
338         window_icon = modest_platform_get_icon (MODEST_APP_ICON, MODEST_ICON_SIZE_BIG);
339         if (window_icon) {
340                 gtk_window_set_icon (GTK_WINDOW (self), window_icon);
341                 g_object_unref (window_icon);
342         }
343
344         /* Dont't restore settings here, 
345          * because it requires a gtk_widget_show(), 
346          * and we don't want to do that until later,
347          * so that the UI is not visible for non-menu D-Bus activation.
348          */
349
350         g_signal_connect (G_OBJECT (self), "map-event",
351                           G_CALLBACK (on_map_event),
352                           G_OBJECT (self));
353         update_progress_hint (self);
354
355         accel_group = gtk_accel_group_new ();
356         gtk_accelerator_parse ("<Control>n", &accel_key, &accel_mods);
357         gtk_widget_add_accelerator (priv->new_message_button, "clicked", accel_group,
358                                     accel_key, accel_mods, 0);
359         gtk_window_add_accel_group (GTK_WINDOW (self), accel_group);
360
361         modest_folder_view_set_filter (MODEST_FOLDER_VIEW (priv->folder_view),
362                                        MODEST_FOLDER_VIEW_FILTER_SHOW_ONLY_MAILBOXES);
363
364         modest_mailboxes_window_set_account (MODEST_MAILBOXES_WINDOW (self), account);
365
366         return MODEST_WINDOW(self);
367 }
368
369 ModestFolderView *
370 modest_mailboxes_window_get_folder_view (ModestMailboxesWindow *self)
371 {
372         ModestMailboxesWindowPrivate *priv = NULL;
373
374         g_return_val_if_fail (MODEST_IS_MAILBOXES_WINDOW(self), FALSE);
375
376         priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE (self);
377         
378         return MODEST_FOLDER_VIEW (priv->folder_view);
379 }
380
381 void
382 modest_mailboxes_window_set_account (ModestMailboxesWindow *self,
383                                      const gchar *account_name)
384 {
385         ModestMailboxesWindowPrivate *priv = NULL;
386         ModestAccountMgr *mgr;
387         ModestAccountSettings *settings = NULL;
388         ModestServerAccountSettings *store_settings = NULL;
389
390         g_return_if_fail (MODEST_IS_MAILBOXES_WINDOW(self));
391
392         priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE (self);
393
394         /* Get account data */
395         mgr = modest_runtime_get_account_mgr ();
396
397         settings = modest_account_mgr_load_account_settings (mgr, account_name);
398         if (!settings)
399                 goto free_refs;
400
401         store_settings = modest_account_settings_get_store_settings (settings);
402         if (!store_settings)
403                 goto free_refs;
404
405         if (priv->current_store_account != NULL)
406                 g_free (priv->current_store_account);
407         priv->current_store_account = g_strdup (modest_server_account_settings_get_account_name (store_settings));
408
409         modest_folder_view_set_account_id_of_visible_server_account
410                 (MODEST_FOLDER_VIEW (priv->folder_view),
411                  priv->current_store_account);
412
413         modest_window_set_active_account (MODEST_WINDOW (self), account_name);
414         update_progress_hint (self);
415
416 free_refs:
417         if (store_settings)
418                 g_object_unref (store_settings);
419         if (settings)
420                 g_object_unref (settings);
421
422 }
423
424 static void
425 on_mailbox_activated (ModestFolderView *mailboxes_view,
426                       TnyFolder *folder,
427                       gpointer userdata)
428 {
429         ModestMailboxesWindowPrivate *priv = NULL;
430         ModestMailboxesWindow *self = (ModestMailboxesWindow *) userdata;
431         GtkWidget *new_window;
432         gboolean registered;
433         const gchar *active_account;
434
435         g_return_if_fail (MODEST_IS_MAILBOXES_WINDOW(self));
436
437         priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE (self);
438
439         if (!folder)
440                 return;
441
442         if (!TNY_IS_FOLDER (folder))
443                 return;
444
445         new_window = GTK_WIDGET (modest_folder_window_new (NULL));
446         registered = modest_window_mgr_register_window (modest_runtime_get_window_mgr (), 
447                                                         MODEST_WINDOW (new_window),
448                                                         MODEST_WINDOW (self));
449
450         if (!registered) {
451                 gtk_widget_destroy (new_window);
452                 new_window = NULL;
453         } else {
454                 const gchar *name;
455                 active_account = modest_window_get_active_account (MODEST_WINDOW (self));
456                 modest_folder_window_set_account (MODEST_FOLDER_WINDOW (new_window), active_account);
457                 name = tny_folder_get_name (folder);
458                 if (name) {
459                         modest_folder_window_set_mailbox (MODEST_FOLDER_WINDOW (new_window), name);
460                 }
461                 gtk_widget_show (new_window);
462         }
463         
464 }
465
466 static gboolean 
467 on_map_event (GtkWidget *widget,
468               GdkEvent *event,
469               gpointer userdata)
470 {
471         ModestMailboxesWindow *self = (ModestMailboxesWindow *) userdata;
472         ModestMailboxesWindowPrivate *priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE (self);
473
474         if (priv->progress_hint) {
475                 hildon_gtk_window_set_progress_indicator (GTK_WINDOW (self), TRUE);
476         }
477
478         return FALSE;
479 }
480
481 static gboolean
482 has_active_operations (ModestMailboxesWindow *self)
483 {
484         GSList *operations = NULL, *node;
485         ModestMailOperationQueue *queue;
486         gboolean has_active = FALSE;
487
488         queue = modest_runtime_get_mail_operation_queue ();
489         operations = modest_mail_operation_queue_get_by_source (queue, G_OBJECT (self));
490
491         for (node = operations; node != NULL; node = g_slist_next (node)) {
492                 if (!modest_mail_operation_is_finished (MODEST_MAIL_OPERATION (node->data))) {
493                         has_active = TRUE;
494                         break;
495                 }
496         }
497
498         if (operations) {
499                 g_slist_foreach (operations, (GFunc) g_object_unref, NULL);
500                 g_slist_free (operations);
501         }
502
503         return has_active;
504 }
505
506 static void
507 update_progress_hint (ModestMailboxesWindow *self)
508 {
509         ModestMailboxesWindowPrivate *priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE (self);
510
511         if (has_active_operations (self)) {
512                 priv->progress_hint = TRUE;
513         } else {
514                 priv->progress_hint = FALSE;
515         }
516
517         if (!priv->progress_hint && priv->current_store_account) {
518                 priv->progress_hint = modest_window_mgr_has_progress_operation_on_account (modest_runtime_get_window_mgr (),
519                                                                                            priv->current_store_account);
520         }
521
522         if (!priv->progress_hint) {
523                 priv->progress_hint = modest_folder_view_get_activity (MODEST_FOLDER_VIEW (priv->folder_view));
524         }
525
526         modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (self));
527
528         if (GTK_WIDGET_VISIBLE (self)) {
529                 hildon_gtk_window_set_progress_indicator (GTK_WINDOW (self), priv->progress_hint ? 1:0);
530         }
531 }
532
533 static void
534 on_progress_list_changed (ModestWindowMgr *mgr,
535                           ModestMailboxesWindow *self)
536 {
537         update_progress_hint (self);
538 }
539
540 static void 
541 on_mail_operation_started (ModestMailOperation *mail_op,
542                            gpointer user_data)
543 {
544         ModestMailboxesWindow *self;
545         ModestMailOperationTypeOperation op_type;
546         GObject *source = NULL;
547
548         self = MODEST_MAILBOXES_WINDOW (user_data);
549         op_type = modest_mail_operation_get_type_operation (mail_op);
550         source = modest_mail_operation_get_source(mail_op);
551         if (G_OBJECT (self) == source) {
552                 update_progress_hint (self);
553         }
554         g_object_unref (source);
555 }
556
557 static void 
558 on_mail_operation_finished (ModestMailOperation *mail_op,
559                             gpointer user_data)
560 {
561         ModestMailboxesWindow *self;
562
563         self = MODEST_MAILBOXES_WINDOW (user_data);
564
565         /* Don't disable the progress hint if there are more pending
566            operations from this window */
567         update_progress_hint (self);
568
569         modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (self));
570 }
571
572 static void
573 on_queue_changed (ModestMailOperationQueue *queue,
574                   ModestMailOperation *mail_op,
575                   ModestMailOperationQueueNotification type,
576                   ModestMailboxesWindow *self)
577 {
578         ModestMailboxesWindowPrivate *priv;
579
580         priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE (self);
581
582         /* If this operations was created by another window, do nothing */
583         if (!modest_mail_operation_is_mine (mail_op, G_OBJECT(self))) 
584                 return;
585
586         if (type == MODEST_MAIL_OPERATION_QUEUE_OPERATION_ADDED) {
587                 priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
588                                                                G_OBJECT (mail_op),
589                                                                "operation-started",
590                                                                G_CALLBACK (on_mail_operation_started),
591                                                                self);
592                 priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
593                                                                G_OBJECT (mail_op),
594                                                                "operation-finished",
595                                                                G_CALLBACK (on_mail_operation_finished),
596                                                                self);
597         } else if (type == MODEST_MAIL_OPERATION_QUEUE_OPERATION_REMOVED) {
598                 priv->sighandlers = modest_signal_mgr_disconnect (priv->sighandlers,
599                                                                   G_OBJECT (mail_op),
600                                                                   "operation-started");
601                 priv->sighandlers = modest_signal_mgr_disconnect (priv->sighandlers,
602                                                                   G_OBJECT (mail_op),
603                                                                   "operation-finished");
604         }
605 }
606
607 static void
608 on_activity_changed (ModestFolderView *view,
609                      gboolean activity,
610                      ModestMailboxesWindow *self)
611 {
612         g_return_if_fail (MODEST_IS_MAILBOXES_WINDOW (self));
613
614         update_progress_hint (self);
615 }
616
617
618 static gboolean
619 on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
620 {
621         ModestMailboxesWindowPrivate *priv;
622         HildonPannableArea *pannable;
623
624         if (event->type == GDK_KEY_RELEASE)
625                 return FALSE;
626
627         priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE(user_data);
628
629         pannable = HILDON_PANNABLE_AREA (gtk_widget_get_parent (priv->folder_view));
630
631         switch (event->keyval) {
632
633         case GDK_Up:
634                 modest_maemo_utils_scroll_pannable(pannable, 0, -1);
635                 break;
636
637         case GDK_Down:
638                 modest_maemo_utils_scroll_pannable(pannable, 0, 1);
639                 break;
640         }
641
642         return FALSE;
643 }