aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2007-11-23 17:06:00 +0800
committerMilan Crha <mcrha@src.gnome.org>2007-11-23 17:06:00 +0800
commit1c88010c53f9a9b7466745041bf55d646bc2aa0a (patch)
tree60d7111e61e7a58b24ae8e1cdfca8645bb8c1835 /mail
parentc67cc6aa87d39bf8ac6d77c54b99dc9d71dc10ac (diff)
downloadgsoc2013-evolution-1c88010c53f9a9b7466745041bf55d646bc2aa0a.tar
gsoc2013-evolution-1c88010c53f9a9b7466745041bf55d646bc2aa0a.tar.gz
gsoc2013-evolution-1c88010c53f9a9b7466745041bf55d646bc2aa0a.tar.bz2
gsoc2013-evolution-1c88010c53f9a9b7466745041bf55d646bc2aa0a.tar.lz
gsoc2013-evolution-1c88010c53f9a9b7466745041bf55d646bc2aa0a.tar.xz
gsoc2013-evolution-1c88010c53f9a9b7466745041bf55d646bc2aa0a.tar.zst
gsoc2013-evolution-1c88010c53f9a9b7466745041bf55d646bc2aa0a.zip
** Fix for bug #335931
2007-11-23 Milan Crha <mcrha@redhat.com> ** Fix for bug #335931 * message-list.c: (struct _regen_list_msg): New member last_row. * message-list.c: (regen_list_regen): Store last_row for later use. * message-list.c: (regen_list_regened): Restore row based on last_row when no uid was selected before. * message-list.c: (mail_regen_list): Init new last_row member. * em-folder-view.c: (emfv_select_next_message): New helper function to select messages in list. * em-folder-view.c: (emfv_popup_mark_junk), (emfv_popup_mark_nojunk), (emfv_popup_delete): Using new helper function, so get same behavior. * message-list.h: (struct _MessageList): * message-list.c: (on_cursor_activated_cmd): Removed cursor_row member. svn path=/trunk/; revision=34567
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog17
-rw-r--r--mail/em-folder-view.c22
-rw-r--r--mail/message-list.c34
-rw-r--r--mail/message-list.h1
4 files changed, 64 insertions, 10 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index e927ba9e03..d8ea57ffed 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,20 @@
+2007-11-23 Milan Crha <mcrha@redhat.com>
+
+ ** Fix for bug #335931
+
+ * message-list.c: (struct _regen_list_msg): New member last_row.
+ * message-list.c: (regen_list_regen): Store last_row for later use.
+ * message-list.c: (regen_list_regened): Restore row based on last_row
+ when no uid was selected before.
+ * message-list.c: (mail_regen_list): Init new last_row member.
+ * em-folder-view.c: (emfv_select_next_message): New helper function
+ to select messages in list.
+ * em-folder-view.c: (emfv_popup_mark_junk), (emfv_popup_mark_nojunk),
+ (emfv_popup_delete): Using new helper function, so get same behavior.
+
+ * message-list.h: (struct _MessageList):
+ * message-list.c: (on_cursor_activated_cmd): Removed cursor_row member.
+
2007-11-22 Milan Crha <mcrha@redhat.com>
** Fix for bug #498551
diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c
index 0d7eed1236..614264f547 100644
--- a/mail/em-folder-view.c
+++ b/mail/em-folder-view.c
@@ -1007,6 +1007,15 @@ emfv_popup_mark_unimportant(EPopup *ep, EPopupItem *pitem, void *data)
}
static void
+emfv_select_next_message (EMFolderView *emfv, int count, gboolean always_can_previous)
+{
+ if (emfv && count == 1) {
+ if (!message_list_select (emfv->list, MESSAGE_LIST_SELECT_NEXT, 0, 0) && (emfv->hide_deleted || always_can_previous))
+ message_list_select (emfv->list, MESSAGE_LIST_SELECT_PREVIOUS, 0, 0);
+ }
+}
+
+static void
emfv_popup_mark_junk (EPopup *ep, EPopupItem *pitem, void *data)
{
EMFolderView *emfv = data;
@@ -1015,8 +1024,8 @@ emfv_popup_mark_junk (EPopup *ep, EPopupItem *pitem, void *data)
count = em_folder_view_mark_selected(emfv,
CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_JUNK|CAMEL_MESSAGE_JUNK_LEARN,
CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_JUNK|CAMEL_MESSAGE_JUNK_LEARN);
- if (count == 1)
- message_list_select(emfv->list, MESSAGE_LIST_SELECT_NEXT, 0, 0);
+
+ emfv_select_next_message (emfv, count, TRUE);
}
static void
@@ -1028,8 +1037,8 @@ emfv_popup_mark_nojunk (EPopup *ep, EPopupItem *pitem, void *data)
count = em_folder_view_mark_selected(emfv,
CAMEL_MESSAGE_JUNK|CAMEL_MESSAGE_JUNK_LEARN,
CAMEL_MESSAGE_JUNK_LEARN);
- if (count == 1)
- message_list_select(emfv->list, MESSAGE_LIST_SELECT_NEXT, 0, 0);
+
+ emfv_select_next_message (emfv, count, TRUE);
}
#define DelInVFolderCheckName "DelInVFolderCheck"
@@ -1086,10 +1095,7 @@ emfv_delete_msg_response (GtkWidget *dialog, int response, gpointer data)
message_list_free_uids(emfv->list, uids);
camel_folder_thaw(emfv->folder);
- if (count == 1) {
- if (!message_list_select (emfv->list, MESSAGE_LIST_SELECT_NEXT, 0, 0) && emfv->hide_deleted)
- message_list_select (emfv->list, MESSAGE_LIST_SELECT_PREVIOUS, 0, 0);
- }
+ emfv_select_next_message (emfv, count, FALSE);
}
if (dialog)
diff --git a/mail/message-list.c b/mail/message-list.c
index 0936938d1a..b9d5cf56cb 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -3241,7 +3241,6 @@ on_cursor_activated_cmd (ETree *tree, int row, ETreePath path, gpointer user_dat
|| (message_list->cursor_uid != NULL && new_uid != NULL && !strcmp (message_list->cursor_uid, new_uid)))
return;
- message_list->cursor_row = row;
g_free (message_list->cursor_uid);
message_list->cursor_uid = g_strdup (new_uid);
@@ -3734,6 +3733,8 @@ struct _regen_list_msg {
CamelFolder *folder;
GPtrArray *summary;
+
+ int last_row; /* last selected (cursor) row */
};
/*
@@ -3758,11 +3759,16 @@ regen_list_regen (struct _mail_msg *mm)
struct _regen_list_msg *m = (struct _regen_list_msg *)mm;
GPtrArray *uids, *uidnew, *showuids, *searchuids = NULL;
CamelMessageInfo *info;
+ ETreePath cursor;
int i;
if (m->folder != m->ml->folder)
return;
+ cursor = e_tree_get_cursor (m->ml->tree);
+ if (cursor)
+ m->last_row = e_tree_table_adapter_row_of_node (e_tree_get_table_adapter (m->ml->tree), cursor);
+
e_profile_event_emit("list.getuids", m->folder->full_name, 0);
/* if we have hidedeleted on, use a search to find it out, merge with existing search if set */
@@ -3848,10 +3854,22 @@ regen_list_regen (struct _mail_msg *mm)
/* first, hide matches */
if (m->ml->hidden) {
+ int subtr = 0;
+
for (i = 0; i < uids->len; i++) {
if (g_hash_table_lookup (m->ml->hidden, uids->pdata[i]) == NULL)
g_ptr_array_add (uidnew, uids->pdata[i]);
+ else if (m->last_row >= 0) {
+ /* if we are going to hide message above last selected row, then we should
+ decrease our last row number, to put cursor on a proper place. */
+ ETreePath node = g_hash_table_lookup (m->ml->uid_nodemap, (const char *) uids->pdata[i]);
+
+ if (node && m->last_row > e_tree_table_adapter_row_of_node (e_tree_get_table_adapter (m->ml->tree), node))
+ subtr ++;
+ }
}
+
+ m->last_row -= subtr;
}
/* then calculate the subrange visible and chop it out */
@@ -3970,6 +3988,19 @@ regen_list_regened (struct _mail_msg *mm)
m->ml->pending_select_uid = NULL;
message_list_select_uid(m->ml, uid);
g_free(uid);
+ } else if (m->ml->regen == NULL && m->ml->cursor_uid == NULL && m->last_row != -1) {
+ ETreeTableAdapter *etta = e_tree_get_table_adapter (m->ml->tree);
+
+ if (m->last_row >= e_table_model_row_count (E_TABLE_MODEL (etta)))
+ m->last_row = e_table_model_row_count (E_TABLE_MODEL (etta)) - 1;
+
+ if (m->last_row >= 0) {
+ ETreePath path;
+
+ path = e_tree_table_adapter_node_at_row (etta, m->last_row);
+ if (path)
+ select_path (m->ml, path);
+ }
}
g_signal_emit (m->ml, message_list_signals[MESSAGE_LIST_BUILT], 0);
@@ -4095,6 +4126,7 @@ mail_regen_list (MessageList *ml, const char *search, const char *hideexpr, Came
g_object_ref(ml);
m->folder = ml->folder;
camel_object_ref(m->folder);
+ m->last_row = -1;
if ((!m->hidedel || !m->dotree) && ml->thread_tree) {
camel_folder_thread_messages_unref(ml->thread_tree);
diff --git a/mail/message-list.h b/mail/message-list.h
index 21cd784c00..c1713dc4d4 100644
--- a/mail/message-list.h
+++ b/mail/message-list.h
@@ -132,7 +132,6 @@ struct _MessageList {
guint frozen:16;
/* Where the ETree cursor is. */
- int cursor_row;
char *cursor_uid;
/* Row-selection and seen-marking timers */