This patch cleanly scroll the byte view to have the bold text in view.
It currently has one hardwired value that should probably be turned into
some function call, I just don't know what it is. I use "+ 4" to the
height of each row of text to get the row spacing in the text box. It
works for the default font, but may not be exactly right for others. But
other than that, it gets rid of any flicker. Even if it doesn't scroll
quite right for different fonts, it's still going to put the scrollbar
in a better position than at the top.
I found that you cannot call gtk_adjustment_set_value on a scroll bar
before the text is unfrozen. One, it crashes, and two, the text area
hasn't recalculated the scroll extents yet. With that in mind, I moved
the freeze/thaw to proto_draw.c instead of main.c. (The scroll stuff
needed BYTE_VIEW_WIDTH.)
-- 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.41
diff -u -r1.41 main.c
--- main.c 1999/11/21 15:06:07 1.41
+++ main.c 1999/11/22 02:27:31
@@ -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:27:32
@@ -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,22 @@
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 = linenum * lineheight;
+
+ /* don't scroll past end */
+ if ( scrollval <= (bv->vadj->upper - bv->vadj->page_size) ) {
+ gtk_adjustment_set_value(bv->vadj, scrollval);
+ }
}
}