static gboolean
check_required_files (void)
{
- FILE *mcc_file = modest_maemo_open_mcc_mapping_file ();
+ FILE *mcc_file = modest_maemo_open_mcc_mapping_file (NULL);
if (!mcc_file) {
g_printerr ("modest: check for mcc file failed\n");
return FALSE;
else
icon_name = MODEST_FOLDER_ICON_ACCOUNT;
} else {
+ TnyFolderType type = modest_tny_folder_guess_folder_type (TNY_FOLDER (store));
if (modest_tny_folder_is_remote_folder (TNY_FOLDER (store))) {
- TnyFolderType type = modest_tny_folder_guess_folder_type (TNY_FOLDER (store));
switch (type) {
case TNY_FOLDER_TYPE_INBOX:
icon_name = MODEST_FOLDER_ICON_INBOX;
default:
icon_name = MODEST_FOLDER_ICON_ACCOUNT;
}
- } else if (modest_tny_folder_is_local_folder (TNY_FOLDER (store)))
- icon_name = MODEST_FOLDER_ICON_NORMAL;
- else if (modest_tny_folder_is_memory_card_folder (TNY_FOLDER (store)))
+ } else if (modest_tny_folder_is_local_folder (TNY_FOLDER (store))) {
+ switch (type) {
+ case TNY_FOLDER_TYPE_OUTBOX:
+ icon_name = MODEST_FOLDER_ICON_OUTBOX;
+ break;
+ case TNY_FOLDER_TYPE_DRAFTS:
+ icon_name = MODEST_FOLDER_ICON_DRAFTS;
+ break;
+ case TNY_FOLDER_TYPE_SENT:
+ icon_name = MODEST_FOLDER_ICON_SENT;
+ break;
+ default:
+ icon_name = MODEST_FOLDER_ICON_NORMAL;
+ }
+ } else if (modest_tny_folder_is_memory_card_folder (TNY_FOLDER (store))) {
icon_name = MODEST_FOLDER_ICON_MMC_FOLDER;
+ }
}
/* Set icon */
}
}
+/* Always returns DUPs so you must free the returned value */
+static gchar *
+get_next_folder_name (const gchar *suggested_name,
+ TnyFolderStore *suggested_folder)
+{
+ const gchar *default_name = _FM("ckdg_va_new_folder_name_stub");
+ unsigned int i;
+ gchar *real_suggested_name;
+
+ if (suggested_name !=NULL) {
+ return g_strdup (suggested_name);
+ }
+
+ for(i = 0; i < 100; ++ i) {
+ gboolean exists = FALSE;
+
+ if (i == 0)
+ real_suggested_name = g_strdup (default_name);
+ else
+ real_suggested_name = g_strdup_printf ("%s(%d)",
+ _FM("ckdg_va_new_folder_name_stub"),
+ i);
+ exists = modest_tny_folder_has_subfolder_with_name (suggested_folder,
+ real_suggested_name,
+ TRUE);
+
+ if (!exists)
+ break;
+
+ g_free (real_suggested_name);
+ }
+
+ /* Didn't find a free number */
+ if (i == 100)
+ real_suggested_name = g_strdup (default_name);
+
+ return real_suggested_name;
+}
+
+typedef struct {
+ ModestFolderView *folder_view;
+ GtkEntry *entry;
+} FolderPickerHelper;
+
static void
folder_picker_clicked (GtkButton *button,
- ModestFolderView *folder_view)
+ FolderPickerHelper *helper)
{
TnyFolderStore *store;
- store = folder_chooser_dialog_run (folder_view);
+ store = folder_chooser_dialog_run (helper->folder_view);
if (store) {
+ const gchar *current_name;
+ gboolean exists;
+
folder_picker_set_store (GTK_BUTTON (button), store);
+
+ /* Update the name of the folder */
+ current_name = gtk_entry_get_text (helper->entry);
+ exists = modest_tny_folder_has_subfolder_with_name (store,
+ current_name,
+ TRUE);
+ if (exists) {
+ gchar *new_name = get_next_folder_name (NULL, store);
+ gtk_entry_set_text (helper->entry, new_name);
+ g_free (new_name);
+ }
}
}
static GtkWidget *
-folder_picker_new (ModestFolderView *folder_view, TnyFolderStore *suggested)
+folder_picker_new (TnyFolderStore *suggested, FolderPickerHelper *helper)
{
GtkWidget *button;
folder_picker_set_store (GTK_BUTTON (button), suggested);
}
- g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (folder_picker_clicked), folder_view);
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (folder_picker_clicked),
+ helper);
return button;
}
ModestFolderView *folder_view;
ModestWindow *folder_window;
ModestHildon2WindowMgr *window_mgr;
+ FolderPickerHelper *helper = NULL;
window_mgr = (ModestHildon2WindowMgr *) modest_runtime_get_window_mgr ();
folder_window = modest_hildon2_window_mgr_get_folder_window (window_mgr);
gtk_misc_set_alignment (GTK_MISC (label_location), 0.0, 0.5);
gtk_size_group_add_widget (sizegroup, label_location);
- account_picker = folder_picker_new (folder_view, suggested_parent);
+ helper = g_slice_new0 (FolderPickerHelper);
+ helper->folder_view = folder_view;
+ helper->entry = (GtkEntry *) entry;
+
+ account_picker = folder_picker_new (suggested_parent, helper);
}
g_object_unref (sizegroup);
gtk_widget_destroy (dialog);
+ if (helper)
+ g_slice_free (FolderPickerHelper, helper);
+
while (gtk_events_pending ())
gtk_main_iteration ();
ModestTnyAccountStore *acc_store;
TnyAccount *account;
- if(suggested_name == NULL)
- {
- const gchar *default_name = _FM("ckdg_va_new_folder_name_stub");
- unsigned int i;
-
- for(i = 0; i < 100; ++ i) {
- gboolean exists = FALSE;
-
- if (i == 0)
- real_suggested_name = g_strdup (default_name);
- else
- real_suggested_name = g_strdup_printf ("%s(%d)",
- _FM("ckdg_va_new_folder_name_stub"),
- i);
- exists = modest_tny_folder_has_subfolder_with_name (suggested_folder,
- real_suggested_name,
- TRUE);
-
- if (!exists)
- break;
-
- g_free (real_suggested_name);
- }
-
- /* Didn't find a free number */
- if (i == 100)
- real_suggested_name = g_strdup (default_name);
- } else {
- real_suggested_name = suggested_name;
- }
+ real_suggested_name = get_next_folder_name ((const gchar *) suggested_name,
+ suggested_folder);
/* In hildon 2.2 we always suggest the archive folder as parent */
acc_store = modest_runtime_get_account_store ();
account = modest_tny_account_store_get_mmc_folders_account (acc_store);
if (account) {
suggested_folder = (TnyFolderStore *)
- modest_tny_account_get_special_folder (account,
+ modest_tny_account_get_special_folder (account,
TNY_FOLDER_TYPE_ARCHIVE);
g_object_unref (account);
account = NULL;
}
- /* If there is not archive folder then fallback to local folders account */
+ /* If there is not archive folder then fallback to local folders account */
if (!suggested_folder)
suggested_folder = (TnyFolderStore *)
modest_tny_account_store_get_local_folders_account (acc_store);
- result = modest_platform_run_folder_common_dialog (parent_window,
+ result = modest_platform_run_folder_common_dialog (parent_window,
suggested_folder,
_HL("ckdg_ti_new_folder"),
_FM("ckdg_fi_new_folder_name"),
folder_name,
parent_folder);
- if (suggested_name == NULL)
- g_free(real_suggested_name);
+ g_free(real_suggested_name);
return result;
}
/* Play sound if the user wants. Show the LED
pattern. Show and play just one */
if (G_UNLIKELY (first_notification)) {
+ TnyAccount *account;
first_notification = FALSE;
"dialog-type", 4);
notify_notification_set_hint_string(NOTIFY_NOTIFICATION (notification),
"led-pattern",
- MODEST_NEW_MAIL_LIGHTING_PATTERN);
+ MODEST_NEW_MAIL_LIGHTING_PATTERN);
+
+ /* Set the account of the headers */
+ account = tny_folder_get_account (folder);
+ if (account) {
+ notify_notification_set_hint_string(NOTIFY_NOTIFICATION (notification),
+ "email-account",
+ tny_account_get_id (account));
+ g_object_unref (account);
+ }
}
/* Notify. We need to do this in an idle because this function
back_button = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_BACK_BUTTON));
folder_view = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_FOLDER_VIEW));
pannable = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_PANNABLE));
-
+
gtk_widget_set_sensitive (back_button, FALSE);
gtk_label_set_text (GTK_LABEL (selection_label), "");
modest_folder_view_show_non_move_folders (MODEST_FOLDER_VIEW (folder_view), TRUE);
modest_folder_view_set_style (MODEST_FOLDER_VIEW (folder_view), MODEST_FOLDER_VIEW_STYLE_SHOW_ALL);
modest_folder_view_set_filter (MODEST_FOLDER_VIEW (folder_view), MODEST_FOLDER_VIEW_FILTER_HIDE_FOLDERS);
- modest_folder_view_unset_filter (MODEST_FOLDER_VIEW (folder_view), MODEST_FOLDER_VIEW_FILTER_HIDE_LOCAL_FOLDERS);
hildon_pannable_area_jump_to (HILDON_PANNABLE_AREA (pannable), 0, 0);
g_object_set_data (G_OBJECT (dialog), MOVE_TO_DIALOG_SHOWING_FOLDERS, GINT_TO_POINTER (FALSE));
back_button = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_BACK_BUTTON));
folder_view = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_FOLDER_VIEW));
pannable = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_PANNABLE));
-
+
gtk_widget_set_sensitive (back_button, TRUE);
account = TNY_ACCOUNT (folder_store);
} else {
selection_label_text = g_strconcat (tny_account_get_name (account), "/", NULL);
}
+ modest_folder_view_set_filter (MODEST_FOLDER_VIEW (folder_view),
+ MODEST_FOLDER_VIEW_FILTER_HIDE_MCC_FOLDERS);
} else if (modest_tny_account_is_memory_card_account (account)) {
account_id = tny_account_get_id (account);
selection_label_text = g_strconcat (tny_account_get_name (account), "/", NULL);
+ modest_folder_view_set_filter (MODEST_FOLDER_VIEW (folder_view),
+ MODEST_FOLDER_VIEW_FILTER_HIDE_LOCAL_FOLDERS);
} else {
account_id = tny_account_get_id (account);
selection_label_text = g_strconcat (tny_account_get_name (account), "/", NULL);
- modest_folder_view_set_filter (MODEST_FOLDER_VIEW (folder_view),
+ modest_folder_view_set_filter (MODEST_FOLDER_VIEW (folder_view),
MODEST_FOLDER_VIEW_FILTER_HIDE_LOCAL_FOLDERS);
+ modest_folder_view_set_filter (MODEST_FOLDER_VIEW (folder_view),
+ MODEST_FOLDER_VIEW_FILTER_HIDE_MCC_FOLDERS);
}
gtk_label_set_text (GTK_LABEL (selection_label), selection_label_text);
g_free (selection_label_text);
gpointer userdata)
{
GtkWidget *dialog = (GtkWidget *) userdata;
+ ModestFolderView *folder_view;
+
+ /* Revert the effect of show_folders filters */
+ folder_view = MODEST_FOLDER_VIEW (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_FOLDER_VIEW));
+ modest_folder_view_set_account_id_of_visible_server_account (folder_view, NULL);
+ modest_folder_view_show_non_move_folders (MODEST_FOLDER_VIEW (folder_view), TRUE);
+ modest_folder_view_unset_filter (folder_view, MODEST_FOLDER_VIEW_FILTER_HIDE_LOCAL_FOLDERS);
+ modest_folder_view_unset_filter (folder_view, MODEST_FOLDER_VIEW_FILTER_HIDE_MCC_FOLDERS);
+ /* Back to show accounts */
move_to_dialog_show_accounts (dialog);
}