+static ModestWindow *
+modest_hildon2_window_mgr_show_initial_window (ModestWindowMgr *self)
+{
+ ModestWindow *initial_window = NULL;
+ ModestTnyAccountStore *acc_store;
+
+ /* Always create accounts window. We'll decide later if we
+ want to show it or not, depending the number of accounts */
+ initial_window = MODEST_WINDOW (modest_accounts_window_new ());
+ modest_window_mgr_register_window (self, initial_window, NULL);
+
+ /* If there are less than 2 remote accounts then directly show
+ the folder window and do not show the accounts window */
+ acc_store = modest_runtime_get_account_store ();
+ if (modest_tny_account_store_get_num_remote_accounts (acc_store) < 2) {
+ ModestAccountMgr *mgr;
+
+ /* Show first the accounts window to add it to the
+ stack. This has to be changed when the new
+ stackable API is available. There will be a method
+ to show all the windows that will only show the
+ last one to the user. The current code shows both
+ windows, one after the other */
+ gtk_widget_show (GTK_WIDGET (initial_window));
+
+ initial_window = MODEST_WINDOW (modest_folder_window_new (NULL));
+ mgr = modest_runtime_get_account_mgr ();
+ modest_folder_window_set_account (MODEST_FOLDER_WINDOW (initial_window),
+ modest_account_mgr_get_default_account (mgr));
+ modest_window_mgr_register_window (self, initial_window, NULL);
+ }
+
+ return initial_window;
+}
+
+
+static ModestWindow *
+modest_hildon2_window_mgr_get_current_top (ModestWindowMgr *self)
+{
+ ModestHildon2WindowMgrPrivate *priv;
+
+ priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
+ return priv->current_top;
+}
+
+static gint
+find_folder_window (gconstpointer a,
+ gconstpointer b)
+{
+ return (MODEST_IS_FOLDER_WINDOW (a)) ? 0 : 1;
+}
+
+ModestWindow *
+modest_hildon2_window_mgr_get_folder_window (ModestHildon2WindowMgr *self)
+{
+ ModestHildon2WindowMgrPrivate *priv;
+ GList *window;
+
+ g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), NULL);
+
+ priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
+
+ window = g_list_find_custom (priv->window_list,
+ NULL,
+ find_folder_window);
+
+ return (window != NULL) ? MODEST_WINDOW (window->data) : NULL;
+}
+
+static gboolean
+modest_hildon2_window_mgr_screen_is_on (ModestWindowMgr *self)
+{
+ ModestHildon2WindowMgrPrivate *priv = NULL;
+
+ g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), FALSE);
+
+ priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
+
+ return (priv->display_state == OSSO_DISPLAY_ON) ? TRUE : FALSE;
+}
+
+static void
+osso_display_event_cb (osso_display_state_t state,
+ gpointer data)
+{
+ ModestHildon2WindowMgrPrivate *priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (data);
+
+ priv->display_state = state;
+
+ /* Stop blinking if the screen becomes on */
+ if (priv->display_state == OSSO_DISPLAY_ON)
+ modest_platform_remove_new_mail_notifications (TRUE);
+}
+