[evolution-patches] Fixes for bug #333707 - Evolution mail list scrolls to beginning for no reason



Hi, here are two patches to fix bug #333707 - "Evolution mail list
scrolls to beginning for no reason"
http://bugzilla.gnome.org/show_bug.cgi?id=333707

That bug is a side-effect of the fix for bug #322776 - "Unable to
keyboard navigate into message headers pane, if no message selected"
http://bugzilla.gnome.org/show_bug.cgi?id=322776

These two patches ensure that a message remains selected in the message
list after:
1) A thread is collapsed with the selection inside
2) Expunge (or other message disappearance) when the disappeared message
is currently selected.

Any comments appreciated.  I'd really like these fixes to make it into
2.6.2.  Thanks to fejj for already taking a look.

-David


--- evolution-2.6.0/widgets/table/e-tree.c.collapsed-cursor	2006-01-30 07:28:21.000000000 -0500
+++ evolution-2.6.0/widgets/table/e-tree.c	2006-04-14 17:21:27.000000000 -0400
@@ -139,6 +139,7 @@
 	int table_model_change_id;
 	int table_row_change_id;
 	int table_cell_change_id;
+	int table_rows_delete_id;
 
 	GnomeCanvas *header_canvas, *table_canvas;
 
@@ -256,10 +257,14 @@
 	if (et->priv->table_cell_change_id != 0)
 		g_signal_handler_disconnect (G_OBJECT (et->priv->etta),
 				             et->priv->table_cell_change_id);
+	if (et->priv->table_rows_delete_id != 0)
+		g_signal_handler_disconnect (G_OBJECT (et->priv->etta),
+				             et->priv->table_rows_delete_id);
 
 	et->priv->table_model_change_id = 0;
 	et->priv->table_row_change_id = 0;
 	et->priv->table_cell_change_id = 0;
+	et->priv->table_rows_delete_id = 0;
 }
 
 static void
@@ -549,6 +554,7 @@
 	e_tree->priv->table_model_change_id  = 0;
 	e_tree->priv->table_row_change_id    = 0;
 	e_tree->priv->table_cell_change_id   = 0;
+	e_tree->priv->table_rows_delete_id   = 0;
 
 	e_tree->priv->alternating_row_colors = 1;
 	e_tree->priv->horizontal_draw_grid   = 1;
@@ -1334,6 +1340,32 @@
 }
 
 static void
+et_table_rows_deleted (ETableModel *table_model, int row, int count, ETree *et)
+{
+	ETreePath * node, * prev_node;
+
+	/* If the cursor is still valid after this deletion, we're done */
+	if (e_selection_model_cursor_row (et->priv->selection) >= 0
+			|| row == 0)
+		return;
+
+	prev_node = e_tree_node_at_row (et, row-1);
+	node = e_tree_get_cursor (et);
+	
+	/* Check if the cursor is a child of the node directly before the
+	 * deleted region (implying that an expander was collapsed with
+	 * the cursor inside it) */
+	while (node) {
+		node = e_tree_model_node_get_parent (et->priv->model, node);
+		if (node == prev_node) {
+			/* Set the cursor to the still-visible parent */
+			e_tree_set_cursor (et, prev_node);
+			return;
+		}
+	}
+}
+
+static void
 et_connect_to_etta (ETree *et)
 {
 	et->priv->table_model_change_id = g_signal_connect (et->priv->etta, "model_changed",
@@ -1344,6 +1376,9 @@
 
 	et->priv->table_cell_change_id = g_signal_connect (et->priv->etta, "model_cell_changed",
 							   G_CALLBACK (et_table_cell_changed), et);
+	
+	et->priv->table_rows_delete_id = g_signal_connect (et->priv->etta, "model_rows_deleted",
+							   G_CALLBACK (et_table_rows_deleted), et);
 
 }



--- message-list.c	5 Apr 2006 10:14:14 -0000	1.425
+++ message-list.c	17 Apr 2006 14:53:10 -0000
@@ -2156,6 +2156,21 @@
 
 }
 
+/* Checks if a message still exists. This is needed to tell if a
+ * message has been expunged while we still have a pointer to it. */
+static gboolean
+message_exists (CamelMessageInfo *info)
+{
+	CamelMessageInfo *mi;
+	
+	if ((mi = camel_folder_summary_uid (info->summary, camel_message_info_uid (info)))) {
+		camel_message_info_free (mi);
+		return TRUE;
+	}
+	
+	return FALSE;
+}
+
 /* we try and find something that isn't deleted in our tree
    there is actually no assurance that we'll find somethign that will
    still be there next time, but its probably going to work most of the time */
@@ -2178,7 +2193,7 @@
 		check |= CAMEL_MESSAGE_DELETED;
 
 	info = get_message_info (ml, node);
-	if (info && (camel_message_info_flags(info) & check) == 0) {
+	if (info && message_exists (info) && (camel_message_info_flags(info) & check) == 0) {
 		return NULL;
 	}
 
@@ -2186,19 +2201,34 @@
 
 	/* model_to_view_row etc simply dont work for sorted views.  Sigh. */
 	vrow = e_tree_row_of_node (et, node);
-
+	
 	/* We already checked this node. */
-	vrow ++;
-
+	vrow++;
+	
 	while (vrow < last) {
 		node = e_tree_node_at_row (et, vrow);
 		info = get_message_info (ml, node);
-		if (info && (camel_message_info_flags(info) & check) == 0) {
+		if (info && message_exists (info) && (camel_message_info_flags(info) & check) == 0) {
 			return g_strdup (camel_message_info_uid (info));
 		}
-		vrow ++;
+		vrow++;
 	}
-
+	
+	/* If we still haven't found a node, search backwards */
+	vrow = e_tree_row_of_node (et, node);
+	
+	/* We already checked this node. */
+	vrow--;
+	
+	while (vrow >= 0) {
+		node = e_tree_node_at_row (et, vrow);
+		info = get_message_info (ml, node);
+		if (info && message_exists (info) && (camel_message_info_flags(info) & check) == 0) {
+			return g_strdup (camel_message_info_uid (info));
+		}
+		vrow--;
+	}
+	
 	return NULL;
 }




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]