TnyFolderStore *parent_folder,
const gchar *suggested_name);
+static GtkWidget* get_folder_view_from_move_to_dialog (GtkWidget *move_to_dialog);
+
+
/*
* This function checks whether a TnyFolderStore is a pop account
*/
ModestAccountMgr *mgr = modest_runtime_get_account_mgr();
ModestTnyAccountStore *store = modest_runtime_get_account_store();
- if (win) account_name = g_strdup (modest_window_get_active_account (win));
- if (!account_name) account_name = modest_account_mgr_get_default_account(mgr);
+ account_name = modest_account_mgr_get_default_account(mgr);
if (!account_name) {
g_printerr ("modest: no account found\n");
goto cleanup;
attachments = g_slist_next(attachments);
}
modest_window_mgr_register_window (modest_runtime_get_window_mgr(), msg_win);
-
- if (win) {
- gtk_window_set_transient_for (GTK_WINDOW (msg_win),
- GTK_WINDOW (win));
- }
gtk_widget_show_all (GTK_WIDGET (msg_win));
cleanup:
status = tny_account_get_connection_status (account);
if (err || canceled) {
- /* TODO: Show an error ? */
goto clean;
}
gpointer user_data)
{
GObject *source;
+ gboolean show_visual_notifications;
source = modest_mail_operation_get_source (self);
-
- /* Notify new messages have been downloaded. Do not notify if
- the send&receive was invoked by the user, i.e, if the mail
- operation has a source (the main window) */
- if ((new_headers != NULL) && (tny_list_get_length (new_headers) > 0) && !source)
- modest_platform_on_new_headers_received (new_headers);
-
+ show_visual_notifications = (source) ? FALSE : TRUE;
if (source)
g_object_unref (source);
+
+ /* Notify new messages have been downloaded. If the
+ send&receive was invoked by the user then do not show any
+ visual notification, only play a sound and activate the LED
+ (for the Maemo version) */
+ if ((new_headers != NULL) && (tny_list_get_length (new_headers) > 0))
+ modest_platform_on_new_headers_received (new_headers,
+ show_visual_notifications);
+
}
gboolean
info = (SendReceiveInfo *) user_data;
if (err || canceled) {
-
goto clean;
}
edit_window = MODEST_MSG_EDIT_WINDOW (user_data);
- /* If there was any error do nothing */
- if (modest_mail_operation_get_error (mail_op) != NULL)
+ /* It might not be a good idea to do nothing if there was an error,
+ * so let's at least show a generic error banner. */
+ /* TODO error while saving attachment, show "Saving draft failed" banner */
+ if (modest_mail_operation_get_error (mail_op) != NULL) {
+ g_warning ("%s failed: %s\n", __FUNCTION__, (modest_mail_operation_get_error (mail_op))->message);
+ modest_platform_information_banner (NULL, NULL, _("mail_ib_file_operation_failed"));
return;
+ }
modest_msg_edit_window_set_draft (edit_window, saved_draft);
}
gpointer user_data)
{
gchar *suggested_name = (gchar *) user_data;
- GtkWindow *main_window = (GtkWindow *) modest_mail_operation_get_source (mail_op);
-
+ GtkWindow *source_win = (GtkWindow *) modest_mail_operation_get_source (mail_op);
+
if (modest_mail_operation_get_error (mail_op)) {
/* Show an error */
- modest_platform_information_banner (GTK_WIDGET (main_window), NULL,
+ modest_platform_information_banner (GTK_WIDGET (source_win), NULL,
_("mail_in_ui_folder_create_error"));
/* Try again */
- do_create_folder (main_window, parent_folder, (const gchar *) suggested_name);
+ do_create_folder (source_win, parent_folder, (const gchar *) suggested_name);
} else {
+ /* the 'source_win' is either the ModestMainWindow, or the 'Move to folder'-dialog
+ * FIXME: any other? */
GtkWidget *folder_view;
- folder_view =
- modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (main_window),
- MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
-
+ if (MODEST_IS_MAIN_WINDOW(source_win))
+ folder_view =
+ modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (source_win),
+ MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
+ else
+ folder_view =
+ get_folder_view_from_move_to_dialog (GTK_WIDGET(source_win));
+
/* Select the newly created folder */
modest_folder_view_select_folder (MODEST_FOLDER_VIEW (folder_view),
new_folder, FALSE);
}
/* Free. Note that the first time it'll be NULL so noop */
g_free (suggested_name);
- g_object_unref (main_window);
+ g_object_unref (source_win);
}
static void
}
}
+static void
+create_folder_performer (gboolean canceled,
+ GError *err,
+ GtkWindow *parent_window,
+ TnyAccount *account,
+ gpointer user_data)
+{
+ TnyFolderStore *parent_folder = TNY_FOLDER_STORE (user_data);
+
+ if (canceled || err) {
+ goto frees;
+ }
+
+ /* Run the new folder dialog */
+ do_create_folder (GTK_WINDOW (parent_window), parent_folder, NULL);
+
+ frees:
+ g_object_unref (parent_folder);
+}
static void
modest_ui_actions_create_folder(GtkWidget *parent_window,
parent_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view));
if (parent_folder) {
-
- /* Run the new folder dialog */
- do_create_folder (GTK_WINDOW (parent_window), parent_folder, NULL);
-
- g_object_unref (parent_folder);
+ /* The parent folder will be freed in the callback */
+ modest_platform_connect_if_remote_and_perform (GTK_WINDOW (parent_window),
+ parent_folder,
+ create_folder_performer,
+ parent_folder);
}
}
modest_msg_edit_window_select_font (window);
}
+
void
modest_ui_actions_on_folder_display_name_changed (ModestFolderView *folder_view,
const gchar *display_name,
GtkWindow *window)
{
+ /* don't update the display name if it was already set;
+ * updating the display name apparently is expensive */
+ const gchar* old_name = gtk_window_get_title (window);
+
+ if (old_name && display_name && strcmp (old_name, display_name) == 0)
+ return; /* don't do anything */
+
/* This is usually used to change the title of the main window, which
* is the one that holds the folder view. Note that this change can
* happen even when the widget doesn't have the focus. */
gtk_window_set_title (window, display_name);
else
gtk_window_set_title (window, " ");
+
}
void
gtk_widget_set_sensitive (new_button, new_sensitive);
}
+
+#define MODEST_MOVE_TO_DIALOG_FOLDER_VIEW "move-to-dialog-folder-view"
+
+static GtkWidget*
+get_folder_view_from_move_to_dialog (GtkWidget *move_to_dialog)
+{
+ return GTK_WIDGET(g_object_get_data (G_OBJECT(move_to_dialog),
+ MODEST_MOVE_TO_DIALOG_FOLDER_VIEW));
+}
+
static GtkWidget*
create_move_to_dialog (GtkWindow *win,
GtkWidget *folder_view,
}
}
+ /* we keep a pointer to the embedded folder view, so we can retrieve it with
+ * get_folder_view_from_move_to_dialog
+ * (see above) later (needed for focus handling)
+ */
+ g_object_set_data (G_OBJECT(dialog), MODEST_MOVE_TO_DIALOG_FOLDER_VIEW, *tree_view);
+
+
/* Hide special folders */
modest_folder_view_show_non_move_folders (MODEST_FOLDER_VIEW (*tree_view), FALSE);
-
+
gtk_container_add (GTK_CONTAINER (scroll), *tree_view);
/* Add scroll to dialog */
TnyList *headers = TNY_LIST (user_data);
if (err || canceled) {
- /* Show an error ? */
goto out;
}
message = g_strdup (_("emev_ib_ui_smtp_send_error"));
break;
default:
- g_return_if_reached ();
+ g_warning ("%s: unexpected TNY_TRANSPORT_ACCOUNT_ERROR %d",
+ __FUNCTION__, err->code);
+ message = g_strdup (_("emev_ib_ui_smtp_send_error"));
+ break;
}
/* TODO if the username or the password where not defined we