Ethereal-dev: [ethereal-dev] slightly better 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: Sun, 21 Nov 1999 20:39:14 -0600
fixed a minor problem I missed.

-- Nathan

------------------------------------------------------------
Nathan Neulinger                       EMail:  nneul@xxxxxxx
University of Missouri - Rolla         Phone: (573) 341-4841
Computing Services                       Fax: (573) 341-4216
? gtk/.proto_draw.c.swp
Index: gtk/main.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/main.c,v
retrieving revision 1.41
diff -u -r1.41 main.c
--- main.c	1999/11/21 15:06:07	1.41
+++ main.c	1999/11/22 02:38:34
@@ -724,15 +724,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);
-  
-  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.5
diff -u -r1.5 proto_draw.c
--- proto_draw.c	1999/11/16 11:44:20	1.5
+++ proto_draw.c	1999/11/22 02:38:34
@@ -60,6 +60,13 @@
   gint     i = 0, j, k, cur;
   gchar    line[128], hexchars[] = "0123456789abcdef";
   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 */
@@ -116,6 +123,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);
   }
 }