#include <modest-tny-msg.h>
#include <modest-tny-account.h>
#include <modest-address-book.h>
-
+#include "modest-error.h"
#include "modest-ui-actions.h"
#include "modest-tny-platform-factory.h"
}
/*
+ * This function is the error handler of the
+ * modest_mail_operation_get_msgs_full operation
+ */
+static void
+modest_ui_actions_get_msgs_full_error_handler (ModestMailOperation *mail_op,
+ gpointer user_data)
+{
+ const GError *error;
+
+ error = modest_mail_operation_get_error (mail_op);
+ if (error->code == MODEST_MAIL_OPERATION_ERROR_SIZE_LIMIT) {
+ GObject *win = modest_mail_operation_get_source (mail_op);
+
+ modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL,
+ error->message);
+ }
+}
+
+/*
* This function is used by both modest_ui_actions_on_open and
* modest_ui_actions_on_header_activated. This way we always do the
* same when trying to open messages.
}
/* Open each message */
- mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT (win));
+ mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
+ G_OBJECT (win),
+ modest_ui_actions_get_msgs_full_error_handler,
+ NULL);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
modest_mail_operation_get_msgs_full (mail_op,
headers,
reply_forward_cb (NULL, header, msg, rf_helper);
} else {
/* Retrieve messages */
- mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(win));
+ mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
+ G_OBJECT(win),
+ modest_ui_actions_get_msgs_full_error_handler,
+ NULL);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
modest_mail_operation_get_msgs_full (mail_op,
header_list,
/* Show account details */
modest_main_window_set_contents_style (main_window, MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS);
} else if (modest_tny_folder_store_is_virtual_local_folders (folder_store )) {
- printf ("DEBUG: %s: folder store.\n", __FUNCTION__);
//TODO: Set the virtual folder store as the "active account" somehow:
modest_main_window_set_contents_style (main_window, MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS);
} else {
}
static void
+modest_ui_actions_delete_folder_error_handler (ModestMailOperation *mail_op,
+ gpointer user_data)
+{
+ GObject *win = modest_mail_operation_get_source (mail_op);
+
+ modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL,
+ _("mail_in_ui_folder_delete_error"));
+}
+
+static void
delete_folder (ModestMainWindow *main_window, gboolean move_to_trash)
{
TnyFolderStore *folder;
g_free (message);
if (response == GTK_RESPONSE_OK) {
- ModestMailOperation *mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_DELETE, G_OBJECT(main_window));
+ ModestMailOperation *mail_op =
+ modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_DELETE,
+ G_OBJECT(main_window),
+ modest_ui_actions_delete_folder_error_handler,
+ NULL);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
mail_op);
modest_mail_operation_remove_folder (mail_op, TNY_FOLDER (folder), move_to_trash);
-
- /* Show error if happened */
- if (modest_mail_operation_get_error (mail_op))
- modest_platform_run_information_dialog (GTK_WINDOW (main_window),
- _("mail_in_ui_folder_delete_error"));
-
g_object_unref (G_OBJECT (mail_op));
}
g_return_if_fail (found);
}
-static void
-move_to_error_checking (const GObject *obj, gpointer user_data)
+void
+modest_ui_actions_move_folder_error_handler (ModestMailOperation *mail_op,
+ gpointer user_data)
{
- ModestWindow *win = NULL;
-
- g_return_if_fail (MODEST_IS_WINDOW (obj));
- win = MODEST_WINDOW (obj);
+ GObject *win = modest_mail_operation_get_source (mail_op);
/* TODO: show error message */
-/* modest_platform_run_information_dialog (GTK_WINDOW (win), */
-/* _("mail_in_ui_folder_move_target_error")); */
+ modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL,
+ _("mail_in_ui_folder_move_target_error"));
}
/*
modest_header_view_set_folder (MODEST_HEADER_VIEW (header_view), NULL);
if (TNY_IS_FOLDER (src_folder)) {
- mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
- G_OBJECT(win),
- move_to_error_checking);
- modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
- mail_op);
+ mail_op =
+ modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
+ G_OBJECT(win),
+ modest_ui_actions_move_folder_error_handler,
+ NULL);
+ modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
modest_mail_operation_xfer_folder (mail_op,
TNY_FOLDER (src_folder),
folder_store,
TRUE);
+ /* Unref mail operation */
g_object_unref (G_OBJECT (mail_op));
-
}
/* Frees */
TRUE,
NULL,
NULL);
+
g_object_unref (G_OBJECT (mail_op));
}
g_object_unref (headers);
}
}
g_object_unref (folder_store);
-
end:
gtk_widget_destroy (dialog);
}
return;
/* Create mail operation */
- mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT (window));
+ mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
+ G_OBJECT (window),
+ modest_ui_actions_get_msgs_full_error_handler,
+ NULL);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
modest_mail_operation_get_msgs_full (mail_op, headers, NULL, NULL, NULL);
g_object_unref (headers);
g_object_unref (mail_op);
}
+
+void
+modest_ui_actions_on_email_menu_activated (GtkAction *action,
+ ModestWindow *window)
+{
+ g_return_if_fail (MODEST_IS_WINDOW (window));
+
+ /* Update dimmed */
+ modest_window_check_dimming_rules (window);
+}
+
+void
+modest_ui_actions_on_edit_menu_activated (GtkAction *action,
+ ModestWindow *window)
+{
+ g_return_if_fail (MODEST_IS_WINDOW (window));
+
+ /* Update dimmed */
+ modest_window_check_dimming_rules (window);
+}
+
+void
+modest_ui_actions_on_toolbar_csm_menu_activated (GtkAction *action,
+ ModestWindow *window)
+{
+ g_return_if_fail (MODEST_IS_WINDOW (window));
+
+ /* Update dimmed */
+ modest_window_check_dimming_rules (window);
+}
+
+void
+modest_ui_actions_on_folder_view_csm_menu_activated (GtkAction *action,
+ ModestWindow *window)
+{
+ g_return_if_fail (MODEST_IS_WINDOW (window));
+
+ /* Update dimmed */
+ modest_window_check_dimming_rules (window);
+}
+
+void
+modest_ui_actions_on_header_view_csm_menu_activated (GtkAction *action,
+ ModestWindow *window)
+{
+ g_return_if_fail (MODEST_IS_WINDOW (window));
+
+ /* Update dimmed */
+ modest_window_check_dimming_rules (window);
+}