Re: [PATCH] Expand a thread, see something useful



On 2001.11.08 19:05 M . Thielker wrote:
...
> Don't scroll the actual message on which the + was clicked to expand 
> the thread out of view - it would be confusing.
...
> Melanie

Yes, but...

If you're reading a message in a thread, close the thread, and then 
reopen the thread, two messages are of interest:
(1) The one that's still showing in the preview pane;
(2) The message you clicked on.
If you can't get them both in the index window, which should be shown? 
I tried (2), but not seeing the highlighted row for the current 
selected message was confusing, so I suggest (1).

The attached patch, against recent cvs, replaces the previous one. If 
the current message has become viewable, scroll just enough to see it 
(at the foot of the window). If it hasn't, or there isn't one, try to 
show all the newly viewable part of the thread, but don't scroll the 
clicked-on message off the top of the window.

Is that a reasonable strategy?
diff -dNru --exclude-from=excl balsa-cvs/src/balsa-index.c balsa-index/src/balsa-index.c
--- balsa-cvs/src/balsa-index.c	Tue Nov  6 07:47:54 2001
+++ balsa-index/src/balsa-index.c	Fri Nov  9 11:02:51 2001
@@ -1299,13 +1299,41 @@
 
 /* tree_expand_cb:
  * callback on expand events
- * set/reset unread style, as appropriate, and check visibility of child */
+ * set/reset unread style, as appropriate
+ * if current message has become viewable, check its visibility,
+ * scrolling only until it is at foot of window;
+ * otherwise find last viewable message in thread and check its
+ * visibility, scrolling only until node is at foot of window, but not
+ * so far that the clicked-on message scrolls off the top */
 static void
 tree_expand_cb(GtkCTree * ctree, GList * node, gpointer user_data)
 {
-    GtkCTreeNode *child = GTK_CTREE_ROW(node)->children;
+    GtkCTreeNode *child = NULL;
+    GtkCTreeNode *parent = NULL;
+    if (GTK_CLIST(ctree)->selection) {
+        /* current message... */
+        GtkCTreeNode *current =
+            g_list_last(GTK_CLIST(ctree)->selection)->data;
+        if (gtk_ctree_is_ancestor(ctree, GTK_CTREE_NODE(node), current)
+            /* ...is in thread... */
+            && gtk_ctree_is_viewable(ctree, current))
+            /* ...and viewable:
+             * check visibility of current only */
+            child = current;
+    }
+    if (child == NULL) {
+        /* get last child... */
+        child = gtk_ctree_last(ctree, GTK_CTREE_ROW(node)->children);
+        while (child && !gtk_ctree_is_viewable(ctree, child))
+            /* ...that is viewable */
+            child = GTK_CTREE_ROW(child)->parent;
+        /* check visibility of parent, too */
+        parent = GTK_CTREE_NODE(node);
+    }
     if (child)
         balsa_index_check_visibility(GTK_CLIST(ctree), child, 1.0);
+    if (parent)
+        balsa_index_check_visibility(GTK_CLIST(ctree), parent, 0.0);
     balsa_index_set_style(BALSA_INDEX(user_data), GTK_CTREE_NODE(node));
 }
 


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