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