aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/proto_draw.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2000-02-29 06:24:41 +0000
committerGuy Harris <guy@alum.mit.edu>2000-02-29 06:24:41 +0000
commit7c113340005e40b182076b765b675e8db7c85c4c (patch)
tree2f87391c5d48dec1712faab6f9f4b38cc017c9ae /gtk/proto_draw.c
parent25c6518e54cb06fb7e6af5304a82a13bf07f5a63 (diff)
downloadwireshark-7c113340005e40b182076b765b675e8db7c85c4c.tar.gz
wireshark-7c113340005e40b182076b765b675e8db7c85c4c.tar.bz2
wireshark-7c113340005e40b182076b765b675e8db7c85c4c.zip
Jeff Foster's changes, with my additions, to allow the user to pop up a
window showing the protocol tree and hex/ASCII data for the currently selected packet. svn path=/trunk/; revision=1670
Diffstat (limited to 'gtk/proto_draw.c')
-rw-r--r--gtk/proto_draw.c76
1 files changed, 75 insertions, 1 deletions
diff --git a/gtk/proto_draw.c b/gtk/proto_draw.c
index 533aa3f567..1b2ef78c63 100644
--- a/gtk/proto_draw.c
+++ b/gtk/proto_draw.c
@@ -1,7 +1,7 @@
/* gtkpacket.c
* Routines for GTK+ packet display
*
- * $Id: proto_draw.c,v 1.13 2000/01/25 03:45:45 gerald Exp $
+ * $Id: proto_draw.c,v 1.14 2000/02/29 06:24:40 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -45,7 +45,9 @@
#include "packet.h"
#include "util.h"
+#include "prefs.h"
#include "proto_draw.h"
+#include "gtkglobals.h"
#define BYTE_VIEW_WIDTH 16
#define BYTE_VIEW_SEP 8
@@ -56,6 +58,51 @@ static void
proto_tree_draw_node(GNode *node, gpointer data);
void
+create_byte_view(gint bv_size, GtkWidget *pane, GtkWidget **byte_view_p,
+ GtkWidget **bv_vscroll_left_p, GtkWidget **bv_vscroll_right_p)
+{
+ GtkWidget *bv_table, *byte_view, *bv_vscroll_left, *bv_vscroll_right;
+
+ /* Byte view. The table is only one row high, but 3 columns
+ * wide. The middle column contains the GtkText with the hex dump.
+ * The left and right columns contain vertical scrollbars. They both
+ * do the same thing, but only one will be shown at a time, in accordance
+ * with where the user wants the other vertical scrollbars places
+ * (on the left or the right).
+ */
+ bv_table = gtk_table_new (1, 3, FALSE);
+ gtk_paned_pack2(GTK_PANED(pane), bv_table, FALSE, FALSE);
+ gtk_widget_set_usize(bv_table, -1, bv_size);
+ gtk_widget_show(bv_table);
+
+ byte_view = gtk_text_new(NULL, NULL);
+ gtk_text_set_editable(GTK_TEXT(byte_view), FALSE);
+ gtk_text_set_word_wrap(GTK_TEXT(byte_view), FALSE);
+ gtk_table_attach (GTK_TABLE (bv_table), byte_view, 1, 2, 0, 1,
+ GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0);
+ gtk_widget_show(byte_view);
+
+ /* The gtk_text widget doesn't scroll horizontally (see gtktext.c)
+ * in the GTK+ distribution, so I removed the horizontal scroll bar
+ * that used to be here. I tried the gtk_text widget with a
+ * gtk_scrolled_window w/ viewport, but the vertical scrolling
+ * did not work well, and sometimes a few pixels were cut off on
+ * the bottom. */
+
+ bv_vscroll_left = gtk_vscrollbar_new(GTK_TEXT(byte_view)->vadj);
+ gtk_table_attach(GTK_TABLE(bv_table), bv_vscroll_left, 0, 1, 0, 1,
+ GTK_FILL, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0);
+
+ bv_vscroll_right = gtk_vscrollbar_new(GTK_TEXT(byte_view)->vadj);
+ gtk_table_attach(GTK_TABLE(bv_table), bv_vscroll_right, 2, 3, 0, 1,
+ GTK_FILL, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0);
+
+ *byte_view_p = byte_view;
+ *bv_vscroll_left_p = bv_vscroll_left;
+ *bv_vscroll_right_p = bv_vscroll_right;
+}
+
+void
packet_hex_print(GtkText *bv, guint8 *pd, gint len, gint bstart, gint blen,
char_enc encoding) {
gint i = 0, j, k, cur;
@@ -161,6 +208,33 @@ packet_hex_print(GtkText *bv, guint8 *pd, gint len, gint bstart, gint blen,
}
}
+void
+create_tree_view(gint tv_size, e_prefs *prefs, GtkWidget *pane,
+ GtkWidget **tv_scrollw_p, GtkWidget **tree_view_p)
+{
+ GtkWidget *tv_scrollw, *tree_view;
+
+ /* Tree view */
+ tv_scrollw = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(tv_scrollw),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_paned_pack1(GTK_PANED(pane), tv_scrollw, TRUE, TRUE);
+ gtk_widget_set_usize(tv_scrollw, -1, tv_size);
+ gtk_widget_show(tv_scrollw);
+
+ tree_view = gtk_ctree_new(1, 0);
+ /* I need this next line to make the widget work correctly with hidden
+ * column titles and GTK_SELECTION_BROWSE */
+ gtk_clist_set_column_auto_resize( GTK_CLIST(tree_view), 0, TRUE );
+ gtk_container_add( GTK_CONTAINER(tv_scrollw), tree_view );
+ set_ptree_sel_browse(tree_view, prefs->gui_ptree_sel_browse);
+ set_ptree_line_style(tree_view, prefs->gui_ptree_line_style);
+ set_ptree_expander_style(tree_view, prefs->gui_ptree_expander_style);
+
+ *tree_view_p = tree_view;
+ *tv_scrollw_p = tv_scrollw;
+}
+
void expand_all_tree(proto_tree *protocol_tree, GtkWidget *tree_view) {
int i;
for(i=0; i < num_tree_types; i++) {