-#ifndef MODEST_TOOLKIT_HILDON2
-/*
- * This function is used to track changes in the selection of the
- * folder view that is inside the "move to" dialog to enable/disable
- * the OK button because we do not want the user to select a disallowed
- * destination for a folder.
- * The user also not desired to be able to use NEW button on items where
- * folder creation is not possibel.
- */
-static void
-on_move_to_dialog_folder_selection_changed (ModestFolderView* self,
- TnyFolderStore *folder_store,
- gboolean selected,
- gpointer user_data)
-{
- GtkWidget *dialog = NULL;
- gboolean ok_sensitive = TRUE, new_sensitive = TRUE;
- gboolean moving_folder = FALSE;
- gboolean is_local_account = TRUE;
- GtkWidget *folder_view = NULL;
- ModestTnyFolderRules rules;
-
- g_return_if_fail (MODEST_IS_FOLDER_VIEW(self));
-
- if (!selected)
- return;
-
- dialog = gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_TYPE_DIALOG);
- if (!dialog)
- return;
-
- /* check if folder_store is an remote account */
- if (TNY_IS_ACCOUNT (folder_store)) {
- TnyAccount *local_account = NULL;
- TnyAccount *mmc_account = NULL;
- ModestTnyAccountStore *account_store = NULL;
-
- account_store = modest_runtime_get_account_store ();
- local_account = modest_tny_account_store_get_local_folders_account (account_store);
- mmc_account = modest_tny_account_store_get_mmc_folders_account (account_store);
-
- if ((gpointer) local_account != (gpointer) folder_store &&
- (gpointer) mmc_account != (gpointer) folder_store) {
- ModestProtocolType proto;
- proto = modest_tny_account_get_protocol_type (TNY_ACCOUNT (folder_store));
- if (proto == MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
- proto = MODEST_PROTOCOLS_STORE_MAILDIR;
- }
- is_local_account = FALSE;
- /* New button should be dimmed on remote
- POP account root */
- new_sensitive = (modest_protocol_registry_protocol_type_has_tag (modest_runtime_get_protocol_registry (),
- proto,
- MODEST_PROTOCOL_REGISTRY_STORE_HAS_FOLDERS));
- }
- g_object_unref (local_account);
-
- /* It could not exist */
- if (mmc_account)
- g_object_unref (mmc_account);
- }
-
- /* Check the target folder rules */
- if (TNY_IS_FOLDER (folder_store)) {
- rules = modest_tny_folder_get_rules (TNY_FOLDER (folder_store));
- if (rules & MODEST_FOLDER_RULES_FOLDER_NON_WRITEABLE) {
- ok_sensitive = FALSE;
- new_sensitive = FALSE;
- goto end;
- }
- }
-
- /* Check if we're moving a folder */
- if (MODEST_IS_MAIN_WINDOW (user_data)) {
- /* Get the widgets */
- folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (user_data),
- MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
- if (gtk_widget_is_focus (folder_view))
- moving_folder = TRUE;
- }
-
- if (moving_folder) {
- TnyFolderStore *moved_folder = NULL, *parent = NULL;
-
- /* Get the folder to move */
- moved_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
-
- /* Check that we're not moving to the same folder */
- if (TNY_IS_FOLDER (moved_folder)) {
- parent = tny_folder_get_folder_store (TNY_FOLDER (moved_folder));
- if (parent == folder_store)
- ok_sensitive = FALSE;
- g_object_unref (parent);
- }
-
- if (ok_sensitive && TNY_IS_ACCOUNT (folder_store)) {
- /* Do not allow to move to an account unless it's the
- local folders account */
- if (!is_local_account)
- ok_sensitive = FALSE;
- }
-
- if (ok_sensitive && (moved_folder == folder_store)) {
- /* Do not allow to move to itself */
- ok_sensitive = FALSE;
- }
- g_object_unref (moved_folder);
- } else {
- TnyFolder *src_folder = NULL;
-
- /* Moving a message */
- if (MODEST_IS_MSG_VIEW_WINDOW (user_data)) {
-
- TnyHeader *header = NULL;
- header = modest_msg_view_window_get_header
- (MODEST_MSG_VIEW_WINDOW (user_data));
- if (!TNY_IS_HEADER(header))
- g_warning ("%s: could not get source header", __FUNCTION__);
- else
- src_folder = tny_header_get_folder (header);
-
- if (header)
- g_object_unref (header);
- } else {
- src_folder =
- TNY_FOLDER (modest_folder_view_get_selected
- (MODEST_FOLDER_VIEW (folder_view)));
- }
-
- if (TNY_IS_FOLDER(src_folder)) {
- /* Do not allow to move the msg to the same folder */
- /* Do not allow to move the msg to an account */
- if ((gpointer) src_folder == (gpointer) folder_store ||
- TNY_IS_ACCOUNT (folder_store))
- ok_sensitive = FALSE;
- g_object_unref (src_folder);
- } else
- g_warning ("%s: could not get source folder", __FUNCTION__);
- }
-
- end:
- /* Set sensitivity of the OK and NEW button */
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, ok_sensitive);
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), MODEST_GTK_RESPONSE_NEW_FOLDER, new_sensitive);
-}
-#endif