-#ifndef MODEST_TOOLKIT_HILDON2
-static void
-set_active_account_from_tny_account (TnyAccount *account,
- ModestWindow *window)
-{
- const gchar *server_acc_name = tny_account_get_id (account);
-
- /* We need the TnyAccount provided by the
- account store because that is the one that
- knows the name of the Modest account */
- TnyAccount *modest_server_account =
- modest_tny_account_store_get_tny_account_by (modest_runtime_get_account_store (),
- MODEST_TNY_ACCOUNT_STORE_QUERY_ID,
- server_acc_name);
- if (!modest_server_account) {
- g_warning ("%s: could not get tny account\n", __FUNCTION__);
- return;
- }
-
- /* Update active account, but only if it's not a pseudo-account */
- if ((!modest_tny_account_is_virtual_local_folders(modest_server_account)) &&
- (!modest_tny_account_is_memory_card_account(modest_server_account))) {
- const gchar *modest_acc_name =
- modest_tny_account_get_parent_modest_account_name_for_server_account (modest_server_account);
- if (modest_acc_name)
- modest_window_set_active_account (window, modest_acc_name);
- }
-
- g_object_unref (modest_server_account);
-}
-
-static void
-folder_refreshed_cb (ModestMailOperation *mail_op,
- TnyFolder *folder,
- gpointer user_data)
-{
- ModestMainWindow *win = NULL;
- GtkWidget *folder_view, *header_view;
- const GError *error;
-
- g_return_if_fail (TNY_IS_FOLDER (folder));
-
- win = MODEST_MAIN_WINDOW (user_data);
-
- /* Check if the operation failed due to memory low conditions */
- error = modest_mail_operation_get_error (mail_op);
- if (error && error->domain == MODEST_MAIL_OPERATION_ERROR &&
- error->code == MODEST_MAIL_OPERATION_ERROR_LOW_MEMORY) {
- modest_platform_run_information_dialog (GTK_WINDOW (win),
- _KR("memr_ib_operation_disabled"),
- TRUE);
- return;
- }
-
- folder_view =
- modest_main_window_get_child_widget(win, MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
- header_view =
- modest_main_window_get_child_widget(win, MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
-
- if (folder_view) {
- TnyFolderStore *current_folder;
-
- current_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
- if (current_folder) {
- gboolean different = ((TnyFolderStore *) folder != current_folder);
- g_object_unref (current_folder);
- if (different)
- return;
- }
- }
-
- /* Check if folder is empty and set headers view contents style */
- if ((tny_folder_get_all_count (folder) == 0) ||
- modest_header_view_is_empty (MODEST_HEADER_VIEW (header_view)))
- modest_main_window_set_contents_style (win,
- MODEST_MAIN_WINDOW_CONTENTS_STYLE_EMPTY);
-}
-
-void
-modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view,
- TnyFolderStore *folder_store,
- gboolean selected,
- ModestMainWindow *main_window)
-{
- GtkWidget *header_view;
-
- g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
-
- header_view = modest_main_window_get_child_widget(main_window,
- MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
- if (!header_view)
- return;
-
-
- if (TNY_IS_ACCOUNT (folder_store)) {
- if (selected) {
- set_active_account_from_tny_account (TNY_ACCOUNT (folder_store), MODEST_WINDOW (main_window));
-
- /* Show account details */
- modest_main_window_set_contents_style (main_window, MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS);
- }
- } else {
- if (TNY_IS_FOLDER (folder_store) && selected) {
- TnyAccount *account;
-
- /* Update the active account */
- account = modest_tny_folder_get_account (TNY_FOLDER (folder_store));
- if (account) {
- set_active_account_from_tny_account (account, MODEST_WINDOW (main_window));
- g_object_unref (account);
- account = NULL;
- }
-
- /* Set the header style by default, it could
- be changed later by the refresh callback to
- empty */
- modest_main_window_set_contents_style (main_window,
- MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS);
-
- /* Set folder on header view. This function
- will call tny_folder_refresh_async so we
- pass a callback that will be called when
- finished. We use that callback to set the
- empty view if there are no messages */
- modest_header_view_set_folder (MODEST_HEADER_VIEW(header_view),
- TNY_FOLDER (folder_store),
- TRUE,
- MODEST_WINDOW (main_window),
- folder_refreshed_cb,
- main_window);
-
- /* Restore configuration. We need to do this
- *after* the set_folder because the widget
- memory asks the header view about its
- folder */
- modest_widget_memory_restore (modest_runtime_get_conf (),
- G_OBJECT(header_view),
- MODEST_CONF_HEADER_VIEW_KEY);
- } else {
- /* No need to save the header view
- configuration for Maemo because it only
- saves the sorting stuff and that it's
- already being done by the sort
- dialog. Remove it when the GNOME version
- has the same behaviour */
-#ifdef MODEST_TOOLKIT_GTK
- if (modest_main_window_get_contents_style (main_window) ==
- MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS)
- modest_widget_memory_save (modest_runtime_get_conf (),
- G_OBJECT (header_view),
- MODEST_CONF_HEADER_VIEW_KEY);
-#endif
- modest_header_view_clear (MODEST_HEADER_VIEW(header_view));
- }
- }
-
- /* Update dimming state */
- modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (main_window));
- modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (main_window));
-}
-#endif
-