TnyStatus *status,
gpointer user_data);
+static void modest_mail_operation_notify_end (ModestMailOperation *self);
enum _ModestMailOperationSignals
{
}
}
- /* Notify the queue */
- modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (), self);
+ /* Notify about operation end */
+ modest_mail_operation_notify_end (self);
}
void
goto cleanup;
}
- modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (), self);
+ modest_mail_operation_notify_end (self);
/* Free */
cleanup:
{
ModestMailOperation *mail_op = MODEST_MAIL_OPERATION (data);
- modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (),
- mail_op);
+ modest_mail_operation_notify_end (mail_op);
g_object_unref (mail_op);
return FALSE;
}
out:
- /* Notify the queue. Note that the info could be freed before
- this idle happens, but the mail operation will be still
- alive */
+ /* Notify about operation end. Note that the info could be
+ freed before this idle happens, but the mail operation will
+ be still alive */
g_idle_add (notify_update_account_queue, info->mail_op);
/* Frees */
g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
MODEST_MAIL_OPERATION_ERROR_ITEM_NOT_FOUND,
"cannot get tny store account for %s\n", account_name);
- modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (),
- self);
+ modest_mail_operation_notify_end (self);
return FALSE;
}
g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
MODEST_MAIL_OPERATION_ERROR_ITEM_NOT_FOUND,
"cannot get tny transport account for %s\n", account_name);
- modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (),
- self);
+ modest_mail_operation_notify_end (self);
return FALSE;
}
/* Set new status */
priv->status = MODEST_MAIL_OPERATION_STATUS_CANCELED;
- /* Notify the queue */
- modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (), self);
+ /* Notify about operation end */
+ modest_mail_operation_notify_end (self);
return TRUE;
}
CHECK_EXCEPTION (priv, MODEST_MAIL_OPERATION_STATUS_FAILED);
}
- /* Notify the queue */
- modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (), self);
+ /* Notify about operation end */
+ modest_mail_operation_notify_end (self);
return new_folder;
}
g_object_unref (G_OBJECT (account));
end:
- /* Notify the queue */
- modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (), self);
+ /* Notify about operation end */
+ modest_mail_operation_notify_end (self);
}
void
}
- /* Notify the queue */
- modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (), self);
+ /* Notify about operation end */
+ modest_mail_operation_notify_end (self);
}
static void
transfer_folder_status_cb (GObject *obj,
- TnyStatus *status,
+ TnyStatus *status,
gpointer user_data)
{
XFerMsgAsyncHelper *helper = NULL;
g_return_if_fail (status->code == TNY_FOLDER_STATUS_CODE_COPY_FOLDER);
helper = (XFerMsgAsyncHelper *) user_data;
- g_return_if_fail (helper != NULL);
-
- /* Temporary FIX: useful when tinymail send us status
- information *after* calling the function callback */
- if (!MODEST_IS_MAIL_OPERATION (helper->mail_op))
- return;
+ g_return_if_fail (helper != NULL);
self = helper->mail_op;
priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
priv->done = status->position;
priv->total = status->of_total;
-
g_signal_emit (G_OBJECT (self), signals[PROGRESS_CHANGED_SIGNAL], 0, NULL);
}
if (*err) {
priv->error = g_error_copy (*err);
priv->done = 0;
- priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
+ priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
} else if (cancelled) {
priv->status = MODEST_MAIL_OPERATION_STATUS_CANCELED;
g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
g_slice_free (XFerFolderAsyncHelper, helper);
g_object_unref (folder);
g_object_unref (into);
- if (new_folder != NULL)
+ if (new_folder != NULL)
g_object_unref (new_folder);
- /* Notify the queue */
- modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (), self);
+ /* Notify about operation end */
+ modest_mail_operation_notify_end (self);
}
TnyFolder *
&(priv->error));
}
- /* Notify the queue */
- modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (), self);
+ /* Notify about operation end */
+ modest_mail_operation_notify_end (self);
return new_folder;
}
/* The moveable restriction is applied also to copy operation */
rules = modest_tny_folder_get_rules (TNY_FOLDER (parent));
if (rules & MODEST_FOLDER_RULES_FOLDER_NON_MOVEABLE) {
- priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
MODEST_MAIL_OPERATION_ERROR_FOLDER_RULES,
_("FIXME: unable to rename"));
/* Notify the queue */
- modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (), self);
+ modest_mail_operation_notify_end (self);
} else {
helper = g_slice_new0 (XFerFolderAsyncHelper);
helper->mail_op = self;
if (helper->pending_ops == 0) {
g_slice_free (GetMsgAsyncHelper, helper);
- /* Notify the queue */
- modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (), self);
+ /* Notify about operation end */
+ modest_mail_operation_notify_end (self);
}
}
tny_iterator_next (iter);
}
- /* Notify the queue */
+ /* Notify about operation end */
g_idle_add (notify_update_account_queue, info->mail_op);
/* Free thread resources. Will be called after all previous idles */
MODEST_MAIL_OPERATION_ERROR_BAD_PARAMETER,
_("emev_ni_ui_imap_msg_sizelimit_error"));
/* Remove from queue and free resources */
- modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (), self);
+ modest_mail_operation_notify_end (self);
if (notify)
notify (user_data);
}
/* Free */
g_object_unref (G_OBJECT (folder));
- /* Notify the queue */
- modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (), self);
+ /* Notify about operation end */
+ modest_mail_operation_notify_end (self);
}
static void
helper = (XFerMsgAsyncHelper *) user_data;
g_return_if_fail (helper != NULL);
- /* Temporary FIX: useful when tinymail send us status
- information *after* calling the function callback */
- if (!MODEST_IS_MAIL_OPERATION (helper->mail_op))
- return;
-
self = helper->mail_op;
priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
g_slice_free (XFerMsgAsyncHelper, helper);
g_object_unref (folder);
- /* Notify the queue */
- modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (), self);
+ /* Notify about operation end */
+ modest_mail_operation_notify_end (self);
}
void
/* Free */
g_object_unref (folder);
- /* Notify the queue */
- modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (), self);
+ /* Notify about operation end */
+ modest_mail_operation_notify_end (self);
}
static void
self);
}
-void
-_modest_mail_operation_notify_end (ModestMailOperation *self)
+/**
+ *
+ * It's used by the mail operation queue to notify the observers
+ * attached to that signal that the operation finished. We need to use
+ * that because tinymail does not give us the progress of a given
+ * operation when it finishes (it directly calls the operation
+ * callback).
+ */
+static void
+modest_mail_operation_notify_end (ModestMailOperation *self)
{
+ /* Notify the observers about the mail opertation end */
g_signal_emit (G_OBJECT (self), signals[PROGRESS_CHANGED_SIGNAL], 0, NULL);
+
+ /* Notify the queue */
+ modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (), self);
}
gtk_tree_selection_get_selected (selection, &model, &iter);
source_row = gtk_tree_model_get_path (model, &iter);
-
gtk_tree_set_row_drag_data (selection_data,
model,
source_row);
TnyFolder *folder;
/* Check if the drag is possible */
- if (!gtk_tree_path_compare (helper->source_row, dest_row) ||
- !gtk_tree_drag_dest_row_drop_possible (GTK_TREE_DRAG_DEST (dest_model),
- dest_row,
- selection_data)) {
+/* if (!gtk_tree_path_compare (helper->source_row, dest_row) || */
+/* !gtk_tree_drag_dest_row_drop_possible (GTK_TREE_DRAG_DEST (dest_model), */
+/* dest_row, */
+/* selection_data)) { */
+ if (!gtk_tree_path_compare (helper->source_row, dest_row)) {
gtk_drag_finish (helper->context, FALSE, FALSE, helper->time);
gtk_tree_path_free (helper->source_row);
/* Do not allow further process */
g_signal_stop_emission_by_name (widget, "drag-data-received");
+ source_widget = gtk_drag_get_source_widget (context);
- /* Get the action (FIXME: only copy is currently implemented */
-/* if (context->action == GDK_ACTION_MOVE) */
-/* delete_source = TRUE; */
+ /* Get the action */
+ if (context->action == GDK_ACTION_MOVE) {
+ delete_source = TRUE;
+
+ /* Notify that there is no folder selected. We need to
+ do this in order to update the headers view (and
+ its monitors, because when moving, the old folder
+ won't longer exist. We can not wait for the end of
+ the operation, because the operation won't start if
+ the folder is in use */
+ if (helper->delete_source && source_widget == widget)
+ g_signal_emit (G_OBJECT (widget),
+ signals[FOLDER_SELECTION_CHANGED_SIGNAL], 0, NULL, TRUE);
+ }
/* Check if the get_data failed */
if (selection_data == NULL || selection_data->length < 0)
gtk_drag_finish (context, success, FALSE, time);
/* Get the models */
- source_widget = gtk_drag_get_source_widget (context);
gtk_tree_get_row_drag_data (selection_data,
&source_model,
&source_row);
/* Do not allow drops between folders */
if (!dest_row ||
- pos == GTK_TREE_VIEW_DROP_BEFORE ||
+ pos == GTK_TREE_VIEW_DROP_BEFORE ||
pos == GTK_TREE_VIEW_DROP_AFTER) {
gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget), NULL, 0);
gdk_drag_status(context, 0, time);
gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (widget), dest_row, pos);
priv->timer_expander = g_timeout_add (500, expand_row_timeout, widget);
}
- gtk_tree_path_free (dest_row);
/* Select the desired action. By default we pick MOVE */
suggested_action = GDK_ACTION_MOVE;
gdk_drag_status(context, GDK_ACTION_DEFAULT, time);
out:
+ if (dest_row)
+ gtk_tree_path_free (dest_row);
g_signal_stop_emission_by_name (widget, "drag-motion");
return valid_location;
}