* Review dimming rules of 'Cancel sending' command.
* Fixes: NB#61952
pmo-trunk-r2507
return vbox;
}
+gboolean
+modest_main_window_send_receive_in_progress (ModestMainWindow *self)
+{
+ ModestMainWindowPrivate *priv = NULL;
+
+ g_return_val_if_fail (MODEST_IS_MAIN_WINDOW (self), FALSE);
+
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
+
+ return priv->send_receive_in_progress;
+}
+
void
modest_main_window_notify_send_receive_initied (ModestMainWindow *self)
{
GtkAction *action = NULL;
GtkWidget *widget = NULL;
-
+ ModestMainWindowPrivate *priv = NULL;
+
g_return_if_fail (MODEST_IS_MAIN_WINDOW (self));
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
+
+ priv->send_receive_in_progress = TRUE;
action = modest_window_get_action (MODEST_WINDOW(self), "/MenuBar/ToolsMenu/ToolsSendReceiveMainMenu/ToolsSendReceiveAllMenu");
gtk_action_set_sensitive (action, FALSE);
{
GtkAction *action = NULL;
GtkWidget *widget = NULL;
-
+ ModestMainWindowPrivate *priv = NULL;
+
g_return_if_fail (MODEST_IS_MAIN_WINDOW (self));
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
+
+ priv->send_receive_in_progress = FALSE;
action = modest_window_get_action (MODEST_WINDOW(self), "/MenuBar/ToolsMenu/ToolsSendReceiveMainMenu/ToolsSendReceiveAllMenu");
gtk_action_set_sensitive (action, TRUE);
void
modest_ui_actions_on_close_window (GtkAction *action, ModestWindow *win)
{
- if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
- gtk_widget_destroy (GTK_WIDGET (win));
- } else if (MODEST_IS_MSG_EDIT_WINDOW (win)) {
- gboolean ret_value;
- g_signal_emit_by_name (G_OBJECT (win), "delete-event", NULL, &ret_value);
- } else if (MODEST_IS_WINDOW (win)) {
- gtk_widget_destroy (GTK_WIDGET (win));
- } else {
- g_return_if_reached ();
- }
+ gboolean ret_value;
+ g_signal_emit_by_name (G_OBJECT (win), "delete-event", NULL, &ret_value);
+
+/* if (MODEST_IS_MSG_VIEW_WINDOW (win)) { */
+/* gtk_widget_destroy (GTK_WIDGET (win)); */
+/* } else if (MODEST_IS_MSG_EDIT_WINDOW (win)) { */
+/* gboolean ret_value; */
+/* g_signal_emit_by_name (G_OBJECT (win), "delete-event", NULL, &ret_value); */
+/* } else if (MODEST_IS_WINDOW (win)) { */
+/* gtk_widget_destroy (GTK_WIDGET (win)); */
+/* } else { */
+/* g_return_if_reached (); */
+/* } */
}
void
/* Set send/receive operation in progress */
modest_main_window_notify_send_receive_initied (MODEST_MAIN_WINDOW(win));
- mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(win));
+/* 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_OPEN,
+ G_OBJECT (win),
+ modest_ui_actions_send_receive_error_handler,
+ NULL);
+
g_signal_connect (G_OBJECT(mail_op), "progress-changed",
G_CALLBACK (_on_send_receive_progress_changed),
win);
g_object_unref (win);
}
+void
+modest_ui_actions_send_receive_error_handler (ModestMailOperation *mail_op,
+ gpointer user_data)
+{
+ GObject *win = modest_mail_operation_get_source (mail_op);
+ const GError *error = modest_mail_operation_get_error (mail_op);
+
+ g_return_if_fail (error != NULL);
+ if (error->message != NULL)
+ g_printerr ("modest: %s\n", error->message);
+ else
+ g_printerr ("modest: unkonw error on sedn&receive operation");
+
+ /* Show error message */
+ modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL,
+ _CS("sfil_ib_unable_to_send"));
+/* g_object_unref (win); */
+}
+
static void
open_msg_for_purge_cb (ModestMailOperation *mail_op,
TnyHeader *header,
**/
void modest_ui_actions_move_folder_error_handler (ModestMailOperation *mail_op,
gpointer user_data);
+/**
+ * modest_ui_actions_send-receive_error_handler:
+ * @mail_op: a #ModestMailOperation
+ * @user_data: user data
+ *
+ * manages an error in a mail operation that tries to execute
+ * a send&receive operation.
+ **/
+void modest_ui_actions_send_receive_error_handler (ModestMailOperation *mail_op,
+ gpointer user_data);
/**
* modest_ui_actions_on_search_messages:
gboolean
modest_ui_dimming_rules_on_cancel_sending (ModestWindow *win, gpointer user_data)
{
+ ModestDimmingRule *rule = NULL;
+ TnyFolderType types[1];
+ guint n_messages = 0;
gboolean dimmed = FALSE;
- /* Check dimmed rule */
- if (!dimmed)
+ g_return_val_if_fail (MODEST_IS_MAIN_WINDOW(win), FALSE);
+ g_return_val_if_fail (MODEST_IS_DIMMING_RULE (user_data), FALSE);
+ rule = MODEST_DIMMING_RULE (user_data);
+
+ types[0] = TNY_FOLDER_TYPE_OUTBOX;
+
+ /* Check dimmed rules */
+ if (!dimmed) {
+ dimmed = _already_opened_msg (win, &n_messages);
+ if (dimmed)
+ modest_dimming_rule_set_notification (rule, _("mcen_ib_message_unableto_cancel_send"));
+ }
+ if (!dimmed) {
+ dimmed = !_selected_folder_is_any_of_type (win, types, 1);
+ if (dimmed)
+ modest_dimming_rule_set_notification (rule, "");
+ }
+ if (!dimmed) {
dimmed = !_sending_in_progress (win);
-
+ if (dimmed)
+ modest_dimming_rule_set_notification (rule, "");
+ }
+
return dimmed;
}
static gboolean
_sending_in_progress (ModestWindow *win)
{
- ModestTnySendQueue *send_queue = NULL;
- ModestTnyAccountStore *acc_store = NULL;
- TnyAccount *account = NULL;
- const gchar *account_name = NULL;
gboolean result = FALSE;
- /* Get transport account */
- acc_store = modest_runtime_get_account_store();
- account_name = modest_window_get_active_account (win);
-
- /* If no account defined, this action must be always dimmed */
- if (account_name == NULL) return FALSE;
- account = modest_tny_account_store_get_transport_account_for_open_connection (acc_store, account_name);
- if (!TNY_IS_TRANSPORT_ACCOUNT (account)) return FALSE;
-
- /* Get send queue for current ransport account */
- send_queue = modest_runtime_get_send_queue (TNY_TRANSPORT_ACCOUNT(account));
- g_return_val_if_fail (MODEST_IS_TNY_SEND_QUEUE (send_queue), FALSE);
+ g_return_val_if_fail (MODEST_IS_MAIN_WINDOW (win), FALSE);
- /* Check if send queue is perfimring any send operation */
- result = modest_tny_send_queue_sending_in_progress (send_queue);
+ /* Check if send operation is in progress */
+ result = modest_main_window_send_receive_in_progress (MODEST_MAIN_WINDOW (win));
return result;
}
* modest_main_window_notify_send_receive_initied:
* @self: the #ModestMainWindow
*
+ * Determines if send&receive operaiton is currently in
+ * progress.
+ *
+ * Returns: TRUE if send$receive operaton is in
+ * progress, FALSE otherwise.
+ **/
+gboolean
+modest_main_window_send_receive_in_progress (ModestMainWindow *self);
+
+/**
+ * modest_main_window_notify_send_receive_initied:
+ * @self: the #ModestMainWindow
+ *
* Notifies main window that send/receive operaiton was just started.
**/
void