Ethereal-dev: [ethereal-dev] can people try out this scroll patch

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Nathan Neulinger <nneul@xxxxxxx>
Date: Tue, 30 Nov 1999 12:03:04 -0600
This is the same one that I sent a week or so ago. I'd like to see people 
try it and see if it works well enough to commit. I haven't had any 
trouble with it, and at the very least, it's a marked improvement over the
'scroll to the top every time' approach of the byte view as it is right now.

The only potential issue I see is with the technique used to get the 
scroll offsets, but it seems like it works ok. Worst case scenario, it 
doesn't scroll to the exact right place. That's still better than 
scrolling to the top every time. 

-- Nathan

------------------------------------------------------------
Nathan Neulinger                       EMail:  nneul@xxxxxxx
University of Missouri - Rolla         Phone: (573) 341-4841
Computing Services                       Fax: (573) 341-4216
Index: gtk/main.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/main.c,v
retrieving revision 1.56
diff -u -r1.56 main.c
--- main.c	1999/11/30 05:33:05	1.56
+++ main.c	1999/11/30 18:00:08
@@ -773,15 +773,9 @@
     tree_selected_len   = finfo->length;
   }
 
-  gtk_text_freeze(GTK_TEXT(byte_view));
-  gtk_text_set_point(GTK_TEXT(byte_view), 0);
-  gtk_text_forward_delete(GTK_TEXT(byte_view),
-    gtk_text_get_length(GTK_TEXT(byte_view)));
   packet_hex_print(GTK_TEXT(byte_view), cf.pd, cf.current_frame->cap_len, 
 		   tree_selected_start, tree_selected_len,
 		   cf.current_frame->encoding);
-  
-  gtk_text_thaw(GTK_TEXT(byte_view));
 }
 
 void collapse_all_cb(GtkWidget *widget, gpointer data) {
Index: gtk/proto_draw.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/proto_draw.c,v
retrieving revision 1.6
diff -u -r1.6 proto_draw.c
--- proto_draw.c	1999/11/22 06:24:55	1.6
+++ proto_draw.c	1999/11/30 18:00:08
@@ -63,6 +63,13 @@
   gchar    line[128], hexchars[] = "0123456789abcdef", c = '\0';
   GdkFont *cur_font, *new_font;
 
+  /* Freeze the text for faster display */
+  gtk_text_freeze(bv);
+
+  /* Clear out the text */
+  gtk_text_set_point(bv, 0);
+  gtk_text_forward_delete(bv, gtk_text_get_length(bv));
+
   while (i < len) {
     /* Print the line number */
     sprintf(line, "%04x  ", i);
@@ -128,6 +135,19 @@
     line[cur++] = '\n';
     line[cur]   = '\0';
     gtk_text_insert(bv, cur_font, NULL, NULL, line, -1);
+  }
+
+  /* scroll text into position */
+  gtk_text_thaw(bv); /* must thaw before adjusting scroll bars */
+  if ( bstart > 0 ) {
+    int lineheight,linenum,scrollval;
+    linenum = bstart / BYTE_VIEW_WIDTH;
+
+    /* need to change to some way of getting that offset instead of +4 */
+    lineheight = gdk_string_height(m_b_font, "0") + 4;
+    scrollval = MIN(linenum * lineheight,bv->vadj->upper - bv->vadj->page_size);
+
+    gtk_adjustment_set_value(bv->vadj, scrollval);
   }
 }