1 /* Copyright (c) 2008, Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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.
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.
30 #include <modest-accounts-window.h>
31 #include <modest-scrollable.h>
32 #include <modest-ui-actions.h>
33 #include <modest-window-mgr.h>
34 #include <modest-signal-mgr.h>
35 #include <modest-runtime.h>
36 #include <modest-platform.h>
37 #include <modest-icon-names.h>
38 #include <modest-defs.h>
39 #include <modest-folder-window.h>
40 #include <modest-ui-dimming-rules.h>
41 #include <modest-ui-dimming-manager.h>
42 #include <modest-window-priv.h>
43 #include <modest-ui-constants.h>
44 #include <modest-account-mgr-helpers.h>
45 #include <modest-mailboxes-window.h>
46 #ifdef MODEST_TOOLKIT_HILDON2
47 #include <hildon/hildon.h>
49 #ifdef MODEST_PLATFORM_MAEMO
50 #include <modest-maemo-utils.h>
52 #include <gdk/gdkkeysyms.h>
55 /* 'private'/'protected' functions */
56 static void modest_accounts_window_class_init (ModestAccountsWindowClass *klass);
57 static void modest_accounts_window_instance_init (ModestAccountsWindow *obj);
58 static void modest_accounts_window_finalize (GObject *obj);
60 static void connect_signals (ModestAccountsWindow *self);
61 static void modest_accounts_window_disconnect_signals (ModestWindow *self);
63 static void on_account_activated (GtkTreeView *treeview,
65 GtkTreeViewColumn *column,
66 ModestAccountsWindow *accounts_window);
67 static void on_progress_list_changed (ModestWindowMgr *mgr,
68 ModestAccountsWindow *self);
69 static void setup_menu (ModestAccountsWindow *self);
70 static gboolean _modest_accounts_window_map_event (GtkWidget *widget,
73 static void update_progress_hint (ModestAccountsWindow *self);
74 static void on_queue_changed (ModestMailOperationQueue *queue,
75 ModestMailOperation *mail_op,
76 ModestMailOperationQueueNotification type,
77 ModestAccountsWindow *self);
78 static void on_row_inserted (GtkTreeModel *tree_model,
82 static void on_row_deleted (GtkTreeModel *tree_model,
85 static void row_count_changed (ModestAccountsWindow *self);
86 static gboolean on_key_press(GtkWidget *widget,
89 static gboolean on_delete_event (GtkWidget *widget,
93 typedef struct _ModestAccountsWindowPrivate ModestAccountsWindowPrivate;
94 struct _ModestAccountsWindowPrivate {
97 GtkWidget *scrollable;
98 GtkWidget *account_view;
99 GtkWidget *no_accounts_container;
100 GtkWidget *new_message_button;
105 gboolean progress_hint;
106 guint queue_change_handler;
108 #define MODEST_ACCOUNTS_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
109 MODEST_TYPE_ACCOUNTS_WINDOW, \
110 ModestAccountsWindowPrivate))
113 static GtkWindowClass *parent_class = NULL;
114 static GtkWidget *pre_created_accounts_window = NULL;
116 /************************************************************************/
119 modest_accounts_window_get_type (void)
121 static GType my_type = 0;
123 static const GTypeInfo my_info = {
124 sizeof(ModestAccountsWindowClass),
125 NULL, /* base init */
126 NULL, /* base finalize */
127 (GClassInitFunc) modest_accounts_window_class_init,
128 NULL, /* class finalize */
129 NULL, /* class data */
130 sizeof(ModestAccountsWindow),
132 (GInstanceInitFunc) modest_accounts_window_instance_init,
135 my_type = g_type_register_static (
136 #ifdef MODEST_TOOLKIT_HILDON2
137 MODEST_TYPE_HILDON2_WINDOW,
139 MODEST_TYPE_SHELL_WINDOW,
141 "ModestAccountsWindow",
148 modest_accounts_window_class_init (ModestAccountsWindowClass *klass)
150 GObjectClass *gobject_class;
151 gobject_class = (GObjectClass*) klass;
152 ModestWindowClass *modest_window_class = (ModestWindowClass *) klass;
154 parent_class = g_type_class_peek_parent (klass);
155 gobject_class->finalize = modest_accounts_window_finalize;
157 g_type_class_add_private (gobject_class, sizeof(ModestAccountsWindowPrivate));
159 modest_window_class->disconnect_signals_func = modest_accounts_window_disconnect_signals;
163 modest_accounts_window_instance_init (ModestAccountsWindow *obj)
165 ModestAccountsWindowPrivate *priv;
167 priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE(obj);
169 priv->sighandlers = NULL;
171 priv->account_view = NULL;
172 priv->progress_hint = FALSE;
177 modest_accounts_window_finalize (GObject *obj)
179 ModestAccountsWindowPrivate *priv;
181 priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE(obj);
183 /* Sanity check: shouldn't be needed, the window mgr should
184 call this function before */
185 modest_accounts_window_disconnect_signals (MODEST_WINDOW (obj));
187 G_OBJECT_CLASS(parent_class)->finalize (obj);
191 modest_accounts_window_disconnect_signals (ModestWindow *self)
193 ModestAccountsWindowPrivate *priv;
194 priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE(self);
196 if (g_signal_handler_is_connected (G_OBJECT (modest_runtime_get_mail_operation_queue ()),
197 priv->queue_change_handler))
198 g_signal_handler_disconnect (G_OBJECT (modest_runtime_get_mail_operation_queue ()),
199 priv->queue_change_handler);
201 modest_signal_mgr_disconnect_all_and_destroy (priv->sighandlers);
202 priv->sighandlers = NULL;
206 connect_signals (ModestAccountsWindow *self)
208 ModestAccountsWindowPrivate *priv;
211 priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE(self);
215 modest_signal_mgr_connect (priv->sighandlers,
216 G_OBJECT (priv->account_view), "row-activated",
217 G_CALLBACK (on_account_activated), self);
220 modest_signal_mgr_connect (priv->sighandlers,
221 G_OBJECT (modest_runtime_get_window_mgr ()),
222 "progress-list-changed",
223 G_CALLBACK (on_progress_list_changed), self);
225 model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->account_view));
228 modest_signal_mgr_connect (priv->sighandlers,
231 G_CALLBACK (on_row_inserted), self);
234 modest_signal_mgr_connect (priv->sighandlers,
237 G_CALLBACK (on_row_deleted), self);
239 #ifdef MODEST_TOOLKIT_HILDON2
241 modest_signal_mgr_connect (priv->sighandlers,
242 G_OBJECT (priv->new_message_button),
244 G_CALLBACK (modest_ui_actions_on_new_msg), self);
247 /* we don't register this in sighandlers, as it should be run
248 * after disconnecting all signals, in destroy stage */
251 g_signal_connect(G_OBJECT(self), "key-press-event",
252 G_CALLBACK(on_key_press), self);
255 static ModestWindow *
256 modest_accounts_window_new_real (void)
258 ModestAccountsWindow *self = NULL;
259 ModestAccountsWindowPrivate *priv = NULL;
260 GdkPixbuf *window_icon;
261 GtkWidget *no_accounts_label;
262 GtkWidget *box_alignment;
264 self = MODEST_ACCOUNTS_WINDOW(g_object_new(MODEST_TYPE_ACCOUNTS_WINDOW, NULL));
265 priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE(self);
267 box_alignment = gtk_alignment_new (0, 0, 1.0, 1.0);
268 gtk_alignment_set_padding (GTK_ALIGNMENT (box_alignment),
269 MODEST_MARGIN_HALF, 0,
270 MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE);
271 priv->box = gtk_vbox_new (FALSE, 0);
273 no_accounts_label = gtk_label_new (_("mcen_ia_noaccounts"));
275 gtk_misc_set_alignment (GTK_MISC (no_accounts_label), 0.5, 0.5);
276 #ifdef MODEST_TOOLKIT_HILDON2
277 hildon_helper_set_logical_font (no_accounts_label, "LargeSystemFont");
280 #ifdef MODEST_TOOLKIT_HILDON2
281 GdkPixbuf *new_message_pixbuf;
282 GtkWidget *empty_view_new_message_button;
284 new_message_pixbuf = modest_platform_get_icon ("general_add", MODEST_ICON_SIZE_BIG);
286 empty_view_new_message_button = hildon_button_new (MODEST_EDITABLE_SIZE, HILDON_BUTTON_ARRANGEMENT_HORIZONTAL);
287 hildon_button_set_title (HILDON_BUTTON (empty_view_new_message_button), _("mcen_ti_new_message"));
288 hildon_button_set_image (HILDON_BUTTON (empty_view_new_message_button), gtk_image_new_from_pixbuf (new_message_pixbuf));
291 priv->no_accounts_container = gtk_vbox_new (FALSE, 0);
292 #ifdef MODEST_TOOLKIT_HILDON2
293 gtk_box_pack_start (GTK_BOX (priv->no_accounts_container), empty_view_new_message_button, FALSE, FALSE, 0);
294 gtk_widget_show_all (empty_view_new_message_button);
295 g_signal_connect (G_OBJECT (empty_view_new_message_button),
297 G_CALLBACK (modest_ui_actions_on_new_msg), self);
299 gtk_box_pack_end (GTK_BOX (priv->no_accounts_container), no_accounts_label, TRUE, TRUE, 0);
300 gtk_widget_show (no_accounts_label);
301 gtk_box_pack_start (GTK_BOX (priv->box), priv->no_accounts_container, TRUE, TRUE, 0);
304 priv->scrollable = modest_toolkit_factory_create_scrollable (modest_runtime_get_toolkit_factory ());
306 priv->queue_change_handler =
307 g_signal_connect (G_OBJECT (modest_runtime_get_mail_operation_queue ()),
309 G_CALLBACK (on_queue_changed),
312 #ifdef MODEST_TOOLKIT_HILDON2
313 priv->new_message_button = hildon_button_new (MODEST_EDITABLE_SIZE,
314 HILDON_BUTTON_ARRANGEMENT_HORIZONTAL);
316 hildon_button_set_title (HILDON_BUTTON (priv->new_message_button), _("mcen_ti_new_message"));
317 hildon_button_set_image (HILDON_BUTTON (priv->new_message_button), gtk_image_new_from_pixbuf (new_message_pixbuf));
319 gtk_widget_show_all (priv->new_message_button);
321 g_object_unref (new_message_pixbuf);
325 gtk_box_pack_start (GTK_BOX (priv->box), priv->scrollable, TRUE, TRUE, 0);
326 gtk_container_add (GTK_CONTAINER (box_alignment), priv->box);
327 gtk_container_add (GTK_CONTAINER (self), box_alignment);
329 gtk_widget_show (priv->scrollable);
330 gtk_widget_show (priv->box);
331 gtk_widget_show (box_alignment);
333 /* Get device name */
334 #ifdef MODEST_PLATFORM_MAEMO
335 modest_maemo_utils_get_device_name ();
338 /* Set window icon */
339 window_icon = modest_platform_get_icon (MODEST_APP_ICON, MODEST_ICON_SIZE_BIG);
341 gtk_window_set_icon (GTK_WINDOW (self), window_icon);
342 g_object_unref (window_icon);
345 #ifdef MODEST_TOOLKIT_HILDON2
347 GdkModifierType accel_mods;
348 GtkAccelGroup *accel_group;
349 accel_group = gtk_accel_group_new ();
350 gtk_accelerator_parse ("<Control>n", &accel_key, &accel_mods);
351 gtk_widget_add_accelerator (priv->new_message_button, "clicked", accel_group,
352 accel_key, accel_mods, 0);
353 gtk_window_add_accel_group (GTK_WINDOW (self), accel_group);
356 return MODEST_WINDOW(self);
360 modest_accounts_window_new (void)
363 ModestAccountsWindowPrivate *priv = NULL;
364 #ifdef MODEST_TOOLKIT_HILDON2
368 if (pre_created_accounts_window) {
369 self = MODEST_WINDOW (pre_created_accounts_window);
370 pre_created_accounts_window = NULL;
372 self = modest_accounts_window_new_real ();
374 priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE(self);
375 priv->account_view = GTK_WIDGET (modest_account_view_new (modest_runtime_get_account_mgr ()));
377 #ifdef MODEST_TOOLKIT_HILDON2
378 GtkWidget *action_area_box;
380 action_area_box = hildon_tree_view_get_action_area_box (GTK_TREE_VIEW (priv->account_view));
381 gtk_box_pack_start (GTK_BOX (action_area_box), priv->new_message_button, TRUE, TRUE, 0);
382 hildon_tree_view_set_action_area_visible (GTK_TREE_VIEW (priv->account_view), TRUE);
384 gtk_container_add (GTK_CONTAINER (priv->scrollable), priv->account_view);
386 connect_signals (MODEST_ACCOUNTS_WINDOW (self));
388 #ifdef MODEST_TOOLKIT_HILDON2
389 app = hildon_program_get_instance ();
390 hildon_program_add_window (app, HILDON_WINDOW (self));
393 /* Dont't restore settings here,
394 * because it requires a gtk_widget_show(),
395 * and we don't want to do that until later,
396 * so that the UI is not visible for non-menu D-Bus activation.
399 g_signal_connect (G_OBJECT (self), "map-event",
400 G_CALLBACK (_modest_accounts_window_map_event),
402 g_signal_connect (G_OBJECT (self), "delete-event",
403 G_CALLBACK (on_delete_event), self);
404 update_progress_hint (MODEST_ACCOUNTS_WINDOW (self));
406 row_count_changed (MODEST_ACCOUNTS_WINDOW (self));
408 modest_window_set_title (MODEST_WINDOW (self), _("mcen_ap_name"));
415 modest_accounts_window_get_account_view (ModestAccountsWindow *self)
417 ModestAccountsWindowPrivate *priv = NULL;
419 g_return_val_if_fail (MODEST_IS_ACCOUNTS_WINDOW(self), FALSE);
421 priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE (self);
423 return MODEST_ACCOUNT_VIEW (priv->account_view);
427 setup_menu (ModestAccountsWindow *self)
429 g_return_if_fail (MODEST_IS_ACCOUNTS_WINDOW(self));
431 /* Settings menu buttons */
432 modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_new_account"), NULL,
433 MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_new_account),
435 modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_inbox_sendandreceive"), NULL,
436 MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_send_receive),
437 MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_send_receive_all));
438 modest_window_add_to_menu (MODEST_WINDOW (self),
439 dngettext(GETTEXT_PACKAGE,
440 "mcen_me_edit_account",
441 "mcen_me_edit_accounts",
444 MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_accounts),
445 MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_edit_accounts));
446 modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_inbox_globalsmtpservers"), NULL,
447 MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_smtp_servers),
448 MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_tools_smtp_servers));
449 modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_outbox_cancelsend"), NULL,
450 MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_cancel_send),
451 MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_cancel_sending_all));
452 modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_inbox_options"), NULL,
453 MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_settings),
459 on_account_activated (GtkTreeView *account_view,
461 GtkTreeViewColumn *column,
462 ModestAccountsWindow *self)
464 ModestAccountsWindowPrivate *priv;
466 GtkWidget *new_window;
468 ModestProtocolType store_protocol;
469 gboolean mailboxes_protocol;
471 priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE (self);
473 account_name = modest_account_view_get_path_account (MODEST_ACCOUNT_VIEW (priv->account_view), path);
477 /* If it's a multimailbox container, we have to show the mailboxes window */
478 store_protocol = modest_account_mgr_get_store_protocol (modest_runtime_get_account_mgr (),
481 modest_protocol_registry_protocol_type_has_tag (modest_runtime_get_protocol_registry (),
483 MODEST_PROTOCOL_REGISTRY_MULTI_MAILBOX_PROVIDER_PROTOCOLS);
484 if (mailboxes_protocol) {
485 new_window = GTK_WIDGET (modest_mailboxes_window_new (account_name));
488 new_window = GTK_WIDGET (modest_folder_window_new (NULL));
491 registered = modest_window_mgr_register_window (modest_runtime_get_window_mgr (),
492 MODEST_WINDOW (new_window),
493 MODEST_WINDOW (self));
496 gtk_widget_destroy (new_window);
499 if (!mailboxes_protocol) {
500 modest_folder_window_set_account (MODEST_FOLDER_WINDOW (new_window), account_name);
502 gtk_widget_show (new_window);
504 g_free (account_name);
508 _modest_accounts_window_map_event (GtkWidget *widget,
512 ModestAccountsWindow *self = (ModestAccountsWindow *) userdata;
513 ModestAccountsWindowPrivate *priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE (self);
515 if (priv->progress_hint) {
516 modest_window_show_progress (MODEST_WINDOW (self), TRUE);
523 has_active_operations (ModestAccountsWindow *self)
525 GSList *operations = NULL, *node;
526 ModestMailOperationQueue *queue;
527 gboolean has_active = FALSE;
529 queue = modest_runtime_get_mail_operation_queue ();
530 operations = modest_mail_operation_queue_get_by_source (queue, G_OBJECT (self));
532 for (node = operations; node != NULL; node = g_slist_next (node)) {
533 if (!modest_mail_operation_is_finished (MODEST_MAIL_OPERATION (node->data))) {
540 g_slist_foreach (operations, (GFunc) g_object_unref, NULL);
541 g_slist_free (operations);
548 update_progress_hint (ModestAccountsWindow *self)
550 ModestAccountsWindowPrivate *priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE (self);
552 if (has_active_operations (self)) {
553 priv->progress_hint = TRUE;
555 priv->progress_hint = FALSE;
558 if (!priv->progress_hint) {
559 priv->progress_hint = modest_window_mgr_has_progress_operation (modest_runtime_get_window_mgr ());
562 if (GTK_WIDGET_VISIBLE (self)) {
563 modest_window_show_progress (MODEST_WINDOW (self), priv->progress_hint?1:0);
568 on_progress_list_changed (ModestWindowMgr *mgr,
569 ModestAccountsWindow *self)
571 update_progress_hint (self);
575 on_row_inserted (GtkTreeModel *tree_model,
580 ModestAccountsWindow *self;
582 self = (ModestAccountsWindow *) user_data;
584 row_count_changed (self);
588 on_row_deleted (GtkTreeModel *tree_model,
592 ModestAccountsWindow *self;
594 self = (ModestAccountsWindow *) user_data;
596 row_count_changed (self);
600 row_count_changed (ModestAccountsWindow *self)
602 ModestAccountsWindowPrivate *priv;
606 priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE (self);
607 model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->account_view));
609 count = gtk_tree_model_iter_n_children (model, NULL);
612 gtk_widget_hide (priv->account_view);
613 gtk_widget_show (priv->no_accounts_container);
614 g_debug ("%s: hiding accounts view", __FUNCTION__);
616 gtk_widget_hide (priv->no_accounts_container);
617 gtk_widget_show (priv->account_view);
618 g_debug ("%s: showing accounts view", __FUNCTION__);
620 gtk_container_child_set (GTK_CONTAINER(priv->box), priv->scrollable,
627 on_mail_operation_started (ModestMailOperation *mail_op,
630 ModestAccountsWindow *self;
631 ModestMailOperationTypeOperation op_type;
632 GObject *source = NULL;
634 self = MODEST_ACCOUNTS_WINDOW (user_data);
635 op_type = modest_mail_operation_get_type_operation (mail_op);
636 source = modest_mail_operation_get_source(mail_op);
637 if (G_OBJECT (self) == source) {
638 update_progress_hint (self);
640 g_object_unref (source);
644 on_mail_operation_finished (ModestMailOperation *mail_op,
647 ModestAccountsWindow *self;
649 self = MODEST_ACCOUNTS_WINDOW (user_data);
651 /* Don't disable the progress hint if there are more pending
652 operations from this window */
653 update_progress_hint (self);
655 modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (self));
659 on_queue_changed (ModestMailOperationQueue *queue,
660 ModestMailOperation *mail_op,
661 ModestMailOperationQueueNotification type,
662 ModestAccountsWindow *self)
664 ModestAccountsWindowPrivate *priv;
666 priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE (self);
668 /* If this operations was created by another window, do nothing */
669 if (!modest_mail_operation_is_mine (mail_op, G_OBJECT(self)))
672 if (type == MODEST_MAIL_OPERATION_QUEUE_OPERATION_ADDED) {
673 priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
676 G_CALLBACK (on_mail_operation_started),
678 priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
680 "operation-finished",
681 G_CALLBACK (on_mail_operation_finished),
683 } else if (type == MODEST_MAIL_OPERATION_QUEUE_OPERATION_REMOVED) {
684 priv->sighandlers = modest_signal_mgr_disconnect (priv->sighandlers,
686 "operation-started");
687 priv->sighandlers = modest_signal_mgr_disconnect (priv->sighandlers,
689 "operation-finished");
694 modest_accounts_window_pre_create (void)
696 static gboolean pre_created = FALSE;
699 pre_created_accounts_window = GTK_WIDGET (modest_accounts_window_new_real ());
705 on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
707 ModestAccountsWindowPrivate *priv;
708 ModestScrollable *scrollable;
710 if (event->type == GDK_KEY_RELEASE)
713 priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE(user_data);
715 scrollable = MODEST_SCROLLABLE (priv->scrollable);
717 switch (event->keyval) {
720 modest_scrollable_scroll (scrollable, 0, -1);
724 modest_scrollable_scroll (scrollable, 0, 1);
732 on_delete_event (GtkWidget *widget,
736 ModestAccountsWindowPrivate *priv;
738 priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE (widget);
740 #ifdef MODEST_TOOLKIT_HILDON2
741 modest_account_view_set_show_last_update (MODEST_ACCOUNT_VIEW (priv->account_view), FALSE);
743 gtk_widget_queue_resize (widget);
745 gdk_window_process_updates (priv->account_view->window, TRUE);
747 /* Take screenshot. We have to wait a bit to ensure that
748 screenshot is properly taken */
749 hildon_gtk_window_take_screenshot (GTK_WINDOW (widget), TRUE);
750 g_usleep (G_USEC_PER_SEC);
752 modest_account_view_set_show_last_update (MODEST_ACCOUNT_VIEW (priv->account_view), TRUE);