+#define MOVE_TO_FOLDER_SEPARATOR "/"
+
+static void
+translate_path (gchar **path)
+{
+ gchar **parts;
+ gchar **current;
+ GString *output;
+ gboolean add_separator;
+
+ parts = g_strsplit (*path, MOVE_TO_FOLDER_SEPARATOR, 0);
+ g_free (*path);
+
+ current = parts;
+ output = g_string_new ("");
+ add_separator = FALSE;
+
+ while (*current != NULL) {
+ TnyFolderType folder_type;
+ gchar *downcase;
+
+ if (add_separator) {
+ output = g_string_append (output, MOVE_TO_FOLDER_SEPARATOR);
+ } else {
+ add_separator = TRUE;
+ }
+
+ downcase = g_ascii_strdown (*current, -1);
+ folder_type = modest_local_folder_info_get_type (downcase);
+ if (strcmp (downcase, "inbox") == 0) {
+ output = g_string_append (output, _("mcen_me_folder_inbox"));
+ } else if (folder_type == TNY_FOLDER_TYPE_ARCHIVE ||
+ folder_type == TNY_FOLDER_TYPE_DRAFTS ||
+ folder_type == TNY_FOLDER_TYPE_SENT ||
+ folder_type == TNY_FOLDER_TYPE_OUTBOX) {
+ output = g_string_append (output, modest_local_folder_info_get_type_display_name (folder_type));
+ } else {
+ output = g_string_append (output, *current);
+ }
+ g_free (downcase);
+
+ current++;
+ }
+
+ g_strfreev (parts);
+ *path = g_string_free (output, FALSE);
+}
+
+static void
+move_to_dialog_set_selected_folder_store (GtkWidget *dialog,
+ TnyFolderStore *folder_store)
+{
+ GtkWidget *action_button;
+ GtkWidget *image = NULL;
+ TnyAccount *account;
+ gchar *account_name = NULL, *short_name = NULL;
+
+ action_button = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_ACTION_BUTTON));
+
+ /* Get account name */
+ if (TNY_IS_FOLDER (folder_store))
+ account = tny_folder_get_account (TNY_FOLDER (folder_store));
+ else
+ account = g_object_ref (folder_store);
+
+ if (modest_tny_account_is_virtual_local_folders (account))
+ account_name = modest_conf_get_string (modest_runtime_get_conf(),
+ MODEST_CONF_DEVICE_NAME, NULL);
+
+ if (!account_name)
+ account_name = g_strdup (tny_account_get_name (account));
+
+ g_object_unref (account);
+
+ /* Set title of button: account or folder name */
+ if (TNY_IS_FOLDER (folder_store))
+ short_name = folder_store_get_display_name (folder_store);
+ else
+ short_name = g_strdup (account_name);
+
+ hildon_button_set_title (HILDON_BUTTON (action_button), short_name);
+
+ /* Set value of button, folder full name */
+ if (TNY_IS_CAMEL_FOLDER (folder_store)) {
+ const gchar *camel_full_name;
+ gchar *last_slash, *full_name;
+
+ camel_full_name = tny_camel_folder_get_full_name (TNY_CAMEL_FOLDER (folder_store));
+ last_slash = g_strrstr (camel_full_name, "/");
+ if (last_slash) {
+ gchar *prefix = g_strndup (camel_full_name, last_slash - camel_full_name + 1);
+ full_name = g_strconcat (account_name, MOVE_TO_FOLDER_SEPARATOR, prefix, short_name, NULL);
+ g_free (prefix);
+ } else {
+ full_name = g_strconcat (account_name, MOVE_TO_FOLDER_SEPARATOR,
+ short_name,
+ NULL);
+ }
+ translate_path (&full_name);
+ hildon_button_set_value (HILDON_BUTTON (action_button), full_name);
+ g_free (full_name);
+ }
+ g_free (account_name);
+ g_free (short_name);
+
+ /* Set image for the button */
+ image = get_image_for_folder_store (folder_store, MODEST_ICON_SIZE_BIG);
+ if (image)
+ hildon_button_set_image (HILDON_BUTTON (action_button), image);
+}