[evolution/gnome-3-8] Bug #626215 - Prefer mail saving in order by UI
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-3-8] Bug #626215 - Prefer mail saving in order by UI
- Date: Fri, 26 Apr 2013 13:36:18 +0000 (UTC)
commit bf761cd2bf4d426b3340cee5f39823e51c49fe7c
Author: Milan Crha <mcrha redhat com>
Date: Fri Apr 26 15:35:47 2013 +0200
Bug #626215 - Prefer mail saving in order by UI
mail/e-mail-reader-utils.c | 10 +++++++
mail/message-list.c | 60 ++++++++++++++++++++++++++++++++++++++++++++
mail/message-list.h | 3 ++
3 files changed, 73 insertions(+), 0 deletions(-)
---
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index dcb3383..7414ba1 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -1605,6 +1605,16 @@ e_mail_reader_save_messages (EMailReader *reader)
uids = e_mail_reader_get_selected_uids (reader);
g_return_if_fail (uids != NULL && uids->len > 0);
+
+ if (uids->len > 1) {
+ GtkWidget *message_list = e_mail_reader_get_message_list (reader);
+
+ g_warn_if_fail (message_list != NULL);
+
+ if (message_list)
+ message_list_sort_uids (MESSAGE_LIST (message_list), uids);
+ }
+
message_uid = g_ptr_array_index (uids, 0);
/* XXX Either e_mail_reader_get_selected_uids()
diff --git a/mail/message-list.c b/mail/message-list.c
index cc23f99..aa7d67e 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -4252,6 +4252,66 @@ message_list_set_selected (MessageList *ml,
g_ptr_array_free (paths, TRUE);
}
+struct ml_sort_uids_data {
+ gchar *uid;
+ gint row;
+};
+
+static gint
+ml_sort_uids_cb (gconstpointer a,
+ gconstpointer b)
+{
+ struct ml_sort_uids_data * const *pdataA = a;
+ struct ml_sort_uids_data * const *pdataB = b;
+
+ return (* pdataA)->row - (* pdataB)->row;
+}
+
+void
+message_list_sort_uids (MessageList *message_list,
+ GPtrArray *uids)
+{
+ struct ml_sort_uids_data *data;
+ GPtrArray *array;
+ ETreePath path;
+ ETreeTableAdapter *adapter;
+ gint ii;
+
+ g_return_if_fail (message_list != NULL);
+ g_return_if_fail (IS_MESSAGE_LIST (message_list));
+ g_return_if_fail (uids != NULL);
+
+ if (uids->len <= 1)
+ return;
+
+ adapter = e_tree_get_table_adapter (E_TREE (message_list));
+
+ array = g_ptr_array_new_full (uids->len, g_free);
+
+ for (ii = 0; ii < uids->len; ii++) {
+ data = g_new0 (struct ml_sort_uids_data, 1);
+ data->uid = g_ptr_array_index (uids, ii);
+
+ path = g_hash_table_lookup (message_list->uid_nodemap, data->uid);
+ if (path)
+ data->row = e_tree_table_adapter_row_of_node (adapter, path);
+ else
+ data->row = ii;
+
+ g_ptr_array_add (array, data);
+ }
+
+ g_ptr_array_sort (array, ml_sort_uids_cb);
+
+ for (ii = 0; ii < uids->len; ii++) {
+ data = g_ptr_array_index (array, ii);
+
+ uids->pdata[ii] = data->uid;
+ }
+
+ g_ptr_array_free (array, TRUE);
+}
+
struct ml_count_data {
MessageList *ml;
guint count;
diff --git a/mail/message-list.h b/mail/message-list.h
index daa27f2..4396291 100644
--- a/mail/message-list.h
+++ b/mail/message-list.h
@@ -229,6 +229,9 @@ void message_list_ensure_message (MessageList *message_list,
const gchar *uid);
void message_list_save_state (MessageList *message_list);
+void message_list_sort_uids (MessageList *message_list,
+ GPtrArray *uids);
+
#define MESSAGE_LIST_LOCK(m, l) g_mutex_lock(((MessageList *)m)->l)
#define MESSAGE_LIST_UNLOCK(m, l) g_mutex_unlock(((MessageList *)m)->l)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]